4

I have some AWS CloudWatch logs which output values every 5 seconds. I'd like to get the max over a rolling 10 minute interval and then get the average value per day based on that. Using the CloudWatch Logs Insights QuerySyntax I cannot seem to get the result of the first bin aggregation to use in the subsequent bin. I tried:

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

But the query syntax is invalid for multiple stats functions. Combining the last two lines into one like:

| stats avg(max(threadCount) by bin(600s)) by bin(24h) as threadCountAvg

Also is invalid. I can't seem to find much in the AWS logs. Am I out of luck? Anyone know a trick?

Ryan Southcliff
  • 143
  • 2
  • 12

0 Answers0