Cloudwatch见解解析正则表达式语法不匹配应匹配的字符串

时间:2019-12-03 00:42:27

标签: amazon-cloudwatch aws-cloudwatch-log-insights

短版

此查询与type,sub_type或missing_fields不匹配。我可以在不使用洞察正则表达式语法的情况下使此查询正常运行,但是我想知道如何弄乱正则表达式语法

长版

我在Cloudwatch见解查询中有一条日志行,看起来像

Extra keys detected in record for schema type "type" and sub_type "sub_type". Error: extra keys not allowed @ data['a_key'],extra keys not allowed @ data['another_key'],

我正在尝试使用

 filter @message like /Extra keys detected/
| parse @message /Extra keys detected in record for schema type \"\[(?<type>\S+)\"\] and sub_type \"\[(?<sub_type>\S+)\"\]. Error: (extra keys not allowed @ data\[(?<missing_fields>.*)\])*,/

这可能缺少任意数量的键。

此查询未捕获type和sub_type,这实际上是我解决此问题所需的全部。字段名称的分组是非常不错的奖励,因为这意味着我不需要进行任何第二遍处理。

0 个答案:

没有答案