我正在使用 AWS Cloudwatch Insights 并运行如下查询:
fields @message, @timestamp
| filter strcontains(@message, "Something of interest happened")
| stats count() as interestCount by bin(10m) as tenMinuteTime
| stats max(interestCount) by datefloor(tenMinuteTime, 1d)
但是,在最后一行,我收到以下错误:mismatched input 'stats' expecting {K_PARSE, K_SEARCH, K_FIELDS, K_DISPLAY, K_FILTER, K_SORT, K_ORDER, K_HEAD, K_LIMIT, K_TAIL}
这似乎意味着我无法在 Insights 中进行多层统计查询,因此无法进行统计的统计。有没有解决的办法?
最佳答案
您目前不能使用多个 stat 命令,据我所知,目前没有直接的方法可以解决这个问题。但是,您可以将单个 stat 命令加厚并用逗号分隔,如下所示:
fields @message, @timestamp
| filter strcontains(@message, "Something of interest happened")
| stats count() as @interestCount,
max(interestCount) as @maxInterest,
interestCount by bin(10m) as @tenMinuteTime
您在 stats
之后定义字段并使用函数,然后处理这些结果字段。
关于amazon-cloudwatch - 在 Amazon Cloudwatch Insights 中,您如何获取统计信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63960452/