CloudWatch Insights查询可创建从字符串中提取数字的直方图

时间:2020-10-10 23:28:50

标签: aws-cloudwatch-log-insights

我正在尝试创建一个洞察力查询,以对每5分钟从日志行提取的值进行直方图绘制。我只是不确定如何随着时间的推移如何使stats()与文字值一起使用,而不是对值使用聚合函数。

两种可能的日志行格式:

@message
2020-10-10T23:12:48.637Z db7ba037-72a3-4791-893d-b8dad87522b2 INFO [function-name] 355 active units found
2020-10-10T23:12:48.637Z db7ba037-72a3-4791-893d-b8dad87522b2 INFO [function-name] 355 items matched query

将数字提取为临时字段的查询:

fields @message
| parse @message /(?<activecount>\d{1,3})\s+(active units found|items matched query)/
| filter @message like /items matched query/ OR @message like /active units found/
| display activecount, @message
| sort @timestamp desc
| limit 2000

结果:

#     activecount      @message
1     355              2020-10-10T23:12:48.637Z db7ba037-72a3-4791-893d-b8dad87522b2 INFO [function-name] 355 active units found
2     355              2020-10-10T23:12:48.637Z db7ba037-72a3-4791-893d-b8dad87522b2 INFO [function-name] 355 items matched query

是否可以在直方图中获得355个值?

0 个答案:

没有答案