metrics[*].scraping.schedule is not optional
See original GitHub issueReport
In the docs here, it mentions this:
Additionally, the following fields are optional: …
scraping.schedule- A scraping schedule for the individual metric; overrides the the one specified inmetricDefaults
However I receive various when this field is omitted.
Expected Behavior
If a metric is missing a scraping schedule, the metric default schedule should be used.
Actual Behavior
If the scraping block is omitted entirely from a metric, this error is thrown:
System.ArgumentNullException: [scraping] cannot be Null. (Parameter 'scraping')
at GuardNet.Guard.For[TException](Func`1 predicate, TException exception)
at GuardNet.Guard.NotNull[TParam,TException](TParam param, TException exception)
at GuardNet.Guard.NotNull[TParam](TParam param, String paramName, String message)
at GuardNet.Guard.NotNull[TParam](TParam param, String paramName)
at Promitor.Core.Scraping.Configuration.Model.Metrics.ScrapeDefinition`1..ctor(AzureMetricConfiguration azureMetricConfiguration, PrometheusMetricDefinition prometheusMetricDefinition, Scraping scraping, TResourceDefinition resource, String subscriptionId, String resourceGroupName) in /src/Promitor.Core.Scraping/Model/Metrics/ScrapeDefinition.cs:line 34
at Promitor.Core.Scraping.Configuration.Model.Metrics.MetricDefinition.CreateScrapeDefinition(IAzureResourceDefinition resource, AzureMetadata azureMetadata) in /src/Promitor.Core.Scraping/Model/Metrics/MetricDefinition.cs:line 74
at Microsoft.Extensions.DependencyInjection.SchedulingExtensions.ScheduleResourceScraping(IAzureResourceDefinition resource, AzureMetadata azureMetadata, MetricDefinition metric, AzureMonitorClientFactory azureMonitorClientFactory, MetricSinkWriter metricSinkWriter, IRuntimeMetricsCollector runtimeMetricCollector, IConfiguration configuration, IOptions`1 azureMonitorLoggingConfiguration, ILoggerFactory loggerFactory, ILogger`1 logger, IServiceCollection services) in /src/Promitor.Agents.Scraper/SchedulingExtensions.cs:line 69
at Microsoft.Extensions.DependencyInjection.SchedulingExtensions.ScheduleMetricScraping(IServiceCollection services) in /src/Promitor.Agents.Scraper/SchedulingExtensions.cs:line 34
at Promitor.Agents.Scraper.Startup.ConfigureServices(IServiceCollection services) in /src/Promitor.Agents.Scraper/Startup.cs:line 55
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.<Build>b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass12_0.<UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at Promitor.Agents.Scraper.Program.Main(String[] args) in /src/Promitor.Agents.Scraper/Program.cs:line 35
I’ve not found a way to omit this, instead I’m just duplicating the default to each metric like this:
version: v1
azureMetadata:
tenantId: "tenant"
subscriptionId: "sub"
resourceGroupName: "group"
metricDefaults:
aggregation:
interval: "00:05:00"
scraping:
schedule: "*/1 * * * *" # DUPLICATED
metrics:
# Loadbalancer metrics, for each aggregation and metric combination
- name: "name"
description: "desc"
scraping:
schedule: "*/1 * * * *" # DUPLICATED
resourceType: "Generic"
labels:
a: "b"
azureMetricConfiguration:
metricName: "foo"
aggregation:
type: "Average"
resources:
- resourceGroupName: "group"
resourceUri: "uri"
I’ve tried to set scraping to ~ or {} too.
Steps to Reproduce the Problem
- Use a
metrics-declaration.yamlconfig file. - Omit the
scrapingfield from a metric, e.g.:
version: v1
azureMetadata:
tenantId: "tenant"
subscriptionId: "sub"
resourceGroupName: "group"
metricDefaults:
aggregation:
interval: "00:05:00"
scraping:
schedule: "*/1 * * * *" # DUPLICATED
metrics:
# Loadbalancer metrics, for each aggregation and metric combination
- name: "name"
description: "desc"
#scraping:
# schedule: "*/1 * * * *" # DUPLICATED
resourceType: "Generic"
labels:
a: "b"
azureMetricConfiguration:
metricName: "foo"
aggregation:
type: "Average"
resources:
- resourceGroupName: "group"
resourceUri: "uri"
Component
Scraper
Version
2.3.0
Configuration
Configuration:
# Add your scraping configuration here
Logs
example
Platform
Microsoft Azure
Contact Details
lewis.jackson@resdiary.com
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Metrics interval does not take scraping cron schedule into ...
Currently every time a metric is scraped it will get a list of all measure points with a fixed interval, currently 1 minute....
Read more >How to correctly scrape and query metrics in Prometheus ...
Scraping every hour is not really the philosophy of Prometheus. ... it could be a better idea to schedule a job sending the...
Read more >Reduce Prometheus metrics usage with relabeling
Reduce Prometheus metrics usage with relabeling This guide describes several techniques you can use to reduce your Prometheus metrics usage on Grafana Cloud ......
Read more >Prometheus and OpenMetrics metrics collection from a host
Optional parameter which, if set, transforms the <METRIC_TO_FETCH> metric key to <DATADOG_METRIC_NAME> in Datadog. If you choose not to use this option, pass...
Read more >Troubleshooting Managed Service for Prometheus
If you are using managed collection, you don't see any errors, but data is not appearing in Cloud Monitoring, then the most likely...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Odd because I don’t use it myself: https://github.com/tomkerkhove/promitor/blob/master/config/promitor/scraper/metrics.yaml
I’ll try to reproduce and see what is causing this.
Another case that triggered this: