-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARM endpoint and JSON Transformer Documentation (#548)
* ARM endpoint and JSON transformation
- Loading branch information
Showing
12 changed files
with
176 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# 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](https://docs.microsoft.com/en-us/rest/api/monitor/alertsmanagement/alerts/getall) | ||
|
||
3. 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](https://docs.microsoft.com/en-us/rest/api/azure/) 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](../Images/ARMAlertsQueryNoFormatting.png) | ||
|
||
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. | ||
|
||
4. Navigate to the tab `Result Settings` | ||
5. Switch the Result Format from `Content` to `JSON Path`. JSON Path is a Workbook transformer. Click [here](../Transformations/JSONPath.md) to learn more about JSON Path in Workbooks. | ||
6. In the JSON Path Settings - JSON Path Table: `$.value.[*].properties.essentials`. This extracts all "value.*.properties.essentials" fields from the returned JSON. | ||
7. Click `Run Query` to see the grid. | ||
|
||
![Image showing an alert data in a grid format using ARM Provider](../Images/ARMAlertsQueryGridFormat.png) | ||
|
||
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` | ||
|
||
8. 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](../Images/ARMAlertsQueryFinal.png) | ||
|
||
|
||
Click [here](https://docs.microsoft.com/en-us/rest/api/azure/) to see a list of other supported ARM calls. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# JSON Path | ||
|
||
Workbooks is able to query data from many sources. Some endpoints, such as Azure Resource Manager or custom endpoint, can return results in JSON. If the JSON data returned by the queried endpoint is not configured in a format that you desire, JSONPath can be used to transform the results. | ||
|
||
JSONPath is a query language for JSON that is similar to XPath for XML. Like XPath, JSONPath allows for the extraction and filtration of data out of a JSON structure. | ||
|
||
Click [here](https://aka.ms/jsonpath) to learn more about JSON Path. | ||
|
||
By using JSONPath transformation, Workbook authors are able to convert JSON into a table structure. The table can then be used to plot Workbook [visualizations](../Visualizations/Visualizations.md). | ||
|
||
## Using JSONPath | ||
|
||
1. Switch the workbook to edit mode by clicking on the _Edit_ toolbar item. | ||
2. Use the _Add query_ link to add a query control to the workbook. | ||
3. Select the query type as _JSON_ | ||
4. Use the JSON editor to enter the following JSON snippet | ||
|
||
```json | ||
{ "store": { | ||
"books": [ | ||
{ "category": "reference", | ||
"author": "Nigel Rees", | ||
"title": "Sayings of the Century", | ||
"price": 8.95 | ||
}, | ||
{ "category": "fiction", | ||
"author": "Evelyn Waugh", | ||
"title": "Sword of Honour", | ||
"price": 12.99 | ||
}, | ||
{ "category": "fiction", | ||
"author": "Herman Melville", | ||
"title": "Moby Dick", | ||
"isbn": "0-553-21311-3", | ||
"price": 8.99 | ||
}, | ||
{ "category": "fiction", | ||
"author": "J. R. R. Tolkien", | ||
"title": "The Lord of the Rings", | ||
"isbn": "0-395-19395-8", | ||
"price": 22.99 | ||
} | ||
], | ||
"bicycle": { | ||
"color": "red", | ||
"price": 19.95 | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Let’s assume we are given the above JSON object as a representation of a store's inventory. Our task is to create a table of the store's available books by listing their titles, authors, and prices. | ||
|
||
5. Select the _Result settings_ tab, and switch the result format from `Content` to `JSON Path` | ||
6. Apply the following JSON Path Settings: | ||
1. JSON Path Table: `$.store.books`. This field represents the path to the root of the table. In this case, we care about the store's book inventory. The table path filters the JSON to the book information. | ||
2. Column IDs: `Title`, `Author`, `Price`. These will be the column headers. | ||
3. Column JSON Paths: `$.title`, `$.author`, `$.price`. These fields represent the path from the root of the table to the column value. For each row in the table, the path will be applied. | ||
|
||
7. Apply the above settings by clicking _Run Query_. | ||
|
||
![Image showing the creation of a grid visualization using JSON Path](../Images/JSONPath-Example-Result.PNG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9b56e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9b56e60