mirror of
https://github.com/unpoller/unpoller.git
synced 2026-03-31 06:24:21 -04:00
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) <noreply@anthropic.com> * fix(inputunifi): log unsupported remote API event endpoints at Info not Error Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user