Skip to content

Instantly share code, notes, and snippets.

@azhinu
Last active June 13, 2023 08:32
Show Gist options
  • Save azhinu/713575b5e50540a9918296df19f5ecda to your computer and use it in GitHub Desktop.
Save azhinu/713575b5e50540a9918296df19f5ecda to your computer and use it in GitHub Desktop.
Grafana alert RocketChat webhook script
// Rocketchat incoming grafana webhook script
// See the following links for some documentation:
// * Grafana outgoing format: https://grafana.com/docs/grafana/latest/alerting/manage-notifications/webhook-notifier/
// * Rocketchat incoming message format: https://developer.rocket.chat/reference/api/rest-api/endpoints/core-endpoints/chat-endpoints/postmessage#attachments-detail
class Script {
process_incoming_request({ request }) {
var attachments = [];
request.content.alerts.map(function(item) {
attachments.push({
"image_url" : item.imageURL,
});
});
return {
content:{
text: request.content.message,
attachments: attachments
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment