Fix site name override for DPI clients, anomalies, and site metrics

- Apply site name override to DPI clients (ClientsDPI) in augmentMetrics
- Apply site name override to client anomalies when collecting events
- Apply site name override to sites (both Name and SiteName fields) when adding to metrics
- Apply site name override to DPI sites, speed tests, and country traffic
- Move applySiteNameOverride call to end of augmentMetrics to ensure all metrics are processed
- This ensures all Prometheus metrics use console names instead of 'Default (default)' for Cloud Gateways
This commit is contained in:
brngates98
2026-01-24 22:26:49 -05:00
parent 3996fd8683
commit 28e77d1ac5
2 changed files with 51 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ package inputunifi
import (
"encoding/base64"
"fmt"
"strings"
"time"
"github.com/unpoller/unifi/v5"
@@ -83,6 +84,14 @@ func (u *InputUnifi) collectAnomalies(logs []any, sites []*unifi.Site, c *Contro
}
for _, e := range events {
// Apply site name override for anomalies if configured
if c.DefaultSiteNameOverride != "" {
lower := strings.ToLower(e.SiteName)
if lower == "default" || strings.Contains(lower, "default") {
e.SiteName = c.DefaultSiteNameOverride
}
}
logs = append(logs, e)
webserver.NewInputEvent(PluginName, s.ID+"_anomalies", &webserver.Event{