pingmesh-报警规则导出
POST
https://api.flashcat.cloud/api/n9e-plus/pingmesh/alert-rules/export
pingmesh
最后修改时间:2024-03-08 11:32:02
body参数说明:
metric:
- ping_percent_packet_loss (icmp协议丢包率) ping_maximum_response_ms(最大延迟)
- net_response_response_time (tcp/udp: 延时 )
aggregation: 指标聚合方法
- max
- avg
- min
op: metric阈值比较方法:
- < 、> 、<= 、>= 、== 、!=
threshold: 阈值(string类型)
- 如 -1, 23.223, 100
logic: 多个metric之间的逻辑运算服
- || 、&&
severity: 报警等级 1,2,3
idc_relation: 机房间关系: idc_inside、idc_between
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.flashcat.cloud/api/n9e-plus/pingmesh/alert-rules/export' \
--header 'Content-Type: application/json' \
--data-raw '{
"notify_channels": [
"feishu",
"qq"
],
"notify_groups": [
"2"
],
"alert_rules": [
{
"idc_relation": "idc_inside",
"severity": 2,
"rules": [
{
"cate": "idc",
"aggregation": "max",
"metric": "ping_percent_packet_loss",
"op": ">",
"threshold": "40",
"logic": "||"
},
{
"cate": "idc",
"aggregation": "max",
"metric": "net_response_response_time",
"op": ">",
"threshold": "43.20",
"logic": ""
}
]
},
{
"idc_relation": "idc_between",
"severity": 2,
"rules": [
{
"cate": "net_ident",
"aggregation": "max",
"metric": "ping_percent_packet_loss",
"op": ">",
"threshold": "40",
"logic": "||"
},
{
"cate": "server",
"aggregation": "max",
"metric": "net_response_response_time",
"op": ">",
"threshold": "43.20",
"logic": ""
}
]
},
{
"idc_relation": "custom",
"severity": 2,
"source_idc": "idc1",
"target_idc": "idc2",
"rules": [
{
"cate": "net_ident",
"aggregation": "max",
"metric": "ping_percent_packet_loss",
"op": ">",
"threshold": "40",
"logic": "||"
},
{
"cate": "server",
"aggregation": "max",
"metric": "net_response_response_time",
"op": ">",
"threshold": "43.20",
"logic": ""
}
]
}
]
}'
响应示例响应示例
{
"dat": [
{
"id": 0,
"group_id": 0,
"cate": "prometheus",
"datasource_ids": [
849
],
"cluster": "",
"name": "pingmesh-IDC内-丢包率or延迟告警",
"note": "pingmesh alert rule of the idc_inside",
"prod": "",
"algorithm": "",
"algo_params": null,
"delay": 0,
"severity": 3,
"severities": null,
"disabled": 0,
"prom_for_duration": 60,
"prom_ql": "max by(sidc,tidc,protocol,relation)(ping_percent_packet_loss{relation=\"idc_inside\"}) > 40 or max by(sidc,tidc,protocol,relation)(net_response_response_time{relation=\"idc_inside\"}) > 43.20",
"rule_config": null,
"prom_eval_interval": 30,
"enable_stime": "00:00",
"enable_stimes": null,
"enable_etime": "23:59",
"enable_etimes": null,
"enable_days_of_week": [
"1",
"2",
"3",
"4",
"5",
"6",
"0"
],
"enable_days_of_weeks": null,
"enable_in_bg": 0,
"notify_recovered": 1,
"notify_channels": [
"feishu",
"qq"
],
"notify_groups_obj": null,
"notify_groups": [
"2"
],
"notify_repeat_step": 60,
"notify_max_number": 0,
"recover_duration": 0,
"callbacks": null,
"runbook_url": "",
"append_tags": null,
"annotations": null,
"extra_config": null,
"create_at": 0,
"create_by": "",
"update_at": 0,
"update_by": ""
},
{
"id": 0,
"group_id": 0,
"cate": "prometheus",
"datasource_ids": [
849
],
"cluster": "",
"name": "pingmesh-IDC之间-机柜之间丢包率or服务器之间延迟告警",
"note": "pingmesh alert rule of the idc_between",
"prod": "",
"algorithm": "",
"algo_params": null,
"delay": 0,
"severity": 3,
"severities": null,
"disabled": 0,
"prom_for_duration": 60,
"prom_ql": "max by(sidc,tidc,protocol,relation,snet_ident,tnet_ident)(ping_percent_packet_loss{relation=\"idc_between\"}) > 40 or max by(sidc,tidc,protocol,relation,snet_ident,tnet_ident,ident,target)(net_response_response_time{relation=\"idc_between\"}) > 43.20",
"rule_config": null,
"prom_eval_interval": 30,
"enable_stime": "00:00",
"enable_stimes": null,
"enable_etime": "23:59",
"enable_etimes": null,
"enable_days_of_week": [
"1",
"2",
"3",
"4",
"5",
"6",
"0"
],
"enable_days_of_weeks": null,
"enable_in_bg": 0,
"notify_recovered": 1,
"notify_channels": [
"feishu",
"qq"
],
"notify_groups_obj": null,
"notify_groups": [
"2"
],
"notify_repeat_step": 60,
"notify_max_number": 0,
"recover_duration": 0,
"callbacks": null,
"runbook_url": "",
"append_tags": null,
"annotations": null,
"extra_config": null,
"create_at": 0,
"create_by": "",
"update_at": 0,
"update_by": ""
},
{
"id": 0,
"group_id": 0,
"cate": "prometheus",
"datasource_ids": [
849
],
"cluster": "",
"name": "pingmesh-IDC之间从idc1到idc2,机柜之间丢包率or服务器之间延迟告警",
"note": "pingmesh alert rule of the custom",
"prod": "",
"algorithm": "",
"algo_params": null,
"delay": 0,
"severity": 3,
"severities": null,
"disabled": 0,
"prom_for_duration": 60,
"prom_ql": "max by(sidc,tidc,protocol,relation,snet_ident,tnet_ident)(ping_percent_packet_loss{sidc=\"41#idc1\",tidc=\"40#idc2\"}) > 40 or max by(sidc,tidc,protocol,relation,snet_ident,tnet_ident,ident,target)(net_response_response_time{sidc=\"41#idc1\",tidc=\"40#idc2\"}) > 43.20",
"rule_config": null,
"prom_eval_interval": 30,
"enable_stime": "00:00",
"enable_stimes": null,
"enable_etime": "23:59",
"enable_etimes": null,
"enable_days_of_week": [
"1",
"2",
"3",
"4",
"5",
"6",
"0"
],
"enable_days_of_weeks": null,
"enable_in_bg": 0,
"notify_recovered": 1,
"notify_channels": [
"feishu",
"qq"
],
"notify_groups_obj": null,
"notify_groups": [
"2"
],
"notify_repeat_step": 60,
"notify_max_number": 0,
"recover_duration": 0,
"callbacks": null,
"runbook_url": "",
"append_tags": null,
"annotations": null,
"extra_config": null,
"create_at": 0,
"create_by": "",
"update_at": 0,
"update_by": ""
}
],
"err": ""
}
请求参数
Header 参数
Authorization
string
可选
示例值:
Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NfdXVpZCI6IjRlNzYxNmY2LWFjZGUtNGNlNS04MmE3LTBiMTgyYzJjYzQ2ZiIsImF1dGhvcml6ZWQiOnRydWUsImV4cCI6MTcwMDA0NjQxNiwidXNlcl9pZGVudGl0eSI6IjEtcm9vdCJ9.Xe_fI7H2tUnLtnwe7fkI4wT0DBYetLkUWG2O_0KuoYM
Body 参数application/json