diff --git a/index.js b/index.js index c61ab4e..b9efda2 100644 --- a/index.js +++ b/index.js @@ -233,13 +233,13 @@ var handleCloudWatch = function(event, context) { var region = event.Records[0].EventSubscriptionArn.split(":")[3]; var subject = "AWS CloudWatch Notification"; var alarmName = message.AlarmName; - var metricName = message.Trigger.MetricName; var oldState = message.OldStateValue; var newState = message.NewStateValue; var alarmDescription = message.AlarmDescription; var alarmReason = message.NewStateReason; var trigger = message.Trigger; var color = "warning"; + var alarmConfigInfo; if (message.NewStateValue === "ALARM") { color = "danger"; @@ -247,6 +247,12 @@ var handleCloudWatch = function(event, context) { color = "good"; } + if (Array.isArray(trigger.Metrics) && trigger.Metrics.length > 0) { + alarmConfigInfo = "Expression based alarm"; + } else { + alarmConfigInfo = trigger.Statistic + " " + trigger.MetricName; + } + var slackMessage = { text: "*" + subject + "*", attachments: [ @@ -257,8 +263,7 @@ var handleCloudWatch = function(event, context) { { "title": "Alarm Description", "value": alarmDescription, "short": false}, { "title": "Trigger", - "value": trigger.Statistic + " " - + metricName + " " + "value": alarmConfigInfo + " " + trigger.ComparisonOperator + " " + trigger.Threshold + " for " + trigger.EvaluationPeriods + " period(s) of " diff --git a/package.json b/package.json index 6e1e021..15d9e24 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "lambda-cloudwatch-slack", "version": "0.3.0", "description": "Better Slack notifications for AWS CloudWatch", - "authors": [ + "authors": [ "Christopher Reichert ", "Cody Reichert ", "Alexandr Promakh "