From 30aaceb1c3bf8d6c48e8479ef42cab5d0d15a400 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 18 Mar 2020 15:43:03 -0700 Subject: [PATCH] etcdserver/api/etcdhttp: log server-side /health checks ref. https://github.com/etcd-io/etcd/pull/11704 Signed-off-by: Gyuho Lee --- etcdserver/api/etcdhttp/metrics.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/etcdserver/api/etcdhttp/metrics.go b/etcdserver/api/etcdhttp/metrics.go index e947abfdd0d..2f6a0a7b2ae 100644 --- a/etcdserver/api/etcdhttp/metrics.go +++ b/etcdserver/api/etcdhttp/metrics.go @@ -50,6 +50,7 @@ func NewHealthHandler(hfunc func() Health) http.HandlerFunc { if r.Method != http.MethodGet { w.Header().Set("Allow", http.MethodGet) http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed) + plog.Warningf("/health error (status code %d)", http.StatusMethodNotAllowed) return } h := hfunc() @@ -97,11 +98,15 @@ func checkHealth(srv etcdserver.ServerV2) Health { as := srv.Alarms() if len(as) > 0 { h.Health = "false" + for _, v := range as { + plog.Warningf("/health error due to an alarm %s", v.String()) + } } if h.Health == "true" { if uint64(srv.Leader()) == raft.None { h.Health = "false" + plog.Warningf("/health error; no leader (status code %d)", http.StatusServiceUnavailable) } } @@ -111,11 +116,13 @@ func checkHealth(srv etcdserver.ServerV2) Health { cancel() if err != nil { h.Health = "false" + plog.Warningf("/health error; QGET failed %v (status code %d)", err, http.StatusServiceUnavailable) } } if h.Health == "true" { healthSuccess.Inc() + plog.Infof("/health OK (status code %d)", http.StatusOK) } else { healthFailed.Inc() }