事件详情过滤规则填写说明
更新时间:2024-08-16
针对云产品事件触发的报警事件运维,运维编排服务OOS支持丰富且灵活的过滤规则配置,多个过滤规则之间是且关系,满足所有过滤规则筛选的事件才会触发运维动作,其格式如下:
[
{"key": targetKey1, "op": op1, "value": targetValue1},
{"key": targetKey2, "op": op2, "value": targetValue2}
]
targetKey可以从云产品事件结构体中获取,op目前支持的可选项及含义如下:
op取值 | 含义 | 示例 | 说明 |
---|---|---|---|
= | 等于 | {"key": "resource.resourceId", "op": "=", "value": "i-oFtYX3xx"} | 发送事件结构体中的resourceId等于i-oFtYX3xx则满足过滤规则 |
= | 等于 | {"key": "resource.region", "op": "!=", "value": "bj"} | 发送事件结构体中的region不等于bj则满足过滤规则 |
in | 被包含 | {"key": "resource.eventType", "op": "in", "value": ["GpuHighTemperature", "InstanceStateChange"]} | 发送事件结构体中的eventType等于GpuHighTemperature或InstanceStateChange则满足过滤规则 |
notin | 不被包含 | {"key": "resource.eventLevel", "op": "notin", "value": ["NOTICE", "WARN"]} | 发送事件结构体中的eventLevel不等于NOTICE且不等于WARN则满足过滤规则 |
exists | 存在该字段 | {"key": "resource.resourceType", "op": "exists", "value": ""} | 发送事件结构体中存在resourceType字段则满足过滤规则 |
notexists | 不存在该字段 | {"key": "resource.timestamp", "op": "notexists", "value": ""} | 发送事件结构体中不存在timestamp字段则满足过滤规则 |
contains | 字符串包含 | {"key": "resource.eventId", "op": "contains", "value": "event___"} | 发送事件结构体中的eventId字段包含event___则满足过滤规则 |
以云服务器BCC事件为例,如果想配置事件等级为NOTICE类型,并且事件类型是GPU温度过高或BCC状态变化通知的过滤规则,则配置示例如下:
[
{"key": "resource.eventLevel", "op": "=", "value": "NOTICE"},
{"key": "resource.eventType", "op": "in", "value": ["GpuHighTemperature", "InstanceStateChange"]}
]
// 云服务器BCC推送报警事件示例如下
{
"eventId": "event-bcc-123",
"eventLevel": "NOTICE",
"timestamp": "2022-12-08T14:47:00Z",
"resourceType": "INSTANCE",
"resourceId": "i-6PcfS1xx",
"longInstanceId": "90828af5-f212-43a0-96b8-d9bee26e0bcd",
"region": "bj",
"eventType": "InstanceStateChange",
"eventAlias": "BCC状态变化通知",
"content": "{\"info\":\"BCC实例状态变化\",\"advice\":\"您的BCC实例i-6PcfS1xx状态已变更为运行中\"}"
}