Skip to content

Instantly share code, notes, and snippets.

@skyzyx
Last active May 18, 2021 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyzyx/6c47ab78adcb4802a67a66c1a2c0f6a3 to your computer and use it in GitHub Desktop.
Save skyzyx/6c47ab78adcb4802a67a66c1a2c0f6a3 to your computer and use it in GitHub Desktop.
CloudWatch Insights snippets
# WHERE logs are json AND fields are boolean...
# BOOL fields are converted to 1 for true, and 0 for false.
# So let's count them.
fields `httpVersions.HTTP/1.1`, `httpVersions.HTTP/2`, `httpVersions.HTTP/3`
| stats sum(`httpVersions.HTTP/1.1`) as http1, sum(`httpVersions.HTTP/2`) as http2, sum(`httpVersions.HTTP/3`) as http3
# OR parse the JSON as plain text.
parse '"HTTP/1.1":true' as @h1
| parse '"HTTP/2":true' as @h2
| parse '"HTTP/3":true' as @h3
| filter ispresent(@h1) or ispresent(@h2) or ispresent(@h3)
| stats count(@h1) as http1, count(@h2) as http2, count(@h3) as http3 by bin(6h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment