Paste this in javascript in the "Script" textarea on Rocket.Chat webhook settings
classScript{process_incoming_request({request}){ // console is a global helper to improve debugconsole.log(request.content);var alertColor ="warning";if(request.content.status ==="Resolved"){ alertColor ="good";}elseif (request.content.status ==="Activated") { alertColor ="danger";}var condition =request.content.context.condition;return{ content:{ username:"Azure", text:"Azure Alert Notification", attachments: [{ title:request.content.context.name, pretext:request.content.context.description, title_link:request.content.context.portalLink, text:condition.failureDetails, color: alertColor, fields: [{ title:"Status", value:request.content.status +" @ "+request.content.context.timestamp},{ title:"Condition", value:condition.metricName +": "+condition.metricValue +""+condition.metricUnit +" for more than "+condition.windowSize +" min."},{ title:"Threshold", value:condition.operator +""+condition.threshold} ]}]}};return{ error:{ success:false, message:'Error'}};}}
This example shows basic processing of azure alerts that will give you the necessary information as to what happened and what is the current status, along with a status color to get an idea at a quick glimpse of the message.
For newer created alerts the azure webhooks can be process by the following script: