plugin/health: Bypass proxy in self health check (#5401)

* add detail to docs; bypass proxy in self health check

Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
Chris O'Haver 2022-06-17 15:49:53 -04:00 committed by GitHub
parent dded10420b
commit 037e4920c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View file

@ -48,13 +48,13 @@ Doing this is supported but both endpoints ":8080" and ":8081" will export the e
## Metrics ## Metrics
If monitoring is enabled (via the *prometheus* plugin) then the following metric is exported: If monitoring is enabled (via the *prometheus* plugin) then the following metrics are exported:
* `coredns_health_request_duration_seconds{}` - duration to process a HTTP query to the local * `coredns_health_request_duration_seconds{}` - The *health* plugin performs a self health check
`/health` endpoint. As this a local operation it should be fast. A (large) increase in this once per second on the `/health` endpoint. This metric is the duration to process that request.
As this is a local operation it should be fast. A (large) increase in this
duration indicates the CoreDNS process is having trouble keeping up with its query load. duration indicates the CoreDNS process is having trouble keeping up with its query load.
* `coredns_health_request_failures_total{}` - The number of times the internal health check loop * `coredns_health_request_failures_total{}` - The number of times the self health check failed.
failed to query `/health`.
Note that these metrics *do not* have a `server` label, because being overloaded is a symptom of Note that these metrics *do not* have a `server` label, because being overloaded is a symptom of
the running process, *not* a specific server. the running process, *not* a specific server.

View file

@ -2,6 +2,7 @@ package health
import ( import (
"context" "context"
"net"
"net/http" "net/http"
"time" "time"
@ -13,9 +14,22 @@ import (
// overloaded queries the health end point and updates a metrics showing how long it took. // overloaded queries the health end point and updates a metrics showing how long it took.
func (h *health) overloaded(ctx context.Context) { func (h *health) overloaded(ctx context.Context) {
bypassProxy := &http.Transport{
Proxy: nil,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
timeout := 3 * time.Second timeout := 3 * time.Second
client := http.Client{ client := http.Client{
Timeout: timeout, Timeout: timeout,
Transport: bypassProxy,
} }
url := "http://" + h.Addr + "/health" url := "http://" + h.Addr + "/health"