mirror of
https://github.com/grafana/grafana.git
synced 2024-11-24 09:50:29 -06:00
Azure Monitor: Fix metric metadata retrieval based on template variables (#60674)
This commit is contained in:
parent
b8253ac3b9
commit
f8cc45f5bd
@ -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', () => {
|
||||
|
@ -260,7 +260,7 @@ export default class AzureMonitorDatasource extends DataSourceWithBackend<AzureM
|
||||
this.templateSrv
|
||||
);
|
||||
return this.getResource(url).then((result: AzureMonitorMetricsMetadataResponse) => {
|
||||
return ResponseParser.parseMetadata(result, metricName);
|
||||
return ResponseParser.parseMetadata(result, this.templateSrv.replace(metricName));
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user