执行探索查询
curl --request POST \
--url 'https://api.flashcat.cloud/monit/query/explore?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"datasource_id": 101,
"expr": "rate(http_requests_total[5m])",
"args": {},
"execution": {
"kind": "range",
"from_ms": 1787187600000,
"to_ms": 1787191200000,
"max_data_points": 1200,
"min_step_seconds": 15
}
}
'import requests
url = "https://api.flashcat.cloud/monit/query/explore?app_key="
payload = {
"datasource_id": 101,
"expr": "rate(http_requests_total[5m])",
"args": {},
"execution": {
"kind": "range",
"from_ms": 1787187600000,
"to_ms": 1787191200000,
"max_data_points": 1200,
"min_step_seconds": 15
}
}
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({
datasource_id: 101,
expr: 'rate(http_requests_total[5m])',
args: {},
execution: {
kind: 'range',
from_ms: 1787187600000,
to_ms: 1787191200000,
max_data_points: 1200,
min_step_seconds: 15
}
})
};
fetch('https://api.flashcat.cloud/monit/query/explore?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/explore?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([
'datasource_id' => 101,
'expr' => 'rate(http_requests_total[5m])',
'args' => [
],
'execution' => [
'kind' => 'range',
'from_ms' => 1787187600000,
'to_ms' => 1787191200000,
'max_data_points' => 1200,
'min_step_seconds' => 15
]
]),
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/explore?app_key="
payload := strings.NewReader("{\n \"datasource_id\": 101,\n \"expr\": \"rate(http_requests_total[5m])\",\n \"args\": {},\n \"execution\": {\n \"kind\": \"range\",\n \"from_ms\": 1787187600000,\n \"to_ms\": 1787191200000,\n \"max_data_points\": 1200,\n \"min_step_seconds\": 15\n }\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/explore?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"datasource_id\": 101,\n \"expr\": \"rate(http_requests_total[5m])\",\n \"args\": {},\n \"execution\": {\n \"kind\": \"range\",\n \"from_ms\": 1787187600000,\n \"to_ms\": 1787191200000,\n \"max_data_points\": 1200,\n \"min_step_seconds\": 15\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/query/explore?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 \"datasource_id\": 101,\n \"expr\": \"rate(http_requests_total[5m])\",\n \"args\": {},\n \"execution\": {\n \"kind\": \"range\",\n \"from_ms\": 1787187600000,\n \"to_ms\": 1787191200000,\n \"max_data_points\": 1200,\n \"min_step_seconds\": 15\n }\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"format": "explore_result.v1",
"result": {
"kind": "frames",
"frames": [
{
"kind": "time_series",
"fields": [
{
"name": "time",
"type": "time",
"values": [
"2026-08-20T10:00:00Z",
"2026-08-20T10:01:00Z"
]
},
{
"name": "value",
"type": "float",
"labels": {
"job": "api"
},
"values": [
1.25,
null
]
}
]
}
]
},
"execution": {
"kind": "range",
"effective_step_seconds": 60
}
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}诊断分析
执行探索查询
对已配置的数据源执行探索查询,返回 frames、samples 或 logs 形态的结果。
POST
/
monit
/
query
/
explore
执行探索查询
curl --request POST \
--url 'https://api.flashcat.cloud/monit/query/explore?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"datasource_id": 101,
"expr": "rate(http_requests_total[5m])",
"args": {},
"execution": {
"kind": "range",
"from_ms": 1787187600000,
"to_ms": 1787191200000,
"max_data_points": 1200,
"min_step_seconds": 15
}
}
'import requests
url = "https://api.flashcat.cloud/monit/query/explore?app_key="
payload = {
"datasource_id": 101,
"expr": "rate(http_requests_total[5m])",
"args": {},
"execution": {
"kind": "range",
"from_ms": 1787187600000,
"to_ms": 1787191200000,
"max_data_points": 1200,
"min_step_seconds": 15
}
}
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({
datasource_id: 101,
expr: 'rate(http_requests_total[5m])',
args: {},
execution: {
kind: 'range',
from_ms: 1787187600000,
to_ms: 1787191200000,
max_data_points: 1200,
min_step_seconds: 15
}
})
};
fetch('https://api.flashcat.cloud/monit/query/explore?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/explore?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([
'datasource_id' => 101,
'expr' => 'rate(http_requests_total[5m])',
'args' => [
],
'execution' => [
'kind' => 'range',
'from_ms' => 1787187600000,
'to_ms' => 1787191200000,
'max_data_points' => 1200,
'min_step_seconds' => 15
]
]),
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/explore?app_key="
payload := strings.NewReader("{\n \"datasource_id\": 101,\n \"expr\": \"rate(http_requests_total[5m])\",\n \"args\": {},\n \"execution\": {\n \"kind\": \"range\",\n \"from_ms\": 1787187600000,\n \"to_ms\": 1787191200000,\n \"max_data_points\": 1200,\n \"min_step_seconds\": 15\n }\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/explore?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"datasource_id\": 101,\n \"expr\": \"rate(http_requests_total[5m])\",\n \"args\": {},\n \"execution\": {\n \"kind\": \"range\",\n \"from_ms\": 1787187600000,\n \"to_ms\": 1787191200000,\n \"max_data_points\": 1200,\n \"min_step_seconds\": 15\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/query/explore?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 \"datasource_id\": 101,\n \"expr\": \"rate(http_requests_total[5m])\",\n \"args\": {},\n \"execution\": {\n \"kind\": \"range\",\n \"from_ms\": 1787187600000,\n \"to_ms\": 1787191200000,\n \"max_data_points\": 1200,\n \"min_step_seconds\": 15\n }\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"format": "explore_result.v1",
"result": {
"kind": "frames",
"frames": [
{
"kind": "time_series",
"fields": [
{
"name": "time",
"type": "time",
"values": [
"2026-08-20T10:00:00Z",
"2026-08-20T10:01:00Z"
]
},
{
"name": "value",
"type": "float",
"labels": {
"job": "api"
},
"values": [
1.25,
null
]
}
]
}
]
},
"execution": {
"kind": "range",
"effective_step_seconds": 60
}
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "Unauthorized",
"message": "You are unauthorized."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InvalidParameter",
"message": "The specified parameter template_id is not valid.",
"reason": "<string>"
}
}限制说明
| 项目 | 说明 |
|---|---|
| 速率限制 | 每个账户 100 次/分钟;16 次/秒 |
| 权限要求 | 数据源查看(monit) |
| Edge 版本要求 | 受支持的部署要求 monit-edge v0.68.0 或更高版本 |
使用说明
- 需要数据源原生结果形态时使用本接口;
/monit/query/data返回稳定的query_result.v1契约。本接口根据data.result.kind(frames、samples或logs)分发结果。 - 数据源由
datasource_id指定。数据源必须属于当前账户、已启用、已绑定 Edge 集群,且类型为prometheus、elasticsearch、loki、clickhouse、mysql、oracle、postgres、sls、victorialogs或tencent_cls之一。若数据源限制了可查询的团队,只有这些团队的成员、其管理团队以及账户所有者或管理员可以查询。 execution.kind决定可接受的配套字段:instant需要to_ms(from_ms可选),range需要from_ms、to_ms和max_data_points,window需要from_ms和to_ms。同时给出两个时间时,from_ms必须小于to_ms。不接受step_seconds,步长由max_data_points与min_step_seconds推导。args为必填(无参数时传{}),用于宏替换(例如 Grafana 风格变量),取值均为字符串。未知或重复的 JSON 键会被拒绝。logs结果最多返回 1,000 条(sls为 100 条),并通过applied_limit与has_more说明截断情况。frames结果最多 1,000 个 frame,表格行合计最多 1,000 行,值合计最多 100,000 个;samples结果最多 1,000 条。请求体上限 256 KiB,成功响应整体上限 10 MiB。- 失败使用标准错误 envelope。
error.reason是稳定的机器可读取值;数据源 ID 不存在时返回 HTTP 400,错误码为ResourceNotFound,且不带reason。 - WebAPI 跨实例转发与 Edge 执行合计可能耗时 35 秒,客户端超时建议至少 40 秒。
授权
在 Flashduty 控制台 我的 → APP Key 中创建的 APP Key。可通过 query 参数 app_key 或请求头 Fd-App-Key 传入。实际可访问范围是该 APP Key 的权限范围与创建者当前角色权限的交集,请妥善保管。
请求体
application/json
探索查询请求。四个顶层字段均为必填,未知字段会被拒绝。
来自 /monit/datasource/list 的数据源 ID。必须是正的 JavaScript 安全整数,对应已认证账户下已启用、且调用方有权查询的数据源。
必填范围:
1 <= x <= 9007199254740991使用数据源原生语言的查询表达式(PromQL、LogsQL、SQL 等)。非空 UTF-8,最大 64 KiB;mysql 最大 16 KiB,tencent_cls 最大 12 KiB。
Minimum string length:
1宏替换参数,按变量名索引,用于 Grafana 风格变量。键最长 256 字节,值最长 64 KiB,总预算 128 KiB。
Show child attributes
Show child attributes
查询的时间语义。可接受的配套字段取决于 kind:instant 使用 to_ms(可选 from_ms),range 需要 from_ms、to_ms 和 max_data_points,window 只使用 from_ms 与 to_ms。同时给出两个时间时,from_ms 必须小于 to_ms。HTTP 接口不接受 step_seconds。
Show child attributes
Show child attributes
此页面对您有帮助吗?