Skip to content

Commit 4c5f48f

Browse files
committed
Silence logging from probes
The kubelet's health check probe results in many log lines so this checks for the prefix of "kube-probe" and silences any logs for the http mode. Fixes an issue reported by an OpenFaaS Pro customer. Fixes: #130 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent a028941 commit 4c5f48f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

executor/http_runner.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"os"
1717
"os/exec"
1818
"os/signal"
19+
"strings"
1920
"syscall"
2021
"time"
2122
)
@@ -168,7 +169,11 @@ func (f *HTTPFunctionRunner) Run(req FunctionRequest, contentLength int64, r *ht
168169
w.Write(bodyBytes)
169170
}
170171

171-
log.Printf("%s %s - %s - ContentLength: %d", r.Method, r.RequestURI, res.Status, res.ContentLength)
172+
// Exclude logging for health check probes from the kubelet which can spam
173+
// log collection systems.
174+
if !strings.HasPrefix(r.UserAgent(), "kube-probe") {
175+
log.Printf("%s %s - %s - ContentLength: %d", r.Method, r.RequestURI, res.Status, res.ContentLength)
176+
}
172177

173178
return nil
174179
}

0 commit comments

Comments
 (0)