I have a scenario like this:
I have a dead-letter-queue and when a message lands into it, a CloudWatch Alarm should trigger.
I have tried to set up an alarm directly using the metrics provided for SQS and the closest that came was the NumberOfMessagesSent metric. But that doesn't get my job done.
The next approach that I thought of is to fire an CloudWatch Event that fires when I send the message the DLQ and have the alarm to trigger when that event is fired. I didn't find any documentation that said that such a thing was possible.
Is there a way to fire off a CloudWatch alarm when a new message is added to an SQS queue?
Related
is there any elegant way to create a reacuuring alarms system to send sns notifications as long as the cloudwatch alarm is in ALARM status ?
i've searched the internet but most of the solutions are pretty complicated for a simple task
You could create a simple process like this:
Create AWS Cloudwatch scheduled events: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/Create-CloudWatch-Events-Scheduled-Rule.html
These scheduled events should trigger a Lambda
The Lambda function should check the alarm status. if the status is ALARM, trigger SNS to send a notification
I have created an alarm that looks for tunnels and sends SNS topic when tunnels are down. Is there a way to trigger lambda as well? I don't see any options for that. It looks like I can only create an event to trigger lambda.
I have a lambda function is responsible for checking the server status. It needs to be called when SQS receives new messages and It is not allowed to change anything in SQS. I tried using SQS Lambda trigger but it will push the message into lambda function => that changed SQS queue.
I am looking the way to handle this problem. I try to use CloudWatch to handle this but I don't know is this possible or not? How Cloudwatch can trigger Lambda functions when SQS receives new messages?
Thanks in advance.
This will be difficult because, if the message is consumed quickly, it might not have an impact on Amazon CloudWatch metrics. You'll need to experiment to see whether this is the case. For example, set a metric for the maximum number of messages received in a 1-minute time period and try to trigger a CloudWatch Alarm when it is greater than zero.
Alternatively, have the system that sends the SQS message send it to Amazon SNS instead. Then, both the SQS queue and the Lambda function can subscribe to the SNS topic and both can be activated.
In fact, I know somebody who always uses SNS in front of SQS "just in case" this type of thing is necessary.
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.
How can i notify a result of lambda when status OK(normal) and NG both?
I set a alarm on cloudwatch when status NG. It was working.
But when i got OK(normal) status, i couldn't get notify email.
I set up custom metrics by lamda result log when OK(normal) status on cloudwatch alarm.
Is it possible on alarm?
Is there an any simple way?
It sounds like your requirements are:
Trigger an AWS Lambda function when a CloudWatch alarm enters the ALARM state
Trigger an AWS Lambda function when a CloudWatch alarm enters the OK state
Each AWS CloudWatch alarm can be configured with multiple Actions.
Therefore, you can create one Action for ALARM and another action for OK:
The CloudWatch Alarm can send a notification to an Amazon SNS topic. The AWS Lambda function can subscribe to the SNS topic and will be triggered when the alarm sends the notification to SNS.