我正在尝试创建一个洞察力查询,以对每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个值?