调用监控对象工具
curl --request POST \
--url 'https://api.flashcat.cloud/monit/tools/invoke?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"account_id": 10001,
"target_locator": "web-01",
"tools": [
{
"tool": "os.overview",
"params": {}
},
{
"tool": "net.tcp_ping",
"params": {
"host": "10.0.0.10",
"port": 3306
}
}
]
}
'import requests
url = "https://api.flashcat.cloud/monit/tools/invoke?app_key="
payload = {
"account_id": 10001,
"target_locator": "web-01",
"tools": [
{
"tool": "os.overview",
"params": {}
},
{
"tool": "net.tcp_ping",
"params": {
"host": "10.0.0.10",
"port": 3306
}
}
]
}
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,
target_locator: 'web-01',
tools: [
{tool: 'os.overview', params: {}},
{tool: 'net.tcp_ping', params: {host: '10.0.0.10', port: 3306}}
]
})
};
fetch('https://api.flashcat.cloud/monit/tools/invoke?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/tools/invoke?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,
'target_locator' => 'web-01',
'tools' => [
[
'tool' => 'os.overview',
'params' => [
]
],
[
'tool' => 'net.tcp_ping',
'params' => [
'host' => '10.0.0.10',
'port' => 3306
]
]
]
]),
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/tools/invoke?app_key="
payload := strings.NewReader("{\n \"account_id\": 10001,\n \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\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/tools/invoke?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"account_id\": 10001,\n \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/tools/invoke?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 \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"target": {
"kind": "host",
"locator": "web-01"
},
"results": [
{
"tool": "os.overview",
"tool_version": "0.5.0",
"data": {
"data": {
"sample_interval_sec": 3,
"degraded": false,
"degradation_reasons": []
},
"summary": "os.overview ...",
"truncated": {
"truncated": false
}
},
"error": null,
"agent_elapsed_ms": 3120,
"e2e_elapsed_ms": 3188
},
{
"tool": "net.tcp_ping",
"tool_version": "0.5.0",
"data": null,
"error": {
"code": "target_unreachable",
"message": "dial tcp 10.0.0.10:3306: i/o timeout"
},
"agent_elapsed_ms": 0,
"e2e_elapsed_ms": 2008
}
],
"error": null
}
}{
"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."
}
}诊断分析
调用监控对象工具
在单个监控对象上并发调用至多 8 个 monit-agent 工具。结果按入参 tools 数组顺序返回。长耗时——单个工具在 Agent 上有自己的超时,整体请求可能耗时数十秒。
POST
/
monit
/
tools
/
invoke
调用监控对象工具
curl --request POST \
--url 'https://api.flashcat.cloud/monit/tools/invoke?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"account_id": 10001,
"target_locator": "web-01",
"tools": [
{
"tool": "os.overview",
"params": {}
},
{
"tool": "net.tcp_ping",
"params": {
"host": "10.0.0.10",
"port": 3306
}
}
]
}
'import requests
url = "https://api.flashcat.cloud/monit/tools/invoke?app_key="
payload = {
"account_id": 10001,
"target_locator": "web-01",
"tools": [
{
"tool": "os.overview",
"params": {}
},
{
"tool": "net.tcp_ping",
"params": {
"host": "10.0.0.10",
"port": 3306
}
}
]
}
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,
target_locator: 'web-01',
tools: [
{tool: 'os.overview', params: {}},
{tool: 'net.tcp_ping', params: {host: '10.0.0.10', port: 3306}}
]
})
};
fetch('https://api.flashcat.cloud/monit/tools/invoke?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/tools/invoke?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,
'target_locator' => 'web-01',
'tools' => [
[
'tool' => 'os.overview',
'params' => [
]
],
[
'tool' => 'net.tcp_ping',
'params' => [
'host' => '10.0.0.10',
'port' => 3306
]
]
]
]),
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/tools/invoke?app_key="
payload := strings.NewReader("{\n \"account_id\": 10001,\n \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\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/tools/invoke?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"account_id\": 10001,\n \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/tools/invoke?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 \"target_locator\": \"web-01\",\n \"tools\": [\n {\n \"tool\": \"os.overview\",\n \"params\": {}\n },\n {\n \"tool\": \"net.tcp_ping\",\n \"params\": {\n \"host\": \"10.0.0.10\",\n \"port\": 3306\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"target": {
"kind": "host",
"locator": "web-01"
},
"results": [
{
"tool": "os.overview",
"tool_version": "0.5.0",
"data": {
"data": {
"sample_interval_sec": 3,
"degraded": false,
"degradation_reasons": []
},
"summary": "os.overview ...",
"truncated": {
"truncated": false
}
},
"error": null,
"agent_elapsed_ms": 3120,
"e2e_elapsed_ms": 3188
},
{
"tool": "net.tcp_ping",
"tool_version": "0.5.0",
"data": null,
"error": {
"code": "target_unreachable",
"message": "dial tcp 10.0.0.10:3306: i/o timeout"
},
"agent_elapsed_ms": 0,
"e2e_elapsed_ms": 2008
}
],
"error": null
}
}{
"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(只读;不受特定权限分类约束) |
使用说明
- 单次调用至多 8 个工具(
MaxToolsPerInvoke);超出需在客户端拆分。8 个工具的上限与单监控对象 Agent 的并发能力对齐。 - 工具在 Agent 上并行执行;webapi 返回的
results[]与请求中的tools[]顺序对齐。 - 长耗时:客户端超时至少设置 35 秒。该接口面向 AI-SRE / 人工排障流程,不适用于交互式 UI。
- 请求级错误(
target_unavailable、ambiguous_target_kind、unknown_toolset_hash、forward_failed)以 HTTP 200 返回,data.error不为空,data.results = []。 - 单工具失败以 HTTP 200 返回,
data.error = null,results[i].error被填充——务必同时检查三层(外层信封error、data.error、再到每个results[i].error)。 - 每条结果带两个耗时字段:
agent_elapsed_ms(Agent 自报,不含网络)与e2e_elapsed_ms(webapi 观测的端到端)。两者差距较大表示网络 / 边缘侧慢,而非工具执行慢。 - 按
/monit/tools/catalog返回的input_schema构造tools[].params。对于无参工具,务必显式传params: {}。
授权
在 Flashduty 控制台 账户 → APP Key 中签发的 app_key。调用任何公开 API 时都必须携带。它等同于所属账户的身份凭证,请妥善保管。
请求体
application/json
此页面对您有帮助吗?
⌘I