如何从 AWS Cloudwatch Logs Insights 中的组合聚合 bin 数据获取统计信息

Rya*_*iff 5 amazon-cloudwatch aws-cloudwatch-log-insights

我有一些 AWS CloudWatch 日志,每 5 秒输出一次值。我想获取滚动 10 分钟间隔内的最大值,然后根据该值获取每天的平均值。使用 CloudWatch Logs Insights QuerySyntaxbin我似乎无法获得在后续中使用的第一个聚合的结果bin。我试过:

fields @timestamp, @message
| filter @LogStream like /mylog/
| parse @message '*' as threadCount
| stats max(threadCount) by bin(600s) as maxThreadCount
| stats avg(maxThreadCount) by bin(24h) as avgThreadCount
Run Code Online (Sandbox Code Playgroud)

stats但查询语法对多个函数无效。将最后两行合并为一行:

| stats avg(max(threadCount) by bin(600s)) by bin(24h) as threadCountAvg
Run Code Online (Sandbox Code Playgroud)

亦无效。我似乎在 AWS 日志中找不到太多信息。我运气不好吗?有人知道窍门吗?