资源类型 | resource_name字段 | record_id字段 | record_tag字段 | 示例 | 备注 |
用户 | sls.common.user | user_id | user_name | {
"user_id": "alex",
"user_name": "Alex",
"email": [
"***@example.com"
],
"country_code": "86",
"phone": "133****3333",
"enabled": true,
"sms_enabled": true,
"voice_enabled": true
}
| 无 |
用户组 | sls.common.user_group | user_group_id | user_group_name | {
"user_group_id": "devops",
"user_group_name": "DevOps Team",
"enabled": true,
"members": [
"alex"
]
}
| 无 |
值班组 | sls.alert.oncall_group | oncall_id | oncall_name | {
"oncall_id": "default_oncall",
"oncall_name": "Default Oncall",
"enabled": true,
"overrides": [],
"rotations": [
{
"targets": [
{
"type": "user",
"target_id": "alex"
},
{
"type": "user_group",
"target_id": "devops"
}
],
"end_time": 0,
"shift_day": "",
"shift_time": "12:00",
"shift_type": "day",
"start_time": 1633017600,
"shift_minute": 0,
"end_time_type": "none",
"shift_interval": 1,
"shift_week_custom": null,
"restriction_date_type": "workday",
"restriction_time_type": "allday",
"restriction_week_range": null,
"restriction_time_custom_range": null
}
],
"calendar_id": "default_calendar"
}
| 配置复杂,建议通过控制台完成配置。 |
Webhook集成 | sls.alert.action_webhook | id | name | {
"id": "custom-webhook",
"name": "Custom Webhook",
"type": "custom",
"url": "http://localhost:9099/data/webhook",
"method": "POST",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Foo",
"value": "bar"
}
]
}
{
"id": "dingtalk",
"name": "Dingtalk Webhook",
"type": "dingtalk",
"url": "https://oapi.dingtalk.com/robot/send?access_token=**********",
"method": "POST",
"secret": "SEC**********",
"headers": []
}
| |
告警策略 | sls.alert.alert_policy | policy_id | policy_name | {
"policy_id": "sls.builtin",
"policy_name": "SLS Builtin Alert Policy",
"parent_id": "sls.root",
"is_default": false,
"group_script": "fire(action_policy=\"sls.builtin\", group={\"project\": \"__a__\", \"uid\": alert.aliuid}, group_wait=\"5s\", group_interval=\"2m\", repeat_interval=\"2m\")\nstop()\nfire(action_policy=\"sls.builtin\", group={\"alert_id\": alert.alert_id}, group_wait=\"5s\", group_interval=\"10s\", repeat_interval=\"2m\")\nif alert.labels.name ~= \"^\\\\w+s$\":\n\tfire(action_policy=\"sls.builtin\", group={\"product\": \"xxs\"}, group_wait=\"5s\", group_interval=\"10s\", repeat_interval=\"2m\")\n\tstop()\nstop()\nfire(action_policy=\"sls.builtin\", group={\"label_name\": alert.labels.name}, group_wait=\"10s\", group_interval=\"10s\", repeat_interval=\"2m\")",
"inhibit_script": "if alert.severity >= 8:\n silence alert.severity < 6",
"silence_script": ""
}
| |
行动策略 | sls.alert.action_policy | action_policy_id | action_policy_name | {
"action_policy_id": "sls.builtin",
"action_policy_name": "SLS Builtin Action Policy",
"labels": {},
"is_default": false,
"primary_policy_script": "fire(type=\"webhook_integration\", integration_type=\"dingtalk\", webhook_id=\"dingtalk-test\", template_id=\"default-template\", period=\"any\")",
"secondary_policy_script": "fire(type=\"voice\", users=[\"jizhi\"], groups=[\"group-jizhi\"], template_id=\"default-template\")",
"escalation_start_enabled": false,
"escalation_start_timeout": "10s",
"escalation_inprogress_enabled": false,
"escalation_inprogress_timeout": "10s",
"escalation_enabled": false,
"escalation_timeout": "4h0m0s"
}
| is_default固定设置为false即可。 labels为保留参数,固定为空对象即可。 primary_policy_script为第一行动策略。 secondary_policy_script为第二行动策略。 escalation_*为控制第二行动策略是否开启的配置,可参见控制台中的配置项。 通过SDK配置时,primary_policy_script和secondary_policy_script只包含DSL脚本信息,无UI配置信息,因此控制台上无法看到相应的图形结构。
|
内容模板 | sls.alert.content_template | template_id | template_name | {
"template_id": "default-template",
"template_name": "Default Template",
"is_default": false,
"templates": {
"fc": {
"limit": 0,
"locale": "zh-CN",
"content": "",
"send_type": "merged"
},
"sms": {
"locale": "zh-CN",
"content": ""
},
"lark": {
"title": "Alerthub告警测试 ${alert_name}",
"locale": "zh-CN",
"content": ""
},
"email": {
"locale": "zh-CN",
"content": "",
"subject": "SLS告警测试-jizhi-test"
},
"slack": {
"title": "Alerthub告警测试 ${alert_name}",
"locale": "zh-CN",
"content": ""
},
"voice": {
"locale": "zh-CN",
"content": ""
},
"wechat": {
"title": "Alerthub告警测试 ${alert_name}",
"locale": "zh-CN",
"content": ""
},
"webhook": {
"limit": 0,
"locale": "zh-CN",
"content": "",
"send_type": "batch"
},
"dingtalk": {
"title": "Alerthub告警测试 ${alert_name}",
"locale": "zh-CN",
"content": ""
},
"event_bridge": {
"locale": "zh-CN",
"content": "",
"subject": "wkb-test"
},
"message_center": {
"locale": "zh-CN",
"content": ""
}
}
}
| |
默认日历 | sls.common.calendar | calendar_id | calendar_name | {
"calendar_id": "default_calendar",
"calendar_name": "Default Calendar",
"timezone": "Asia/Shanghai",
"workdays": [
1,
2,
3,
4,
5
],
"worktime": [
{
"end_time": "21:00",
"start_time": "09:00"
}
],
"reset_days": [],
"holiday_sync": "china"
}
| |