postgres_exporter
postgres_exporter copied to clipboard
feat: scrape timeout
Allow to configure a scrape timeout to prevent queries from hanging forever.
Prometheus sends the scrape timeout in HTTP headers, we should reuse it.
While I've seen that, I wasn't sure how well this plays with caching of slow queries 🤔 Could there be queries, where the cache was previously populated after 2-3 fetches, which would always fail with a small timeout?
Looking at https://github.com/prometheus/client_golang support for the X-Prometheus-Scrape-Timeout-Seconds
header doesn't seem to be provided yet, any pointers how that works @roidelapluie , @SuperQ ?
This exporter is using the handler provided by the golang client at the moment https://github.com/prometheus-community/postgres_exporter/blob/57719ba53cac428769aaf3c4c0bb742df3cfca98/cmd/postgres_exporter/main.go#L117
I do not think that the context is propagated to any of the collectors at this time. While the http.Request may be cancelled by the header timeout, the downstream functions in the collector have no way to access it. I think this implementation is reasonable at this time based on the interfaces that we have to work with.
Any further steps I could do to drive this forward @sysadmind @roidelapluie @SuperQ ?
Ping :-)
Yes, in order to do this the "usual way", you need to implement http.HandlerFunc()
.
The mysqld_exporter does this.
I think we should focus on getting https://github.com/prometheus-community/postgres_exporter/pull/618 finished so we have the new multi-target handler functionality.