AzureMonitor: Use resource type display names in the UI (#35060)

* AzureMonitor: Use display names for resource types and locations

* de-pluralize resource types

* Rename Namespace field to Resource Type, and use display names

* add comments
This commit is contained in:
Josh Hunt 2021-06-02 11:47:04 +01:00 committed by GitHub
parent e6f2b10a36
commit 3be0a2d328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 1108 additions and 200 deletions

View File

@ -0,0 +1,2 @@
export * from './locations';
export * from './resourceTypes';

View File

@ -0,0 +1,334 @@
// Unfortunately this list is manually maintained as there's no (nice) automated way to get
// data from Azure.
export const locationMetadata = [
{
location: 'eastus',
displayName: 'East US',
supportsLogs: true,
},
{
location: 'eastus2',
displayName: 'East US 2',
supportsLogs: true,
},
{
location: 'southcentralus',
displayName: 'South Central US',
supportsLogs: true,
},
{
location: 'westus2',
displayName: 'West US 2',
supportsLogs: true,
},
{
location: 'westus3',
displayName: 'West US 3',
supportsLogs: true,
},
{
location: 'australiaeast',
displayName: 'Australia East',
supportsLogs: true,
},
{
location: 'southeastasia',
displayName: 'Southeast Asia',
supportsLogs: true,
},
{
location: 'northeurope',
displayName: 'North Europe',
supportsLogs: true,
},
{
location: 'uksouth',
displayName: 'UK South',
supportsLogs: true,
},
{
location: 'westeurope',
displayName: 'West Europe',
supportsLogs: true,
},
{
location: 'centralus',
displayName: 'Central US',
supportsLogs: true,
},
{
location: 'northcentralus',
displayName: 'North Central US',
supportsLogs: true,
},
{
location: 'westus',
displayName: 'West US',
supportsLogs: true,
},
{
location: 'southafricanorth',
displayName: 'South Africa North',
supportsLogs: true,
},
{
location: 'centralindia',
displayName: 'Central India',
supportsLogs: true,
},
{
location: 'eastasia',
displayName: 'East Asia',
supportsLogs: true,
},
{
location: 'japaneast',
displayName: 'Japan East',
supportsLogs: true,
},
{
location: 'jioindiawest',
displayName: 'Jio India West',
supportsLogs: true,
},
{
location: 'koreacentral',
displayName: 'Korea Central',
supportsLogs: true,
},
{
location: 'canadacentral',
displayName: 'Canada Central',
supportsLogs: true,
},
{
location: 'francecentral',
displayName: 'France Central',
supportsLogs: true,
},
{
location: 'germanywestcentral',
displayName: 'Germany West Central',
supportsLogs: true,
},
{
location: 'norwayeast',
displayName: 'Norway East',
supportsLogs: true,
},
{
location: 'switzerlandnorth',
displayName: 'Switzerland North',
supportsLogs: true,
},
{
location: 'uaenorth',
displayName: 'UAE North',
supportsLogs: true,
},
{
location: 'brazilsouth',
displayName: 'Brazil South',
supportsLogs: true,
},
{
location: 'centralusstage',
displayName: 'Central US (Stage)',
supportsLogs: true,
},
{
location: 'eastusstage',
displayName: 'East US (Stage)',
supportsLogs: true,
},
{
location: 'eastus2stage',
displayName: 'East US 2 (Stage)',
supportsLogs: true,
},
{
location: 'northcentralusstage',
displayName: 'North Central US (Stage)',
supportsLogs: true,
},
{
location: 'southcentralusstage',
displayName: 'South Central US (Stage)',
supportsLogs: true,
},
{
location: 'westusstage',
displayName: 'West US (Stage)',
supportsLogs: true,
},
{
location: 'westus2stage',
displayName: 'West US 2 (Stage)',
supportsLogs: true,
},
{
location: 'asia',
displayName: 'Asia',
supportsLogs: true,
},
{
location: 'asiapacific',
displayName: 'Asia Pacific',
supportsLogs: true,
},
{
location: 'australia',
displayName: 'Australia',
supportsLogs: true,
},
{
location: 'brazil',
displayName: 'Brazil',
supportsLogs: true,
},
{
location: 'canada',
displayName: 'Canada',
supportsLogs: true,
},
{
location: 'europe',
displayName: 'Europe',
supportsLogs: true,
},
{
location: 'global',
displayName: 'Global',
supportsLogs: true,
},
{
location: 'india',
displayName: 'India',
supportsLogs: true,
},
{
location: 'japan',
displayName: 'Japan',
supportsLogs: true,
},
{
location: 'uk',
displayName: 'United Kingdom',
supportsLogs: true,
},
{
location: 'unitedstates',
displayName: 'United States',
supportsLogs: true,
},
{
location: 'eastasiastage',
displayName: 'East Asia (Stage)',
supportsLogs: true,
},
{
location: 'southeastasiastage',
displayName: 'Southeast Asia (Stage)',
supportsLogs: true,
},
{
location: 'westcentralus',
displayName: 'West Central US',
supportsLogs: true,
},
{
location: 'southafricawest',
displayName: 'South Africa West',
supportsLogs: true,
},
{
location: 'australiacentral',
displayName: 'Australia Central',
supportsLogs: true,
},
{
location: 'australiacentral2',
displayName: 'Australia Central 2',
supportsLogs: true,
},
{
location: 'australiasoutheast',
displayName: 'Australia Southeast',
supportsLogs: true,
},
{
location: 'japanwest',
displayName: 'Japan West',
supportsLogs: true,
},
{
location: 'koreasouth',
displayName: 'Korea South',
supportsLogs: true,
},
{
location: 'southindia',
displayName: 'South India',
supportsLogs: true,
},
{
location: 'westindia',
displayName: 'West India',
supportsLogs: true,
},
{
location: 'canadaeast',
displayName: 'Canada East',
supportsLogs: true,
},
{
location: 'francesouth',
displayName: 'France South',
supportsLogs: true,
},
{
location: 'germanynorth',
displayName: 'Germany North',
supportsLogs: true,
},
{
location: 'norwaywest',
displayName: 'Norway West',
supportsLogs: true,
},
{
location: 'switzerlandwest',
displayName: 'Switzerland West',
supportsLogs: true,
},
{
location: 'ukwest',
displayName: 'UK West',
supportsLogs: true,
},
{
location: 'uaecentral',
displayName: 'UAE Central',
supportsLogs: true,
},
{
location: 'brazilsoutheast',
displayName: 'Brazil Southeast',
supportsLogs: true,
},
];
export const logsSupportedLocationsKusto = locationMetadata
.filter((v) => v.supportsLogs)
.map((v) => `"${v.location}"`)
.join(',');
// Object, keyed by location ID
export const locationDisplayNames: Record<string, string> = locationMetadata.reduce(
(acc, location) => ({
...acc,
[location.location]: location.displayName,
}),
{}
);

View File

@ -0,0 +1,569 @@
// Unfortunately this list is manually maintained as there's no (nice) automated way to get
// data from Azure.
export const resourceTypeMetadata = [
{
resourceType: 'microsoft.analysisservices/servers',
displayName: 'Analysis Services',
supportsLogs: true,
},
{
resourceType: 'microsoft.synapse/workspaces/bigdatapools',
displayName: 'Apache Spark pool',
supportsLogs: true,
},
{
resourceType: 'microsoft.apimanagement/service',
displayName: 'API Management service',
supportsLogs: true,
},
{
resourceType: 'microsoft.appconfiguration/configurationstores',
displayName: 'App Configuration',
supportsLogs: true,
},
{
resourceType: 'microsoft.web/sites/slots',
displayName: 'App Service (Slot)',
supportsLogs: true,
},
{
resourceType: 'microsoft.web/hostingenvironments',
displayName: 'App Service Environment',
supportsLogs: true,
},
{
resourceType: 'microsoft.web/serverfarms',
displayName: 'App Service plan',
supportsLogs: true,
},
{
resourceType: 'microsoft.web/sites',
displayName: 'App Service',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/applicationgateways',
displayName: 'Application gateway',
supportsLogs: true,
},
{
resourceType: 'microsoft.insights/components',
displayName: 'Application Insights',
supportsLogs: true,
},
{
resourceType: 'microsoft.automation/automationaccounts',
displayName: 'Automation Account',
supportsLogs: true,
},
{
resourceType: 'microsoft.insights/autoscalesettings',
displayName: 'Autoscale Settings',
supportsLogs: true,
},
{
resourceType: 'microsoft.aadiam/azureadmetrics',
displayName: 'Azure AD Metrics',
supportsLogs: true,
},
{
resourceType: 'microsoft.cache/redis',
displayName: 'Azure Cache for Redis',
supportsLogs: true,
},
{
resourceType: 'microsoft.documentdb/databaseaccounts',
displayName: 'Azure Cosmos DB account',
supportsLogs: true,
},
{
resourceType: 'microsoft.kusto/clusters',
displayName: 'Azure Data Explorer Cluster',
supportsLogs: true,
},
{
resourceType: 'microsoft.dbformariadb/servers',
displayName: 'Azure Database for MariaDB server',
supportsLogs: true,
},
{
resourceType: 'microsoft.dbformysql/servers',
displayName: 'Azure Database for MySQL server',
supportsLogs: true,
},
{
resourceType: 'microsoft.dbforpostgresql/flexibleservers',
displayName: 'Azure Database for PostgreSQL flexible server',
supportsLogs: true,
},
{
resourceType: 'microsoft.dbforpostgresql/servergroupsv2',
displayName: 'Azure Database for PostgreSQL server group',
supportsLogs: true,
},
{
resourceType: 'microsoft.dbforpostgresql/servers',
displayName: 'Azure Database for PostgreSQL server',
supportsLogs: true,
},
{
resourceType: 'microsoft.dbforpostgresql/serversv2',
displayName: 'Azure Database for PostgreSQL server v2',
supportsLogs: true,
},
{
resourceType: 'microsoft.resources/subscriptions',
displayName: 'Subscription',
supportsLogs: true,
},
{
resourceType: 'microsoft.appplatform/spring',
displayName: 'Azure Spring Cloud',
supportsLogs: true,
},
{
resourceType: 'microsoft.databoxedge/databoxedgedevices',
displayName: 'Azure Stack Edge / Data Box Gateway',
supportsLogs: true,
},
{
resourceType: 'microsoft.azurestackresourcemonitor/storageaccountmonitor',
displayName: 'Azure Stack Resource Monitor',
supportsLogs: true,
},
{
resourceType: 'microsoft.synapse/workspaces',
displayName: 'Synapse workspace',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/bastionhosts',
displayName: 'Bastion',
supportsLogs: true,
},
{
resourceType: 'microsoft.batch/batchaccounts',
displayName: 'Batch account',
supportsLogs: true,
},
{
resourceType: 'microsoft.botservice/botservices',
displayName: 'Bot Service',
supportsLogs: true,
},
{
resourceType: 'microsoft.netapp/netappaccounts/capacitypools',
displayName: 'Capacity pool',
supportsLogs: true,
},
{
resourceType: 'microsoft.classiccompute/domainnames',
displayName: 'Cloud service (classic)',
supportsLogs: true,
},
{
resourceType: 'microsoft.vmwarecloudsimple/virtualmachines',
displayName: 'CloudSimple Virtual Machine',
supportsLogs: true,
},
{
resourceType: 'microsoft.cognitiveservices/accounts',
displayName: 'Cognitive Services',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/networkwatchers/connectionmonitors',
displayName: 'Connection Monitors',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/connections',
displayName: 'Connection',
supportsLogs: true,
},
{
resourceType: 'microsoft.containerinstance/containergroups',
displayName: 'Container instances',
supportsLogs: true,
},
{
resourceType: 'microsoft.containerregistry/registries',
displayName: 'Container registry',
supportsLogs: true,
},
{
resourceType: 'microsoft.insights/qos',
displayName: 'Custom Metric Usage',
supportsLogs: true,
},
{
resourceType: 'microsoft.customerinsights/hubs',
displayName: 'CustomerInsights',
supportsLogs: true,
},
{
resourceType: 'microsoft.datafactory/datafactories',
displayName: 'Data factory',
supportsLogs: true,
},
{
resourceType: 'microsoft.datafactory/factories',
displayName: 'Data factory (V2)',
supportsLogs: true,
},
{
resourceType: 'microsoft.datalakeanalytics/accounts',
displayName: 'Data Lake Analytics',
supportsLogs: true,
},
{
resourceType: 'microsoft.datalakestore/accounts',
displayName: 'Data Lake Storage Gen1',
supportsLogs: true,
},
{
resourceType: 'microsoft.datashare/accounts',
displayName: 'Data Share',
supportsLogs: true,
},
{
resourceType: 'microsoft.synapse/workspaces/sqlpools',
displayName: 'Dedicated SQL pool',
supportsLogs: true,
},
{
resourceType: 'microsoft.devices/provisioningservices',
displayName: 'Device Provisioning Service',
supportsLogs: true,
},
{
resourceType: 'microsoft.compute/disks',
displayName: 'Disk',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/dnszones',
displayName: 'DNS zone',
supportsLogs: true,
},
{
resourceType: 'microsoft.eventgrid/domains',
displayName: 'Event Grid Domain',
supportsLogs: true,
},
{
resourceType: 'microsoft.eventgrid/systemtopics',
displayName: 'Event Grid System Topic',
supportsLogs: true,
},
{
resourceType: 'microsoft.eventgrid/topics',
displayName: 'Event Grid Topic',
supportsLogs: true,
},
{
resourceType: 'microsoft.eventhub/clusters',
displayName: 'Event Hubs Cluster',
supportsLogs: true,
},
{
resourceType: 'microsoft.eventhub/namespaces',
displayName: 'Event Hubs Namespace',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/expressroutecircuits',
displayName: 'ExpressRoute circuit',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/expressrouteports',
displayName: 'ExpressRoute Direct',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/expressroutegateways',
displayName: 'ExpressRoute Gateways',
supportsLogs: true,
},
{
resourceType: 'microsoft.fabric.admin/fabriclocations',
displayName: 'Fabric Locations',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/azurefirewalls',
displayName: 'Firewall',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/frontdoors',
displayName: 'Front Door',
supportsLogs: true,
},
{
resourceType: 'microsoft.hdinsight/clusters',
displayName: 'HDInsight cluster',
supportsLogs: true,
},
{
resourceType: 'microsoft.storagecache/caches',
displayName: 'HPC cache',
supportsLogs: true,
},
{
resourceType: 'microsoft.logic/integrationserviceenvironments',
displayName: 'Integration Service Environment',
supportsLogs: true,
},
{
resourceType: 'microsoft.iotcentral/iotapps',
displayName: 'IoT Central Application',
supportsLogs: true,
},
{
resourceType: 'microsoft.devices/iothubs',
displayName: 'IoT Hub',
supportsLogs: true,
},
{
resourceType: 'microsoft.keyvault/vaults',
displayName: 'Key vault',
supportsLogs: true,
},
{
resourceType: 'microsoft.kubernetes/connectedclusters',
displayName: 'Kubernetes - Azure Arc',
supportsLogs: true,
},
{
resourceType: 'microsoft.containerservice/managedclusters',
displayName: 'Kubernetes service',
supportsLogs: true,
},
{
resourceType: 'microsoft.media/mediaservices/liveevents',
displayName: 'Live event',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/loadbalancers',
displayName: 'Load balancer',
supportsLogs: true,
},
{
resourceType: 'microsoft.operationalinsights/workspaces',
displayName: 'Log Analytics workspace',
supportsLogs: true,
},
{
resourceType: 'microsoft.logic/workflows',
displayName: 'Logic app',
supportsLogs: true,
},
{
resourceType: 'microsoft.machinelearningservices/workspaces',
displayName: 'Machine learning',
supportsLogs: true,
},
{
resourceType: 'microsoft.media/mediaservices',
displayName: 'Media service',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/natgateways',
displayName: 'NAT gateway',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/networkinterfaces',
displayName: 'Network interface',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/networkvirtualappliances',
displayName: 'Network Virtual Appliances',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/networkwatchers',
displayName: 'Network Watcher',
supportsLogs: true,
},
{
resourceType: 'microsoft.notificationhubs/namespaces/notificationhubs',
displayName: 'Notification Hub',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/p2svpngateways',
displayName: 'P2S VPN Gateways',
supportsLogs: true,
},
{
resourceType: 'microsoft.peering/peeringservices',
displayName: 'Peering Service',
supportsLogs: true,
},
{
resourceType: 'microsoft.powerbidedicated/capacities',
displayName: 'Power BI Embedded',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/privateendpoints',
displayName: 'Private endpoint',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/privatelinkservices',
displayName: 'Private link service',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/publicipaddresses',
displayName: 'Public IP address',
supportsLogs: true,
},
{
resourceType: 'microsoft.cache/redisenterprise',
displayName: 'Redis Enterprise',
supportsLogs: true,
},
{
resourceType: 'microsoft.relay/namespaces',
displayName: 'Relay',
supportsLogs: true,
},
{
resourceType: 'microsoft.synapse/workspaces/scopepools',
displayName: 'Scope pool',
supportsLogs: true,
},
{
resourceType: 'microsoft.search/searchservices',
displayName: 'Search service',
supportsLogs: true,
},
{
resourceType: 'microsoft.servicebus/namespaces',
displayName: 'Service Bus Namespace',
supportsLogs: true,
},
{
resourceType: 'microsoft.signalrservice/signalr',
displayName: 'SignalR',
supportsLogs: true,
},
{
resourceType: 'microsoft.operationsmanagement/solutions',
displayName: 'Solution',
supportsLogs: true,
},
{
resourceType: 'microsoft.sql/servers/databases',
displayName: 'SQL database',
supportsLogs: true,
},
{
resourceType: 'microsoft.sql/servers/elasticpools',
displayName: 'SQL elastic pool',
supportsLogs: true,
},
{
resourceType: 'microsoft.sql/managedinstances',
displayName: 'SQL managed instance',
supportsLogs: true,
},
{
resourceType: 'microsoft.storage/storageaccounts',
displayName: 'Storage account',
supportsLogs: true,
},
{
resourceType: 'microsoft.classicstorage/storageaccounts',
displayName: 'Storage account (classic)',
supportsLogs: true,
},
{
resourceType: 'microsoft.storagesync/storagesyncservices',
displayName: 'Storage Sync Service',
supportsLogs: true,
},
{
resourceType: 'microsoft.streamanalytics/streamingjobs',
displayName: 'Stream Analytics job',
supportsLogs: true,
},
{
resourceType: 'microsoft.media/mediaservices/streamingendpoints',
displayName: 'Streaming Endpoint',
supportsLogs: true,
},
{
resourceType: 'microsoft.timeseriesinsights/environments',
displayName: 'Time Series Insights environment',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/trafficmanagerprofiles',
displayName: 'Traffic Manager profile',
supportsLogs: true,
},
{
resourceType: 'microsoft.compute/virtualmachinescalesets',
displayName: 'Virtual machine scale set',
supportsLogs: true,
},
{
resourceType: 'microsoft.compute/virtualmachines',
displayName: 'Virtual machine',
supportsLogs: true,
},
{
resourceType: 'microsoft.classiccompute/virtualmachines',
displayName: 'Virtual machine (classic)',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/virtualnetworkgateways',
displayName: 'Virtual network gateway',
supportsLogs: true,
},
{
resourceType: 'microsoft.netapp/netappaccounts/capacitypools/volumes',
displayName: 'Volume',
supportsLogs: true,
},
{
resourceType: 'microsoft.network/vpngateways',
displayName: 'VPN Gateways',
supportsLogs: true,
},
{
resourceType: 'microsoft.cdn/cdnwebapplicationfirewallpolicies',
displayName: 'Content Delivery Network WAF policy',
supportsLogs: true,
},
{
resourceType: 'microsoft.web/hostingenvironments/workerpools',
displayName: 'WorkerPools',
supportsLogs: true,
},
];
export const logsSupportedResourceTypesKusto = resourceTypeMetadata
.filter((v) => v.supportsLogs)
.map((v) => `"${v.resourceType}"`)
.join(',');
// Object, keyed by resourceType ID
export const resourceTypeDisplayNames: Record<string, string> = resourceTypeMetadata.reduce(
(acc, resourceType) => ({
...acc,
[resourceType.resourceType]: resourceType.displayName,
}),
{}
);

View File

@ -185,7 +185,7 @@ describe('AzureMonitorDatasource', () => {
it('should return a list of namespaces', async () => {
const results = await ctx.ds.metricFindQuery('Namespaces(nodesapp)');
expect(results.length).toEqual(1);
expect(results[0].text).toEqual('Microsoft.Network/networkInterfaces');
expect(results[0].text).toEqual('Network interface');
expect(results[0].value).toEqual('Microsoft.Network/networkInterfaces');
});
});
@ -216,7 +216,7 @@ describe('AzureMonitorDatasource', () => {
it('should return a list of namespaces', async () => {
const results = await ctx.ds.metricFindQuery('namespaces(11112222-eeee-4949-9b2d-9106972f9123, nodesapp)');
expect(results.length).toEqual(1);
expect(results[0].text).toEqual('Microsoft.Network/networkInterfaces');
expect(results[0].text).toEqual('Network interface');
expect(results[0].value).toEqual('Microsoft.Network/networkInterfaces');
});
});
@ -596,11 +596,11 @@ describe('AzureMonitorDatasource', () => {
.getMetricDefinitions('9935389e-9122-4ef9-95f9-1513dd24753f', 'nodesapp')
.then((results: Array<{ text: string; value: string }>) => {
expect(results.length).toEqual(7);
expect(results[0].text).toEqual('Microsoft.Network/networkInterfaces');
expect(results[0].text).toEqual('Network interface');
expect(results[0].value).toEqual('Microsoft.Network/networkInterfaces');
expect(results[1].text).toEqual('Microsoft.Compute/virtualMachines');
expect(results[1].text).toEqual('Virtual machine');
expect(results[1].value).toEqual('Microsoft.Compute/virtualMachines');
expect(results[2].text).toEqual('Microsoft.Storage/storageAccounts');
expect(results[2].text).toEqual('Storage account');
expect(results[2].value).toEqual('Microsoft.Storage/storageAccounts');
expect(results[3].text).toEqual('Microsoft.Storage/storageAccounts/blobServices');
expect(results[3].value).toEqual('Microsoft.Storage/storageAccounts/blobServices');

View File

@ -28,6 +28,7 @@ import { mergeMap } from 'rxjs/operators';
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
import { getAuthType, getAzureCloud } from '../credentials';
import { getManagementApiRoute } from '../api/routes';
import { resourceTypeDisplayNames } from '../azureMetadata';
const defaultDropdownValue = 'select';
@ -392,7 +393,10 @@ export default class AzureMonitorDatasource extends DataSourceWithBackend<AzureM
});
}
return result;
return result.map((v) => ({
value: v.value,
text: resourceTypeDisplayNames[v.value.toLowerCase()] || v.value,
}));
});
}

View File

@ -5,7 +5,7 @@ import { AzureMonitorQuery, AzureMonitorOption, AzureMonitorErrorish } from '../
import { useMetricsMetadata } from '../metrics';
import SubscriptionField from '../SubscriptionField';
import MetricNamespaceField from './MetricNamespaceField';
import NamespaceField from './NamespaceField';
import ResourceTypeField from './ResourceTypeField';
import ResourceGroupsField from './ResourceGroupsField';
import ResourceNameField from './ResourceNameField';
import MetricNameField from './MetricNameField';
@ -58,7 +58,7 @@ const MetricsQueryEditor: React.FC<MetricsQueryEditorProps> = ({
</InlineFieldRow>
<InlineFieldRow>
<NamespaceField
<ResourceTypeField
query={query}
datasource={datasource}
subscriptionId={subscriptionId}

View File

@ -6,7 +6,7 @@ import { Field } from '../Field';
import { findOption, toOption } from '../../utils/common';
import { AzureQueryEditorFieldProps, AzureMonitorOption } from '../../types';
const ERROR_SOURCE = 'metrics-namespace';
const ERROR_SOURCE = 'resource-type';
const NamespaceField: React.FC<AzureQueryEditorFieldProps> = ({
query,
datasource,
@ -57,10 +57,10 @@ const NamespaceField: React.FC<AzureQueryEditorFieldProps> = ({
const options = useMemo(() => [...namespaces, variableOptionGroup], [namespaces, variableOptionGroup]);
return (
<Field label="Namespace">
{/* It's expected that the label reads Namespace but the property is metricDefinition */}
<Field label="Resource type">
{/* It's expected that the label reads Resource type but the property is metricDefinition */}
<Select
inputId="azure-monitor-metrics-namespace-field"
inputId="azure-monitor-metrics-resource-type-field"
value={findOption(namespaces, query.azureMonitor.metricDefinition)}
onChange={handleChange}
options={options}

View File

@ -0,0 +1,65 @@
export const LOCATION_DISPLAY_NAMES = {
eastus: 'East US',
eastus2: 'East US 2',
southcentralus: 'South Central US',
westus2: 'West US 2',
westus3: 'West US 3',
australiaeast: 'Australia East',
southeastasia: 'Southeast Asia',
northeurope: 'North Europe',
uksouth: 'UK South',
westeurope: 'West Europe',
centralus: 'Central US',
northcentralus: 'North Central US',
westus: 'West US',
southafricanorth: 'South Africa North',
centralindia: 'Central India',
eastasia: 'East Asia',
japaneast: 'Japan East',
jioindiawest: 'Jio India West',
koreacentral: 'Korea Central',
canadacentral: 'Canada Central',
francecentral: 'France Central',
germanywestcentral: 'Germany West Central',
norwayeast: 'Norway East',
switzerlandnorth: 'Switzerland North',
uaenorth: 'UAE North',
brazilsouth: 'Brazil South',
centralusstage: 'Central US (Stage)',
eastusstage: 'East US (Stage)',
eastus2stage: 'East US 2 (Stage)',
northcentralusstage: 'North Central US (Stage)',
southcentralusstage: 'South Central US (Stage)',
westusstage: 'West US (Stage)',
westus2stage: 'West US 2 (Stage)',
asia: 'Asia',
asiapacific: 'Asia Pacific',
australia: 'Australia',
brazil: 'Brazil',
canada: 'Canada',
europe: 'Europe',
global: 'Global',
india: 'India',
japan: 'Japan',
uk: 'United Kingdom',
unitedstates: 'United States',
eastasiastage: 'East Asia (Stage)',
southeastasiastage: 'Southeast Asia (Stage)',
westcentralus: 'West Central US',
southafricawest: 'South Africa West',
australiacentral: 'Australia Central',
australiacentral2: 'Australia Central 2',
australiasoutheast: 'Australia Southeast',
japanwest: 'Japan West',
koreasouth: 'Korea South',
southindia: 'South India',
westindia: 'West India',
canadaeast: 'Canada East',
francesouth: 'France South',
germanynorth: 'Germany North',
norwaywest: 'Norway West',
switzerlandwest: 'Switzerland West',
ukwest: 'UK West',
uaecentral: 'UAE Central',
brazilsoutheast: 'Brazil Southeast',
};

View File

@ -0,0 +1,112 @@
export const RESOURCE_TYPE_NAMES: Record<string, string> = {
'microsoft.analysisservices/servers': 'Analysis Services',
'microsoft.synapse/workspaces/bigdatapools': 'Apache Spark pools',
'microsoft.apimanagement/service': 'API Management services',
'microsoft.appconfiguration/configurationstores': 'App Configuration',
'microsoft.web/sites/slots': 'App Service (Slots)',
'microsoft.web/hostingenvironments': 'App Service Environments',
'microsoft.web/serverfarms': 'App Service plans',
'microsoft.web/sites': 'App Services',
'microsoft.network/applicationgateways': 'Application gateways',
'microsoft.insights/components': 'Application Insights',
'microsoft.automation/automationaccounts': 'Automation Accounts',
'microsoft.insights/autoscalesettings': 'Autoscale Settings',
'microsoft.aadiam/azureadmetrics': 'Azure AD Metrics',
'microsoft.cache/redis': 'Azure Cache for Redis',
'microsoft.documentdb/databaseaccounts': 'Azure Cosmos DB accounts',
'microsoft.kusto/clusters': 'Azure Data Explorer Clusters',
'microsoft.dbformariadb/servers': 'Azure Database for MariaDB servers',
'microsoft.dbformysql/servers': 'Azure Database for MySQL servers',
'microsoft.dbforpostgresql/flexibleservers': 'Azure Database for PostgreSQL flexible servers',
'microsoft.dbforpostgresql/servergroupsv2': 'Azure Database for PostgreSQL server groups',
'microsoft.dbforpostgresql/servers': 'Azure Database for PostgreSQL servers',
'microsoft.dbforpostgresql/serversv2': 'Azure Database for PostgreSQL servers v2',
'microsoft.resources/subscriptions': 'Azure Resource Manager',
'microsoft.appplatform/spring': 'Azure Spring Cloud',
'microsoft.databoxedge/databoxedgedevices': 'Azure Stack Edge / Data Box Gateway',
'microsoft.azurestackresourcemonitor/storageaccountmonitor': 'Azure Stack Resource Monitor',
'microsoft.synapse/workspaces': 'Azure Synapse Analytics',
'microsoft.network/bastionhosts': 'Bastions',
'microsoft.batch/batchaccounts': 'Batch accounts',
'microsoft.botservice/botservices': 'Bot Services',
'microsoft.netapp/netappaccounts/capacitypools': 'Capacity pools',
'microsoft.classiccompute/domainnames': 'Cloud services (classic)',
'microsoft.vmwarecloudsimple/virtualmachines': 'CloudSimple Virtual Machines',
'microsoft.cognitiveservices/accounts': 'Cognitive Services',
'microsoft.network/networkwatchers/connectionmonitors': 'Connection Monitors',
'microsoft.network/connections': 'Connections',
'microsoft.containerinstance/containergroups': 'Container instances',
'microsoft.containerregistry/registries': 'Container registries',
'microsoft.insights/qos': 'Custom Metric Usage',
'microsoft.customerinsights/hubs': 'CustomerInsights',
'microsoft.datafactory/datafactories': 'Data factories',
'microsoft.datafactory/factories': 'Data factories (V2)',
'microsoft.datalakeanalytics/accounts': 'Data Lake Analytics',
'microsoft.datalakestore/accounts': 'Data Lake Storage Gen1',
'microsoft.datashare/accounts': 'Data Shares',
'microsoft.synapse/workspaces/sqlpools': 'Dedicated SQL pools',
'microsoft.devices/provisioningservices': 'Device Provisioning Services',
'microsoft.compute/disks': 'Disks',
'microsoft.network/dnszones': 'DNS zones',
'microsoft.eventgrid/domains': 'Event Grid Domains',
'microsoft.eventgrid/systemtopics': 'Event Grid System Topics',
'microsoft.eventgrid/topics': 'Event Grid Topics',
'microsoft.eventhub/clusters': 'Event Hubs Clusters',
'microsoft.eventhub/namespaces': 'Event Hubs Namespaces',
'microsoft.network/expressroutecircuits': 'ExpressRoute circuits',
'microsoft.network/expressrouteports': 'ExpressRoute Direct',
'microsoft.network/expressroutegateways': 'ExpressRoute Gateways',
'microsoft.fabric.admin/fabriclocations': 'Fabric Locations',
'microsoft.network/azurefirewalls': 'Firewalls',
'microsoft.network/frontdoors': 'Front Doors',
'microsoft.hdinsight/clusters': 'HDInsight clusters',
'microsoft.storagecache/caches': 'HPC caches',
'microsoft.logic/integrationserviceenvironments': 'Integration Service Environments',
'microsoft.iotcentral/iotapps': 'IoT Central Applications',
'microsoft.devices/iothubs': 'IoT Hub',
'microsoft.keyvault/vaults': 'Key vaults',
'microsoft.kubernetes/connectedclusters': 'Kubernetes - Azure Arc',
'microsoft.containerservice/managedclusters': 'Kubernetes services',
'microsoft.media/mediaservices/liveevents': 'Live events',
'microsoft.network/loadbalancers': 'Load balancers',
'microsoft.operationalinsights/workspaces': 'Log Analytics workspaces',
'microsoft.logic/workflows': 'Logic apps',
'microsoft.machinelearningservices/workspaces': 'Machine learning',
'microsoft.media/mediaservices': 'Media Services',
'microsoft.network/natgateways': 'NAT gateways',
'microsoft.network/networkinterfaces': 'Network interfaces',
'microsoft.network/networkvirtualappliances': 'Network Virtual Appliances',
'microsoft.network/networkwatchers': 'Network Watchers',
'microsoft.notificationhubs/namespaces/notificationhubs': 'Notification Hubs',
'microsoft.network/p2svpngateways': 'P2S VPN Gateways',
'microsoft.peering/peeringservices': 'Peering Services',
'microsoft.powerbidedicated/capacities': 'Power BI Embedded',
'microsoft.network/privateendpoints': 'Private endpoints',
'microsoft.network/privatelinkservices': 'Private link services',
'microsoft.network/publicipaddresses': 'Public IP addresses',
'microsoft.cache/redisenterprise': 'Redis Enterprise',
'microsoft.relay/namespaces': 'Relays',
'microsoft.synapse/workspaces/scopepools': 'Scope pools',
'microsoft.search/searchservices': 'Search services',
'microsoft.servicebus/namespaces': 'Service Bus Namespaces',
'microsoft.signalrservice/signalr': 'SignalR',
'microsoft.operationsmanagement/solutions': 'Solutions',
'microsoft.sql/servers/databases': 'SQL databases',
'microsoft.sql/servers/elasticpools': 'SQL elastic pools',
'microsoft.sql/managedinstances': 'SQL managed instances',
'microsoft.storage/storageaccounts': 'Storage accounts',
'microsoft.classicstorage/storageaccounts': 'Storage accounts (classic)',
'microsoft.storagesync/storagesyncservices': 'Storage Sync Services',
'microsoft.streamanalytics/streamingjobs': 'Stream Analytics jobs',
'microsoft.media/mediaservices/streamingendpoints': 'Streaming Endpoints',
'microsoft.timeseriesinsights/environments': 'Time Series Insights environments',
'microsoft.network/trafficmanagerprofiles': 'Traffic Manager profiles',
'microsoft.compute/virtualmachinescalesets': 'Virtual machine scale sets',
'microsoft.compute/virtualmachines': 'Virtual machines',
'microsoft.classiccompute/virtualmachines': 'Virtual machines (classic)',
'microsoft.network/virtualnetworkgateways': 'Virtual network gateways',
'microsoft.netapp/netappaccounts/capacitypools/volumes': 'Volumes',
'microsoft.network/vpngateways': 'VPN Gateways',
'microsoft.cdn/cdnwebapplicationfirewallpolicies': 'Web application firewall policies (WAF)',
'microsoft.web/hostingenvironments/workerpools': 'WorkerPools',
};

View File

@ -1,5 +1,11 @@
import { FetchResponse, getBackendSrv } from '@grafana/runtime';
import { getLogAnalyticsResourcePickerApiRoute } from '../api/routes';
import {
locationDisplayNames,
logsSupportedLocationsKusto,
logsSupportedResourceTypesKusto,
resourceTypeDisplayNames,
} from '../azureMetadata';
import { ResourceRowType, ResourceRow, ResourceRowGroup } from '../components/ResourcePicker/types';
import { parseResourceURI } from '../components/ResourcePicker/utils';
import { getAzureCloud } from '../credentials';
@ -10,7 +16,6 @@ import {
RawAzureResourceGroupItem,
RawAzureResourceItem,
} from '../types';
import { SUPPORTED_LOCATIONS, SUPPORTED_RESOURCE_TYPES } from './supportedResources';
const RESOURCE_GRAPH_URL = '/providers/Microsoft.ResourceGraph/resources?api-version=2020-04-01-preview';
@ -42,7 +47,7 @@ export default class ResourcePickerData {
| project resourceGroupURI=id, resourceGroupName=name, resourceGroup
) on resourceGroup
| where type in (${SUPPORTED_RESOURCE_TYPES})
| where type in (${logsSupportedResourceTypesKusto})
// Get only unique resource groups and subscriptions. Also acts like a project
| summarize count() by resourceGroupName, resourceGroupURI, subscriptionName, subscriptionURI
@ -63,7 +68,7 @@ export default class ResourcePickerData {
const { ok, data: response } = await this.makeResourceGraphRequest<RawAzureResourceItem[]>(`
resources
| where id hasprefix "${resourceGroup.id}"
| where type in (${SUPPORTED_RESOURCE_TYPES}) and location in (${SUPPORTED_LOCATIONS})
| where type in (${logsSupportedResourceTypesKusto}) and location in (${logsSupportedLocationsKusto})
`);
// TODO: figure out desired error handling strategy
@ -222,7 +227,7 @@ function formatResourceGroupChildren(rawData: RawAzureResourceItem[]): ResourceR
id: item.id,
resourceGroupName: item.resourceGroup,
type: ResourceRowType.Resource,
typeLabel: item.type, // TODO: these types can be quite long, we may wish to format them more
location: item.location, // TODO: we may wish to format these locations, by default they are written as 'northeurope' rather than a more human readable "North Europe"
typeLabel: resourceTypeDisplayNames[item.type] || item.type,
location: locationDisplayNames[item.location] || item.location,
}));
}

View File

@ -1,183 +0,0 @@
// TODO: should this list be different for logs vs metrics?
export const SUPPORTED_RESOURCE_TYPES = [
'microsoft.analysisservices/servers',
'microsoft.apimanagement/service',
'microsoft.network/applicationgateways',
'microsoft.insights/components',
'microsoft.web/hostingenvironments',
'microsoft.web/serverfarms',
'microsoft.web/sites',
'microsoft.automation/automationaccounts',
'microsoft.botservice/botservices',
'microsoft.appplatform/spring',
'microsoft.network/bastionhosts',
'microsoft.batch/batchaccounts',
'microsoft.cdn/cdnwebapplicationfirewallpolicies',
'microsoft.classiccompute/domainnames',
'microsoft.classiccompute/virtualmachines',
'microsoft.vmwarecloudsimple/virtualmachines',
'microsoft.cognitiveservices/accounts',
'microsoft.appconfiguration/configurationstores',
'microsoft.network/connections',
'microsoft.containerinstance/containergroups',
'microsoft.containerregistry/registries',
'microsoft.containerservice/managedclusters',
'microsoft.documentdb/databaseaccounts',
'microsoft.databoxedge/databoxedgedevices',
'microsoft.datafactory/datafactories',
'microsoft.datafactory/factories',
'microsoft.datalakeanalytics/accounts',
'microsoft.datalakestore/accounts',
'microsoft.datashare/accounts',
'microsoft.dbformysql/servers',
'microsoft.devices/provisioningservices',
'microsoft.compute/disks',
'microsoft.network/dnszones',
'microsoft.eventgrid/domains',
'microsoft.eventgrid/topics',
'microsoft.eventgrid/systemtopics',
'microsoft.eventhub/namespaces',
'microsoft.eventhub/clusters',
'microsoft.network/expressroutecircuits',
'microsoft.network/expressrouteports',
'microsoft.network/azurefirewalls',
'microsoft.network/frontdoors',
'microsoft.hdinsight/clusters',
'microsoft.iotcentral/iotapps',
'microsoft.devices/iothubs',
'microsoft.keyvault/vaults',
'microsoft.kubernetes/connectedclusters',
'microsoft.kusto/clusters',
'microsoft.network/loadbalancers',
'microsoft.operationalinsights/workspaces',
'microsoft.logic/workflows',
'microsoft.logic/integrationserviceenvironments',
'microsoft.machinelearningservices/workspaces',
'microsoft.dbformariadb/servers',
'microsoft.media/mediaservices',
'microsoft.media/mediaservices/streamingendpoints',
'microsoft.network/natgateways',
'microsoft.netapp/netappaccounts/capacitypools',
'microsoft.netapp/netappaccounts/capacitypools/volumes',
'microsoft.network/networkinterfaces',
'microsoft.notificationhubs/namespaces/notificationhubs',
'microsoft.peering/peeringservices',
'microsoft.dbforpostgresql/servers',
'microsoft.dbforpostgresql/serversv2',
'microsoft.powerbidedicated/capacities',
'microsoft.network/privateendpoints',
'microsoft.network/privatelinkservices',
'microsoft.network/publicipaddresses',
'microsoft.cache/redis',
'microsoft.cache/redisenterprise',
'microsoft.relay/namespaces',
'microsoft.search/searchservices',
'microsoft.dbforpostgresql/servergroupsv2',
'microsoft.servicebus/namespaces',
'microsoft.signalrservice/signalr',
'microsoft.operationsmanagement/solutions',
'microsoft.sql/managedinstances',
'microsoft.sql/servers/databases',
'microsoft.sql/servers/elasticpools',
'microsoft.storage/storageaccounts',
'microsoft.storagecache/caches',
'microsoft.classicstorage/storageaccounts',
'microsoft.storagesync/storagesyncservices',
'microsoft.streamanalytics/streamingjobs',
'microsoft.synapse/workspaces',
'microsoft.synapse/workspaces/bigdatapools',
'microsoft.synapse/workspaces/scopepools',
'microsoft.synapse/workspaces/sqlpools',
'microsoft.timeseriesinsights/environments',
'microsoft.network/trafficmanagerprofiles',
'microsoft.compute/virtualmachines',
'microsoft.compute/virtualmachinescalesets',
'microsoft.network/virtualnetworkgateways',
'microsoft.web/sites/slots',
'microsoft.resources/subscriptions',
'microsoft.insights/autoscalesettings',
'microsoft.aadiam/azureadmetrics',
'microsoft.azurestackresourcemonitor/storageaccountmonitor',
'microsoft.network/networkwatchers/connectionmonitors',
'microsoft.customerinsights/hubs',
'microsoft.insights/qos',
'microsoft.network/expressroutegateways',
'microsoft.fabric.admin/fabriclocations',
'microsoft.network/networkvirtualappliances',
'microsoft.media/mediaservices/liveevents',
'microsoft.network/networkwatchers',
'microsoft.network/p2svpngateways',
'microsoft.dbforpostgresql/flexibleservers',
'microsoft.network/vpngateways',
'microsoft.web/hostingenvironments/workerpools',
]
.map((type) => `"${type}"`)
.join(',');
export const SUPPORTED_LOCATIONS = [
'eastus',
'eastus2',
'southcentralus',
'westus2',
'westus3',
'australiaeast',
'southeastasia',
'northeurope',
'uksouth',
'westeurope',
'centralus',
'northcentralus',
'westus',
'southafricanorth',
'centralindia',
'eastasia',
'japaneast',
'jioindiawest',
'koreacentral',
'canadacentral',
'francecentral',
'germanywestcentral',
'norwayeast',
'switzerlandnorth',
'uaenorth',
'brazilsouth',
'centralusstage',
'eastusstage',
'eastus2stage',
'northcentralusstage',
'southcentralusstage',
'westusstage',
'westus2stage',
'asia',
'asiapacific',
'australia',
'brazil',
'canada',
'europe',
'global',
'india',
'japan',
'uk',
'unitedstates',
'eastasiastage',
'southeastasiastage',
'westcentralus',
'southafricawest',
'australiacentral',
'australiacentral2',
'australiasoutheast',
'japanwest',
'koreasouth',
'southindia',
'westindia',
'canadaeast',
'francesouth',
'germanynorth',
'norwaywest',
'switzerlandwest',
'ukwest',
'uaecentral',
'brazilsoutheast',
]
.map((type) => `"${type}"`)
.join(',');