feat(inputunifi): add save_speedtest toggle for the WAN speed test poll

The Site Speed Test poll against the controller's aggregated-dashboard
endpoint has always run unconditionally, so operators whose controllers
misbehave on that endpoint have no way to skip the request. Every other
optional collection already has a save_* flag; this adds the missing one.

Defaults to true in all three default paths (local defaults,
per-controller defaults and remote discovery) so existing setups keep
behaving exactly as before.

Refs #1030

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Sebastian Peters
2026-08-06 23:11:45 +02:00
co-authored by Claude Opus 5
parent 251aebf19a
commit 04f0010fce
9 changed files with 33 additions and 5 deletions
+1
View File
@@ -25,6 +25,7 @@ save_anomalies = true
save_ids = true save_ids = true
save_traffic = true save_traffic = true
save_rogue = true save_rogue = true
save_speedtest = true
save_syslog = true save_syslog = true
save_protect_logs = false save_protect_logs = false
verify_ssl = true verify_ssl = true
+1
View File
@@ -15,6 +15,7 @@
"save_ids": true, "save_ids": true,
"save_traffic": true, "save_traffic": true,
"save_rogue": true, "save_rogue": true,
"save_speedtest": true,
"save_syslog": true, "save_syslog": true,
"save_protect_logs": false, "save_protect_logs": false,
"verify_ssl": true "verify_ssl": true
+1
View File
@@ -28,6 +28,7 @@ unifi:
save_ids: true save_ids: true
save_traffic: true save_traffic: true
save_rogue: true save_rogue: true
save_speedtest: true
save_syslog: true save_syslog: true
save_protect_logs: false save_protect_logs: false
# Remote API requires SSL verification # Remote API requires SSL verification
+6
View File
@@ -226,6 +226,11 @@
## This saves neighboring access point metrics in a dedicated table or namespace. ## This saves neighboring access point metrics in a dedicated table or namespace.
save_rogue = false save_rogue = false
## WAN speed test results, polled from the controller's aggregated-dashboard
## endpoint. Enabled by default. Set to false to skip that request entirely if
## your controller misbehaves on it or you simply don't want the metrics.
save_speedtest = true
# If your UniFi controller has a valid SSL certificate (like lets encrypt), # If your UniFi controller has a valid SSL certificate (like lets encrypt),
# you can enable this option to validate it. Otherwise, any SSL certificate is # you can enable this option to validate it. Otherwise, any SSL certificate is
# valid. If you don't know if you have a valid SSL cert, then you don't have one. # valid. If you don't know if you have a valid SSL cert, then you don't have one.
@@ -259,5 +264,6 @@
# save_dpi = false # save_dpi = false
# save_traffic = false # save_traffic = false
# save_rogue = false # save_rogue = false
# save_speedtest = true
# verify_ssl = false # verify_ssl = false
# ssl_cert_paths = [] # ssl_cert_paths = []
+7 -5
View File
@@ -190,11 +190,13 @@ func (u *InputUnifi) pollController(c *Controller) (*poller.Metrics, error) {
len(m.Devices.USWs), len(m.Devices.UDMs)) len(m.Devices.USWs), len(m.Devices.UDMs))
// Get speed test results for all WANs // Get speed test results for all WANs
if m.SpeedTests, err = c.Unifi.GetSpeedTests(sites, historySeconds); err != nil { if c.SaveSpeedTest != nil && *c.SaveSpeedTest {
// Don't fail collection if speed tests fail - older controllers may not have this endpoint if m.SpeedTests, err = c.Unifi.GetSpeedTests(sites, historySeconds); err != nil {
u.LogDebugf("unifi.GetSpeedTests(%s): %v (continuing)", c.URL, err) // Don't fail collection if speed tests fail - older controllers may not have this endpoint
} else { u.LogDebugf("unifi.GetSpeedTests(%s): %v (continuing)", c.URL, err)
u.LogDebugf("Found %d SpeedTests entries", len(m.SpeedTests)) } else {
u.LogDebugf("Found %d SpeedTests entries", len(m.SpeedTests))
}
} }
// Get DHCP leases with associations. // Get DHCP leases with associations.
+11
View File
@@ -48,6 +48,7 @@ type Controller struct {
SaveDPI *bool `json:"save_dpi" toml:"save_dpi" xml:"save_dpi" yaml:"save_dpi"` SaveDPI *bool `json:"save_dpi" toml:"save_dpi" xml:"save_dpi" yaml:"save_dpi"`
SaveTraffic *bool `json:"save_traffic" toml:"save_traffic" xml:"save_traffic" yaml:"save_traffic"` SaveTraffic *bool `json:"save_traffic" toml:"save_traffic" xml:"save_traffic" yaml:"save_traffic"`
SaveRogue *bool `json:"save_rogue" toml:"save_rogue" xml:"save_rogue" yaml:"save_rogue"` SaveRogue *bool `json:"save_rogue" toml:"save_rogue" xml:"save_rogue" yaml:"save_rogue"`
SaveSpeedTest *bool `json:"save_speedtest" toml:"save_speedtest" xml:"save_speedtest" yaml:"save_speedtest"`
HashPII *bool `json:"hash_pii" toml:"hash_pii" xml:"hash_pii" yaml:"hash_pii"` HashPII *bool `json:"hash_pii" toml:"hash_pii" xml:"hash_pii" yaml:"hash_pii"`
DropPII *bool `json:"drop_pii" toml:"drop_pii" xml:"drop_pii" yaml:"drop_pii"` DropPII *bool `json:"drop_pii" toml:"drop_pii" xml:"drop_pii" yaml:"drop_pii"`
SaveSites *bool `json:"save_sites" toml:"save_sites" xml:"save_sites" yaml:"save_sites"` SaveSites *bool `json:"save_sites" toml:"save_sites" xml:"save_sites" yaml:"save_sites"`
@@ -315,6 +316,12 @@ func (u *InputUnifi) setDefaults(c *Controller) { //nolint:cyclop
c.SaveRogue = &f c.SaveRogue = &f
} }
// Defaults to true: the speed test poll has always run unconditionally,
// so an explicit opt-out keeps existing setups behaving the same.
if c.SaveSpeedTest == nil {
c.SaveSpeedTest = &t
}
if c.SaveIDs == nil { if c.SaveIDs == nil {
c.SaveIDs = &f c.SaveIDs = &f
} }
@@ -433,6 +440,10 @@ func (u *InputUnifi) setControllerDefaults(c *Controller) *Controller { //nolint
c.SaveRogue = u.Default.SaveRogue c.SaveRogue = u.Default.SaveRogue
} }
if c.SaveSpeedTest == nil {
c.SaveSpeedTest = u.Default.SaveSpeedTest
}
if c.SaveEvents == nil { if c.SaveEvents == nil {
c.SaveEvents = u.Default.SaveEvents c.SaveEvents = u.Default.SaveEvents
} }
+1
View File
@@ -190,6 +190,7 @@ func (u *InputUnifi) logController(c *Controller) {
u.Logf(" => Save Alarms %v / Anomalies %v / Protect Logs %v (thumbnails: %v)", *c.SaveAlarms, *c.SaveAnomal, *c.SaveProtectLogs, *c.ProtectThumbnails) u.Logf(" => Save Alarms %v / Anomalies %v / Protect Logs %v (thumbnails: %v)", *c.SaveAlarms, *c.SaveAnomal, *c.SaveProtectLogs, *c.ProtectThumbnails)
u.Logf(" => Save Rogue APs: %v", *c.SaveRogue) u.Logf(" => Save Rogue APs: %v", *c.SaveRogue)
u.Logf(" => Save Traffic %v", *c.SaveTraffic) u.Logf(" => Save Traffic %v", *c.SaveTraffic)
u.Logf(" => Save Speed Tests: %v", *c.SaveSpeedTest)
} }
// Events allows you to pull only events (and IDs) from the UniFi Controller. // Events allows you to pull only events (and IDs) from the UniFi Controller.
+4
View File
@@ -155,6 +155,10 @@ func (u *InputUnifi) discoverRemoteControllers(apiKey string) ([]*Controller, er
controller.SaveRogue = &f controller.SaveRogue = &f
} }
if controller.SaveSpeedTest == nil {
controller.SaveSpeedTest = &t
}
if controller.SaveSyslog == nil { if controller.SaveSyslog == nil {
controller.SaveSyslog = &f controller.SaveSyslog = &f
} }
+1
View File
@@ -74,6 +74,7 @@ func formatControllers(controllers []*Controller) []*Controller {
SaveAnomal: c.SaveAnomal, SaveAnomal: c.SaveAnomal,
SaveAlarms: c.SaveAlarms, SaveAlarms: c.SaveAlarms,
SaveRogue: c.SaveRogue, SaveRogue: c.SaveRogue,
SaveSpeedTest: c.SaveSpeedTest,
SaveEvents: c.SaveEvents, SaveEvents: c.SaveEvents,
SaveSyslog: c.SaveSyslog, SaveSyslog: c.SaveSyslog,
SaveProtectLogs: c.SaveProtectLogs, SaveProtectLogs: c.SaveProtectLogs,