Skip to content

Commit 4723bce

Browse files
committed
fix: suppress kube-probe health check logs, add user_agent to request logs
1 parent f2b128d commit 4723bce

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

internal/handlers/middleware.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package handlers
33

44
import (
5+
"strings"
56
"time"
67

78
"github.com/gin-gonic/gin"
@@ -13,6 +14,11 @@ import (
1314
// appearing in logs. The authenticated username is included when available.
1415
func ZapLogger(log *zap.Logger) gin.HandlerFunc {
1516
return func(c *gin.Context) {
17+
if strings.HasPrefix(c.Request.UserAgent(), "kube-probe/") {
18+
c.Next()
19+
return
20+
}
21+
1622
start := time.Now()
1723
path := c.Request.URL.Path
1824

@@ -33,6 +39,7 @@ func ZapLogger(log *zap.Logger) gin.HandlerFunc {
3339
zap.Int("status", c.Writer.Status()),
3440
zap.Duration("latency", time.Since(start)),
3541
zap.String("ip", c.ClientIP()),
42+
zap.String("user_agent", c.Request.UserAgent()),
3643
}
3744
if redacted {
3845
fields = append(fields, zap.Bool("query_redacted", true))

0 commit comments

Comments
 (0)