The following script is able to parse a file that contains exposed metrics.
Install prometheus_client and forked-path:
pip install prometheus_client forked-path
parseFile.py:
from prometheus_client.openmetrics.parser import text_string_to_metric_families
from path import path
metrics = path('/path/to/metrics.txt').bytes()
for family in text_string_to_metric_families(metrics):
for sample in family.samples:
print("Name: {0} Labels: {1} Value: {2} Timestamp: {3}".format(*sample))
Expected Behavior
All produces metrics must be able to be parsed by the openmetrics python parser.
Actual Behavior
Metrics are only tested via unit tests.
Specifications
Further comments
The following script is able to parse a file that contains exposed metrics.
Install
prometheus_client
andforked-path
:parseFile.py: