prometheus / exporter-toolkit

Utility package to build exporters
Apache License 2.0
265 stars 81 forks source link

Automatically enable `--web.systemd-socket` when `$LISTEN_FDS` is set #225

Open septatrix opened 4 months ago

septatrix commented 4 months ago

Almost two years ago (#95) exporter-toolkit added the --web.systemd-socket flag to listen on a pre-opened socket passed as a file descriptor. We have used this feature with success since then. However, having to manually set the flag when using a socket is quite cumbersome and error prone. Additionally, when the flag is set, exporters fail to start unless a socket is passed. This is a reasonable behavior as one explicitly told the exporter to use an existing socket.

However, it would be better to check the $LISTEN_FDS environment variable and automatically use a socket if that variable is set. If that variable is not set, the exporter would fall back to opening a port on its own.