Cloudwatch Log Insights snippet that returns the number of cold starts and init duration.
Uses CloudWatch Insights to query a given log group and returns the number of Lambda cold starts and the init duration bucketed by 5 minutes.
filter @type="REPORT" and ispresent(@initDuration)
| stats count() as coldStarts, avg(@initDuration), min(@initDuration), max(@initDuration) by bin(5m)