From 5c5c3bdd947452079ef51c42a68f5fa721a3bf17 Mon Sep 17 00:00:00 2001 From: shuotli <63325084+shuotli@users.noreply.github.com> Date: Wed, 14 Jul 2021 09:23:07 -0700 Subject: [PATCH] AzureMonitor: Improve Azure Resource Graph docs (#34450) * Add macros in ARG doc * Update docs/sources/datasources/azuremonitor.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/azuremonitor.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/azuremonitor.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/azuremonitor.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/azuremonitor.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/azuremonitor.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/datasources/azuremonitor.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> --- .../datasources/azuremonitor/_index.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/sources/datasources/azuremonitor/_index.md b/docs/sources/datasources/azuremonitor/_index.md index a9d813d5a50..a613a9c7c2c 100644 --- a/docs/sources/datasources/azuremonitor/_index.md +++ b/docs/sources/datasources/azuremonitor/_index.md @@ -231,6 +231,28 @@ In Azure Resource Graph many nested properties (`properties.displayName`) are of The Azure documentation also hosts [many sample queries](https://docs.microsoft.com/en-gb/azure/governance/resource-graph/samples/starter) to help you get started +### Azure Resource Graph macros + +You can use Grafana macros when constructing a query. Use the macros in the where clause of a query: + +- `$__timeFilter()` - Expands to + `timestamp ≥ datetime(2018-06-05T18:09:58.907Z) and` + `timestamp ≤ datetime(2018-06-05T20:09:58.907Z)` where the from and to datetimes are from the Grafana time picker. + +- `$__timeFilter(datetimeColumn)` - Expands to + `datetimeColumn ≥ datetime(2018-06-05T18:09:58.907Z) and` + `datetimeColumn ≤ datetime(2018-06-05T20:09:58.907Z)` where the from and to datetimes are from the Grafana time picker. + +- `$__timeFrom()` - Returns the From datetime from the Grafana picker. Example: `datetime(2018-06-05T18:09:58.907Z)`. + +- `$__timeTo()` - Returns the To datetime from the Grafana picker. Example: `datetime(2018-06-05T20:09:58.907Z)`. + +- `$__escapeMulti($myVar)` - Use with multi-value template variables that contain illegal characters. If `$myVar` has the two values as a string `'\\grafana-vm\Network(eth0)\Total','\\hello!'`, then it expands to: `@'\\grafana-vm\Network(eth0)\Total', @'\\hello!'`. If you are using single value variables, then there is no need for this macro, simply escape the variable inline instead - `@'\$myVar'`. + +- `$__contains(colName, $myVar)` - Use with multi-value template variables. If `$myVar` has the value `'value1','value2'`, the it expands to: `colName in ('value1','value2')`. + + If using the `All` option, then check the `Include All Option` checkbox and in the `Custom all value` field type in the following value: `all`. If `$myVar` has value `all` then the macro will instead expand to `1 == 1`. For template variables with a lot of options, this will increase the query performance by not building a large "where..in" clause. + ## Going further with Azure Monitor See the following topics to learn more about the Azure Monitor data source: