Note
This documentation for Azure workbooks is now located at: https://learn.microsoft.com/en-us/azure/azure-monitor/visualize/workbooks-commonly-used-components#use-azure-resource-manager-to-retrieve-alerts-in-a-subscription Please do not edit this file. All up-to-date information is in the new location and documentation should only be updated there.
This sample shows you how to use the Azure Resource Manager (preview) query control to list all existing alerts in a subscription. This guide will also use JSON Path transformations to format the results.
- Create an empty workbook.
- Click
Add parameter
to create a new one. Use the following settings:- Parameter name:
Subscription
- Parameter type:
Subscription picker
- Required:
Checked
- Get data from:
Default Subscriptions
- Use the
Save
button in the toolbar to save this parameter.
- Parameter name:
To get a list of existing alerts for a subscription, we will utilize the Alerts - Get All REST call
-
Click
Add query
to create a query control.-
Data source:
Azure Resource Manager (Preview)
-
Http Method:
GET
-
Path:
/subscriptions/{Subscription:id}/providers/Microsoft.AlertsManagement/alerts
-
Add the api-version parameter in the
Parameters
tab- Parameter:
api-version
- Value:
2018-05-05
Note: Supported api-versions are listed in the Azure REST API Reference documentation
- Parameter:
-
Select a subscription from the created subscription parameter and click the
Run Query
button to see the results.
This is the raw JSON results returned from Azure Resource Manager (ARM).
-
You may be satisfied with the information here. However, let us extract some interesting properties and format the response in an easy to read way.
- Navigate to the tab
Result Settings
- Switch the Result Format from
Content
toJSON Path
. JSON Path is a Workbook transformer. Click here to learn more about JSON Path in Workbooks. - In the JSON Path Settings - JSON Path Table:
$.value.[*].properties.essentials
. This extracts all "value.*.properties.essentials" fields from the returned JSON. - Click
Run Query
to see the grid.
JSON Path also allows you to pick and choose information from the generated table to show as columns. For example, if you would like to filter the results to the following columns: TargetResource
, Severity
, AlertState
, Description
, AlertRule
, StartTime
, ResolvedTime
- Add the following rows in the columns table in JSON Path:
Column ID | Column JSON Path |
---|---|
TargetResource | $.targetResource |
Severity | $.severity |
AlertState | $.alertState |
AlertRule | $.alertRule |
Description | $.description |
StartTime | $.startDateTime |
ResolvedTime | $.monitorConditionResolvedDateTime |
Click here to see a list of other supported ARM calls.