Commit Graph
38 Commits
Author SHA1 Message Date
Cody LeeandClaude Opus 5 d5dfc771d5 feat: add opt-in UNAS Pro support (closes #785)
Adds a new `unas` input plugin that polls UNAS Pro storage consoles and
exports console health, storage pools, disks and shares to Prometheus,
InfluxDB and DataDog.

UNAS is a separate plugin rather than a device type inside inputunifi
because a storage-only console has no Network application: it cannot
answer /status, has no sites, and shares none of the UniFi device schema.

The plugin is opt-in and inert until an operator names a console. Opt-in
is expressed as "no devices configured" rather than a `disable` flag,
because a bool named `disable` zero-values to false and so cannot make a
plugin default-off. Initialize returns silently on an empty device list
and, unlike inputunifi, nothing synthesizes a default URL.

Two behaviours are worth calling out for reviewers:

  - Metrics returns (metrics, nil) whenever any console was collected.
    poller.collectMetrics uses `if err != nil {} else if metric != nil`,
    so returning both would discard every healthy console because one
    failed. Only a total failure returns an error.

  - Re-auth fires on total failure, not on a 401. A mid-session 401 from
    GetData surfaces as ErrInvalidStatusCode, not ErrAuthenticationFailed,
    so there is no sentinel to match on. Session expiry fails all four
    endpoints at once, which is exactly the total-failure case.

Prometheus metrics use the `unifi_unas_` prefix, which diverges from the
`unas_` prefix used by the reference implementation; dashboards built
against that will need query edits.

Requires unifi/v5 v5.31.0 for the UNAS client and structs.

Credit to alexgreenbank/unaspoller for mapping the endpoints.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 07:52:37 -05:00
Cody LeeandClaude Sonnet 4.6 521c2f88bc feat(otelunifi): add OpenTelemetry output plugin (#978)
* 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>
2026-03-23 18:19:18 -05:00
Cody Lee 1900e69d7a all to pkg 2022-12-02 20:48:01 -05:00
Cody Lee 06594f67eb move to the pkg dir 2022-12-02 20:46:16 -05:00
Cody Lee babdf53f15 go mod tidy works again 2022-11-23 21:39:43 -06:00
Cody Lee 7f91dff9d3 cleanup 2022-11-23 21:21:24 -06:00
Cody Lee 52c9bffab7 more fixes 2022-11-23 21:13:50 -06:00
Cody Lee 68e71bde56 import path fixes 2022-11-23 21:10:53 -06:00
Cody Lee 4ce8a079d3 fix imports first pass 2022-11-23 20:59:50 -06:00
Cody Lee cec311bf3b minor fix 2022-11-23 20:55:33 -06:00
Cody Lee ca96b98cca more path changes 2022-11-23 20:46:52 -06:00
Cody Lee fbb28c15ab deal with golint on master branch failing CI for varnamelen lint check 2022-01-25 15:47:21 -06:00
Cody Lee 902afcd32e enable datadog collector as an option 2022-01-17 15:09:27 -06:00
David Newhall II 81ab41571e rename org 2021-06-23 03:27:48 -07:00
David Newhall II b0044155f5 add base for new features 2021-03-15 00:01:43 -07:00
davidnewhall2 cddf2942b0 re-arrangement 2020-07-19 00:10:36 -07:00
davidnewhall2 870421ef69 add web server code 2020-06-28 04:48:05 -07:00
davidnewhall2 a22c59be09 add loki support 2020-06-24 03:13:55 -07:00
davidnewhall2 13ce2fe6f6 updates 2020-06-21 02:43:08 -07:00
davidnewhall2 b7c83eebbb Add TZ env usage to set local time zone. 2020-06-13 18:50:32 -07:00
davidnewhall2 f13f902e7b Update deps 2020-02-01 19:19:18 -08:00
davidnewhall2 5267bc9e57 Update Imports 2019-12-30 16:28:09 -08:00
davidnewhall2 5e203701b5 initial 2019-12-28 17:08:16 -08:00
davidnewhall2 0b8473657e convert input to plugin 2019-12-15 20:56:42 -08:00
davidnewhall2 ac39d1727f make output plugins call in to initialize 2019-12-15 02:52:43 -08:00
davidnewhall2 ebe05ec3e5 move pkgs, update readme, add two more metrics to influx client 2019-11-30 01:45:42 -08:00
davidnewhall2 1b75963002 Updates 2019-11-25 00:17:59 -08:00
davidnewhall2 f6c73e7edb Rename all the packages 2019-11-12 00:36:49 -08:00
davidnewhall2 e2af4d9f72 rename internal package 2019-11-12 00:05:51 -08:00
David Newhall II b814a85155 move more 2019-06-24 01:20:35 -07:00
DN2 12ea5d0d47 Projectize the project. 2018-04-22 14:10:55 -07:00
DN2 3bcaab3c34 Shuffle things around a bit more. 2018-04-21 00:51:57 -07:00
DN2 8b1f682cf4 Split out config data. 2018-04-21 00:02:34 -07:00
DN2 863ed5c75a Restructure the code. 2018-04-20 23:42:03 -07:00
DN2 d0f1899311 Eliminate global variables. 2018-04-20 13:33:51 -07:00
DN2 b3159d55cf Minor Cleanup 2018-04-20 13:20:07 -07:00
Garrett Bjerkhoel cf2be3ede8 Clean up some of the code 2016-09-30 11:24:17 -07:00
Garrett Bjerkhoel c226f420b2 Build heroku compatible app 2016-09-30 00:08:55 -07:00