funerr
funerr

Reputation: 8156

How can I get AWS lambda usage for the last hour?

I would like to know if there is a way to get all of my lambda invocation usages for the last 1 hour (better if every 5 minutes).
It could also be nice to get the cost usage (but from what I've read it only updates once a day).

From looking at the documentation it seems like I can use GetMetricData (Cloudwatch), is there a better one for my use case?

Upvotes: 1

Views: 1154

Answers (2)

saart
saart

Reputation: 402

There are many tools to get metrics on your lambda, so it really depends on your needs. What do you mean by "is there a better one for my use case"?

If you prefer, you can check it through the console: Go to cloudwatch -> metrics -> and navigate to your lambda. You can aggregate the data differently (examples: average per 5 minutes, or total a day, etc.)

Here's a great doc: https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics.html#monitoring-metrics-invocation

Moreover, here's a solution that I gave that surveys different approaches to monitor lambda resources: Best Way to Monitor Customer Usage of AWS Lambda

Disclosoure: I work for Lumigo, a company that does exactly that.

Upvotes: 0

Chris Williams
Chris Williams

Reputation: 35188

You can get this information by region within CloudWatch metrics.

In the AWS/Lambda namespace is a metric named Invocations, this can be viewed for the entire region or on a per Lambda basis.

If you look at the Sum per whichever period you want to use (you can get down to per 1 minute values for this metric), you will be able to get these values in near real-time.

You can get these values from within the console or by using the get-metric-data command within the CLI or SDK.

Upvotes: 2

Related Questions