Last active
September 6, 2025 16:34
-
-
Save perpil/abfba2feedad54def6698583baed9393 to your computer and use it in GitHub Desktop.
Cloudwatch Logs Insights Query to get coldstart stats by lambda runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| filter @message like /INIT_START|REPORT|START/ | | |
| parse @message /INIT_START Runtime Version: (?<runtime>\S+)/ | | |
| parse @message /^START RequestId: .* Version: (?<version>\S+)/ | | |
| stats sortslast(runtime) as `lambda runtime version`, sortslast(@initDuration) as iD, sortslast(version) as `software version` by @logStream | | |
| filter ispresent(`software version`) | | |
| stats pct(iD, 50) as p50, pct(iD, 90) as p90, pct(iD, 95) as p95, pct(iD, 99) as p99 by `lambda runtime version`, `software version` |
Author
Author
This one shows coldstart time by lambda runtime and memory:
filter @message like /INIT_START|REPORT/ |
parse @message /Runtime Version: (?<runtime>\S+)/ |
parse @message /Memory Size: (?<memorysize>\S+)/ |
stats sortslast(runtime) as rt, sortslast(memorysize) as mem, sortslast(@initDuration) as iD by @logStream|
filter mem > 0 | #filter logs that are missing REPORT
stats min(iD) as `min`, pct(iD, 50) as p50, pct(iD, 90) as p90, pct(iD, 95) as p95, pct(iD, 99) as p99, pct(iD, 100) as p100, count(*) by rt, mem |
order by p50Example:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output looks like this:
