lambda-cloudwatch-slack
lambda-cloudwatch-slack copied to clipboard
Setting up the CloudWatch -> SNS?
Hello! I've deployed the bot, but I have not set up any flow for Alarms to go into SNS queues, so there is nothing for the bot to process. Is there any suggested documentation/blog post on how to do that?
Which AWS service do you want to receive events from? e.g. Elasitc Beanstalk, EC2, RDS, etc.
The basic process is:
- Create an SNS subscription (
my-test-subscription
) and attach it to the Lambda Function - Pick a service, e.g. RDS
- Create a CloudWatch alarm for that service
- Configure the CloudWatch alarm to send events to the SNS subscription
For example, the assertible-rds-alarms
is a SNS topic I created for our database
If you let me know what service you want to connect to, I can help out more.
I am starting off with creating alerts for a different Lambda function. I have metrics that measure logs coming from that function, so I can set an alert based on the count of those logs, send those to an SNS, and see those piped through the Cloudwatch-Slack bot into our Slack channel.
Re the first step:
- when I create a subscription in SNS, what protocol would I specify?
- in what way should I attach the subscription to the Cloudwatch-Slack Lambda function?
I know how to do the subsequent steps, so I think I'll be set if you can clarify the first step further. Thanks so much!
when I create a subscription in SNS, what protocol would I specify?
I'm not sure exactly what you mean by protocol (I could be missing something). If I go to create an SNS topic, I see this:
That's a separate step from any Lambda-specific functionality. I imagine if you already have a CloudWatch alarm for a Lambda function, you can navigate to it and set the SNS topic to propagate the events to, similar to the image I posted in the last comment. I'm a little lost on this part, but would be happy to help further if I could get a bit more info.
in what way should I attach the subscription to the Cloudwatch-Slack Lambda function?
For this one, navigate to your lambda-cloudwatch-slack notification (whatever you named it), and click the Triggers tab.
From there, you'll see an "Add trigger" at the bottom. Clicking that will get you into the right area to add the topic:
Let me know if that gets you further
Great! Now I've got it all working. I was confused as your first comment said subscription, but I think actually meant "topic". (It appears that creating a CloudWatch alarm automatically creates the subscription to that topic).
So, the steps were:
- Create a topic in SNS. Call it CloudWatchNotifications OR change the name of what's in config.js.
- Create a CloudWatch alarm, and set its notification to go to the CloudWatchNotifications list
- Navigate to the Triggers tab of Lambda functions. Add a new trigger from SNS, specify CloudWatchNotifications list.
I think it'd help to put those steps in the README somewhere, along with the nice screenshots that you put here. Thanks so much for the help! :-)
I will confess I have another question, and hopefully it'd help others. I've moved on to setting up the Beanstalk notifications, and the UI there is a bit confusing.
It desires an email address, even though I don't need it to go to an email. Do you just put something there anyway?
That configuration dialog is definitely confusing. I generally configure w/o email and only rely on the SNS topics. What service did you take that picture from?
I agree with you on the doc improvements. Feel free to create a PR, if you want. We're committing more improvements, though, so I'll definitely add the suggestions when I have a chance.
That screenshot was from Elastic Beanstalk -> Monitoring -> Alarm icon on upper right of the graph. Where did you set your Beanstalk Alarms up, in CloudWatch?
Ok, I can send a PR after figuring this part out.
@pamelafox that UI (beanstalk) requires an email, which sucks. You'll have to do this via settings{} blocks in your .config or via terraform/cloudformation. You simply cant via the UI. I've opened a ticket with aws support 2 years ago and it hasnt moved. If you submit one as well as a feature request maybe theyll move it along.