创建分派策略¶
通过以下接口创建睿象云分派策略
示例¶
请求cURl
curl --location --request POST 'https://caweb.aiops.com/api/alert/rest/api/v1/escalation' \
--user 'email@example.com:<access_token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
"description":"分派名称",
"triggers":[
{
"integrateType":"zabbix",
"exps":[
{
"tagKey":"app",
"condition":"equals",
"tagValue":"7a2d2afe2ae140538exxxxxxxxxx0bec",
"labelId":"app",
"useReg":1,
"symbol":0
},
{
"tagKey":"priority",
"condition":"equals",
"tagValue":"1",
"labelId":"00000000-0000-0000-0000-000000000002",
"useReg":1,
"symbol":0
}
]
},
{
"integrateType":"prometheus",
"exps":[
{
"tagKey":"app",
"condition":"equals",
"tagValue":"e832fec76c89457d9cxxxxxxxxxx6a04",
"labelId":"app",
"useReg":1,
"symbol":1
},
{
"tagKey":"alarmContent",
"condition":"equals",
"tagValue":"测试",
"labelId":"00000000-0000-0000-0000-000000000001",
"useReg":0,
"symbol":1
}
]
}
],
"policies":[
{
"interval":"30",
"users":"100004604423",
"schedulers":"",
"cooperation":"",
"groups":"",
"cooperationUsers":[
]
},
{
"interval":"30",
"users":"",
"schedulers":"",
"cooperation":"7ad18da9ac2340e6bae4ad4272bba03e,24b8f75684fc41efbc4bea9bcdfc3f1a",
"groups":"",
"cooperationUsers":[
{
"cooperation":"7ad18da9ac2340e6bae4ad4272bba03e",
"users":[
]
},
{
"cooperation":"24b8f75684fc41efbc4bea9bcdfc3f1a",
"users":[
"100004604423"
]
}
]
}
]
}
access_token如何获取请参考文档 api令牌
提示
• 示例邮箱应替换为用户注册所用邮箱
• access_token应替换为您手动获取的access_token
• 如需对请求进行加密处理:请将
--user 'email@example.com:access_token' \
--header 'Accept: application/json'
替换为:
--header 'Authorization: Basic Z2FveWluaW5nOTk5NUAxNjMuY29tOmt1WWl6bmljZ3oxN0JBVjk=' \
--header 'Content-Type: application/json'
• 替换步骤请参考加密步骤
请求参数¶
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| description | string | 必须 | 分派的描述 |
| triggers | Array(trigger) | 必须 | 分派条件,值得注意的是,此列表是必须的,也不能是空的列表。 |
| policies | Array(policy) | 必须 | 分派对象,值得注意的是,此列表是必须的,但可以是空的列表 |
| exps | Array(exp) | 必须 | 策略列表(用于trigger构造) |
| integrateType | string | 必须 | 接入类型(用于trigger构造) |
| tagKey | string | 必须 | 目标标签(你可以通过标签来获取标签) |
| condition | string | 必须 | 表达式 :equals--等于 not_equals--不等于 in--在列表中 not_in--不在列表中。 |
| tagValue | string | 必须 | 目标值 |
| useReg | int | 必须 | 是否正则 |
| symbol | int | 必须 | 策略关系 1:且 0或 |
| labelId | string | 必须 | 标签Id |
| interval | string | 必须 | 间隔(分钟) |
| users | string | 非必须 | 分派用户,参阅用户,将用户Id用英文逗号隔开的字符串。 |
| schedulers | string | 非必须 | 排班,参阅排班,将排班Id用英文逗号隔开的字符串。 |
| cooperation | string | 非必须 | 协作,参阅协作,将协作Id用英文逗号隔开的字符串。 |
| groups | string | 非必须 | 分组,参阅分组,将分组Id用英文逗号隔开的字符串。 |
| cooperationUsers | Aarry(obj) | 非必须 | 协作指定@用户,由coopreation&users构造,cooperation字段要符合在协作字段中的一个,并将userId按照Array |
错误响应码¶
| 错误码 | 说明 |
|---|---|
| 200 | 成功 |
| 400 | 失败,传入的参数有问题 |
| 401 | 认证失败,用户名密码错误 |
| 403 | 权限失败,用户没有权限做此操作 |