I have a CloudWatch alarm created for testing purposes. It checks the number of bytes read on a Kinesis Stream. If less than 1 bytes are received within 1 minute, it triggers alarm and send email via SNS. So, I get email after 1 min, but then after that I don’t get any further email. Is it right the email notification sent only once? In my test data is not flowing all the time. So, ideally, it should send email every minute. Correct?
Whether or not the action keeps firing depends on the type of action.
SNS actions only trigger once when the state changes to ALARM. Other actions such as EC2 auto scaling keep triggering as long as the alarm is in ALARM state.
If your alarm reverts to OK state and then back again to ALARM, SNS will get triggered again.
AWS docs
If CloudWatch alarm switched to ALARM state after specified period (1 minute), then in your case it means it received less than 1 byte. When switched, it will trigger configured actions (in your case it is email notification). As long as alarm remains in the ALARM state without switching it state back to OK, nothing will be triggered again.
if alarm returned back to OK state and then again after the specified period it switched to ALARM, configured action will be triggered again.
For more information, refer to documentation.
Related
In our team's infrastructure we have a Databricks job which sends data to an SQS queue which triggers a Lambda function. The Databricks job runs one in every 30 minutes. A week ago the Databricks job was failing continuously so it was not sending data, therefore the Lambda function was not triggered. Is there any way to set up an alert so that I get notified if the lambda function is not triggered for a period of 2 hours?
When I searched for a solution I was only able to see to get an alert if and when a Lambda fails or if a specific log type is found in its cloudwatch logs etc, but couldn't see any solution for the above scenario.
You can create a Cloudwatch alarm for the Invocation metrics for that lambda; you can configure the alarm so that if there are no invocations over a timespan of two hours, it goes into an ALARM state.
If you wish to be notified, you can also configure the Cloudwatch alarm to send a message to an SNS topic, which can then be configured to trigger SES so that it sends you an email (for example).
I'm using enable_alarm_actions() / disable_alarm_actions() on CloudWatch alarm to implement mechanism for downtiming CloudWatch alarms.
If the alarm changed it state, while it's "downtimed" (ActionsEnabled property is set to false) it doesn't trigger corresponding action, as expected. But when you enable_alarm_actions() back the action on the alarm still not triggering. And you're running into situation, when you're not notified when the alarm went to ALARM state while being downtimed after downtime expires.
So, the question, is this expected and is there a way to manually trigger an action on the alarm?
If I understand correctly what you are describing, is that Cloudwatch wont trigger action when it is in alarm state and when you enable its action.
This is by design. Alarms invoke actions only when alarm change state occurs. Being in alarm state is not enough.
The docs write:
Alarms invoke actions for sustained state changes only. CloudWatch
alarms don't invoke actions simply because they are in a particular
state, the state must have changed and been maintained for a specified
number of periods.
So when your actions are enabled when Alarm is already in alarm state, nothing is going to happen. You have to wait for next alarm state changes.
I had setup an Alert for CPU utilization on EC2 instance. Created one SNS topic to send alerts on mail. It sends me an alert when CPU utilization goes to ALARM state but I want repeated alerts till ALARM state get resolved. Please help me... I'm newbie to AWS.
What you can do is setup a Lambda function with a CloudWatch event trigger so that it runs periodically, and inside it call the CloudWatch GetMetricStatistics API. Then, simply check if it is above or below your preferred threshold (or if you want, whether or not it's in Alarm state) and publish a message to SNS. There are a lot of SDK documentations on how to use these API's with your preferred language.
It is not possible to get repeated notifications after getting into the ALARM state. As the alarm is entering the ALARM state only once that means the notification via Amazon SNS will be sent only once.
Autoscaling policy will be triggered by the same alarm. But mail will be sent only once.
I have an instance in AWS that from time to time it's CPU cross the threshold of 90%.
I have created an alert for this, however I saw that I received one notification only and it was during the first 5 minutes while the CPU was at 100% for 2 hours.
How do I set the metric so I will keep getting notifications all the time?
Cloudwatch does not send notifications continuously if the threshold is breached. Cloudwatch can send a Notification only when the state changes.
Alarms invoke actions for sustained state changes only. CloudWatch alarms do not invoke actions simply because they are in a particular state, the state must have changed and been maintained for a specified number of periods.
Ref: AWS Cloudwatch Documentation
One possible solution that I can think of is to create a Multiple Cloudwatch Alarms with Multiple thresholds.
As the above answer already says it is not triggered again, one thing you can do is changing the alarm conditions to a very large value and then the orginal value and the state change will occur again.
I have monitored the status of VPN tunnels in my account.I have created CloudWatch alarms and configured SNS notifications when they are down.
At the moment, that is working fine. Now, I have got another requirement saying I have to send alarm whenever the state changes to OK.
This is the image of the alarm configuration :
There, in the snapshot, it says :
Whenever this alarm : STATE is ALARM
I would change that to :
Whenever this alarm : STATE is OK
But, by doing that, will the Cloud Watch send me notifications every 5 minutes until the state is in OK?
I have this doubt because it is written STATE is OK instead of STATE changes to OK.
Please let me know.
An Amazon CloudWatch alarm only sends a notification on a change of state.
So, if your alarm is set to send a notification when State = OK: If the state is already OK, it will not send a notification. However, when the state changes to something else and the changes back to OK, it would send a notification.