From 857f7681bbc9f0faf365ccc4afbdeccf84e5cd68 Mon Sep 17 00:00:00 2001 From: Bob Callaway Date: Mon, 16 Dec 2024 09:16:36 -0500 Subject: [PATCH] turn down prober log levels Signed-off-by: Bob Callaway --- cmd/prober/prober.go | 4 ++-- cmd/prober/prometheus.go | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/prober/prober.go b/cmd/prober/prober.go index ba0b54aba..2e20d3f11 100644 --- a/cmd/prober/prober.go +++ b/cmd/prober/prober.go @@ -147,11 +147,11 @@ func init() { retryableClient.RequestLogHook = func(_ retryablehttp.Logger, r *http.Request, attempt int) { ctx := context.WithValue(r.Context(), attemptCtxKey("attempt_number"), attempt) *r = *r.WithContext(ctx) - Logger.Infof("attempt #%d for %v %v", attempt, r.Method, r.URL) + Logger.Debugf("attempt #%d for %v %v", attempt, r.Method, r.URL) } retryableClient.ResponseLogHook = func(_ retryablehttp.Logger, r *http.Response) { attempt := r.Request.Context().Value(attemptCtxKey("attempt_number")) - Logger.With(zap.Int("bytes", int(r.ContentLength))).Infof("attempt #%d result: %d", attempt, r.StatusCode) + Logger.With(zap.Int("bytes", int(r.ContentLength))).Debugf("attempt #%d result: %d", attempt, r.StatusCode) } var rekorFlagRequests []ReadProberCheck diff --git a/cmd/prober/prometheus.go b/cmd/prober/prometheus.go index 04db73638..3cee2aad7 100644 --- a/cmd/prober/prometheus.go +++ b/cmd/prober/prometheus.go @@ -70,7 +70,11 @@ func exportDataToPrometheus(resp *http.Response, host, endpoint, method string, endpointLatenciesSummary.With(labels).Observe(float64(latency)) endpointLatenciesHistogram.With(labels).Observe(float64(latency)) - Logger.With(zap.Int("status", statusCode), zap.Int("bytes", int(resp.ContentLength)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Infof("[DEBUG] %v %v", method, host+endpoint) + if statusCode >= 400 { + Logger.With(zap.Int("status", statusCode), zap.Int("bytes", int(resp.ContentLength)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Warnf("[DEBUG] %v %v", method, host+endpoint) + } else { + Logger.With(zap.Int("status", statusCode), zap.Int("bytes", int(resp.ContentLength)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Debugf("[DEBUG] %v %v", method, host+endpoint) + } } func exportGrpcDataToPrometheus(statusCode codes.Code, host string, endpoint string, method string, latency int64) { @@ -82,7 +86,11 @@ func exportGrpcDataToPrometheus(statusCode codes.Code, host string, endpoint str } endpointLatenciesSummary.With(labels).Observe(float64(latency)) endpointLatenciesHistogram.With(labels).Observe(float64(latency)) - Logger.With(zap.Int32("status", int32(statusCode)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Infof("[DEBUG] %v %v %v", method, endpoint, host) + if statusCode != codes.OK { + Logger.With(zap.Int32("status", int32(statusCode)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Warnf("[DEBUG] %v %v %v", method, endpoint, host) + } else { + Logger.With(zap.Int32("status", int32(statusCode)), zap.Duration("latency", time.Duration(latency)*time.Millisecond)).Debugf("[DEBUG] %v %v %v", method, endpoint, host) + } } // NewVersionCollector returns a collector that exports metrics about current version