Topic:   Getting invocation statistics for a Lambda function.
Mar 10, 2022 16:27 1 Replies 3118 Views ribinadia

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?

Prev Next
Topic Replies (1)
  1. 1
    idnkx user

    Ultra The Reviews

    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.

Leave a Reply
Guest User

Not sure what solution is right for you?

Choose the right one for you.
Get the help of the experts and find a solution that best suits your needs.


Let`s Connect