Alerts are a blessing.
Instead of having to keep an eye on your resources all day you simply configure alerts to make them notify you about your events of interest. But, lately I’ve been wondering - given the amount of different signal types and monitoring services there are - what would be a good setup to actually integrate them and build a manageable and streamlined alerting experience?
Logic Apps and the common alert schema to the rescue.
Common alert schema
The common alert schema unifies the payloads emitted by all the alerts, whether it is a metric, log or activity log alert. They now share a common set of fields called Essentials and alert-specific fields called Alert Context. This allows for easy and standardized consumption of notifications. To make an alert use the common alert schema you have to opt-in for it in your action group.
Now that all the alerts being taken action on through your common alert schema enabled action group, let’s build a Logic App battery to deliver them!
Dispatcher Logic App
Taking advantage of the common alert schema structure I wired up a dispatcher Logic App switching on the different signal types and monitoring services. Depending on the alert this Logic App then forwards the payload to the respectice worker Logic App built for processing exactly that type of Alert Context.
This has two advantages. First, you can just call the dispatcher Logic App from within your action group regardless of the underlying type of alert. Second, things are logically separated and your Logic Apps won’t become too complex.
Below is a picture of the dispatcher Logic App in the Designer so you can get the idea.
Worker Logic Apps
From within the separate worker Logic Apps for each type of alert you can now setup your notifications and deliver them wherever you want. Extract all the information you need from the Alert Context and your configured dimensions and - as an example - post a notification to a Microsoft Teams channel. Unlimited possibilities!
Have a look at one of my worker Logic Apps below.
To make the worker Logic Apps even more concise I think you could safely ditch the payload verification steps there as they are already implemented by the dispatcher Logic App, but you know - better safe than sorry.
That’s all for now.
Absolutely check out the Microsoft Docs from where I did get my inspiration to this topic from, especially these articles are worth a read -
Common alert schema definitions
How to trigger complex actions with Azure Monitor alerts