This repository contains a collection of pre-built Grafana dashboard templates for Microsoft Azure resources. Use the armclient tool to automatically generate Grafana dashboards which you can import into your Grafana server.
For details on the armclient tool, please refer to the following:
https://github.com/asheniam/armclient
usage: armclient grafana --title=TITLE --datasource=DATASOURCE --resourcetype=RESOURCETYPE [<flags>] Generate Grafana dashboard JSON files for given Azure resource type. Flags: --help Show context-sensitive help (also try --help-long and --help-man). --config.file="sample-azure.yml" Azure configuration file --debug Debug flag --title=TITLE This will be used as prefix in the dashboard title --datasource=DATASOURCE The Azure Monitor data source name on Grafana --resourcetype=RESOURCETYPE The Azure Resource Manager (ARM) resource type --kind="" The kind property on the Azure Resource Manager (ARM) resource type. This is optional. --maxdashboardresource=10 The max number of Azure resources to include in each dashboard. Default to 10. --maxcontinuation=10 The max number of continuations to follow when calling ARM API. Default to 10.
Prerequisite:
This assumes that you are familiar with Grafana and the Azure Monitor data source plugin. For more information, please refer to the following article:
https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitor-send-to-grafana
How to use:
-
Create a service principal which has Reader permission to access your Azure subscription. https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal
-
Create armclient config file with service principal credentials.
Example: sample-azure.yml
Credentials: environment: public subscription_id: <subscriptionId> client_id: <clientId> client_secret: <clientSecret> tenant_id: <tenantId>
- Run armclient command line tool to generate Grafana dashboard JSON files.
You will need the name of the Azure Monitor data source on your Grafana server and the ARM resource type that you want to generate dashboards.
Example: ./armclient --config.file=sample-azure.yml grafana --title=production --datasource=AzureMonitorDataSource --resourcetype=microsoft.storage/storageaccounts
- production = This string is added to the title of the generated Grafana dashboard
- AzureMonitorDataSource = This is the name of the Azure Monitor data source on your Grafana server
- microsoft.storage/storageaccounts = This is the Azure Resource Manager (ARM) resource type
The armclient tool will generate dashboard JSON files -- one for each region and one for all regions.
In the above example the following JSON files could be generated:
dashboard_production_microsoft_storage_storageaccounts_overview_allregions.json dashboard_production_microsoft_storage_storageaccounts_overview_eastus.json dashboard_production_microsoft_storage_storageaccounts_overview_southcentralus.json dashboard_production_microsoft_storage_storageaccounts_overview_westcentralus.json
-
Import the dashboard JSON files into your Grafana server.
-
Enjoy!
How to contribute
The armclient automatically pulls dashboard templates from this GitHub repository. To contribute new dashboard templates, please following the following instructions.
-
On your Grafana server, create a dashboard for a given Azure Resource Manager (ARM) resource type. Note: In your dashboard, you should only select single Azure resource for each of the charts. The armclient tool will automatically replace all the Azure Monitor targets in the dashboard JSON using ARM resource IDs from the given Azure subscription.
-
Export the dashboard to JSON. Save the JSON into a file called template.json.
-
Anonymize the contents of template.json
- Replace the data source name with {dataSourceName}
- Replace the resource group name with {resourceGroupName}
- Replace the resource name with {resourceName}
- Create the following directory structure: <ARM resource type>/<dashboard friendly name>
For example, if you are creating a dashboard specific to Azure Storage account latencies, you could create the following directory structure:
microsoft.storage/storageaccounts/latency
- In the new directory, create the following 3 files:
- template.json : This is the dashboard template from step #3
- dashboard.png : This is a sample screenshot of the dashboard.
- README.md : This README contains the dashboard screenshot and a sample armclient command to generate the dashboard.
-
Submit a pull request.
-
After the pull request is merged, anyone who runs ./armclient grafana command for the given ARM resource type will generate dashboards using your template.