3c68684dd2
* Use relative aliases for all non-current Grafana aliases Prevents non-latest documentation "stealing" the page away from latest and through permanent redirects for latest pages that no longer exist. The redirected pages are indexed by search engines but our robots.txt forbids them crawling the non-latest page. Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Remove all current page aliases find docs/sources -type f -name '*.md' -exec sed -z -i 's#\n *- /docs/grafana/next/[^\n]*\n#\n#' {} \; find docs/sources -type f -name '*.md' -exec sed -z -i 's#\n *- /docs/grafana/latest/[^\n]*\n#\n#' {} \; find docs/sources -type f -name '*.md' -exec sed -Ez -i 's#\n((aliases:\n *-)|aliases:\n)#\n\2#' {} \; Signed-off-by: Jack Baldry <jack.baldry@grafana.com> Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
3.2 KiB
3.2 KiB
description, keywords, title, weight
| description | keywords | title | weight | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Using template variables with Azure Monitor in Grafana |
|
Azure Monitor template variables | 2 |
Template variables
Instead of hard-coding values for fields like resource group or resource name in your queries, you can use variables in their place to create more interactive, dynamic, and reusable dashboards.
Check out the [Templating]({{< relref "../../dashboards/variables" >}}) documentation for an introduction to the templating feature and the different types of template variables.
The Azure Monitor data source provides the following queries you can specify in the Query field in the Variable edit view
| Name | Description |
|---|---|
| Subscriptions | Returns subscriptions. |
| Resource Groups | Returns resource groups for a specified subscription. |
| Namespaces | Returns metric namespaces for the specified subscription and resource group. |
| Resource Names | Returns a list of resource names for a specified subscription, resource group and namespace. |
| Metric Names | Returns a list of metric names for a resource. |
| Workspaces | Returns a list of workspaces for the specified subscription. |
| Logs | Use a KQL query to return values. |
| Resource Graph | Use an ARG query to return values. |
Any Log Analytics KQL query that returns a single list of values can also be used in the Query field. For example:
| Query | Description |
|---|---|
workspace("myWorkspace").Heartbeat | distinct Computer |
Returns a list of Virtual Machines |
workspace("$workspace").Heartbeat | distinct Computer |
Returns a list of Virtual Machines with template variable |
workspace("$workspace").Perf | distinct ObjectName |
Returns a list of objects from the Perf table |
workspace("$workspace").Perf | where ObjectName == "$object" | distinct CounterName |
Returns a list of metric names from the Perf table |
Example of a time series query using variables:
Perf
| where ObjectName == "$object" and CounterName == "$metric"
| where TimeGenerated >= $__timeFrom() and TimeGenerated <= $__timeTo()
| where $__contains(Computer, $computer)
| summarize avg(CounterValue) by bin(TimeGenerated, $__interval), Computer
| order by TimeGenerated asc