Skip to content

Latest commit

 

History

History
62 lines (44 loc) · 3.48 KB

File metadata and controls

62 lines (44 loc) · 3.48 KB

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.

Using Azure Resource Manager provider to retrieve alerts in a subscription

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.

Setup parameters

  1. Create an empty workbook.
  2. Click Add parameter to create a new one. Use the following settings:
    1. Parameter name: Subscription
    2. Parameter type: Subscription picker
    3. Required: Checked
    4. Get data from: Default Subscriptions
    5. Use the Save button in the toolbar to save this parameter.

To get a list of existing alerts for a subscription, we will utilize the Alerts - Get All REST call

  1. Click Add query to create a query control.

    1. Data source: Azure Resource Manager (Preview)

    2. Http Method: GET

    3. Path: /subscriptions/{Subscription:id}/providers/Microsoft.AlertsManagement/alerts

    4. Add the api-version parameter in the Parameters tab

      1. Parameter: api-version
      2. Value: 2018-05-05

      Note: Supported api-versions are listed in the Azure REST API Reference documentation

    5. 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).

    Image showing an alert data JSON response using ARM Provider

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.

  1. Navigate to the tab Result Settings
  2. Switch the Result Format from Content to JSON Path. JSON Path is a Workbook transformer. Click here to learn more about JSON Path in Workbooks.
  3. In the JSON Path Settings - JSON Path Table: $.value.[*].properties.essentials. This extracts all "value.*.properties.essentials" fields from the returned JSON.
  4. Click Run Query to see the grid.

Image showing an alert data in a grid format using ARM Provider

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

  1. 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

Image showing an alert data in a grid format using ARM Provider

Click here to see a list of other supported ARM calls.