Created
January 29, 2018 19:06
-
-
Save kstolte/3d80e0d2c073977e31a5b27af7f71e1c to your computer and use it in GitHub Desktop.
Webtask to have an Azure Alert be sent to a Slack Channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
module.exports = function (context, done) { | |
var recBody = context.body; | |
var rContext = recBody.context; | |
var rCondition = rContext.condition; | |
var icon = recBody.status === 'Activated' ? ':open_mouth:': ':party_parrot:'; | |
var outText = `${rContext.resourceName} - ${rContext.name} - ${recBody.status} <${rContext.portalLink}|Click Here> | |
Condition: ${rCondition.metricName} ${rCondition.operator} ${rCondition.threshold} (${rCondition.metricUnit}) in the last ${rCondition.windowSize} minutes | |
Raw Value: ${rCondition.metricName} @ ${rCondition.metricValue} (${rCondition.metricUnit})`; | |
request({ | |
url: "{YourSlackChannelURL}", | |
method: 'POST', | |
json: true, | |
body: { | |
text: `${outText}`, | |
icon_emoji: `${icon}` | |
} | |
}); | |
done(null, { | |
text: `${outText}`, | |
icon_emoji: `${icon}` | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment