CloudWatch 事件模式匹配中的正则表达式
regex in CloudWatch event pattern matching
如何在正则表达式上匹配 CloudWatch 事件。我只需要调用特定作业名称上的特定 SNS 目标。例如,如下所示,我想在 TranscriptionJobName 上进行正则表达式匹配。谢谢
{
"source": [
"aws.transcribe"
],
"detail-type": [
"Transcribe Job State Change"
],
"detail": {
"TranscriptionJobStatus": [
"COMPLETED",
"FAILED"
],
"TranscriptionJobName": [
"transcription-localhost-*"
]
}
}
我最终为每个目标 SNS 主题创建了单独的规则。
我也在尝试解决这个问题,但根据以下 AWS 文档,这似乎不可能。
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CloudWatchEventsandEventPatterns.html
It is important to remember the following about event pattern
matching:
For a pattern to match an event, the event must contain all the field names listed in the pattern. The field names must appear in the
event with the same nesting structure.
Other fields of the event not mentioned in the pattern are ignored; effectively, there is a "": "" wildcard for fields not mentioned.
The matching is exact (character-by-character), without case-folding or any other string normalization.
The values being matched follow JSON rules: Strings enclosed in quotes, numbers, and the unquoted keywords true, false, and null.
Number matching is at the string representation level. For example, 300, 300.0, and 3.0e2 are not considered equal.
无赖...
EventBridge 及其 ability to do prefix matching 现在可以做到这一点。这对我有用。我将 Lambda 函数设置为目标,该函数仅在转录作业达到 COMPLETED
状态且作业名称以 voicemail-
.
开头时执行
{
"source": [
"aws.transcribe"
],
"detail": {
"TranscriptionJobName": [
{
"prefix": "voicemail-"
}
],
"TranscriptionJobStatus": [
"COMPLETED"
]
}
}
我已经通过在事件模式中使用数字匹配表达式来解决这个问题,如下所示;
{
"detail": {
"severity": [{
"numeric": [">", 0, "<=", 8.9]
}]
},
"detail-type": [
"GuardDuty Finding"
],
"source": [
"aws.guardduty"
]
}
如何在正则表达式上匹配 CloudWatch 事件。我只需要调用特定作业名称上的特定 SNS 目标。例如,如下所示,我想在 TranscriptionJobName 上进行正则表达式匹配。谢谢
{
"source": [
"aws.transcribe"
],
"detail-type": [
"Transcribe Job State Change"
],
"detail": {
"TranscriptionJobStatus": [
"COMPLETED",
"FAILED"
],
"TranscriptionJobName": [
"transcription-localhost-*"
]
}
}
我最终为每个目标 SNS 主题创建了单独的规则。
我也在尝试解决这个问题,但根据以下 AWS 文档,这似乎不可能。
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/CloudWatchEventsandEventPatterns.html
It is important to remember the following about event pattern matching:
For a pattern to match an event, the event must contain all the field names listed in the pattern. The field names must appear in the event with the same nesting structure.
Other fields of the event not mentioned in the pattern are ignored; effectively, there is a "": "" wildcard for fields not mentioned.
The matching is exact (character-by-character), without case-folding or any other string normalization.
The values being matched follow JSON rules: Strings enclosed in quotes, numbers, and the unquoted keywords true, false, and null.
Number matching is at the string representation level. For example, 300, 300.0, and 3.0e2 are not considered equal.
无赖...
EventBridge 及其 ability to do prefix matching 现在可以做到这一点。这对我有用。我将 Lambda 函数设置为目标,该函数仅在转录作业达到 COMPLETED
状态且作业名称以 voicemail-
.
{
"source": [
"aws.transcribe"
],
"detail": {
"TranscriptionJobName": [
{
"prefix": "voicemail-"
}
],
"TranscriptionJobStatus": [
"COMPLETED"
]
}
}
我已经通过在事件模式中使用数字匹配表达式来解决这个问题,如下所示;
{
"detail": {
"severity": [{
"numeric": [">", 0, "<=", 8.9]
}]
},
"detail-type": [
"GuardDuty Finding"
],
"source": [
"aws.guardduty"
]
}