mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Azure Monitor: Fix namespace selection for storageaccounts (#56449)
This commit is contained in:
parent
f98ec2c582
commit
3bea8f2462
@ -4,8 +4,10 @@ describe('setQueryValue', () => {
|
|||||||
describe('setCustomNamespace', () => {
|
describe('setCustomNamespace', () => {
|
||||||
it('The metricnamespace must be: microsoft.storage/storageaccounts for storage accounts.', () => {
|
it('The metricnamespace must be: microsoft.storage/storageaccounts for storage accounts.', () => {
|
||||||
const result = setCustomNamespace({ refId: 'A' }, 'microsoft.storage/storageaccounts/fileservices');
|
const result = setCustomNamespace({ refId: 'A' }, 'microsoft.storage/storageaccounts/fileservices');
|
||||||
expect(result.azureMonitor?.customNamespace).toEqual('');
|
expect(result.azureMonitor?.customNamespace).toBeUndefined();
|
||||||
|
expect(result.azureMonitor?.metricNamespace).toEqual('microsoft.storage/storageaccounts/fileservices');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Set a custom namespace for non storage accounts.', () => {
|
it('Set a custom namespace for non storage accounts.', () => {
|
||||||
const result = setCustomNamespace({ refId: 'A' }, 'foo/bar');
|
const result = setCustomNamespace({ refId: 'A' }, 'foo/bar');
|
||||||
expect(result.azureMonitor?.customNamespace).toEqual('foo/bar');
|
expect(result.azureMonitor?.customNamespace).toEqual('foo/bar');
|
||||||
|
@ -4,13 +4,26 @@ export function setCustomNamespace(query: AzureMonitorQuery, selection: string |
|
|||||||
if (query.azureMonitor?.customNamespace === selection) {
|
if (query.azureMonitor?.customNamespace === selection) {
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
const customNamespace = selection?.toLowerCase().startsWith('microsoft.storage/storageaccounts/') ? '' : selection;
|
|
||||||
|
if (selection?.toLowerCase().startsWith('microsoft.storage/storageaccounts/')) {
|
||||||
|
return {
|
||||||
|
...query,
|
||||||
|
azureMonitor: {
|
||||||
|
...query.azureMonitor,
|
||||||
|
metricNamespace: selection,
|
||||||
|
metricName: undefined,
|
||||||
|
aggregation: undefined,
|
||||||
|
timeGrain: '',
|
||||||
|
dimensionFilters: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...query,
|
...query,
|
||||||
azureMonitor: {
|
azureMonitor: {
|
||||||
...query.azureMonitor,
|
...query.azureMonitor,
|
||||||
customNamespace,
|
customNamespace: selection,
|
||||||
metricName: undefined,
|
metricName: undefined,
|
||||||
aggregation: undefined,
|
aggregation: undefined,
|
||||||
timeGrain: '',
|
timeGrain: '',
|
||||||
|
Loading…
Reference in New Issue
Block a user