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?
2
Answers
You need to have your Lambda function send logs to Cloudwatch. Then, whenever it executes, you get something like:
You can then export the logs and using whatever tool you like get your monthly total.
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
andperformance 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
Docs for creating cloud watch alarm