feat(admin): exclude health check entries from admin logs
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m43s
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m43s
Filter out automated health check log entries (such as `/health`, `/healthz`, and `/api/v1/health`) from the admin logs view. This reduces noise in the dashboard caused by frequent container health pings. Also added corresponding unit tests to verify the filtering behavior.
This commit is contained in:
@@ -1731,11 +1731,29 @@ func readLogEntries(file string) ([]adminLogEntry, error) {
|
||||
if err := json.Unmarshal(line, &raw); err != nil {
|
||||
continue
|
||||
}
|
||||
if isHealthCheckLogEntry(raw) {
|
||||
continue
|
||||
}
|
||||
entries = append(entries, logEntryFromMap(raw))
|
||||
}
|
||||
return entries, scanner.Err()
|
||||
}
|
||||
|
||||
func isHealthCheckLogEntry(raw map[string]any) bool {
|
||||
path := strings.TrimSpace(firstLogString(raw, "path", "route"))
|
||||
if path == "" {
|
||||
return false
|
||||
}
|
||||
fields := strings.Fields(path)
|
||||
if len(fields) > 0 {
|
||||
path = fields[len(fields)-1]
|
||||
}
|
||||
if idx := strings.IndexByte(path, '?'); idx >= 0 {
|
||||
path = path[:idx]
|
||||
}
|
||||
return path == "/health" || path == "/healthz" || path == "/api/v1/health"
|
||||
}
|
||||
|
||||
func logEntryFromMap(raw map[string]any) adminLogEntry {
|
||||
entry := adminLogEntry{
|
||||
Date: logString(raw, "date"),
|
||||
|
||||
Reference in New Issue
Block a user