Getting invocation statistics for a Lambda function.

0

I have a moderate collection of Lambda functions that have been developed over a period of several years and I'm attempting a clean up and rationalisation. As part of this, I am attempting to run some reports on the frequency of invocation and success of these functions over time. I would like to do this programmatically - initially from the command line and subsequently from a Python program. I'm calling "aws cloudwatch get-metric-statistics" with input from a json file :

"aws cloudwatch get-metric-statistics --cli-input-json file://get-stats.json"

where the input file is:
"{
"Namespace": "AWS/Lambda",
"MetricName": "Invocations",
"Dimensions": [
{
"Name": "FunctionName",
"Value": "serverWatchdog"
},
{
"Name": "Resource",
"Value": "serverWatchdog"
}

],  
"StartTime": "2020-12-01T00:00:00",  
"EndTime": "2020-12-05T00:00:00",  
"Period": 360,  
"Statistics": \[  
    "Average"  
],  

"Unit": "Count"  

}"

I know that this function is being called several times per hour - I can see it on the Cloudwatch console. But my CLI command always returns:

{
"Label": "Invocations",
"Datapoints": []
}

Any suggestions as to what I'm doing wrong?

TIA
Martin

Maby
asked 3 years ago1823 views
2 Answers
0

get rid of this section (and the leading comma):
{
"Name": "Resource",
"Value": "serverWatchdog"
}

..and try that.

the return is a little lacking, in that what it should say is "function not found"..but instead it looks like it's returning no data for that time range.

answered 3 years ago
0

Thanks for that - it did fix it. It is an aspect of AWS that is not well documented!

Martin

Maby
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions