Skip to content

Commit

Permalink
Silence logging from probes
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
alexellis committed Feb 20, 2022
1 parent a028941 commit 4c5f48f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion executor/http_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"os"
"os/exec"
"os/signal"
"strings"
"syscall"
"time"
)
Expand Down Expand Up @@ -168,7 +169,11 @@ func (f *HTTPFunctionRunner) Run(req FunctionRequest, contentLength int64, r *ht
w.Write(bodyBytes)
}

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

return nil
}
Expand Down

0 comments on commit 4c5f48f

Please sign in to comment.