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
481 stars 254 forks source link

Format of messages in slack #22

Closed tg-tomer closed 7 years ago

tg-tomer commented 7 years ago

Hi, I'm testing your code with the following configuration:

  1. Cloudwatch alarm created on Redshift is sent to SNS topic
  2. SNS topic is set as trigger for the Lambda

Expected result: Alt text

Actual result: Alt text

Can you help please?

CodyReichert commented 7 years ago

Hey @tg-tomer - thanks for opening! We recently added a 'default' message format for alarms that don't match one of the pre-formatted ones. It looks like your second picture is hitting that default case, so it's not formatted like in the first picture.

Did you close this because you got it working? I can take a look if you're still seeing this, just post your JSON even (remove any sensitive info).

JonFranchi commented 6 years ago

I have this exact same problem. Cloudwatch metric -> SNS looks the same as @tg-tomer second picture above.

JonFranchi commented 6 years ago

I think I see what's going on. It looks like possibly custom metrics don't get CloudWatchNotifications in the ARN, or that it no longer puts it in the ARN at all. I only have this custom metric example at the moment, but eventSubscriptionArn does not include that string and neither does TopicArn.

I wonder if there is something I can modify to get it to say cloudwatch somewhere, because otherwise the formatting would be perfect if it were processed by the handleCloudWatch() function instead of handleCatchAll().

JonFranchi commented 6 years ago

As far as I can tell, this would only work if you created an SNS topic called CloudWatchNotifications and directed every alarm to notify there. Is it the case that this used to happen by default and thats how it got written that way? I think it would be helpful to include this in the documentation if that's the intended way to utilize this.