lukasmalkmus / rpi_exporter

A Raspberry Pi CPU temperature exporter.
Apache License 2.0
79 stars 17 forks source link

Add json logging output format #17

Closed josegonzalez closed 10 months ago

josegonzalez commented 3 years ago

Lots of tools are standardizing on json logging as it is easy to parse/ship/index. It would be great to add this in addition to the default logfmt format that is currently in use. A way to do it might be to detect a tty and automatically switch to json if none is detected, or add a flag/env var to control the format.

ToMe25 commented 10 months ago

While I do not understand which part of the code adds this argument, this is possible using the log.format argument.

This can be seen, even with an example for json output, when running the exporter with the help argument.

Edit: To print logging in json format to the standard output stream, use --log.format="logger:stdout?json=true".

josegonzalez commented 10 months ago

Oh thats great. I'll close this then.