prometheus / prometheus/client_python
OpenMetrics parser cannot parse the output of `promtool tsdb dump-openmetrics`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 4.4k
- Forks
- 876
- Ø Merge
- 8 T. 4 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
I tried using the example code...
import sys
from prometheus_client.openmetrics.parser import text_string_to_metric_families
for family in text_string_to_metric_families(sys.stdin.read()):
for sample in family.samples:
print("Name: {0} Labels: {1} Value: {2} Timestamp: {3}".format(*sample))
...to parse an OpenMetrics file produced by promtool tsdb dump-openmetrics, but I run into the following issue:
Traceback (most recent call last):
File "/home/nicolas/IE6/synapse-meshsim/exp/./normalise_timestamps.py", line 6, in <module>
for family in text_string_to_metric_families(sys.stdin.read()):
File "/home/nicolas/IE6/synapse-meshsim/exp/venv/lib/python3.11/site-packages/prometheus_client/openmetrics/parser.py", line 18, in text_string_to_metric_families
yield from text_fd_to_metric_families(StringIO.StringIO(text))
File "/home/nicolas/IE6/synapse-meshsim/exp/venv/lib/python3.11/site-packages/prometheus_client/openmetrics/parser.py", line 543, in text_fd_to_metric_families
yield build_metric(name, documentation, typ, unit, samples)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/nicolas/IE6/synapse-meshsim/exp/venv/lib/python3.11/site-packages/prometheus_client/openmetrics/parser.py", line 472, in build_metric
raise ValueError("Clashing name: " + name + suffix)
ValueError: Clashing name: go_gc_duration_seconds
This comes from this code: https://github.com/prometheus/client_python/blob/46eae7bae88f76951f7246d9f359f2dd5eeff110/prometheus_client/openmetrics/parser.py#L487-L489
But I don't understand why this check exists in the first place? In my case, I have the same metrics for multiple instances, and dump-openmetrics groups them by instance, then by metrics name. Can't we just remove this check altogether?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit prometheus_client/openmetrics/parser.py bei der verlinkten build_metric-Prüfung und vergleiche deren Annahmen mit der gruppierten Ausgabe von promtool tsdb dump-openmetrics. Reproduziere den Fehler mithilfe des Beispiel-Parser-Codes und dieser Ausgabe. Als erledigt gilt die Aufgabe, wenn das Verhalten des Parsers bei wiederholten Metriknamen definiert und der gemeldete Fehler aufgrund kollidierender Namen behoben ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- observability-sre
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100