curl --request POST \
--url 'https://api.flashcat.cloud/monit/query/data?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"ds_type": "prometheus",
"ds_name": "prod-prom",
"expr": "sum by (job) (rate(http_requests_total[5m]))",
"delay_seconds": 0,
"args": {}
}
'import requests
url = "https://api.flashcat.cloud/monit/query/data?app_key="
payload = {
"ds_type": "prometheus",
"ds_name": "prod-prom",
"expr": "sum by (job) (rate(http_requests_total[5m]))",
"delay_seconds": 0,
"args": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
ds_type: 'prometheus',
ds_name: 'prod-prom',
expr: 'sum by (job) (rate(http_requests_total[5m]))',
delay_seconds: 0,
args: {}
})
};
fetch('https://api.flashcat.cloud/monit/query/data?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/query/data?app_key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ds_type' => 'prometheus',
'ds_name' => 'prod-prom',
'expr' => 'sum by (job) (rate(http_requests_total[5m]))',
'delay_seconds' => 0,
'args' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.flashcat.cloud/monit/query/data?app_key="
payload := strings.NewReader("{\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"sum by (job) (rate(http_requests_total[5m]))\",\n \"delay_seconds\": 0,\n \"args\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.flashcat.cloud/monit/query/data?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"sum by (job) (rate(http_requests_total[5m]))\",\n \"delay_seconds\": 0,\n \"args\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/query/data?app_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"sum by (job) (rate(http_requests_total[5m]))\",\n \"delay_seconds\": 0,\n \"args\": {}\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"format": "query_result.v1",
"result": {
"kind": "samples",
"samples": [
{
"labels": {
"job": "api"
},
"value": 1.25
}
]
}
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter is not valid."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "AccessDenied",
"message": "Access Denied."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "RequestTooFrequently",
"message": "Request too frequently."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InternalError",
"message": "We encountered an internal error, and it has been reported. Please try again later."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "ServiceUnavailable",
"message": "service temporarily unavailable"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}查询结构化数据
对已配置的数据源执行同步即席查询,并返回稳定的 query_result.v1 结果;结果会按自然语义呈现为 frames、records 或 samples。此公开接口要求 monit-edge v0.65.0 或更高版本。
curl --request POST \
--url 'https://api.flashcat.cloud/monit/query/data?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"ds_type": "prometheus",
"ds_name": "prod-prom",
"expr": "sum by (job) (rate(http_requests_total[5m]))",
"delay_seconds": 0,
"args": {}
}
'import requests
url = "https://api.flashcat.cloud/monit/query/data?app_key="
payload = {
"ds_type": "prometheus",
"ds_name": "prod-prom",
"expr": "sum by (job) (rate(http_requests_total[5m]))",
"delay_seconds": 0,
"args": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
ds_type: 'prometheus',
ds_name: 'prod-prom',
expr: 'sum by (job) (rate(http_requests_total[5m]))',
delay_seconds: 0,
args: {}
})
};
fetch('https://api.flashcat.cloud/monit/query/data?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/query/data?app_key=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ds_type' => 'prometheus',
'ds_name' => 'prod-prom',
'expr' => 'sum by (job) (rate(http_requests_total[5m]))',
'delay_seconds' => 0,
'args' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.flashcat.cloud/monit/query/data?app_key="
payload := strings.NewReader("{\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"sum by (job) (rate(http_requests_total[5m]))\",\n \"delay_seconds\": 0,\n \"args\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.flashcat.cloud/monit/query/data?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"sum by (job) (rate(http_requests_total[5m]))\",\n \"delay_seconds\": 0,\n \"args\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/query/data?app_key=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"sum by (job) (rate(http_requests_total[5m]))\",\n \"delay_seconds\": 0,\n \"args\": {}\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"format": "query_result.v1",
"result": {
"kind": "samples",
"samples": [
{
"labels": {
"job": "api"
},
"value": 1.25
}
]
}
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter is not valid."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "AccessDenied",
"message": "Access Denied."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "RequestTooFrequently",
"message": "Request too frequently."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InternalError",
"message": "We encountered an internal error, and it has been reported. Please try again later."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "ServiceUnavailable",
"message": "service temporarily unavailable"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}调用限制
| 项 | 值 |
|---|---|
| 速率限制 | 每账户 100 次/分钟、5 次/秒 |
| 权限 | 任意有效的 app_key(只读,不受特定权限分类限制) |
| Edge 版本要求 | 受支持的部署要求 monit-edge v0.65.0 或更高版本 |
使用说明
- 此公开接口以 monit-edge v0.65.0 为最低受支持版本。迁移期间,WebAPI 仍保留旧版 Edge 适配器:query.v2 结果仍可能保留 frames、records 或 samples,而 legacy rows 只能提供其已保留的信息。这些适配器不会改变最低支持版本;旧协议缺少 query.v3 的取消和错误生命周期语义,legacy rows 已丢失的数据也无法恢复。
- 公开响应格式固定为
query_result.v1,与 Edge 内部查询协议版本无关。必须根据result.kind(frames、records或samples)分发结果,不要根据ds_type或 Edge 版本猜测结果形态。 frames结果可以包含多个表格或时序 Frame。字段值按列组织,同一 Frame 中所有字段的值数量一致。records结果可以包含嵌套 JSON 和 null record。超出 JavaScript 安全整数范围的整数字面量会以十进制字符串返回。samples结果包含标签集合和瞬时值。值可以是数字,也可以是字符串NaN、+Inf或-Inf。- 最终成功响应上限为 8 MiB,查询结果上限为 1,000 行。超限时请缩短时间范围、减少字段或在数据源侧聚合。
- 查询失败使用非 2xx HTTP 状态码和标准错误 envelope。不要透明回退到已弃用的
/monit/query/rows接口。 - WebAPI 跨实例转发和 Edge 执行合计可能耗时 35 秒。客户端超时建议至少设为 40 秒,并在调用方放弃查询时向下传播取消信号。
授权
在 Flashduty 控制台 账户 → APP Key 中签发的 app_key。调用任何公开 API 时都必须携带。它等同于所属账户的身份凭证,请妥善保管。
请求体
稳定结构化查询接口的请求。字段与已下线的 rows 接口一致。
数据源类型;必须匹配租户下已配置的数据源。示例:prometheus、loki、victorialogs、sls、elasticsearch、mysql、postgres、oracle、clickhouse。
数据源名称;必须匹配租户下已配置的数据源。
查询表达式。语法取决于 ds_type,由对应的 monit-edge 客户端解释(Prometheus 用 PromQL,Loki 用 LogQL,SQL 类数据源用 SQL,等等)。
可选的一致性校验。若提供,必须等于已认证账户;不一致将被拒绝。业务执行始终使用已认证账户。
应用于点查询(Prometheus、Loki stats、VictoriaLogs stats)的回看偏移,单位秒。明细 / raw 查询忽略该字段。
透传给 monit-edge 的多态键值扩展参数。所有值必须是字符串,键一律按数据源加前缀(如 sls.project、loki.type)。校验规则取决于 ds_type:SLS 必须提供 sls.project 与 sls.logstore;Elasticsearch 的 es.type 只接受 sql 或不传,其他值一律拒绝;Loki 与 VictoriaLogs 的 <source>.type 接受 stats、raw 或不传,其中 raw 还必须给出时间范围——<source>.start + <source>.end,或 <source>.timespan.value + <source>.timespan.unit(单位取 s/m/h/d)。Prometheus 及其余 SQL 类数据源完全忽略 args。
Show child attributes
Show child attributes
此页面对您有帮助吗?