From dcdbef6687d308eb46966cf8e1bc7087416491f2 Mon Sep 17 00:00:00 2001 From: Cody Lee Date: Mon, 23 Mar 2026 14:30:49 -0500 Subject: [PATCH] fix(inputunifi): gracefully handle 404s from remote API event endpoints (#971) * fix(inputunifi): gracefully handle 404s from remote API event endpoints The UniFi remote API (api.ui.com) does not support legacy event endpoints such as /stat/event, causing repeated [ERROR] log lines for users who have save_events = true with a remote controller. When a remote controller returns an invalid HTTP status code (e.g. 404), log a warning and continue to the next event collector instead of propagating the error. This keeps metrics collection working and stops the noisy error loop. Fixes #966 Co-Authored-By: Claude Sonnet 4.6 (1M context) * fix(inputunifi): log unsupported remote API event endpoints at Info not Error Co-Authored-By: Claude Sonnet 4.6 (1M context) --------- Co-authored-by: Claude Sonnet 4.6 (1M context) --- pkg/inputunifi/collectevents.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/inputunifi/collectevents.go b/pkg/inputunifi/collectevents.go index ed451f87..53deceda 100644 --- a/pkg/inputunifi/collectevents.go +++ b/pkg/inputunifi/collectevents.go @@ -2,6 +2,7 @@ package inputunifi import ( "encoding/base64" + "errors" "fmt" "strings" "time" @@ -38,6 +39,14 @@ func (u *InputUnifi) collectControllerEvents(c *Controller) ([]any, error) { for _, call := range []caller{u.collectIDs, u.collectAnomalies, u.collectAlarms, u.collectEvents, u.collectSyslog, u.collectProtectLogs} { if newLogs, err = call(logs, sites, c); err != nil { + if c.Remote && errors.Is(err, unifi.ErrInvalidStatusCode) { + // The remote API (api.ui.com) does not support all event endpoints (e.g. /stat/event + // returns 404). Log a warning and continue so other collectors still run. + u.Logf("Failed to collect events from controller %s: %v (endpoint may not be supported by the remote API)", c.URL, err) + + continue + } + return logs, err }