Open petarmaric opened 1 year ago
Hello, I am not opposed to adding a function to prometheus_client.openmetrics
for textfile if it doesn't add confusion, but I am curious what your use case is? As far as I know the node exporter textfile collector only supports the Prometheus format, but I could have missed an update.
Thank you for the interest :) Honestly, can't give too many specifics right now, as I'm waiting for approval from the company I work for to actually Open Source the tool I'm building.
What I can say right now is that it's a console app and Python API for converting reports outputted by "a tool" into the OpenMetrics text format. Such metrics are then meant to be pushed into Grafana (data source), via VictoriaMetrics API.
Once it's Open Sourced I'll be sure to provide a link here, so you can see the use-case more clearly - there are a few reasons I've opted in for OpenMetrics in lieu of Prometheus text format...
As promised, https://pypi.org/project/locust_csv2openmetrics/ has (finally) hit 1.0.0 today.
We use this tool to convert locust’s load test CSV formatted reports into the OpenMetrics text format, pushing the obtained metrics into Grafana (data source), via VictoriaMetrics API.
Because these load tests are run non-continuously and at irregular time intervals we need to push their metrics into Grafana (data source), as opposed to the much more common way of Prometheus pulling data from a load-tests-like service to collect the metrics. I hope this clarifies our use case.
That use case makes sense to me, it is also the format you need to backfill data into Prometheus using promtool. That said, it looks like what you did is the correct thing to do, call generate_latest and save to a file. The reason write_to_textfile
exists is that atomic writes are necessary in order to use the textfile exporter, but backfilling data does not require an atomic write.
Currently
prometheus_client.exposition.write_to_textfile
doesn't support the OpenMetrics text format, which I'm addressing with this (private) hack:Would your project be interested in a non-hacky (as is the case above) OpenMetrics support for textfile collector?