Open kqdtran opened 8 years ago
@kqdtran i think only cloudwatch alarm notifications are supported, not events from logs
@kqdtran Are you saying there was a failed Cloudwatch event and you saw that error in the logs? Where was the event from?
Sorry on the README, I'll get that updated today
No prob on the README, thanks for working on it!
Yes, there are lots of Cloudwatch events and we are currently not receiving any notification on Slack (we are via email, however.) What's the best course of action to test that things work after running make deploy
?
If it makes any difference, our instances and RDS db are all in a VPC. Do we need to specify the VPC config for this lambda function?
It's likely failing on a call like this:
var snsSubject = event.Records[0].Sns.Subject;
It would help to get the event json (or the shape) if at all possible. I'll run through some tests on this in our infra and see if I can come up with anything.
I'm not sure if this is what you're looking for, but here's the json of an event we recently got an email for.
{
"version": "1.0",
"oldState": {
"stateValue": "ALARM",
"stateReason": "Threshold Crossed: 1 datapoint (3.5420000000000003) was less than or equal to the threshold (30.0).",
"stateReasonData": {
"version": "1.0",
"queryDate": "2016-08-30T18:41:08.688+0000",
"startDate": "2016-08-30T18:35:00.000+0000",
"unit": "Percent",
"statistic": "Average",
"period": 60,
"recentDatapoints": [
3.5420000000000003
],
"threshold": 30
}
},
"newState": {
"stateValue": "INSUFFICIENT_DATA",
"stateReason": "Insufficient Data: 1 datapoint was unknown.",
"stateReasonData": {
"version": "1.0",
"queryDate": "2016-08-30T18:42:08.690+0000",
"unit": "Percent",
"statistic": "Average",
"period": 60,
"recentDatapoints": [],
"threshold": 30
}
}
}
Thanks again for looking into it! Let me know if/how I can be more helpful.
I'm still having trouble getting this to work. If it makes any difference, our instances and RDS db live inside a VPC. Do we need to specify the VPC configurations for the lambda function to make this work?
The problem I see so far is that the event you posted doesn't appear to be the full event (it doesn't even mention the metric):
Here's what a CloudWatch notification looks like in our test data:
{
"Records": [
{
"EventSource": "aws:sns",
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:us-west-2:123456789123:CloudWatchNotifications:00000000-0000-0000-0000-000000000000",
"Sns": {
"Type": "Notification",
"MessageId": "00000000-0000-0000-0000-000000000000",
"TopicArn": "arn:aws:sns:us-west-2:123456789123:CloudWatchNotifications",
"Timestamp": "2016-08-11T07:24:05.959Z",
"Subject": "ALARM: \"awsrds-app-High-DB-Connections\" in US West - Oregon",
"Message": "{\"AlarmName\":\"awsrds-app-High-DB-Connections\",\"AlarmDescription\":null,\"AWSAccountId\":\"123456789123\",\"NewStateValue\":\"ALARM\",\"NewStateReason\":\"Threshold Crossed: 1 datapoint (10.0) was greater than or equal to the threshold (10.0).\",\"StateChangeTime\":\"2016-07-24T22:05:19.737+0000\",\"Region\":\"US West - Oregon\",\"OldStateValue\":\"OK\",\"Trigger\":{\"MetricName\":\"DatabaseConnections\",\"Namespace\":\"AWS/RDS\",\"Statistic\":\"AVERAGE\",\"Unit\":null,\"Dimensions\":[{\"name\":\"DBInstanceIdentifier\",\"value\":\"app\"}],\"Period\":300,\"EvaluationPeriods\":1,\"ComparisonOperator\":\"GreaterThanOrEqualToThreshold\",\"Threshold\":10.0}}",
"MessageAttributes": {}
}
}
]
}
When I check out our teams Lambda logs in cloudwatch, I see events like this:
make test
for this project and did it successfully post messages to your channel?To my knowledge, you don't need any special VPC settings. You might double check your IAM lambda_exec_role to ensure it can execute the function and has no other problems.
Hey @CodyReichert and the Assertible team, thanks again for this very useful module. I'm having some problem getting it to work. I've changed the settings in the Makefile:
and also in the
config.js
:(the rest of the settings in
config.js
are left unchanged.) I then runnpm install
andmake test
, and it works perfectly. The four sample notifications were posted to our slack channel. Yay!Since the current version of the README ends here, I played around and figured that I needed to run
make deploy
to use this in production (I also added theAWS_ACCESS_KEY_ID
andAWS_ACCESS_KEY_SECRET
while doing this). So I ran this, and it worked great as well.All look good. I wait for a bit but receives no notification on the Slack channel, so I decide to check the AWS Lambda page on the console. I then choose Test => Configure test event => Cloudwatch logs in the sample event template. The test result looks like:
, which indicates that there's some bug with the module (I don't know nodejs, just purely guessing), or that I'm doing something wrong and the notification is not being posted correctly.
Any suggestion would be greatly appreciated, thanks!