Subscribe to Health Resources events and send them to Azure monitor alerts (Preview)
Health Resources system topic in Azure Event Grid provides accurate, reliable, and comprehensive information on health of your Azure resources such as single instance virtual machines (VMs), Virtual Machine Scale Set VMS, and Virtual Machine Scale Sets. This feature enables a deeper understanding of the diverse service issues impacting your resources. You can now set up Azure Monitor alerts to notify you when your workload is impacted.
Prerequisites
- Create a Health Resources system topic by following instructions from Subscribe to Azure Resource Notifications - Health Resources events.
- Learn about the event types supported by the system topic and their properties by reading through the Health Resources events in Azure Event Grid article.
- To learn about Azure Monitor alerts, see How to send events to Azure monitor alerts.
Create and configure the event subscription
Navigate to the Event Grid system topic you created as part of the prerequisites.
Select + Event Subscription on the command bar.
Enter a name for event subscription.
For Event Schema, select the event schema as Cloud Events Schema v1.0. It's the only schema type that the Azure Monitor alerts destination supports.
Select the Topic Type to
microsoft resourcenotifications healthresources
.For Event Types, select the event types that you're interested in. In this case, select the two event types offered for consumption:
AvailabilityStatusChanged
andResourceAnnotated
.For Endpoint Type, select Azure Monitor Alert as a destination.
Select Configure an endpoint link.
On the Select Monitor Alert Configuration page, follow these steps.
- Select the alert severity.
- [Optional] Select the action group. See Create an action group in the Azure portal.
- Enter a description for the alert.
- Select Confirm Selection.
Now, on the Create Event Subscription page, select Create to create the event subscription. For detailed steps, see subscribe to events through portal.
Azure Monitor alerts
In Azure monitor alerts, the Event Grid alerts appear as shown in the following image.
Sample Event Grid alert for AvailabilityStatusChanged
:
Sample Event Grid alert for ResourceAnnotated
:
Event Filters
The event filter enables users to receive alerts for a specific resource group, specific transitions (when the availability state changes), or specific annotations (see Resource Health virtual machine Health Annotations for the full list of annotations). Users can use this feature to customize their alerts based on their specific monitoring needs.
Select the Filters tab to provide subject filtering and advanced filtering. For example, to filter for events from resources in a specific resource group, follow these steps:
Select Enable subject filtering.
In the Subject Filters section, for Subject begins with, provide the value of the resource group in this format:
/subscriptions/{subscription-id}/resourceGroups/{resourceGroup-id}
.Alternately, filter for a specific resource by specifying the resource name in the Subject ends with parameter within the advanced filters introduced in the next step.
For advanced filtering, navigate to the Filters tab of the event subscription and select Advanced filters. For detailed instructions, see Event filtering for Azure Event Grid.
For example, to get alerted when VMs go down, set a filter to look for VM availability transitions that go from
Available
toUnavailable
. It's done by creating the following conditions:
Sample JSON events
Sample ResourceAnnotated event
Here's a sample ResourceAnnotated
event. Notice that the type
is set to Microsoft.ResourceNotifications.HealthResources.ResourceAnnotated
.
{
"id": "sample-id",
"source": "/subscriptions/sample-subscription",
"specversion": "1.0",
"type": "Microsoft.ResourceNotifications.HealthResources.ResourceAnnotated",
"subject": "/subscriptions/sample-subscription/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-machine",
"time": "2024-02-22T01:39:48.3385828Z",
"data": {
"resourceInfo": {
"id": "/subscriptions/sample-subscription/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-machine/providers/Microsoft.ResourceHealth/resourceAnnotations/current",
"name": "current",
"type": "Microsoft.ResourceHealth/resourceAnnotations",
"properties": {
"targetResourceId": "/subscriptions/sample-subscription/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-machine",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"occurredTime": "2024-02-22T01:39:48.3385828Z",
"annotationName": "VirtualMachineRebootInitiatedByControlPlane",
"reason": "Rebooted by user",
"summary": "The Virtual Machine is undergoing a reboot as requested by an authorized user or process from within the Virtual machine. No other action is required at this time. ",
"context": "Customer Initiated",
"category": "Not Applicable",
"impactType": "Informational"
}
},
"operationalInfo": {
"resourceEventTime": "2024-02-22T01:39:48.3385828+00:00"
},
"apiVersion": "2022-08-01"
}
}
Sample AvailabilityStatusChanged event
Here's a sample AvailabilityStatusChanged
event. Notice that the type
is set to Microsoft.ResourceNotifications.HealthResources.AvailabilityStatusChanged
.
{
"id": "sample-id",
"source": "/subscriptions/sample-subscription",
"specversion": "1.0",
"type": "Microsoft.ResourceNotifications.HealthResources.AvailabilityStatusChanged",
"subject": "/subscriptions/sample-subscription/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-machine",
"time": "2024-02-22T01:40:17.6532683Z",
"data": {
"resourceInfo": {
"id": "/subscriptions/sample-subscription/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-machinee/providers/Microsoft.ResourceHealth/availabilityStatuses/current",
"name": "current",
"type": "Microsoft.ResourceHealth/availabilityStatuses",
"properties": {
"targetResourceId": "/subscriptions/sample-subscription/resourceGroups/sample-rg/providers/Microsoft.Compute/virtualMachines/sample-machine",
"targetResourceType": "Microsoft.Compute/virtualMachines",
"occurredTime": "2024-02-22T01:39:50.177Z",
"previousAvailabilityState": "Available",
"availabilityState": "Unavailable"
}
},
"operationalInfo": {
"resourceEventTime": "2024-02-22T01:39:50.177+00:00"
},
"apiVersion": "2023-12-01"
}
}
Next steps
See the following articles: