AWS Cloudwatch Json指标过滤器模式 [英] AWS Cloudwatch Json Metric Filter Pattern
问题描述
按照 Json Metric过滤器的Amazon示例,
我试图复制他们的例子。在创建指标过滤器的过程中,您可以先使用示例日志对其进行测试。所以我去了自定义日志,
从上面的链接中复制了示例:
Following the Amazon Example for Json Metric Filter,
I tried to copy their example. In the process of creating a metric filter, you can test it with example logs first. So I went for "Custom Log",
copy-pasted the example from the link given above:
{
"eventType": "UpdateTrail",
"sourceIPAddress": "111.111.111.111",
"arrayKey": [
"value",
"another value"
],
"objectList": [
{
"name": "a",
"id": 1
},
{
"name": "b",
"id": 2
}
],
"SomeObject": null,
"ThisFlag": true
}
而我的模式是: {$ .eventType = UpdateTrail}
如示例中所述
and my pattern is: { $.eventType = "UpdateTrail" }
as stated in the example
这是测试模式的输出:
在示例日志中的20个事件中找到0个匹配项。
Found 0 matches out of 20 event(s) in the sample log.
如何正确使用它们?我似乎不太了解这个概念。
How to use them correctly? I seem to not quite grasp the concept.
从我这边更新:换行符似乎有问题,出于我自己的目的,我只是将整个自定义json放在一行中它由 logger.info(json.dumps(my_message))
发布。
我在这里放置了此修复,以防有人偶然发现相同的问题。
我还是想听听常规解决方案!
Update from my side: It seems to have problems with line breaks, for my own purposes I just put my entire custom json into one line which is published by logger.info(json.dumps(my_message))
.
I put this "fix" here in case someone stumbles upon the same problem.
I'd still like to hear a general solution!
推荐答案
使用测试指标时AWS控制台中的过滤器功能,每个日志事件必须在单独的行中。您仍然可以运行相同的测试,但是必须从示例数据中删除所有新行。
When using the Test Metric Filter feature in the AWS Console, each log event has to be in a separate line. You can still run the same test, but you have to remove all new lines from the sample data.
这篇关于AWS Cloudwatch Json指标过滤器模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!