过滤规则示例
本章节介绍所有匹配类型的过滤规则示例,供您参考。
匹配类型如下所示:
完全匹配
指定某个String类型字段的值进行完全匹配。如下表所示,过滤规则匹配“source”为“HC.OBS”的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}]
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
指定某个Number类型字段的值进行完全匹配。如下表所示,过滤规则只匹配“data”下“age”是10的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"age":10
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"age":[{
"op": "NumberIn",
"values":[10]
}]
}
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"age":10
}
}]
} |
除外匹配
指定某个String类型字段与除了提供的值之外的任何值进行匹配。如下表所示,过滤规则只匹配“type”不是“object:get”的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"type": [{
"op": "StringNotIn",
"values": ["object:get"]
}]
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
指定某个Number类型字段与除了提供的值之外的任何值进行匹配。如下表所示,过滤规则只匹配“data”下“age”不是“11”的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"age":10
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"age":[{
"op": "NumberNotIn",
"values":[11]
}]
}
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"age":10
}
}]
} |
前缀匹配
指定某个字段的值进行前缀匹配。如下表所示,过滤规则只匹配“type”字段以“object:”开头的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"type": [{
"op": "StringStartsWith",
"values": ["object:"]
}]
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
前缀不匹配
指定某个字段的值进行前缀不匹配。如下表所示,过滤规则只匹配“source”字段不以“HC”开头的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"source": [{
"op": "StringNotStartsWith",
"values": ["HC"]
}]
} |
无 |
后缀匹配
指定某个字段的值进行后缀匹配。如下表所示,过滤规则只匹配“subject”字段以“jpg”结尾的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"subject": [{
"op": "StringEndsWith",
"values": ["jpg"]
}]
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
后缀不匹配
指定某个字段的值进行后缀不匹配。如下表所示,过滤规则只匹配“subject”字段不以“txt”结尾的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"subject":[{
"op": "StringNotEndsWith",
"values": ["txt"]
}]
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable"
}
}]
} |
数值范围匹配
指定某个字段的数值范围。如下表所示,过滤规则只匹配“data”下“size”字段小于20的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"size":[{
"op": "NumberLessThan",
"value":20
}]
}
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
如下表所示,过滤规则只匹配“data”下“size”字段大于等于2的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"size":[{
"op": "NumberNotLessThan",
"value":2
}]
}
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
如下表所示,过滤规则只匹配“data”下“size”字段大于9的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"size":[{
"op": "NumberGreaterThan",
"value":9
}]
}
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
如下表所示,过滤规则只匹配“data”下“size”字段不大于9的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"size":[{
"op": "NumberNotGreaterThan",
"value":9
}]
}
} |
无 |
如下表所示,过滤规则只匹配“data”下“size”字段取值在1到20之间的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"size":[{
"op": "NumberInRange",
"values":[
[
1,
20
]
]
}]
}
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
如下表所示,过滤规则只匹配“data”下“size”字段取值小于1或大于20的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"size":[{
"op": "NumberNotInRange",
"values":[
[
1,
20
]
]
}]
}
} |
无 |
空值匹配
检查某个字段的值是否为null或未定义。如下表所示,过滤规则只匹配“data”下“size”和“age”字段取值为null或未定义的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size": null
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"size":[{
"op": "IsNull"
}],
"age":[{
"op": "IsNull"
}]
}
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":null
}
}]
} |
非空匹配
检查某个字段的值是否不为null。如下表所示,过滤规则只匹配“data”下“size”和“name”字段取值不为null的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size": 10
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"size":[{
"op": "IsNotNull"
}],
"name":[{
"op": "IsNotNull"
}]
}
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size":10
}
}]
} |
为true匹配
检查某个字段的值是否为true。如下表所示,过滤规则只匹配“data”下存在“size”和“name”字段取值为true的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": true,
"state": "enable",
"size": true
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"size":[{
"op": "IsTrue"
}],
"name":[{
"op": "IsTrue"
}]
}
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": true,
"state": "enable",
"size":true
}
}]
} |
不为true匹配
检查某个字段的值是否不为true。如下表所示,过滤规则只匹配“data”下存在“name”字段取值不为true的事件。
|
从事件源接收的事件 |
过滤规则 |
过滤后的事件 |
|---|---|---|
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size": null
}
}]
} |
{
"source": [{
"op": "StringIn",
"values": ["HC.OBS"]
}],
"data":{
"name":[{
"op": "IsNotTrue"
}]
}
} |
{
"events":[{
"id": "4b26115b-778e-11ec-******",
"specversion": "1.0",
"source": "HC.OBS",
"type": "object:put",
"datacontenttype": "application/json",
"subject": "xxx.jpg",
"time": "2022-01-17T12:07:00.955Z",
"data": {
"name": "test01",
"state": "enable",
"size": null
}
}]
}
|