mirror of
https://github.com/unpoller/unpoller.git
synced 2026-03-31 06:33:57 -04:00
* feat(otelunifi): add OpenTelemetry output plugin Adds a new push-based output plugin that exports UniFi metrics to any OTLP-compatible backend (Grafana Alloy/Mimir, Honeycomb, Datadog via OTel, New Relic, etc.) using the Go OpenTelemetry SDK v1.42. Config (default disabled): [otel] url = "http://localhost:4318" protocol = "http" # or "grpc" interval = "30s" timeout = "10s" disable = false api_key = "" # optional Bearer auth Env var prefix: UP_OTEL_* Exported metrics: - Sites: user/guest/IoT counts, AP/GW/SW counts, latency, uptime, tx/rx rates per subsystem - Clients: uptime, rx/tx bytes & rates; signal/noise/RSSI for wireless - UAP: up, uptime, CPU/mem, load, per-radio channel/power, per-VAP station count/satisfaction/bytes - USW: up, uptime, CPU/mem, load, aggregate rx/tx bytes, per-port up/speed/bytes/packets/errors/dropped/PoE - USG: up, uptime, CPU/mem, load, per-WAN rx/tx bytes/packets/errors - UDM/UXG: up, uptime, CPU/mem, load averages Closes #933 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(otelunifi): rename unused ctx parameter to _ in recordGauge Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(otelunifi): replace Disable with Enable (default false) Plugin is opt-in: set enable=true / UP_OTEL_ENABLE=true to activate. Closes part of #933. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package otelunifi
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/unpoller/unpoller/pkg/webserver"
|
|
)
|
|
|
|
// Logf logs an informational message.
|
|
func (u *OtelOutput) Logf(msg string, v ...any) {
|
|
webserver.NewOutputEvent(PluginName, PluginName, &webserver.Event{
|
|
Ts: time.Now(),
|
|
Msg: fmt.Sprintf(msg, v...),
|
|
Tags: map[string]string{"type": "info"},
|
|
})
|
|
|
|
if u.Collector != nil {
|
|
u.Collector.Logf(msg, v...)
|
|
}
|
|
}
|
|
|
|
// LogErrorf logs an error message.
|
|
func (u *OtelOutput) LogErrorf(msg string, v ...any) {
|
|
webserver.NewOutputEvent(PluginName, PluginName, &webserver.Event{
|
|
Ts: time.Now(),
|
|
Msg: fmt.Sprintf(msg, v...),
|
|
Tags: map[string]string{"type": "error"},
|
|
})
|
|
|
|
if u.Collector != nil {
|
|
u.Collector.LogErrorf(msg, v...)
|
|
}
|
|
}
|
|
|
|
// LogDebugf logs a debug message.
|
|
func (u *OtelOutput) LogDebugf(msg string, v ...any) {
|
|
webserver.NewOutputEvent(PluginName, PluginName, &webserver.Event{
|
|
Ts: time.Now(),
|
|
Msg: fmt.Sprintf(msg, v...),
|
|
Tags: map[string]string{"type": "debug"},
|
|
})
|
|
|
|
if u.Collector != nil {
|
|
u.Collector.LogDebugf(msg, v...)
|
|
}
|
|
}
|