5

I need to know when a lambda was executed last time. I will notify if the lambda is now being executed for more than 10 minutes during work time period.

I've been reading a lot (

featured links:

https://youtu.be/FpmVHTPTlIM

https://coralogix.com/integrations/cloudwatch-metrics/

https://docs.aws.amazon.com/lambda/latest/dg/monitoring-functions-metrics.html

AWS CLI get-metric-statistics)

They help me make getMetriStatistics() working and return DataPoints but is not properly working. Since it ALWAYS return data. Even when data does not exist.

Here I have an screenshot that shows AWS cloudfront metrics console. As you can see there are no lambda executions between 5:17 and 5:41. Cloudfront metrics

Having that, if I invoke getMetricStatistics I should get no DataPoints. But this is what I get: enter image description here

What can I do to get "no results" if the lambda didn't run? I don't understand why Average, Minimun, Maximum are 1 (must be 0) and SampleCount seems to be random to me. This is my code:

$client = self::getCWInstance();
    $result = $client->getMetricStatistics(array(
        'Namespace' => 'AWS/Lambda',
        'MetricName' => $name,
        'Dimentions' =>array(
            'Name' => 'FunctionName',
            'Value' => 'AddDataSyncWeb'
        ),
        //StartTime : mixed type: string (date format)|int (unix timestamp)|\DateTime
        'StartTime' => strtotime('-225 minutes'),
        //EndTime : mixed type: string (date format)|int (unix timestamp)|\DateTime
        'EndTime' => strtotime('-220 minutes'),
        //The granularity, in seconds, of the returned datapoints. Period must be at least 60 seconds and must be a multiple of 60. The default value is 60
        'Period' => 60,
        'Statistics' => array('Maximum', 'Minimum', 'Average', 'SampleCount'),
    ));

Any ideas? Thanks in advance

Adrián Rodriguez
  • 430
  • 11
  • 26

0 Answers0