From f38a03b47fdb2c2e72da729533fc2b36141bb358 Mon Sep 17 00:00:00 2001 From: Tom Kerkhove Date: Mon, 1 Jun 2020 09:28:31 +0200 Subject: [PATCH 1/5] Add resource name in job name --- .../Extensions/IServiceCollectionExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs b/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs index 0d523e05e..6542edf83 100644 --- a/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs +++ b/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs @@ -61,7 +61,7 @@ public static IServiceCollection ScheduleMetricScraping(this IServiceCollection var azureMonitorClient = azureMonitorClientFactory.CreateIfNotExists(metrics.AzureMetadata.Cloud, metrics.AzureMetadata.TenantId, resourceSubscriptionId, metricSinkWriter, runtimeMetricCollector, configuration, azureMonitorLoggingConfiguration, loggerFactory); var scrapeDefinition = metric.CreateScrapeDefinition(resource, metrics.AzureMetadata); - var jobName = $"{scrapeDefinition.SubscriptionId}-{scrapeDefinition.PrometheusMetricDefinition.Name}"; + var jobName = $"{scrapeDefinition.SubscriptionId}-{scrapeDefinition.PrometheusMetricDefinition.Name}-{resource.GetResourceName()}"; services.AddScheduler(builder => { From 783e35f8eaa1f7cf86693dd1af0a11747e731ccc Mon Sep 17 00:00:00 2001 From: Tom Kerkhove Date: Mon, 1 Jun 2020 09:28:58 +0200 Subject: [PATCH 2/5] Use namespace for resource name --- .../Metrics/ResourceTypes/ServiceBusQueueResourceDefinition.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ServiceBusQueueResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ServiceBusQueueResourceDefinition.cs index 83230d601..892257e75 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ServiceBusQueueResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ServiceBusQueueResourceDefinition.cs @@ -13,6 +13,6 @@ public ServiceBusQueueResourceDefinition(string subscriptionId, string resourceG public string QueueName { get; } /// - public override string GetResourceName() => QueueName; + public override string GetResourceName() => Namespace; } } \ No newline at end of file From 4be2172be72bd54a9acb494299d4c2cc17651846 Mon Sep 17 00:00:00 2001 From: Tom Kerkhove Date: Mon, 1 Jun 2020 10:51:32 +0200 Subject: [PATCH 3/5] Ensure jobs have unique names --- .../Extensions/IServiceCollectionExtensions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs b/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs index 6542edf83..84592e56d 100644 --- a/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs +++ b/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Threading.Tasks; using JustEat.StatsD; using Microsoft.Extensions.Configuration; @@ -60,8 +61,7 @@ public static IServiceCollection ScheduleMetricScraping(this IServiceCollection var resourceSubscriptionId = string.IsNullOrWhiteSpace(resource.SubscriptionId) ? metrics.AzureMetadata.SubscriptionId : resource.SubscriptionId; var azureMonitorClient = azureMonitorClientFactory.CreateIfNotExists(metrics.AzureMetadata.Cloud, metrics.AzureMetadata.TenantId, resourceSubscriptionId, metricSinkWriter, runtimeMetricCollector, configuration, azureMonitorLoggingConfiguration, loggerFactory); var scrapeDefinition = metric.CreateScrapeDefinition(resource, metrics.AzureMetadata); - - var jobName = $"{scrapeDefinition.SubscriptionId}-{scrapeDefinition.PrometheusMetricDefinition.Name}-{resource.GetResourceName()}"; + var jobName = $"{scrapeDefinition.SubscriptionId}-{scrapeDefinition.ResourceGroupName}-{scrapeDefinition.PrometheusMetricDefinition.Name}-{resource.GetResourceName()}-{Guid.NewGuid()}"; services.AddScheduler(builder => { From ca228a712cde7cb3f6edb6ff86a5019f75838e67 Mon Sep 17 00:00:00 2001 From: Tom Kerkhove Date: Mon, 1 Jun 2020 10:52:17 +0200 Subject: [PATCH 4/5] Use configured defaults --- .../PrometheusScrapingEndpointMetricSink.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Promitor.Integrations.Sinks.Prometheus/PrometheusScrapingEndpointMetricSink.cs b/src/Promitor.Integrations.Sinks.Prometheus/PrometheusScrapingEndpointMetricSink.cs index dd24bb6cf..9bdad6259 100644 --- a/src/Promitor.Integrations.Sinks.Prometheus/PrometheusScrapingEndpointMetricSink.cs +++ b/src/Promitor.Integrations.Sinks.Prometheus/PrometheusScrapingEndpointMetricSink.cs @@ -42,7 +42,7 @@ public async Task ReportMetricAsync(string metricName, string metricDescription, foreach (var measuredMetric in scrapeResult.MetricValues) { - var metricValue = measuredMetric.Value ?? 0; + var metricValue = DetermineMetricMeasurement(measuredMetric); var metricDefinition = _metricsDeclarationProvider.GetPrometheusDefinition(metricName); var metricLabels = DetermineLabels(metricDefinition, scrapeResult, measuredMetric); @@ -54,6 +54,12 @@ public async Task ReportMetricAsync(string metricName, string metricDescription, await Task.WhenAll(reportMetricTasks); } + private double DetermineMetricMeasurement(MeasuredMetric scrapedMetricResult) + { + var metricUnavailableValue = _prometheusConfiguration.CurrentValue?.MetricUnavailableValue ?? Defaults.Prometheus.MetricUnavailableValue; + return scrapedMetricResult.Value ?? metricUnavailableValue; + } + public Task ReportMetricAsync(string metricName, string metricDescription, double metricValue, Dictionary labels) { Guard.NotNullOrEmpty(metricName, nameof(metricName)); From 23d27b9c6f948a4125e8808dd164a55bb302c85d Mon Sep 17 00:00:00 2001 From: Tom Kerkhove Date: Mon, 1 Jun 2020 18:14:11 +0200 Subject: [PATCH 5/5] Use unique name for resource Signed-off-by: Tom Kerkhove --- config/promitor/scraper/metrics.yaml | 2 ++ .../IServiceCollectionExtensions.cs | 20 ++++++++++++++++++- .../Model/Metrics/AzureResourceDefinition.cs | 3 +++ .../Model/Metrics/IAzureResourceDefinition.cs | 5 +++++ .../ApiManagementResourceDefinition.cs | 3 +++ .../AppPlanResourceDefinition.cs | 3 +++ .../BlobStorageResourceDefinition.cs | 3 +++ .../ContainerInstanceResourceDefinition.cs | 3 +++ .../ContainerRegistryResourceDefinition.cs | 3 +++ .../CosmosDbResourceDefinition.cs | 3 +++ ...ceProvisioningServiceResourceDefinition.cs | 3 +++ .../FileStorageResourceDefinition.cs | 3 +++ .../FunctionAppResourceDefinition.cs | 3 +++ .../GenericAzureResourceDefinition.cs | 5 ++++- .../ResourceTypes/IoTHubResourceDefinition.cs | 3 +++ .../KeyVaultResourceDefinition.cs | 3 +++ .../NetworkInterfaceResourceDefinition.cs | 3 +++ .../PostgreSqlResourceDefinition.cs | 3 +++ .../RedisCacheResourceDefinition.cs | 3 +++ .../ServiceBusQueueResourceDefinition.cs | 3 +++ .../SqlDatabaseResourceDefinition.cs | 3 +++ .../SqlManagedInstanceResourceDefinition.cs | 3 +++ .../SqlServerResourceDefinition.cs | 3 +++ .../StorageAccountResourceDefinition.cs | 3 +++ .../StorageQueueResourceDefinition.cs | 3 +++ .../VirtualMachineResourceDefinition.cs | 3 +++ ...rtualMachineScaleSetsResourceDefinition.cs | 3 +++ .../ResourceTypes/WebAppResourceDefinition.cs | 3 +++ 28 files changed, 102 insertions(+), 2 deletions(-) diff --git a/config/promitor/scraper/metrics.yaml b/config/promitor/scraper/metrics.yaml index c4a9ad40e..a5a00eca0 100644 --- a/config/promitor/scraper/metrics.yaml +++ b/config/promitor/scraper/metrics.yaml @@ -59,6 +59,8 @@ metrics: resources: - namespace: promitor-messaging queueName: orders + - namespace: promitor-messaging + queueName: sales - namespace: promitor-messaging-other-subscription queueName: orders subscriptionId: 0329dd2a-59dc-4493-aa54-cb01cb027dc2 diff --git a/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs b/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs index 84592e56d..819d86d42 100644 --- a/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs +++ b/src/Promitor.Agents.Scraper/Extensions/IServiceCollectionExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Text; using System.Threading.Tasks; using JustEat.StatsD; using Microsoft.Extensions.Configuration; @@ -23,6 +24,7 @@ using Promitor.Agents.Scraper.Validation; using Promitor.Core.Metrics; using Promitor.Core.Metrics.Sinks; +using Promitor.Core.Scraping.Configuration.Model.Metrics; using Promitor.Core.Scraping.Configuration.Runtime; using Promitor.Core.Scraping.Interfaces; using Promitor.Integrations.AzureMonitor.Configuration; @@ -61,7 +63,7 @@ public static IServiceCollection ScheduleMetricScraping(this IServiceCollection var resourceSubscriptionId = string.IsNullOrWhiteSpace(resource.SubscriptionId) ? metrics.AzureMetadata.SubscriptionId : resource.SubscriptionId; var azureMonitorClient = azureMonitorClientFactory.CreateIfNotExists(metrics.AzureMetadata.Cloud, metrics.AzureMetadata.TenantId, resourceSubscriptionId, metricSinkWriter, runtimeMetricCollector, configuration, azureMonitorLoggingConfiguration, loggerFactory); var scrapeDefinition = metric.CreateScrapeDefinition(resource, metrics.AzureMetadata); - var jobName = $"{scrapeDefinition.SubscriptionId}-{scrapeDefinition.ResourceGroupName}-{scrapeDefinition.PrometheusMetricDefinition.Name}-{resource.GetResourceName()}-{Guid.NewGuid()}"; + var jobName = GenerateJobName(scrapeDefinition, resource); services.AddScheduler(builder => { @@ -87,6 +89,22 @@ public static IServiceCollection ScheduleMetricScraping(this IServiceCollection return services; } + private static string GenerateJobName(ScrapeDefinition scrapeDefinition, IAzureResourceDefinition resource) + { + var jobNameBuilder = new StringBuilder(); + jobNameBuilder.Append(scrapeDefinition.SubscriptionId); + jobNameBuilder.Append("-"); + jobNameBuilder.Append(scrapeDefinition.ResourceGroupName); + jobNameBuilder.Append("-"); + jobNameBuilder.Append(scrapeDefinition.PrometheusMetricDefinition.Name); + jobNameBuilder.Append("-"); + jobNameBuilder.Append(resource.GetUniqueName()); + jobNameBuilder.Append("-"); + jobNameBuilder.Append(Guid.NewGuid().ToString()); + + return jobNameBuilder.ToString(); + } + /// /// Defines the dependencies that Promitor requires /// diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/AzureResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/AzureResourceDefinition.cs index 596f71a62..e7c181d6c 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/AzureResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/AzureResourceDefinition.cs @@ -38,5 +38,8 @@ protected AzureResourceDefinition(ResourceType resourceType, string subscription /// public abstract string GetResourceName(); + + /// + public abstract string GetUniqueName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/IAzureResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/IAzureResourceDefinition.cs index 2c5cecda8..51d3a6783 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/IAzureResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/IAzureResourceDefinition.cs @@ -31,5 +31,10 @@ public interface IAzureResourceDefinition /// For an Azure SQL Database it should be the name of the DB, not the server /// string GetResourceName(); + + /// + /// Gets a unique name for the resource + /// + string GetUniqueName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ApiManagementResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ApiManagementResourceDefinition.cs index d9ff122cf..8c3ae5553 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ApiManagementResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ApiManagementResourceDefinition.cs @@ -29,5 +29,8 @@ public ApiManagementResourceDefinition(string subscriptionId, string resourceGro /// public override string GetResourceName() => InstanceName; + + /// + public override string GetUniqueName() => $"{InstanceName}-{LocationName}"; } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/AppPlanResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/AppPlanResourceDefinition.cs index 013f1434b..f54eb3810 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/AppPlanResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/AppPlanResourceDefinition.cs @@ -15,5 +15,8 @@ public AppPlanResourceDefinition(string subscriptionId, string resourceGroupName /// public override string GetResourceName() => AppPlanName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/BlobStorageResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/BlobStorageResourceDefinition.cs index 4b0130d13..2cebd42ad 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/BlobStorageResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/BlobStorageResourceDefinition.cs @@ -24,5 +24,8 @@ public BlobStorageResourceDefinition(string subscriptionId, string resourceGroup /// public override string GetResourceName() => AccountName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ContainerInstanceResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ContainerInstanceResourceDefinition.cs index 92cb3f6ce..4448b220e 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ContainerInstanceResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ContainerInstanceResourceDefinition.cs @@ -12,5 +12,8 @@ public ContainerInstanceResourceDefinition(string subscriptionId, string resourc /// public override string GetResourceName() => ContainerGroup; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ContainerRegistryResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ContainerRegistryResourceDefinition.cs index 990381fb1..e0ff17c59 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ContainerRegistryResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ContainerRegistryResourceDefinition.cs @@ -12,5 +12,8 @@ public ContainerRegistryResourceDefinition(string subscriptionId, string resourc /// public override string GetResourceName() => RegistryName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/CosmosDbResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/CosmosDbResourceDefinition.cs index f95b5fdf8..e534efcbd 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/CosmosDbResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/CosmosDbResourceDefinition.cs @@ -12,5 +12,8 @@ public CosmosDbResourceDefinition(string subscriptionId, string resourceGroupNam /// public override string GetResourceName() => DbName; + + /// + public override string GetUniqueName() => GetResourceName(); } } diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/DeviceProvisioningServiceResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/DeviceProvisioningServiceResourceDefinition.cs index 0ac7d80d9..a6973214b 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/DeviceProvisioningServiceResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/DeviceProvisioningServiceResourceDefinition.cs @@ -12,5 +12,8 @@ public DeviceProvisioningServiceResourceDefinition(string subscriptionId, string /// public override string GetResourceName() => DeviceProvisioningServiceName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/FileStorageResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/FileStorageResourceDefinition.cs index 4d347fb8d..5c83ad3e2 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/FileStorageResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/FileStorageResourceDefinition.cs @@ -24,5 +24,8 @@ public FileStorageResourceDefinition(string subscriptionId, string resourceGroup /// public override string GetResourceName() => AccountName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/FunctionAppResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/FunctionAppResourceDefinition.cs index 176ae70f7..d0dcd3005 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/FunctionAppResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/FunctionAppResourceDefinition.cs @@ -20,5 +20,8 @@ public FunctionAppResourceDefinition(string subscriptionId, string resourceGroup /// public override string GetResourceName() => FunctionAppName; + + /// + public override string GetUniqueName() => $"{FunctionAppName}-{SlotName}"; } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/GenericAzureResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/GenericAzureResourceDefinition.cs index bcf87127d..3a7eca512 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/GenericAzureResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/GenericAzureResourceDefinition.cs @@ -13,6 +13,9 @@ public GenericAzureResourceDefinition(string subscriptionId, string resourceGrou public string ResourceUri { get; } /// - public override string GetResourceName() => null; + public override string GetResourceName() => ResourceUri; + + /// + public override string GetUniqueName() => $"{ResourceUri}"; } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/IoTHubResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/IoTHubResourceDefinition.cs index c8ed74143..b3747c724 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/IoTHubResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/IoTHubResourceDefinition.cs @@ -12,5 +12,8 @@ public IoTHubResourceDefinition(string subscriptionId, string resourceGroupName, /// public override string GetResourceName() => IoTHubName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/KeyVaultResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/KeyVaultResourceDefinition.cs index aa0289e6e..57116068b 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/KeyVaultResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/KeyVaultResourceDefinition.cs @@ -12,5 +12,8 @@ public KeyVaultResourceDefinition(string subscriptionId, string resourceGroupNam /// public override string GetResourceName() => VaultName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/NetworkInterfaceResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/NetworkInterfaceResourceDefinition.cs index dc9a2b5c8..9491113a0 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/NetworkInterfaceResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/NetworkInterfaceResourceDefinition.cs @@ -12,5 +12,8 @@ public NetworkInterfaceResourceDefinition(string subscriptionId, string resource /// public override string GetResourceName() => NetworkInterfaceName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/PostgreSqlResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/PostgreSqlResourceDefinition.cs index afcaa74f2..a3e3fc488 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/PostgreSqlResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/PostgreSqlResourceDefinition.cs @@ -12,5 +12,8 @@ public PostgreSqlResourceDefinition(string subscriptionId, string resourceGroupN /// public override string GetResourceName() => ServerName; + + /// + public override string GetUniqueName() => GetResourceName(); } } diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/RedisCacheResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/RedisCacheResourceDefinition.cs index 2c4ab93eb..d81c3e53f 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/RedisCacheResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/RedisCacheResourceDefinition.cs @@ -12,5 +12,8 @@ public RedisCacheResourceDefinition(string subscriptionId, string resourceGroupN /// public override string GetResourceName() => CacheName; + + /// + public override string GetUniqueName() => GetResourceName(); } } diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ServiceBusQueueResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ServiceBusQueueResourceDefinition.cs index 892257e75..0c21fd4aa 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ServiceBusQueueResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/ServiceBusQueueResourceDefinition.cs @@ -14,5 +14,8 @@ public ServiceBusQueueResourceDefinition(string subscriptionId, string resourceG /// public override string GetResourceName() => Namespace; + + /// + public override string GetUniqueName() => $"{Namespace}-{QueueName}"; } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlDatabaseResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlDatabaseResourceDefinition.cs index d3e51e29d..746348fea 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlDatabaseResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlDatabaseResourceDefinition.cs @@ -31,5 +31,8 @@ public SqlDatabaseResourceDefinition(string subscriptionId, string resourceGroup /// public override string GetResourceName() => DatabaseName; + + /// + public override string GetUniqueName() => $"{ServerName}-{DatabaseName}"; } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlManagedInstanceResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlManagedInstanceResourceDefinition.cs index 99a011aaf..a14f039fd 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlManagedInstanceResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlManagedInstanceResourceDefinition.cs @@ -24,5 +24,8 @@ public SqlManagedInstanceResourceDefinition(string subscriptionId, string resour /// public override string GetResourceName() => InstanceName; + + /// + public override string GetUniqueName() => GetResourceName(); } } diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlServerResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlServerResourceDefinition.cs index 3738b29cb..ac9f23306 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlServerResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/SqlServerResourceDefinition.cs @@ -24,5 +24,8 @@ public SqlServerResourceDefinition(string subscriptionId, string resourceGroupNa /// public override string GetResourceName() => ServerName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/StorageAccountResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/StorageAccountResourceDefinition.cs index e3c8da3da..59eb369bf 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/StorageAccountResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/StorageAccountResourceDefinition.cs @@ -24,5 +24,8 @@ public StorageAccountResourceDefinition(string subscriptionId, string resourceGr /// public override string GetResourceName() => AccountName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/StorageQueueResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/StorageQueueResourceDefinition.cs index da2ca0b4a..83ef0d871 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/StorageQueueResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/StorageQueueResourceDefinition.cs @@ -16,5 +16,8 @@ public StorageQueueResourceDefinition(string subscriptionId, string resourceGrou /// public override string GetResourceName() => AccountName; + + /// + public override string GetUniqueName() => $"{AccountName}-{QueueName}"; } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/VirtualMachineResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/VirtualMachineResourceDefinition.cs index 2cf45156a..936b91cb2 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/VirtualMachineResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/VirtualMachineResourceDefinition.cs @@ -12,5 +12,8 @@ public VirtualMachineResourceDefinition(string subscriptionId, string resourceGr /// public override string GetResourceName() => VirtualMachineName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/VirtualMachineScaleSetsResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/VirtualMachineScaleSetsResourceDefinition.cs index 563da6276..91e9abca6 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/VirtualMachineScaleSetsResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/VirtualMachineScaleSetsResourceDefinition.cs @@ -12,5 +12,8 @@ public VirtualMachineScaleSetResourceDefinition(string subscriptionId, string re /// public override string GetResourceName() => ScaleSetName; + + /// + public override string GetUniqueName() => GetResourceName(); } } \ No newline at end of file diff --git a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/WebAppResourceDefinition.cs b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/WebAppResourceDefinition.cs index 9fc9cbb0c..9afec41ac 100644 --- a/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/WebAppResourceDefinition.cs +++ b/src/Promitor.Core.Scraping/Configuration/Model/Metrics/ResourceTypes/WebAppResourceDefinition.cs @@ -21,5 +21,8 @@ public WebAppResourceDefinition(string subscriptionId, string resourceGroupName, /// public override string GetResourceName() => WebAppName; + + /// + public override string GetUniqueName() => $"{WebAppName}-{SlotName}"; } } \ No newline at end of file