Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save miqui/11c68110d0327332f5b823e678b948b6 to your computer and use it in GitHub Desktop.
Save miqui/11c68110d0327332f5b823e678b948b6 to your computer and use it in GitHub Desktop.
Assorted queries for AWS CloudWatch Insights

CloudWatch Insights Queries

Assorted queries for AWS CloudWatch Insights

# profile lambda memory usage
filter @type = "REPORT"
| fields
@requestId,
@timestamp,
@billedDuration,
@memorySize / 1024 / 1024 as provisonedMemoryMB,
@maxMemoryUsed / 1024 / 1024 as memoryUsedMB,
memoryUsedMB / provisonedMemoryMB * 100 as memoryUtilizationPercent,
provisonedMemoryMB - memoryUsedMB as overProvisionedMB
| sort by memoryUtilizationPercent desc
# groups invocation cost by lambda name & provisioned memory
# makes it easy to compare costs after tweaking a lambda's provisioned memory
filter @type = "REPORT"
| fields
substr(@log, 25) as name,
@billedDuration,
@memorySize / 1024 / 1024 as provisonedMemoryMB,
@billedDuration * provisonedMemoryMB / 1000 as cost
| stats
avg(@billedDuration) as avgDuration,
avg(cost) as avgCost
by
name,
provisonedMemoryMB
| sort by avgCost desc
#| sort by avgDuration desc
#| sort by provisonedMemoryMB, avgDuration desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment