diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.test.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.test.ts index dcfa1085ae1..406e9d39891 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.test.ts +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.test.ts @@ -307,6 +307,30 @@ describe('AzureMonitorDatasource', () => { expect(results.supportedTimeGrains.length).toEqual(5); // 4 time grains from the API + auto }); }); + + it('should replace a template variable for the metric name', () => { + templateSrv.init([ + { + id: 'metric', + name: 'metric', + current: { + value: 'UsedCapacity', + }, + }, + ]); + return ctx.ds.azureMonitorDatasource + .getMetricMetadata({ + resourceUri: + '/subscriptions/mock-subscription-id/resourceGroups/nodeapp/providers/microsoft.insights/components/resource1', + metricNamespace: 'microsoft.insights/components', + metricName: '$metric', + }) + .then((results) => { + expect(results.primaryAggType).toEqual('Total'); + expect(results.supportedAggTypes.length).toEqual(6); + expect(results.supportedTimeGrains.length).toEqual(5); // 4 time grains from the API + auto + }); + }); }); describe('When performing interpolateVariablesInQueries for azure_monitor_metrics', () => { diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.ts b/public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.ts index 1c53a56ad79..ad4633dd32c 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.ts +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_monitor/azure_monitor_datasource.ts @@ -260,7 +260,7 @@ export default class AzureMonitorDatasource extends DataSourceWithBackend { - return ResponseParser.parseMetadata(result, metricName); + return ResponseParser.parseMetadata(result, this.templateSrv.replace(metricName)); }); }