事件模式
更新时间:2024-10-22
事件模式是事件总线EventBridge用来过滤相关事件的模式定义。事件总线EventBridge通过事件模式过滤事件并将事件路由到事件目标,事件模式必须和匹配的事件具有相同的结构。本文介绍事件模式的常用类型。一期暂只支持指定值匹配,二期支持前缀匹配,包含匹配,后缀匹配,除外匹配,数值匹配等。
指定值匹配
您可以指定某个字段的值进行匹配。例如,以下示例事件模式只匹配source是阿里云对象存储OSS的事件。下表介绍事件从事件源发出经过事件模式过滤的过程。
- 从事件源接收的事件
{
"data": {
"name": "test",
"info": "系统出现异常",
"advice": "请联系管理员"
},
"id": "*****",
"source": "xxxxx",
"specversion": "1.0",
"type": "CFS-USAGE_MORE_80_PERCENT",
"subject": "*****",
"time": "2020-11-19T21:04:41+08:00",
"level": "CRITICAL",
"accountId": "*****",
"eventBusId": "eb-1b63902d",
"eventBusName": "defualt",
"eventAlias": "Lessthan20%ofremainingcapacity",
"eventAliasEn": "CFS-USAGE_MORE_80_PERCENT",
"region": "bj",
"recvTimestamp": "2020-11-19T21:04:41+08:00"
}
- 事件模式
"source": "xxxxx",
- 模式过滤后的事件:
{
"data": {
"name": "test",
"info": "系统出现异常",
"advice": "请联系管理员"
},
"id": "*****",
"source": "xxxxx",
"specversion": "1.0",
"type": "CFS-USAGE_MORE_80_PERCENT",
"subject": "*****",
"time": "2020-11-19T21:04:41+08:00",
"level": "CRITICAL",
"accountId": "*****",
"eventBusId": "eb-1b63902d",
"eventBusName": "defualt",
"eventAlias": "Lessthan20%ofremainingcapacity",
"eventAliasEn": "CFS-USAGE_MORE_80_PERCENT",
"region": "bj",
"recvTimestamp": "2020-11-19T21:04:41+08:00"
}