Hmm, I see your use case, and that restarting the exporter when it's the sidecar of a stateful pod is painful. However, wherever we have introduced live reload (such as the statsd exporter) it has brought a lot of complexity and potential bugs that need to be taken into account for all subsequent development.
Can you say more about the use case for turning individual collectors on or off while a pod is running? Under what circumstances do you need to do this? Would it be an on/off for everything at once, or do you need to enable specific collectors for specific pods at specific times?
There's a mechanism to
filter collectors at scrape time, i.e. in
Prometheus configuration. I believe you may be able to use that instead of incurring the cost of live reload: configure the exporter with the superset of collectors you may want for a given pod, then use the filter mechanism to only
request the metrics that you need. With this, you can make use of Prometheus' service discovery (and the prometheus-exporter) to change what you actually collect at run time: either change the *Monitor to toggle a collector on for all monitored pods, or write relabeling rules to make use of a pod annotation to decide whether to include or exclude certain collectors. This will probably get very annoying if you are looking for a generic "let me configure every collector differently for every pod" mechanism, but it should be manageable for either "configure the list of collectors for
all pods" (change the monitor) or "toggle extra debug collectors for a specific pod" (have a relabeling rule that matches a "debug yes/no" annotation).
An alternative fallback solution would be to wrap the exporter in a binary (or shell script) that reads the list of exporters from a (configmap) file and restarts it as necessary.
Would either of these solve the use case without incurring the maintenance overhead of live reload capabilities in the exporter?
/MR