From 42fa46b1a018f72fcd8351b0f2ce7598f974f742 Mon Sep 17 00:00:00 2001 From: Caleb Metz Date: Tue, 4 Feb 2025 13:33:36 -0500 Subject: [PATCH 1/3] Skip reading counters and gauges with NaN value. Signed-off-by: Caleb Metz --- lading/src/target_metrics/prometheus.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lading/src/target_metrics/prometheus.rs b/lading/src/target_metrics/prometheus.rs index a76b6aa52..cb059afec 100644 --- a/lading/src/target_metrics/prometheus.rs +++ b/lading/src/target_metrics/prometheus.rs @@ -276,6 +276,11 @@ pub(crate) async fn scrape_metrics( } }; + if value.is_nan() { + warn!("Skipping NaN guage value"); + continue; + } + gauge!(format!("target/{name}"), &all_labels.unwrap_or_default()).set(value); } Some(MetricType::Counter) => { @@ -287,6 +292,11 @@ pub(crate) async fn scrape_metrics( } }; + if value.is_nan() { + warn!("Skipping NaN counter value"); + continue; + } + let value = if value < 0.0 { warn!("Negative counter value unhandled"); continue; From 4dff200c5acac16909158172c0a645724d26ac32 Mon Sep 17 00:00:00 2001 From: Caleb Metz Date: Tue, 4 Feb 2025 13:40:28 -0500 Subject: [PATCH 2/3] Spelling Signed-off-by: Caleb Metz --- lading/src/target_metrics/prometheus.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lading/src/target_metrics/prometheus.rs b/lading/src/target_metrics/prometheus.rs index cb059afec..61dd97118 100644 --- a/lading/src/target_metrics/prometheus.rs +++ b/lading/src/target_metrics/prometheus.rs @@ -277,7 +277,7 @@ pub(crate) async fn scrape_metrics( }; if value.is_nan() { - warn!("Skipping NaN guage value"); + warn!("Skipping NaN gauge value"); continue; } From 42c5a6cc0aea33b19d9073745c6b6736206c6460 Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Thu, 6 Feb 2025 17:19:45 +0000 Subject: [PATCH 3/3] Adds changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c3296bf..10d3f2e19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Introduced the ability for users to configure lading's sample rate, configuration option `sample_period_milliseconds` in `lading.yaml`. - Users can now configure expvar scraping on https endpoints, skipping certificate validation. +- Fixes issue when parsing `NaN` values from a prometheus endpoint ## [0.25.4] ## Changed