curl --request POST \
--url 'https://api.flashcat.cloud/monit/query/rows?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"account_id": 10001,
"ds_type": "prometheus",
"ds_name": "prod-prom",
"expr": "up",
"delay_seconds": 30
}
'import requests
url = "https://api.flashcat.cloud/monit/query/rows?app_key="
payload = {
"account_id": 10001,
"ds_type": "prometheus",
"ds_name": "prod-prom",
"expr": "up",
"delay_seconds": 30
}
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({
account_id: 10001,
ds_type: 'prometheus',
ds_name: 'prod-prom',
expr: 'up',
delay_seconds: 30
})
};
fetch('https://api.flashcat.cloud/monit/query/rows?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/rows?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([
'account_id' => 10001,
'ds_type' => 'prometheus',
'ds_name' => 'prod-prom',
'expr' => 'up',
'delay_seconds' => 30
]),
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/rows?app_key="
payload := strings.NewReader("{\n \"account_id\": 10001,\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"up\",\n \"delay_seconds\": 30\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/rows?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"account_id\": 10001,\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"up\",\n \"delay_seconds\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/query/rows?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 \"account_id\": 10001,\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"up\",\n \"delay_seconds\": 30\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": [
{
"fields": {
"__name__": "up",
"instance": "10.0.0.1:9100",
"job": "node"
},
"values": {
"__value__": 1
}
}
]
}{
"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": "RequestTooFrequently",
"message": "Request too frequently."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InternalError",
"message": "We encountered an internal error, and it has been reported. Please try again later."
}
}查询数据源原始行
对已配置的数据源执行同步即席查询并返回原始行。供 Flashduty AI SRE 及 UI 预览使用。请求通过 WebSocket 转发至 monit-edge,由其对底层数据源(Prometheus / Loki / VictoriaLogs / SLS / MySQL / Postgres / Oracle / ClickHouse / Elasticsearch)执行查询。
curl --request POST \
--url 'https://api.flashcat.cloud/monit/query/rows?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"account_id": 10001,
"ds_type": "prometheus",
"ds_name": "prod-prom",
"expr": "up",
"delay_seconds": 30
}
'import requests
url = "https://api.flashcat.cloud/monit/query/rows?app_key="
payload = {
"account_id": 10001,
"ds_type": "prometheus",
"ds_name": "prod-prom",
"expr": "up",
"delay_seconds": 30
}
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({
account_id: 10001,
ds_type: 'prometheus',
ds_name: 'prod-prom',
expr: 'up',
delay_seconds: 30
})
};
fetch('https://api.flashcat.cloud/monit/query/rows?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/rows?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([
'account_id' => 10001,
'ds_type' => 'prometheus',
'ds_name' => 'prod-prom',
'expr' => 'up',
'delay_seconds' => 30
]),
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/rows?app_key="
payload := strings.NewReader("{\n \"account_id\": 10001,\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"up\",\n \"delay_seconds\": 30\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/rows?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"account_id\": 10001,\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"up\",\n \"delay_seconds\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/query/rows?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 \"account_id\": 10001,\n \"ds_type\": \"prometheus\",\n \"ds_name\": \"prod-prom\",\n \"expr\": \"up\",\n \"delay_seconds\": 30\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": [
{
"fields": {
"__name__": "up",
"instance": "10.0.0.1:9100",
"job": "node"
},
"values": {
"__value__": 1
}
}
]
}{
"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": "RequestTooFrequently",
"message": "Request too frequently."
}
}{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"error": {
"code": "InternalError",
"message": "We encountered an internal error, and it has been reported. Please try again later."
}
}调用限制
| 项 | 值 |
|---|---|
| 速率限制 | 600 次/分钟;10 次/秒 每账户 |
| 权限 | 任意有效的 app_key(只读;不受特定权限分类约束) |
使用说明
- 请求通过 WebSocket 转发至
monit-edge;ds_type+ds_name指定的数据源必须已在调用方账户下存在。 - 请求体中的
account_id为可选;若提供,必须与已认证账户一致,否则拒绝。 - 存在两层错误:webapi 层失败使用标准错误信封返回,而
monit-edge执行查询时抛出的错误以 HTTP 200 返回,并在响应体中携带error对象。除 HTTP 状态外,务必同时检查响应体中的error。 - monit-edge 强制行数上限;过大结果集会返回
error.message = "too many rows"。请收窄时间范围或在数据源端聚合。 args是一个多态string→string映射,原样转发。语义取决于ds_type(SLS 需要sls.project+sls.logstore;Loki / VictoriaLogs 原始模式需要通过*.start/*.end或*.timespan.value/*.timespan.unit指定时间范围;Prometheus 与 SQL 类数据源忽略该字段)。各数据源的键列表见 monit-webapi query-api 文档。
授权
在 Flashduty 控制台 账户 → APP Key 中签发的 app_key。调用任何公开 API 时都必须携带。它等同于所属账户的身份凭证,请妥善保管。
请求体
数据源类型;必须匹配租户下已配置的数据源。示例: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。所有值必须为字符串。语义取决于 ds_type:SLS 需要 sls.project + sls.logstore;Loki / VictoriaLogs 原始模式需要通过 <source>.start/<source>.end 或 <source>.timespan.value + <source>.timespan.unit 指定时间范围;Prometheus 与 SQL 类数据源忽略该字段。键务必按数据源命名空间区分(如 sls.project、loki.type)。
Show child attributes
Show child attributes
响应
成功
成功响应结构。2xx 响应中 request_id 标识本次调用(同时出现在 Flashcat-Request-Id 响应头中),data 为接口业务 payload。失败响应使用不同结构,参见 ErrorResponse。
此页面对您有帮助吗?