mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Azure Monitor: Fix bug that did not show alert rule preview (#68339)
This commit is contained in:
parent
43df362aed
commit
f9601f8f27
@ -27,6 +27,8 @@ const azureMonitorQueryV9_0 = {
|
||||
dimensionFilters: [],
|
||||
metricName: 'dependencies/duration',
|
||||
metricNamespace: 'microsoft.insights/components',
|
||||
resourceGroup: 'cloud-datasources',
|
||||
resourceName: 'AppInsightsTestData',
|
||||
resourceUri:
|
||||
'/subscriptions/44693801-6ee6-49de-9b2d-9106972f9572/resourceGroups/cloud-datasources/providers/microsoft.insights/components/AppInsightsTestData',
|
||||
timeGrain: 'auto',
|
||||
@ -204,9 +206,22 @@ describe('AzureMonitor: migrateQuery', () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('correctly remove outdated fields', () => {
|
||||
const result = migrateQuery(azureMonitorQueryV9_0);
|
||||
expect(result).toMatchObject(
|
||||
expect.objectContaining({
|
||||
azureMonitor: expect.objectContaining({
|
||||
resources: modernMetricsQuery.azureMonitor!.resources,
|
||||
}),
|
||||
})
|
||||
);
|
||||
expect(result.azureMonitor).not.toHaveProperty('resourceGroup');
|
||||
expect(result.azureMonitor).not.toHaveProperty('resourceName');
|
||||
});
|
||||
});
|
||||
|
||||
it('should migrate a sigle resource for Logs', () => {
|
||||
it('should migrate a single resource for Logs', () => {
|
||||
const q = {
|
||||
...modernMetricsQuery,
|
||||
azureLogAnalytics: {
|
||||
|
@ -176,13 +176,22 @@ function migrateDimensionToResourceObj(query: AzureMonitorQuery): AzureMonitorQu
|
||||
function migrateResourceGroupAndName(query: AzureMonitorQuery): AzureMonitorQuery {
|
||||
let workingQuery = query;
|
||||
|
||||
if (workingQuery.azureMonitor) {
|
||||
workingQuery.azureMonitor.resources = [
|
||||
{ resourceGroup: workingQuery.azureMonitor.resourceGroup, resourceName: workingQuery.azureMonitor.resourceName },
|
||||
];
|
||||
if (workingQuery.azureMonitor?.resourceGroup && workingQuery.azureMonitor?.resourceName) {
|
||||
workingQuery = {
|
||||
...workingQuery,
|
||||
azureMonitor: {
|
||||
...workingQuery.azureMonitor,
|
||||
resources: [
|
||||
{
|
||||
resourceGroup: workingQuery.azureMonitor.resourceGroup,
|
||||
resourceName: workingQuery.azureMonitor.resourceName,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
delete workingQuery.azureMonitor.resourceGroup;
|
||||
delete workingQuery.azureMonitor.resourceName;
|
||||
delete workingQuery.azureMonitor?.resourceGroup;
|
||||
delete workingQuery.azureMonitor?.resourceName;
|
||||
}
|
||||
|
||||
return workingQuery;
|
||||
|
Loading…
Reference in New Issue
Block a user