-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
suppress health check noise #1650
Conversation
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]>
e70c464
to
4bc5c52
Compare
👍 |
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}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative could be
var healthcheckFilters []*eskip.Filter
if healthy {
if log.IsLevelEnabled(log.DebugLevel) {
healthcheckFilters, _ = eskip.ParseFilters(`status(200)`)
} else {
healthcheckFilters, _ = eskip.ParseFilters(`disableAccessLog(200) -> status(200)`)
}
} else {
healthcheckFilters, _ = eskip.ParseFilters(`status(503)`)
}
adjusted test
diff --git a/dataclients/kubernetes/kube_test.go b/dataclients/kubernetes/kube_test.go
index cd899715..8a3e60f1 100644
--- a/dataclients/kubernetes/kube_test.go
+++ b/dataclients/kubernetes/kube_test.go
@@ -410,10 +410,11 @@ func checkHealthcheck(t *testing.T, got []*eskip.Route, expected, healthy, rever
return
}
- if healthy && f.Args[0] != http.StatusOK {
- t.Error("invalid healthcheck status", f.Args[0], http.StatusOK)
- } else if !healthy && f.Args[0] != http.StatusServiceUnavailable {
- t.Error("invalid healthcheck status", f.Args[0], http.StatusServiceUnavailable)
+ status := int(f.Args[0].(float64))
+ if healthy && status != http.StatusOK {
+ t.Error("invalid healthcheck status", status, http.StatusOK)
+ } else if !healthy && status != http.StatusServiceUnavailable {
+ t.Error("invalid healthcheck status", status, http.StatusServiceUnavailable)
}
return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parsing functionality is awesome to know!
My personal preference is to use static type compiler support whenever possible, not sure how expensive runtime parsing is but I’d expect a magnitude!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more about readabilty, skipper parses hundreds of routes on route table update anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We normally don’t parse filters like this in the dataclient if it’s not eskip or inline route
@@ -348,9 +349,19 @@ func shuntRoute(r *eskip.Route) { | |||
} | |||
|
|||
func healthcheckRoute(healthy, reverseSourcePredicate bool) *eskip.Route { | |||
status := http.StatusOK | |||
logFilters := []*eskip.Filter{{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can also call logFilters
as just filters
, because their main gig is not the logging part but the status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merged
👍 |
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