assertible / lambda-cloudwatch-slack

Send AWS CloudWatch notifications to a Slack channel using Lambda
https://assertible.com/blog/npm-package-lambda-cloudwatch-slack
MIT License
482 stars 250 forks source link

Setting up the CloudWatch -> SNS? #15

Open pamelafox opened 7 years ago

pamelafox commented 7 years ago

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?

creichert commented 7 years ago

Which AWS service do you want to receive events from? e.g. Elasitc Beanstalk, EC2, RDS, etc.

The basic process is:

For example, the assertible-rds-alarms is a SNS topic I created for our database

cloudwatch alarm to sns subscription

If you let me know what service you want to connect to, I can help out more.

pamelafox commented 7 years ago

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:

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!

creichert commented 7 years ago

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.

import-form-twitter-api-postman-collection-dry-run1

From there, you'll see an "Add trigger" at the bottom. Clicking that will get you into the right area to add the topic:

import-form-twitter-api-postman-collection-dry-run1

Let me know if that gets you further

pamelafox commented 7 years ago

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: 1) Create a topic in SNS. Call it CloudWatchNotifications OR change the name of what's in config.js. 2) Create a CloudWatch alarm, and set its notification to go to the CloudWatchNotifications list 2) 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! :-)

pamelafox commented 7 years ago

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.

screen shot 2017-05-22 at 2 25 53 pm It desires an email address, even though I don't need it to go to an email. Do you just put something there anyway?

creichert commented 7 years ago

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.

pamelafox commented 7 years ago

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.

myoung34 commented 6 years ago

@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.