View metrics for Lambda functions
When your AWS Lambda function finishes processing an event, Lambda sends metrics about the invocation to Amazon CloudWatch. There is no charge for these metrics.
On the CloudWatch console, you can build graphs and dashboards with these metrics. You can set
alarms to respond to changes in utilization, performance, or error rates. Lambda sends metric
data to CloudWatch in 1-minute intervals. For more immediate insight into your Lambda function, you can
create high-resolution
custom metrics
This page describes the Lambda function invocation, performance, and concurrency metrics available on the CloudWatch console.
Viewing metrics on the CloudWatch console
You can use the CloudWatch console to filter and sort function metrics by function name, alias, or version.
To view metrics on the CloudWatch console
-
Open the Metrics page
( AWS/Lambda
namespace) of the CloudWatch console. -
On the Browse tab, under Metrics, choose any of the following dimensions:
-
By Function Name (
FunctionName
) – View aggregate metrics for all versions and aliases of a function. -
By Resource (
Resource
) – View metrics for a version or alias of a function. -
By Executed Version (
ExecutedVersion
) – View metrics for a combination of alias and version. Use theExecutedVersion
dimension to compare error rates for two versions of a function that are both targets of a weighted alias. -
Across All Functions (none) – View aggregate metrics for all functions in the current AWS Region.
-
-
Choose a metric, then choose Add to graph or another graphing option.
By default, graphs use the Sum
statistic for all metrics. To choose a different statistic and
customize the graph, use the options on the Graphed metrics tab.
Note
The timestamp on a metric reflects when the function was invoked. Depending on the duration of the invocation, this can be several minutes before the metric is emitted. For example, if your function has a 10-minute timeout, then look more than 10 minutes in the past for accurate metrics.
For more information about CloudWatch, see the Amazon CloudWatch User Guide.
Types of metrics
The following section describes the types of Lambda metrics available on the CloudWatch console.
Invocation metrics
Invocation metrics are binary indicators of the outcome of a Lambda function invocation.
For example, if the function returns an error, then Lambda sends the Errors
metric with a value of 1. To get a count of the number of function errors that occurred each
minute, view the Sum
of the Errors
metric with a period of 1
minute.
Note
View the following invocation metrics with the Sum
statistic.
-
Invocations
– The number of times that your function code is invoked, including successful invocations and invocations that result in a function error. Invocations aren't recorded if the invocation request is throttled or otherwise results in an invocation error. The value ofInvocations
equals the number of requests billed. -
Errors
– The number of invocations that result in a function error. Function errors include exceptions that your code throws and exceptions that the Lambda runtime throws. The runtime returns errors for issues such as timeouts and configuration errors. To calculate the error rate, divide the value ofErrors
by the value ofInvocations
. Note that the timestamp on an error metric reflects when the function was invoked, not when the error occurred. -
DeadLetterErrors
– For asynchronous invocation, the number of times that Lambda attempts to send an event to a dead-letter queue (DLQ) but fails. Dead-letter errors can occur due to incorrectly set resources or size limits. -
DestinationDeliveryFailures
– For asynchronous invocation and supported event source mappings, the number of times that Lambda attempts to send an event to a destination but fails. For event source mappings, Lambda supports destinations for stream sources (DynamoDB and Kinesis). Delivery errors can occur due to permissions errors, incorrectly configured resources, or size limits. Errors can also occur if the destination you have configured is an unsupported type such as an Amazon SQS FIFO queue or an Amazon SNS FIFO topic. -
Throttles
– The number of invocation requests that are throttled. When all function instances are processing requests and no concurrency is available to scale up, Lambda rejects additional requests with aTooManyRequestsException
error. Throttled requests and other invocation errors don't count as eitherInvocations
orErrors
. -
OversizedRecordCount
– For Amazon DocumentDB event sources, the number of events your function receives from your change stream that are over 6 MB in size. Lambda drops the message and emits this metric. -
ProvisionedConcurrencyInvocations
– The number of times that your function code is invoked using provisioned concurrency. -
ProvisionedConcurrencySpilloverInvocations
– The number of times that your function code is invoked using standard concurrency when all provisioned concurrency is in use. -
RecursiveInvocationsDropped
– The number of times that Lambda has stopped invocation of your function because it's detected that your function is part of an infinite recursive loop. Lambda recursive loop detection monitors how many times a function is invoked as part of a chain of requests by tracking metadata added by supported AWS SDKs. If your function is invoked as part of a chain of requests more than 16 times, Lambda drops the next invocation.
Performance metrics
Performance metrics provide performance details about a single function invocation. For
example, the Duration
metric indicates the amount of time in milliseconds that
your function spends processing an event. To get a sense of how fast your function processes
events, view these metrics with the Average
or Max
statistic.
-
Duration
– The amount of time that your function code spends processing an event. The billed duration for an invocation is the value ofDuration
rounded up to the nearest millisecond.Duration
does not include cold start time. -
PostRuntimeExtensionsDuration
– The cumulative amount of time that the runtime spends running code for extensions after the function code has completed. -
IteratorAge
– For DynamoDB, Kinesis, and Amazon DocumentDB event sources, the age of the last record in the event. This metric measures the time between when a stream receives the record and when the event source mapping sends the event to the function. -
OffsetLag
– For self-managed Apache Kafka and Amazon Managed Streaming for Apache Kafka (Amazon MSK) event sources, the difference in offset between the last record written to a topic and the last record that your function's consumer group processed. Though a Kafka topic can have multiple partitions, this metric measures the offset lag at the topic level.
Duration
also supports percentile (p
) statistics. Use
percentiles to exclude outlier values that skew Average
and
Maximum
statistics. For example, the p95
statistic shows the
maximum duration of 95 percent of invocations, excluding the slowest 5 percent. For more
information, see Percentiles in the Amazon CloudWatch User Guide.
Concurrency metrics
Lambda reports concurrency metrics as an aggregate count of the number of instances
processing events across a function, version, alias, or AWS Region. To see how close you
are to hitting concurrency limits, view these
metrics with the Max
statistic.
-
ConcurrentExecutions
– The number of function instances that are processing events. If this number reaches your concurrent executions quota for the Region, or the reserved concurrency limit on the function, then Lambda throttles additional invocation requests. -
ProvisionedConcurrentExecutions
– The number of function instances that are processing events using provisioned concurrency. For each invocation of an alias or version with provisioned concurrency, Lambda emits the current count. -
ProvisionedConcurrencyUtilization
– For a version or alias, the value ofProvisionedConcurrentExecutions
divided by the total amount of provisioned concurrency configured. For example, if you configure a provisioned concurrency of 10 for your function, and yourProvisionedConcurrentExecutions
is 7, then yourProvisionedConcurrencyUtilization
is 0.7. -
UnreservedConcurrentExecutions
– For a Region, the number of events that functions without reserved concurrency are processing. -
ClaimedAccountConcurrency
– For a Region, the amount of concurrency that is unavailable for on-demand invocations.ClaimedAccountConcurrency
is equal toUnreservedConcurrentExecutions
plus the amount of allocated concurrency (i.e. the total reserved concurrency plus total provisioned concurrency). For more information, see Working with the ClaimedAccountConcurrency metric.
Asynchronous invocation metrics
Asynchronous invocation metrics provide details about asynchronous invocations from
event sources and direct invocations. You can set thresholds and alarms to notify you of
certain changes. For example, when there's an undesired increase in the number of events
queued for processing (AsyncEventsReceived
). Or, when an event has been waiting
a long time to be processed (AsyncEventAge
).
-
AsyncEventsReceived
– The number of events that Lambda successfully queues for processing. This metric provides insight into the number of events that a Lambda function receives. Monitor this metric and set alarms for thresholds to check for issues. For example, to detect an undesirable number of events sent to Lambda, and to quickly diagnose issues resulting from incorrect trigger or function configurations. Mismatches betweenAsyncEventsReceived
andInvocations
can indicate a disparity in processing, events being dropped, or a potential queue backlog. -
AsyncEventAge
– The time between when Lambda successfully queues the event and when the function is invoked. The value of this metric increases when events are being retried due to invocation failures or throttling. Monitor this metric and set alarms for thresholds on different statistics for when a queue buildup occurs. To troubleshoot an increase in this metric, look at theErrors
metric to identify function errors and theThrottles
metric to identify concurrency issues. -
AsyncEventsDropped
– The number of events that are dropped without successfully executing the function. If you configure a dead-letter queue (DLQ) orOnFailure
destination, then events are sent there before they're dropped. Events are dropped for various reasons. For example, events can exceed the maximum event age or exhaust the maximum retry attempts, or reserved concurrency might be set to 0. To troubleshoot why events are dropped, look at theErrors
metric to identify function errors and theThrottles
metric to identify concurrency issues.