turbot/aws_thrifty

Control: Are there any lambda functions with excessive timeout?

Description

Excessive timeouts result in retries and additional execution time for the function, incurring request charges and billed duration. The control checks for functions with a timeout rate of more than 10% a day in one of the last 7 days.

Usage

Run the control in your terminal:

powerpipe control run aws_thrifty.control.lambda_function_excessive_timeout

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run aws_thrifty.control.lambda_function_excessive_timeout --share

Steampipe Tables

SQL

with lambda_duration as (
select
name,
avg(average:: numeric) as avg_duration
from
aws_lambda_function_metric_duration_daily
where
date_part('day', now() - timestamp) <=7
group by
name
)
select
arn as resource,
case
when avg_duration is null then 'error'
when ((timeout :: numeric*1000) - avg_duration)/(timeout :: numeric*1000) > 0.1 then 'alarm'
else 'ok'
end as status,
case
when avg_duration is null then 'CloudWatch lambda metrics not available for ' || title || '.'
else title || ' Timeout of ' || timeout::numeric*1000 || ' milliseconds is ' || round(((timeout :: numeric*1000)-avg_duration)/(timeout :: numeric*1000)*100,1) || '% more as compared to average of ' || round(avg_duration,0) || ' milliseconds.'
end as reason
, region, account_id
from
aws_lambda_function f
left join lambda_duration as d on f.name = d.name;

Tags