grafana/azure-monitor-datasource

Template Variable Support

Closed this issue · 10 comments

It is not currently possible to create template variables using the Azure Monitor plugin as a data source. It is a bit tricky as there is no real query language for the API's. To implement this, I think we should copy the way we have done it in the CloudWatch plugin, where we predefine a list of functions that can be used in the query field e.g. resourceNames(), metricNames()

image

+1. Would love to see support for template variables. Without this feature, I don't see any way to add pre-built Azure dashboards to the Grafana Dashboard gallery.

@asheniam got any ideas on how template variable queries should work for the Azure Monitor data source? What would you need to be able to build a dashboard for the gallery?

I think the dashboard authors would choose the Azure resource types (i.e. metric namespace) and metric names and pre-arrange the charts in some useful manner. For example, we might have pre-built dashboards like "Azure Storage Overview", "Azure Storage Blob Latencies", "Azure Web Apps Overview", etc.

The consumers of the dashboards would plugin the information that is specific to their Azure subscriptions. As you noted initially, I think we'll need functions like resourceNames() or perhaps resourceNamesByResourceType(), etc. I have to experiment with some of the existing Grafana dashboards in the gallery to provide some better feedback.

I've also been experimenting with some ideas for Azure Grafana dashboards in the following repo:
https://github.com/asheniam/azure-grafana-dashboard-templates

I have started implementing this. The Application Insights template variables support was straight forward and is merged to master.

Name Description
AppInsightsMetricNames() Returns a list of metric names.
AppInsightsGroupBys(aMetricName) Returns a list of group bys for the specified metric name.

For Azure Monitor, so far I have three template variable queries:

Name Description
AzureMonitorResourceGroups() Returns a list of resource groups.
AzureMonitorNamespaces(aResourceGroup) Returns a list of namespaces for the specified resource group.
AzureMonitorResourceNames(aResourceGroup, aNamespace) Returns a list of resource names.

This looks good based on existing pattern in Azure Monitor data source.

Will hopefully do some more work on the Azure Monitor variable queries tomorrow and get out a new release as well.

@asheniam your dashboard repo looks really interesting! What OSS license are you planning to use for it?

Dashboard repo was a pet project of mine. I haven't looked into what OSS license to use. What OSS license do you recommend / would help you be able to consume it?

@asheniam MIT or Apache are the two common ones.

See this site from GitHub that helps you choose the right license: https://choosealicense.com/

Thanks. I went with MIT.