Windows_exporter: duplicate metric in textfile cause scraping to fail completely

Created on 8 Nov 2018  路  3Comments  路  Source: prometheus-community/windows_exporter

WMI-exporter expose absolutely no metrics when a textfile has duplicate metric. e.g the http://localhost:/metrics has single metric, only a message d'error is displayed (see below).

Error message on the /metrics page:

An error has occurred during metrics gathering:
collected metric wmi_zzz_test_duplicate_metric_name label:<name:"name" value:"foo" > untyped:<value:13 >  was collected before with the same name and label values

Expected result :

  • The .prom file with invalid / duplicate entry should be ignored.
  • The usual (WMI) metrics should be avaialble for scrape.
  • The WMI exporter metric wmi_textfile_scrape_error should equal 1
  • The other .prom file in the textfile directory should be published

Step to reproduce:

  • Create a .prom file with duplicate metrics in WMI-exporter's textfile directory.

Exemple invalid .prom file :

wmi_zzz_test_duplicate_metric_name{name="foo"} 1
wmi_zzz_test_duplicate_metric_name{name="foo"} 13
bug collectotextfile

Most helpful comment

Actually no, I think that was a different bug (although with the same symptoms). The textfile collector in wmi_exporter was copied from node_exporter in April this year, when the fix was already merged.

Anyway. I've implemented a fix now which tracks duplicate metrics. I'm doing some benchmarking to ensure this doesn't come with a too large hit to performance or memory usage, but will hopefully open a PR tonight.

All 3 comments

Hi @finkr,
Thanks for reporting! Agree that this isn't great. The enforcement of duplicates is actually done by the Prometheus client library, so handling this better isn't completely straight-forward. We'll need to add some tracking of seen metric/label combinations and then avoid passing the metrics to the client library at all.

Node-exporter had the same issue:

https://github.com/prometheus/node_exporter/pull/738

Actually no, I think that was a different bug (although with the same symptoms). The textfile collector in wmi_exporter was copied from node_exporter in April this year, when the fix was already merged.

Anyway. I've implemented a fix now which tracks duplicate metrics. I'm doing some benchmarking to ensure this doesn't come with a too large hit to performance or memory usage, but will hopefully open a PR tonight.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

carlpett picture carlpett  路  7Comments

wizardmatas picture wizardmatas  路  5Comments

fullenw1 picture fullenw1  路  6Comments

Knuspel picture Knuspel  路  5Comments

jdx-john picture jdx-john  路  4Comments