2

I was able to create a cw alarm based on the duration metric (raise alarm if lambda runs for over a minute) using the GUI. But I was wondering how to do this with cloudformation. So far, I have this -

Resources:
  testAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmName: test-alarm
      AlarmDescription: "I'm taking too long!"
      ComparisonOperator: GreaterThanThreshold
      EvaluationPeriods: 1
      DatapointsToAlarm: 1
      MetricName: Duration
      Namespace: aws/lambda
      Period: 60
      Statistic: Maximum
      Threshold: 0
      Dimensions:
        - Name: 'FunctionName'
          Value: 'hello world'
      TreatMissingData: notBreaching

I am not able to link the duration metric of the lambda function. I tried doing that with the dimensions above but it understandably doesn't work. Any help would be strongly appreciated!

Edit - doesn't work as in the alarm doesn't turn on, the threshold is 0, so if the duration>0 which I do with time.sleep, the alarm should be active. But there is no change and the graph doesn't depict duration in the test runs. It does so for the alarm I created with the web console.

Teh__docco
  • 155
  • 10
  • "doesn't work" is not specific. Why exactly if fails? Any error messages? Please describe details of why you think it fails, and explain what is desired output. – Marcin Nov 23 '21 at 05:28
  • doesn't work as in the alarm doesn't turn on. The threshold is 0, so if the duration>0 which I do with `time.sleep`, the alarm should be active. But there is no change and the graph doesn't depict duration in the test runs. It does so for the alarm I created with the web console. – Teh__docco Nov 23 '21 at 05:45
  • Can you provide screenshot of manually created alarms with details, and the one created by CFN? – Marcin Nov 23 '21 at 05:45
  • 1
    [Web console](https://i.imgur.com/9wCowSX.png) [CFN](https://i.imgur.com/sGxj6bS.png) Thank you!! I noticed the difference, the case of aws/lambda was different and it should've been AWS/Lambda. I was behind thinking there should've been additional steps to link lambda metrics. – Teh__docco Nov 23 '21 at 06:17

1 Answers1

2

Based on the comments, the issue was that it should be:

Namespace: AWS/Lambda

rather then

Namespace: aws/lambda
Marcin
  • 215,873
  • 14
  • 235
  • 294