plugin/health: add logging for local health request
@@ -12,7 +12,7 @@ import (
// overloaded queries the health end point and updates a metrics showing how long it took.
func (h *health) overloaded() {
- timeout := time.Duration(5 * time.Second)
+ timeout := time.Duration(3 * time.Second)
client := http.Client{
Timeout: timeout,
}
@@ -27,10 +27,15 @@ func (h *health) overloaded() {
resp, err := client.Get(url)
if err != nil {
HealthDuration.Observe(timeout.Seconds())
+ log.Warningf("Local health request to %q failed: %s", url, err)
continue
}
resp.Body.Close()
- HealthDuration.Observe(time.Since(start).Seconds())
+ elapsed := time.Since(start)
+ HealthDuration.Observe(elapsed.Seconds())
+ if elapsed > time.Second { // 1s is pretty random, but a *local* scrape taking that long isn't good
+ log.Warningf("Local health request to %q took more than 1s: %s", url, elapsed)
+ }
case <-h.stop:
return
