Files
unpoller_unpoller/pkg/datadogunifi/speedtest.go
T
Cody Lee 65ad210f20 feat: add UniFi Protect device metrics (closes #1015)
Collects Protect device data (sensors, cameras, lights, bridges, link
stations, NVR) via the official Integration API and exports it through
Prometheus, InfluxDB, and DataDog. Opt-in via save_protect_devices,
gated by protect_api_key.

Bumps github.com/unpoller/unifi to v6, which added the Protect API
client (breaking change: FlexInt/FlexBool/FlexFloat replace nullable
pointers).
2026-08-19 15:14:43 -05:00

40 lines
1018 B
Go

package datadogunifi
import (
"github.com/unpoller/unifi/v6"
)
// batchSpeedTest generates Unifi Speed Test datapoints for Datadog.
// These points can be passed directly to Datadog.
func (u *DatadogUnifi) batchSpeedTest(r report, st *unifi.SpeedTestResult) {
if st == nil {
return
}
metricName := metricNamespace("speedtest")
tags := []string{
tag("site_name", st.SiteName),
tag("source", st.SourceName),
tag("wan_interface", st.InterfaceName),
tag("wan_group", st.WANNetworkGroup),
tag("network_conf_id", st.NetworkConfID),
}
data := map[string]float64{
"download_mbps": st.DownloadMbps.Val,
"upload_mbps": st.UploadMbps.Val,
"latency_ms": st.LatencyMs.Val,
"timestamp": st.Time.Val,
}
if st.WANProviderCapabilities != nil {
data["provider_download_kbps"] = st.WANProviderCapabilities.DownloadKbps.Val
data["provider_upload_kbps"] = st.WANProviderCapabilities.UploadKbps.Val
}
for name, value := range data {
_ = r.reportGauge(metricName(name), value, tags)
}
}