claws / aioprometheus

A Prometheus Python client library for asyncio-based applications
175 stars 21 forks source link

How to get another output format for /metrics handler ? #49

Closed remort closed 3 years ago

remort commented 3 years ago

Tried to pass different headers in Accept header which I found in source code of your tool, but no luck, metrics render in default text format (supposed to be default IFormatter) always.

claws commented 3 years ago

The library supports returning metrics in text format and optionally the binary format. The binary format was retired by Prometheus a while ago. The text format is the default format used. This format will be used if no format is specified or if the library can't map the requested format to either the text or binary format.

It is possible to add additional formats by implementing a new formatting class based on the IFormatter interface class and then updating the negotiate function in negotiator.py. Prometheus would never ask for your custom format but if you plan to scape using a different tool then this could be an option I guess.