curl --request POST \
--url 'https://api.flashcat.cloud/monit/rule/v2/create?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"folder_id": 100,
"name": "CPU High",
"ds_type": "prometheus",
"ds_list": [
"prometheus*"
],
"enabled": true,
"cron_pattern": "0 * * * * *",
"channel_ids": [
20001
],
"rule_configs": {
"queries": [
{
"name": "A",
"expr": "100 - avg(cpu_usage_idle)"
}
],
"check_threshold": {
"enabled": true,
"alerting_check_times": 3,
"alerting_window_size": 5,
"recovery_check_times": 2,
"critical": "$A > 90",
"warning": "$A > 80",
"recovery_mode": "condition_clear"
}
}
}
'import requests
url = "https://api.flashcat.cloud/monit/rule/v2/create?app_key="
payload = {
"folder_id": 100,
"name": "CPU High",
"ds_type": "prometheus",
"ds_list": ["prometheus*"],
"enabled": True,
"cron_pattern": "0 * * * * *",
"channel_ids": [20001],
"rule_configs": {
"queries": [
{
"name": "A",
"expr": "100 - avg(cpu_usage_idle)"
}
],
"check_threshold": {
"enabled": True,
"alerting_check_times": 3,
"alerting_window_size": 5,
"recovery_check_times": 2,
"critical": "$A > 90",
"warning": "$A > 80",
"recovery_mode": "condition_clear"
}
}
}
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({
folder_id: 100,
name: 'CPU High',
ds_type: 'prometheus',
ds_list: ['prometheus*'],
enabled: true,
cron_pattern: '0 * * * * *',
channel_ids: [20001],
rule_configs: {
queries: [{name: 'A', expr: '100 - avg(cpu_usage_idle)'}],
check_threshold: {
enabled: true,
alerting_check_times: 3,
alerting_window_size: 5,
recovery_check_times: 2,
critical: '$A > 90',
warning: '$A > 80',
recovery_mode: 'condition_clear'
}
}
})
};
fetch('https://api.flashcat.cloud/monit/rule/v2/create?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/rule/v2/create?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([
'folder_id' => 100,
'name' => 'CPU High',
'ds_type' => 'prometheus',
'ds_list' => [
'prometheus*'
],
'enabled' => true,
'cron_pattern' => '0 * * * * *',
'channel_ids' => [
20001
],
'rule_configs' => [
'queries' => [
[
'name' => 'A',
'expr' => '100 - avg(cpu_usage_idle)'
]
],
'check_threshold' => [
'enabled' => true,
'alerting_check_times' => 3,
'alerting_window_size' => 5,
'recovery_check_times' => 2,
'critical' => '$A > 90',
'warning' => '$A > 80',
'recovery_mode' => 'condition_clear'
]
]
]),
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/rule/v2/create?app_key="
payload := strings.NewReader("{\n \"folder_id\": 100,\n \"name\": \"CPU High\",\n \"ds_type\": \"prometheus\",\n \"ds_list\": [\n \"prometheus*\"\n ],\n \"enabled\": true,\n \"cron_pattern\": \"0 * * * * *\",\n \"channel_ids\": [\n 20001\n ],\n \"rule_configs\": {\n \"queries\": [\n {\n \"name\": \"A\",\n \"expr\": \"100 - avg(cpu_usage_idle)\"\n }\n ],\n \"check_threshold\": {\n \"enabled\": true,\n \"alerting_check_times\": 3,\n \"alerting_window_size\": 5,\n \"recovery_check_times\": 2,\n \"critical\": \"$A > 90\",\n \"warning\": \"$A > 80\",\n \"recovery_mode\": \"condition_clear\"\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/rule/v2/create?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"folder_id\": 100,\n \"name\": \"CPU High\",\n \"ds_type\": \"prometheus\",\n \"ds_list\": [\n \"prometheus*\"\n ],\n \"enabled\": true,\n \"cron_pattern\": \"0 * * * * *\",\n \"channel_ids\": [\n 20001\n ],\n \"rule_configs\": {\n \"queries\": [\n {\n \"name\": \"A\",\n \"expr\": \"100 - avg(cpu_usage_idle)\"\n }\n ],\n \"check_threshold\": {\n \"enabled\": true,\n \"alerting_check_times\": 3,\n \"alerting_window_size\": 5,\n \"recovery_check_times\": 2,\n \"critical\": \"$A > 90\",\n \"warning\": \"$A > 80\",\n \"recovery_mode\": \"condition_clear\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/rule/v2/create?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 \"folder_id\": 100,\n \"name\": \"CPU High\",\n \"ds_type\": \"prometheus\",\n \"ds_list\": [\n \"prometheus*\"\n ],\n \"enabled\": true,\n \"cron_pattern\": \"0 * * * * *\",\n \"channel_ids\": [\n 20001\n ],\n \"rule_configs\": {\n \"queries\": [\n {\n \"name\": \"A\",\n \"expr\": \"100 - avg(cpu_usage_idle)\"\n }\n ],\n \"check_threshold\": {\n \"enabled\": true,\n \"alerting_check_times\": 3,\n \"alerting_window_size\": 5,\n \"recovery_check_times\": 2,\n \"critical\": \"$A > 90\",\n \"warning\": \"$A > 80\",\n \"recovery_mode\": \"condition_clear\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"id": 50001,
"account_id": 888,
"folder_id": 100,
"name": "CPU High",
"labels": {},
"ds_type": "prometheus",
"ds_list": [
"prometheus*"
],
"ds_ids": [],
"enabled": true,
"debug_log_enabled": false,
"rule_configs": {
"queries": [
{
"name": "A",
"expr": "100 - avg(cpu_usage_idle)"
}
],
"check_threshold": {
"enabled": true,
"alerting_check_times": 3,
"alerting_window_size": 5,
"recovery_check_times": 2,
"critical": "$A > 90",
"warning": "$A > 80",
"recovery_mode": "condition_clear"
}
},
"cron_pattern": "0 * * * * *",
"timezone": "Asia/Shanghai",
"delay_seconds": 0,
"enabled_times": [
{
"days": [
1,
2,
3,
4,
5,
6,
0
],
"stime": "00:00",
"etime": "23:59"
}
],
"annotations": {},
"description_type": "text",
"description": "",
"channel_ids": [
20001
],
"repeat_interval": 3600,
"repeat_total": 3,
"investigation_targets": [],
"creator_id": 66,
"creator_name": "zhangsan",
"updater_id": 66,
"updater_name": "zhangsan",
"created_at": 1712000000,
"updated_at": 1712000000
}
}{
"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."
}
}Create alert rule (V2)
Create a new V2 alert rule. Returns the created rule with its assigned ID.
curl --request POST \
--url 'https://api.flashcat.cloud/monit/rule/v2/create?app_key=' \
--header 'Content-Type: application/json' \
--data '
{
"folder_id": 100,
"name": "CPU High",
"ds_type": "prometheus",
"ds_list": [
"prometheus*"
],
"enabled": true,
"cron_pattern": "0 * * * * *",
"channel_ids": [
20001
],
"rule_configs": {
"queries": [
{
"name": "A",
"expr": "100 - avg(cpu_usage_idle)"
}
],
"check_threshold": {
"enabled": true,
"alerting_check_times": 3,
"alerting_window_size": 5,
"recovery_check_times": 2,
"critical": "$A > 90",
"warning": "$A > 80",
"recovery_mode": "condition_clear"
}
}
}
'import requests
url = "https://api.flashcat.cloud/monit/rule/v2/create?app_key="
payload = {
"folder_id": 100,
"name": "CPU High",
"ds_type": "prometheus",
"ds_list": ["prometheus*"],
"enabled": True,
"cron_pattern": "0 * * * * *",
"channel_ids": [20001],
"rule_configs": {
"queries": [
{
"name": "A",
"expr": "100 - avg(cpu_usage_idle)"
}
],
"check_threshold": {
"enabled": True,
"alerting_check_times": 3,
"alerting_window_size": 5,
"recovery_check_times": 2,
"critical": "$A > 90",
"warning": "$A > 80",
"recovery_mode": "condition_clear"
}
}
}
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({
folder_id: 100,
name: 'CPU High',
ds_type: 'prometheus',
ds_list: ['prometheus*'],
enabled: true,
cron_pattern: '0 * * * * *',
channel_ids: [20001],
rule_configs: {
queries: [{name: 'A', expr: '100 - avg(cpu_usage_idle)'}],
check_threshold: {
enabled: true,
alerting_check_times: 3,
alerting_window_size: 5,
recovery_check_times: 2,
critical: '$A > 90',
warning: '$A > 80',
recovery_mode: 'condition_clear'
}
}
})
};
fetch('https://api.flashcat.cloud/monit/rule/v2/create?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/rule/v2/create?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([
'folder_id' => 100,
'name' => 'CPU High',
'ds_type' => 'prometheus',
'ds_list' => [
'prometheus*'
],
'enabled' => true,
'cron_pattern' => '0 * * * * *',
'channel_ids' => [
20001
],
'rule_configs' => [
'queries' => [
[
'name' => 'A',
'expr' => '100 - avg(cpu_usage_idle)'
]
],
'check_threshold' => [
'enabled' => true,
'alerting_check_times' => 3,
'alerting_window_size' => 5,
'recovery_check_times' => 2,
'critical' => '$A > 90',
'warning' => '$A > 80',
'recovery_mode' => 'condition_clear'
]
]
]),
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/rule/v2/create?app_key="
payload := strings.NewReader("{\n \"folder_id\": 100,\n \"name\": \"CPU High\",\n \"ds_type\": \"prometheus\",\n \"ds_list\": [\n \"prometheus*\"\n ],\n \"enabled\": true,\n \"cron_pattern\": \"0 * * * * *\",\n \"channel_ids\": [\n 20001\n ],\n \"rule_configs\": {\n \"queries\": [\n {\n \"name\": \"A\",\n \"expr\": \"100 - avg(cpu_usage_idle)\"\n }\n ],\n \"check_threshold\": {\n \"enabled\": true,\n \"alerting_check_times\": 3,\n \"alerting_window_size\": 5,\n \"recovery_check_times\": 2,\n \"critical\": \"$A > 90\",\n \"warning\": \"$A > 80\",\n \"recovery_mode\": \"condition_clear\"\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/rule/v2/create?app_key=")
.header("Content-Type", "application/json")
.body("{\n \"folder_id\": 100,\n \"name\": \"CPU High\",\n \"ds_type\": \"prometheus\",\n \"ds_list\": [\n \"prometheus*\"\n ],\n \"enabled\": true,\n \"cron_pattern\": \"0 * * * * *\",\n \"channel_ids\": [\n 20001\n ],\n \"rule_configs\": {\n \"queries\": [\n {\n \"name\": \"A\",\n \"expr\": \"100 - avg(cpu_usage_idle)\"\n }\n ],\n \"check_threshold\": {\n \"enabled\": true,\n \"alerting_check_times\": 3,\n \"alerting_window_size\": 5,\n \"recovery_check_times\": 2,\n \"critical\": \"$A > 90\",\n \"warning\": \"$A > 80\",\n \"recovery_mode\": \"condition_clear\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flashcat.cloud/monit/rule/v2/create?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 \"folder_id\": 100,\n \"name\": \"CPU High\",\n \"ds_type\": \"prometheus\",\n \"ds_list\": [\n \"prometheus*\"\n ],\n \"enabled\": true,\n \"cron_pattern\": \"0 * * * * *\",\n \"channel_ids\": [\n 20001\n ],\n \"rule_configs\": {\n \"queries\": [\n {\n \"name\": \"A\",\n \"expr\": \"100 - avg(cpu_usage_idle)\"\n }\n ],\n \"check_threshold\": {\n \"enabled\": true,\n \"alerting_check_times\": 3,\n \"alerting_window_size\": 5,\n \"recovery_check_times\": 2,\n \"critical\": \"$A > 90\",\n \"warning\": \"$A > 80\",\n \"recovery_mode\": \"condition_clear\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4",
"data": {
"id": 50001,
"account_id": 888,
"folder_id": 100,
"name": "CPU High",
"labels": {},
"ds_type": "prometheus",
"ds_list": [
"prometheus*"
],
"ds_ids": [],
"enabled": true,
"debug_log_enabled": false,
"rule_configs": {
"queries": [
{
"name": "A",
"expr": "100 - avg(cpu_usage_idle)"
}
],
"check_threshold": {
"enabled": true,
"alerting_check_times": 3,
"alerting_window_size": 5,
"recovery_check_times": 2,
"critical": "$A > 90",
"warning": "$A > 80",
"recovery_mode": "condition_clear"
}
},
"cron_pattern": "0 * * * * *",
"timezone": "Asia/Shanghai",
"delay_seconds": 0,
"enabled_times": [
{
"days": [
1,
2,
3,
4,
5,
6,
0
],
"stime": "00:00",
"etime": "23:59"
}
],
"annotations": {},
"description_type": "text",
"description": "",
"channel_ids": [
20001
],
"repeat_interval": 3600,
"repeat_total": 3,
"investigation_targets": [],
"creator_id": 66,
"creator_name": "zhangsan",
"updater_id": 66,
"updater_name": "zhangsan",
"created_at": 1712000000,
"updated_at": 1712000000
}
}{
"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."
}
}Restrictions
| Aspect | Value |
|---|---|
| Rate limits | 300 requests/minute; 20 requests/second per account |
| Permissions | Alerting Rules Manage (monit) |
Usage
name,ds_type,enabled,cron_pattern, andrule_configs.queriesare required; eitherds_list(supports wildcards) ords_idsmust be non-empty.enabledmust be passed explicitly (includingfalse); omitting it returnsInvalidParameter.id,account_id,creator_*,updater_*,created_at, andupdated_atare assigned by the server; client-supplied values are ignored.namemust be unique withinfolder_id; a duplicate returnsInvalidParameter.channel_idscan be empty; alerts will then route through the global integration.- The request body tolerates additional unknown fields (forward compatibility); they are ignored.
- Every call is recorded in the account audit log. Don’t put secrets in request fields.
Authorizations
App key issued from the Flashduty console under Account → APP Keys. Required on every public API call. Keep it secret — it grants the same access as the owning account.
Body
Complete V2 alert rule configuration. The core difference from V1 lives in rule_configs: the three checkers describe recovery and ending semantics with the lifecycle v2 recovery_mode/end_mode enums.
ID of the folder the rule belongs to; list folders via POST /monit/folder/list. Cannot be changed through the update API — use /monit/rule/move instead.
Rule name. Must be unique within the folder and at most 128 characters.
Datasource type identifier (e.g. prometheus, elasticsearch).
Whether the rule is enabled. Required — the server enforces an explicit value (including false) while decoding. Setting it to false on update clears the rule's active alerts.
Detection configuration: query list plus trigger/recovery conditions. See AlertRuleConfigsV2.
Show child attributes
Show child attributes
Schedule expression: a 6-field cron (with seconds) or an @every 30s interval. Must not start with CRON_TZ= or TZ=; set the timezone in the timezone field instead.
Rule ID. Required on update; omit on create (assigned by the server).
Account ID, filled by the server from the authentication context; any client-supplied value is ignored.
Custom labels.
Show child attributes
Show child attributes
Datasource name match patterns (wildcards supported). At least one of ds_list / ds_ids must be non-empty; both are merged to decide which datasources the rule monitors.
Datasource ID list, merged with ds_list to decide the monitored datasources; IDs survive datasource renames. At least one of ds_list / ds_ids must be provided.
Enable debug logging; the edge then emits detailed evaluation logs for this rule, useful when the rule does not trigger as expected.
Timezone the rule runs in; it decides how the cron schedule and enabled time windows are interpreted. Only IANA names are accepted (e.g. Asia/Shanghai, UTC, Europe/London); abbreviations or offsets like Local, UTC+8, CST are rejected. Empty falls back to Asia/Shanghai.
Seconds the evaluation query window is shifted back, compensating for data ingestion latency.
Time windows during which the rule is in effect. When omitted or empty, the rule is active 00:00–23:59 every day.
Show child attributes
Show child attributes
Extra annotation key-value pairs delivered with alert events; keys must not start with $ (reserved for query fields).
Show child attributes
Show child attributes
Format of the description content. Empty or omitted defaults to text. text = plain text; markdown = Markdown, rendered as such in alert details.
text, markdown Rule description, Markdown format.
Collaboration space IDs alerts are sent to. May be empty; alerts then route through the global integration.
Notification repeat interval in seconds. Values below 1 fall back to the default 3600.
Maximum number of repeat notifications. Values below 1 fall back to the default 3.
Drill-down entries linked from the alert event detail page; at most 20 items, duplicates rejected. On update the field is presence-based: omit it to keep the current value, pass [] to clear.
Show child attributes
Show child attributes
Creator member ID, filled by the server from the current user; any client-supplied value is ignored.
Creator name, filled by the server; any client-supplied value is ignored.
ID of the member who last updated the rule, filled by the server; any client-supplied value is ignored.
Name of the member who last updated the rule, filled by the server; any client-supplied value is ignored.
Creation time as a Unix timestamp in seconds, generated by the server; any client-supplied value is ignored.
Last update time as a Unix timestamp in seconds, generated by the server; any client-supplied value is ignored.
Response
Success
Success response envelope. On every 2xx response, request_id identifies the call (also mirrored in the Flashcat-Request-Id header) and data holds the endpoint-specific payload. Failure responses use a different shape — see ErrorResponse.
Unique ID for this request. Mirrored in the Flashcat-Request-Id response header. Include it when reporting issues.
"01HK8XQE3Z7JM2NTFQ5YJ8P9R4"
Complete V2 alert rule configuration. The core difference from V1 lives in rule_configs: the three checkers describe recovery and ending semantics with the lifecycle v2 recovery_mode/end_mode enums.
Show child attributes
Show child attributes
Was this page helpful?