如何从非结构化日志创建cloudwatch指标过滤器?

时间:2018-07-09 16:08:43

标签: java amazon-web-services amazon-cloudwatch amazon-cloudwatchlogs amazon-cloudwatch-metrics

考虑日志输出:

2018-07-09 14:59:48,938 INFO [req-id:aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa] [sqs-m-id:aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa] [bucket:my-bucket] [s3Key:folder/myFile.pdf] com.mycompany.MyJavaClass - some message with spaces
2018-07-09 14:59:48,938 INFO [req-id:bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb] [sqs-m-id:bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb] [bucket:my-bucket] [s3Key:folder/myOtherFile.pdf] com.mycompany.MyJavaClass - some other message also with spaces
2018-07-09 14:59:48,938 INFO [req-id:bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb] [sqs-m-id:bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb] [bucket:my-bucket] [s3Key:folder/myOtherFile.pdf] com.mycompany.MyJavaClass - ELAPSED_TIME_NS 1520093301
START RequestId: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa Version: $LATEST

如何提取仅应用于ELAPSED_TIME_NS行的指标。并从中获取价值?

1 个答案:

答案 0 :(得分:1)

此模式应为您工作:

[..., message=ELAPSED_TIME_NS, nanoseconds]

在此处查看更多详细信息:https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html#extract-log-event-values