postgres_exporter icon indicating copy to clipboard operation
postgres_exporter copied to clipboard

feat: scrape timeout

Open johanneswuerbach opened this issue 3 years ago • 7 comments

Allow to configure a scrape timeout to prevent queries from hanging forever.

johanneswuerbach avatar Jul 13 '21 12:07 johanneswuerbach

Prometheus sends the scrape timeout in HTTP headers, we should reuse it.

roidelapluie avatar Jul 13 '21 12:07 roidelapluie

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?

johanneswuerbach avatar Jul 13 '21 12:07 johanneswuerbach

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

johanneswuerbach avatar Jul 13 '21 18:07 johanneswuerbach

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.

sysadmind avatar Jul 13 '21 18:07 sysadmind

Any further steps I could do to drive this forward @sysadmind @roidelapluie @SuperQ ?

johanneswuerbach avatar Aug 13 '21 13:08 johanneswuerbach

Ping :-)

johanneswuerbach avatar Jan 27 '22 23:01 johanneswuerbach

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.

SuperQ avatar May 31 '22 10:05 SuperQ