
* builds out refactored setup topics * Automatically fix some relrefs with mv-manager Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Use refs for tutorials content which is outside of this repository Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Manually fix complicated relrefs Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * consolidates team sync and db encryption topics * Fix relrefs Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * updates setup index file * Convert TOML to YAML Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Add current alias for new alerting content Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Add current aliases to new setup-grafana and configure-security pages Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Update docs/sources/setup-grafana/configure-grafana/_index.md Co-authored-by: Torkel Ödegaard <torkel@grafana.com> * moves saml docs, updates order in TOC * Manually fix relrefs Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * added usage insights topics, adjusted weights * corrected relrefs * Fix relrefs broken in rebase Signed-off-by: Jack Baldry <jack.baldry@grafana.com> Co-authored-by: Jack Baldry <jack.baldry@grafana.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
5.1 KiB
aliases | 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 "../../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. |
ResourceGroups() |
Returns resource groups. |
ResourceGroups(subscriptionID) |
Returns resource groups for a specified subscription. |
Namespaces(aResourceGroup) |
Returns namespaces for the default subscription and specified resource group. |
Namespaces(subscriptionID, aResourceGroup) |
Returns namespaces for the specified subscription and resource group. |
ResourceNames(aResourceGroup, aNamespace) |
Returns a list of resource names. |
ResourceNames(subscriptionID, aResourceGroup, aNamespace) |
Returns a list of resource names for a specified subscription. |
MetricNamespace(aResourceGroup, aNamespace, aResourceName) |
Returns a list of metric namespaces. |
MetricNamespace(subscriptionID, aResourceGroup, aNamespace, aResourceName) |
Returns a list of metric namespaces for a specified subscription. |
MetricNames(aResourceGroup, aMetricDefinition, aResourceName, aMetricNamespace) |
Returns a list of metric names. |
MetricNames(aSubscriptionID, aMetricDefinition, aResourceName, aMetricNamespace) |
Returns a list of metric names for a specified subscription. |
workspaces() |
Returns a list of workspaces for the default subscription. |
workspaces(subscriptionID) |
Returns a list of workspaces for the specified subscription (the parameter can be quoted or unquoted). |
Where a subscription ID is not specified, a default subscription must be specified in the data source configuration, which will be used.
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