This query runs against Lambda function logs to get the following information:
- InvocationCount -- This is the number of times the Lambda function was invoked.
- ColdStartCount -- This is the number of times the Lambda function had initialization overhead (cold start).
- InitDuration (min, avg, max) -- This is the amount of time it took the Lambda function to initialize (cold start time).
- Duration (min, avg, max) -- This is the amount of time it took the Lambda function to run after initialization.
- AllocatedMemory -- This is the amount of memory allocated to the Lambda function in MB.
- MaxMemoryUsed (min, avg, max) -- This is the max amount of memory that the Lambda function used during its invocation in MB.
Note: @ignored*
is placeholder field that is necessary due to the way Cloudwatch Insights parses text fields for information
filter @type = "REPORT"
| parse @log "*/aws/lambda/*" as @ignored1, @functionName
| parse @message "*Memory Size: * MB*Init Duration: * ms*" as @ignored2, memorySize, @ignored3, @initDuration
| stats count(@message) as @invocationCount,
count(@initDuration) as @coldStartCount,
min(@initDuration)/1000 as @minInitDuration,
avg(@initDuration)/1000 as @avgInitDuration,
max(@initDuration)/1000 as @maxInitDuration,
min(@duration)/1000 as @minDuration,
avg(@duration)/1000 as @avgDuration,
max(@duration)/1000 as @maxDuration,
max(memorySize) as allocatedMemory,
min(@maxMemoryUsed)/(1024*1024) as @minMaxMemoryUsed,
avg(@maxMemoryUsed)/(1024*1024) as @avgMaxMemoryUsed,
max(@maxMemoryUsed)/(1024*1024) as @maxMaxMemoryUsed
by @functionName
| sort by @invocationCount desc