查询 Prometheus 标签值列表
curl --request GET \
--url 'https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key=' \
--header 'X-DSID: <x-dsid>'import requests
url = "https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key="
headers = {"X-DSID": "<x-dsid>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-DSID': '<x-dsid>'}};
fetch('https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-DSID: <x-dsid>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key="
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-DSID", "<x-dsid>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key=")
.header("X-DSID", "<x-dsid>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-DSID"] = '<x-dsid>'
response = http.request(request)
puts response.read_body{
"status": "success",
"data": [
"api",
"db",
"worker"
]
}"<string>"{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
}
}"<string>""<string>"告警数据源
查询 Prometheus 标签值列表
通过监控代理从 Prometheus 兼容数据源读取标签值列表。
GET
/
monit
/
prometheus
/
api
/
v1
/
label
/
{label_name}
/
values
查询 Prometheus 标签值列表
curl --request GET \
--url 'https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key=' \
--header 'X-DSID: <x-dsid>'import requests
url = "https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key="
headers = {"X-DSID": "<x-dsid>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-DSID': '<x-dsid>'}};
fetch('https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key=', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-DSID: <x-dsid>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key="
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-DSID", "<x-dsid>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key=")
.header("X-DSID", "<x-dsid>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/prometheus/api/v1/label/{label_name}/values?app_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-DSID"] = '<x-dsid>'
response = http.request(request)
puts response.read_body{
"status": "success",
"data": [
"api",
"db",
"worker"
]
}"<string>"{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
}
}"<string>""<string>"限制说明
| 项目 | 说明 |
|---|---|
| 速率限制 | 每个账户 1,000 次/分钟;50 次/秒 |
| 权限要求 | 任意有效的 app_key(只读,不受特定权限分类限制) |
| Edge 版本要求 | 受支持的部署要求 monit-edge v0.35.0 或更高版本 |
使用说明
- 通过
X-DSID请求头指定目标数据源,必须是当前账户下 Prometheus 兼容类型的数据源;可用/monit/datasource/list获取 ID。 - 200 响应体是数据源原生的 Prometheus HTTP API 结构,不是统一的
{ request_id, data }envelope。未到达数据源前发生的失败以text/plain返回,并携带对应的 4xx/5xx 状态码。 - 省略
X-DSID时会回退到平台自有的 Prometheus 代理;需要查询指定数据源时必须携带该请求头。
授权
在 Flashduty 控制台 账户 → APP Key 中签发的 app_key。调用任何公开 API 时都必须携带。它等同于所属账户的身份凭证,请妥善保管。
请求头
要查询的数据源 ID,必须是当前账户下 Prometheus 兼容类型的数据源。
路径参数
要枚举取值的标签名,例如 job。
响应
数据源返回的原生 Prometheus 标签值响应。
所查询数据源返回的原生 Prometheus HTTP API 响应。本接口不会把结果包装进 Flashduty 统一响应 envelope。
此页面对您有帮助吗?