Reputation: 13
I have an android app that uses AWS lambda as a backend to fetch data - which usually takes a few seconds of execution time per request.
I would like to be able to fetch data and cache it at the end of the month if there is still free execution time available, however, I could not find a way to access that information inside a lambda function. Is there a way to do this?
Upvotes: 1
Views: 726
Reputation: 11523
if there is still free execution time available
You cannot directly do that, need to perform cloudwatch log aggregation as told by @Dan M, but the most ideal way would be to always set an alarm and notification once your overall execution time( across all functions ) exceeds your desired value
It is a very straightforward approach using cloudwatch alarms
:-
across all functions
to be able to view aggregated execution time for all functions in that region. Check how to view all functionsInvocation
and performance metrics
, you need to focus on performance metrics, for these metrics you need to consider their average statisticDuration metric
( under performance metric) and add sns rule when ever alarm breaches your desired valueAccording to Docs for duration metric
The amount of time that your function code spends processing an event. The billed duration for an invocation is the value of Duration rounded up to the nearest millisecond.
Docs for creating cloud watch alarm
Upvotes: 1
Reputation: 4377
You need to have your Lambda function send logs to Cloudwatch. Then, whenever it executes, you get something like:
REPORT RequestId: c9999f19-0b99-4996-8dea-94c9999999de Duration: 5495.59 ms Billed Duration: 5496 ms Memory Size: 128 MB Max Memory Used: 82 MB Init Duration: 306.78 ms
You can then export the logs and using whatever tool you like get your monthly total.
Upvotes: 0