Allow triggering refresh through HTTP request
I have a bunch of restic jobs scheduled through systemd timers. I also have the exporter set to refresh once a day since I’m backing up to remote object storage. There’s consequently a long gap between when the backup finishes and when the exporter updates its stats.
It’d be useful to be able to POST to /refresh (for instance) so each job could ping its exporter to refresh the stats and reset the timer upon completion. Then I could set the refresh interval to something absurdly large and still have up-to-date metrics with minimal requests to the storage backend.
It looks like prometheus_client’s start_http_server is small and pretty much hard-coded to only serve metrics, so this would probably require something like Flask with the Prometheus middleware.
One alternative I can think of is to use a control socket instead, such as with socketserver.UnixDatagramServer, so there’s no need for any extra HTTP machinery. That would suffice for my needs, since the jobs run on the same machine as the exporter.