Skip to content

Commit b7b446f

Browse files
cmetz100scottopell
andauthored
Ignore metrics read over prometheus with NaN value (#1231)
* Skip reading counters and gauges with NaN value. Signed-off-by: Caleb Metz <[email protected]> * Spelling Signed-off-by: Caleb Metz <[email protected]> * Adds changelog entry --------- Signed-off-by: Caleb Metz <[email protected]> Co-authored-by: Scott Opell <[email protected]>
1 parent b06706c commit b7b446f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Introduced the ability for users to configure lading's sample rate,
1313
configuration option `sample_period_milliseconds` in `lading.yaml`.
1414
- Users can now configure expvar scraping on https endpoints, skipping certificate validation.
15+
- Fixes issue when parsing `NaN` values from a prometheus endpoint
1516

1617
## [0.25.4]
1718
## Changed

lading/src/target_metrics/prometheus.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ pub(crate) async fn scrape_metrics(
276276
}
277277
};
278278

279+
if value.is_nan() {
280+
warn!("Skipping NaN gauge value");
281+
continue;
282+
}
283+
279284
gauge!(format!("target/{name}"), &all_labels.unwrap_or_default()).set(value);
280285
}
281286
Some(MetricType::Counter) => {
@@ -287,6 +292,11 @@ pub(crate) async fn scrape_metrics(
287292
}
288293
};
289294

295+
if value.is_nan() {
296+
warn!("Skipping NaN counter value");
297+
continue;
298+
}
299+
290300
let value = if value < 0.0 {
291301
warn!("Negative counter value unhandled");
292302
continue;

0 commit comments

Comments
 (0)