Skip to content

Commit

Permalink
suppress health check noise (#1650)
Browse files Browse the repository at this point in the history
This change suppresses logging of the Skipper health check path in normal conditions, reducing log noise.

The logging is enabled if the health check fails or debugging levels are enabled

Signed-off-by: Samuel Lang <[email protected]>
  • Loading branch information
universam1 authored Dec 15, 2020
1 parent 481835f commit b6f20ec
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions dataclients/kubernetes/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
log "github.com/sirupsen/logrus"

"github.com/zalando/skipper/eskip"
"github.com/zalando/skipper/filters/accesslog"
"github.com/zalando/skipper/filters/builtin"
"github.com/zalando/skipper/predicates/source"
)
Expand Down Expand Up @@ -348,9 +349,19 @@ func shuntRoute(r *eskip.Route) {
}

func healthcheckRoute(healthy, reverseSourcePredicate bool) *eskip.Route {
status := http.StatusOK
logFilters := []*eskip.Filter{{
Name: builtin.StatusName,
Args: []interface{}{http.StatusOK}},
}
if !healthy {
status = http.StatusServiceUnavailable
logFilters[0].Args = []interface{}{http.StatusServiceUnavailable}
}
// log if unhealthy or a debug loglevel
if healthy && !log.IsLevelEnabled(log.DebugLevel) {
logFilters = append(logFilters, &eskip.Filter{
Name: accesslog.DisableAccessLogName,
Args: []interface{}{200},
})
}

var p []*eskip.Predicate
Expand All @@ -370,11 +381,8 @@ func healthcheckRoute(healthy, reverseSourcePredicate bool) *eskip.Route {
Id: healthcheckRouteID,
Predicates: p,
Path: healthcheckPath,
Filters: []*eskip.Filter{{
Name: builtin.StatusName,
Args: []interface{}{status}},
},
Shunt: true,
Filters: logFilters,
Shunt: true,
}
}

Expand Down

0 comments on commit b6f20ec

Please sign in to comment.