From 07781214c3444d6fabdcceda06d637f8bfc82079 Mon Sep 17 00:00:00 2001 From: Cody Lee Date: Sun, 25 Jan 2026 11:24:33 -0600 Subject: [PATCH] Add config option to suppress unknown device type messages Adds log_unknown_types config option (default: false) to control logging of unknown UniFi device types. When disabled (default), unknown devices are silently ignored to reduce log volume. When enabled, they are logged as DEBUG messages instead of ERROR. Addresses issue #912. Co-Authored-By: Claude Sonnet 4.5 --- examples/remote_api_example.conf | 4 ++++ examples/remote_api_example.yaml | 4 ++++ examples/up.conf.example | 5 +++++ examples/up.json.example | 3 ++- examples/up.yaml.example | 4 ++++ pkg/influxunifi/influxdb.go | 4 +++- pkg/poller/config.go | 7 ++++--- pkg/promunifi/collector.go | 4 +++- 8 files changed, 29 insertions(+), 6 deletions(-) diff --git a/examples/remote_api_example.conf b/examples/remote_api_example.conf index 4673de17..149bb204 100644 --- a/examples/remote_api_example.conf +++ b/examples/remote_api_example.conf @@ -7,6 +7,10 @@ [poller] debug = false quiet = false +# log_unknown_types = false # Set to true to log unknown device types as DEBUG messages. + # By default, newer UniFi device types that aren't recognized + # are silently ignored to reduce log volume. Enable this when + # debugging or reporting new device types to developers. [unifi] remote = true diff --git a/examples/remote_api_example.yaml b/examples/remote_api_example.yaml index 00ed1b00..3f8982ac 100644 --- a/examples/remote_api_example.yaml +++ b/examples/remote_api_example.yaml @@ -7,6 +7,10 @@ poller: debug: false quiet: false + # log_unknown_types: false # Set to true to log unknown device types as DEBUG messages. + # By default, newer UniFi device types that aren't recognized + # are silently ignored to reduce log volume. Enable this when + # debugging or reporting new device types to developers. unifi: # Enable remote API mode - automatically discovers all consoles diff --git a/examples/up.conf.example b/examples/up.conf.example index 898416ce..24394482 100644 --- a/examples/up.conf.example +++ b/examples/up.conf.example @@ -11,6 +11,11 @@ # Recommend enabling debug with this setting for better error logging. quiet = false + # Log unknown device types as DEBUG messages. By default (false), newer UniFi + # device types that aren't recognized are silently ignored to reduce log volume. + # Enable this when debugging or reporting new device types to developers. + # log_unknown_types = false + # Load dynamic plugins. Advanced use; only sample mysql plugin provided by default. plugins = [] diff --git a/examples/up.json.example b/examples/up.json.example index d43bb14e..85438477 100644 --- a/examples/up.json.example +++ b/examples/up.json.example @@ -2,7 +2,8 @@ "poller": { "debug": false, "quiet": false, - "plugins": [] + "plugins": [], + "log_unknown_types": false }, "prometheus": { diff --git a/examples/up.yaml.example b/examples/up.yaml.example index 213e21c4..616939b2 100644 --- a/examples/up.yaml.example +++ b/examples/up.yaml.example @@ -9,6 +9,10 @@ poller: debug: false quiet: false plugins: [] + # log_unknown_types: false # Set to true to log unknown device types as DEBUG messages. + # By default, newer UniFi device types that aren't recognized + # are silently ignored to reduce log volume. Enable this when + # debugging or reporting new device types to developers. prometheus: disable: false diff --git a/pkg/influxunifi/influxdb.go b/pkg/influxunifi/influxdb.go index 82153818..d5c4c2a5 100644 --- a/pkg/influxunifi/influxdb.go +++ b/pkg/influxunifi/influxdb.go @@ -467,6 +467,8 @@ func (u *InfluxUnifi) switchExport(r report, v any) { //nolint:cyclop case *unifi.SpeedTestResult: u.batchSpeedTest(r, v) default: - u.LogErrorf("invalid export type: %T", v) + if u.Collector.Poller().LogUnknownTypes { + u.LogDebugf("unknown export type: %T", v) + } } } diff --git a/pkg/poller/config.go b/pkg/poller/config.go index f520ab5a..f7caf535 100644 --- a/pkg/poller/config.go +++ b/pkg/poller/config.go @@ -102,9 +102,10 @@ type Config struct { // Poller is the global config values. type Poller struct { - Plugins []string `json:"plugins" toml:"plugins" xml:"plugin" yaml:"plugins"` - Debug bool `json:"debug" toml:"debug" xml:"debug,attr" yaml:"debug"` - Quiet bool `json:"quiet" toml:"quiet" xml:"quiet,attr" yaml:"quiet"` + Plugins []string `json:"plugins" toml:"plugins" xml:"plugin" yaml:"plugins"` + Debug bool `json:"debug" toml:"debug" xml:"debug,attr" yaml:"debug"` + Quiet bool `json:"quiet" toml:"quiet" xml:"quiet,attr" yaml:"quiet"` + LogUnknownTypes bool `json:"log_unknown_types" toml:"log_unknown_types" xml:"log_unknown_types" yaml:"log_unknown_types"` } // LoadPlugins reads-in dynamic shared libraries. diff --git a/pkg/promunifi/collector.go b/pkg/promunifi/collector.go index a4f310d0..7d0934de 100644 --- a/pkg/promunifi/collector.go +++ b/pkg/promunifi/collector.go @@ -452,6 +452,8 @@ func (u *promUnifi) switchExport(r report, v any) { case *unifi.UsageByCountry: u.exportCountryTraffic(r, v) default: - u.LogErrorf("invalid type: %T", v) + if u.Collector.Poller().LogUnknownTypes { + u.LogDebugf("unknown type: %T", v) + } } }