Commit Graph

4864 Commits

Author SHA1 Message Date
brngates98
0cb331a745 Fix golangci-lint empty-block errors in input.go
Remove empty if blocks by inverting conditions:
- Line 289: Invert Remote check for URL default
- Line 303: Invert APIKey check in Remote mode
- Line 401: Invert Remote check for URL default in setControllerDefaults
2026-01-25 08:34:06 -05:00
brngates98
28e77d1ac5 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
2026-01-24 22:26:49 -05:00
brngates98
3996fd8683 Format code with gofmt 2026-01-24 18:22:40 -05:00
brngates98
d0abba6ddb Improve site name override to handle all default site name variations
- Add isDefaultSiteName helper to match any site name containing 'default' (case-insensitive)
- Handles variations like 'Default', 'default', 'Default (default)', etc.
- Ensures site_name in metrics shows console names instead of generic 'Default' values
- Makes metrics more compatible with existing dashboards that expect meaningful site names
- Also checks SiteName field on sites in addition to Name field
2026-01-24 18:22:34 -05:00
brngates98
1440f1426e Fix site name override for remote API Cloud Gateways
- Keep actual site name 'default' for API calls to prevent 404 errors
- Apply site name override only in metrics for display purposes
- Fixes issue where console names were used in API paths causing 404s
- Site name override now correctly applied to devices, clients, sites, and rogue APs in metrics only
2026-01-24 17:46:32 -05:00
brngates98
5f76c59fa2 fix duplicate controllers due to cloud gateways site being default 2026-01-24 17:42:54 -05:00
brngates98
28eae6ab22 Add remote API support for UniFi Site Manager
- Add remote API mode with automatic controller discovery
- Discover consoles via /v1/hosts endpoint
- Auto-discover sites for each console via integration API
- Use console name from hosts response as site name override for Cloud Gateways
- Support both config-level and per-controller remote mode
- Add example configs for YAML, JSON, and TOML formats
- Remote API uses api.ui.com with X-API-Key authentication
- Automatically discovers all consoles when remote=true and remote_api_key is set

This enables monitoring multiple UniFi Cloud Gateways through a single
API key without requiring direct network access to each controller.
2026-01-24 17:32:36 -05:00
Cody Lee
1df4ba9932 Merge pull request #908 from unpoller/dependabot/go_modules/all-cf2caa1bb8
Bump golang.org/x/crypto from 0.46.0 to 0.47.0 in the all group
2026-01-23 16:10:14 -07:00
dependabot[bot]
dc0cacd615 Bump golang.org/x/crypto from 0.46.0 to 0.47.0 in the all group
Bumps the all group with 1 update: [golang.org/x/crypto](https://github.com/golang/crypto).


Updates `golang.org/x/crypto` from 0.46.0 to 0.47.0
- [Commits](https://github.com/golang/crypto/compare/v0.46.0...v0.47.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.47.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-19 02:53:41 +00:00
Cody Lee
f47b463384 Merge pull request #907 from unpoller/dependabot/go_modules/all-0542acbba5 2026-01-13 06:02:42 -06:00
dependabot[bot]
2a2dfb0e59 Bump the all group with 2 updates
Bumps the all group with 2 updates: [github.com/prometheus/common](https://github.com/prometheus/common) and [golang.org/x/term](https://github.com/golang/term).


Updates `github.com/prometheus/common` from 0.67.4 to 0.67.5
- [Release notes](https://github.com/prometheus/common/releases)
- [Changelog](https://github.com/prometheus/common/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/common/compare/v0.67.4...v0.67.5)

Updates `golang.org/x/term` from 0.38.0 to 0.39.0
- [Commits](https://github.com/golang/term/compare/v0.38.0...v0.39.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/common
  dependency-version: 0.67.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: golang.org/x/term
  dependency-version: 0.39.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-12 02:46:23 +00:00
Cody Lee
c71cc9a681 Merge pull request #905 from aharper343/fix/nil-dereference v2.21.0 2025-12-24 13:25:50 -06:00
aharper343
25ba0bd14a Fix incorrect initialization of SaveTraffic 2025-12-24 14:08:47 -05:00
Cody Lee
db85517166 Merge pull request #903 from aharper343/feat/traffic-support 2025-12-24 12:55:07 -06:00
aharper343
f7d488a887 Lint and format cleanup 2025-12-24 12:09:19 -05:00
aharper343
9b62519bfe Rebasing 2025-12-24 00:25:09 -05:00
aharper343
6205900446 Adding constants for periods and debug logs for retrieved counts 2025-12-24 00:23:05 -05:00
aharper343
ab7073d63d Added support for regions and sub-regions 2025-12-24 00:23:05 -05:00
aharper343
22dfc25801 Temp fix for test cases and warning from Dockerfile 2025-12-24 00:23:05 -05:00
aharper343
0b9d3de5cc First working version DPI metrics and traffic exported 2025-12-24 00:23:00 -05:00
Cody Lee
bb4a4c823f Merge pull request #902 from svennergr/fix/http-timeout-config v2.20.1 2025-12-23 07:55:44 -06:00
Sven Grossmann
7e59c4883b fix: add HTTP timeout configuration to prevent indefinite hangs
The UniFi controller HTTP client was created without a timeout, causing
unpoller to hang indefinitely when the controller becomes unresponsive.
This resulted in random stops where polling would cease until the
container was restarted.

Changes:
- Add Timeout field to Controller struct (cnfg.Duration)
- Set default timeout of 60 seconds
- Pass timeout to unifi.Config when creating the client
- Log timeout value on startup for visibility

The timeout can be configured via:
- Config file: timeout = "60s"
- Environment: UP_UNIFI_DEFAULT_TIMEOUT=60s

Fixes issue where container would hang overnight:
  2025/12/22 22:29:27 - Requesting https://unifi/.../stat/sta
  [~2 hour gap - request hung indefinitely]
  2025/12/23 00:17:57 - Unmarshalling Device Type: udm...
2025-12-23 11:13:54 +01:00
Cody Lee
0d39302c19 Merge pull request #901 from svennergr/feature/protect-logs
feat: add UniFi Protect logs support with Loki integration
v2.20.0
2025-12-22 17:14:22 -06:00
Sven Grossmann
7e7fd0ff12 chore: upgrade to unifi 5.5.0 2025-12-22 23:41:24 +01:00
Sven Grossmann
07e1e5bc4d feat: add UniFi Protect logs support with Loki integration
- Add SaveProtectLogs config option to enable Protect log collection
- Add ProtectThumbnails config option to fetch event thumbnails
- Add collectProtectLogs function with 24h default fetch window
- Add ProtectLogEvent for Loki reporting with separate thumbnail log lines
- Add PII redaction for Protect log entries
- Filter thumbnail fetching to camera events only (motion, smartDetect*, etc.)
- Update log output to show Protect logs status
2025-12-22 22:55:30 +01:00
Cody Lee
703dff9b1e Merge pull request #900 from svennergr/svennergr/add-syslog 2025-12-22 11:33:22 -06:00
Sven Grossmann
02c7b6afa4 chore: upgrade to unifi 5.4.0 2025-12-22 18:16:00 +01:00
Sven Grossmann
47267073ac chore: comment out local replace directive for unifi module in go.mod 2025-12-22 17:28:42 +01:00
Sven Grossmann
a3dc4cd0b2 feat: add save_syslog option for v2 system-log API
Add new save_syslog config option to collect events from the v2 UniFi
system-log API (/v2/api/site/{site}/system-log/all).

Changes:
- Add SaveSyslog field to Controller struct
- Add collectSyslog() function using v2 API
- Keep collectEvents() using v1 API for backwards compatibility
- Add RedactIPPII() helper for PII redaction
- Update lokiunifi to log raw JSON (parseable with Loki | json)
- Reduce indexed labels to low-cardinality fields only
- Add SystemLogEntry handler in lokiunifi report

Config: save_syslog (v2 API) vs save_events (v1 API)
Env: UP_UNIFI_DEFAULT_SAVE_SYSLOG=true
2025-12-22 17:23:53 +01:00
Cody Lee
966cac1053 Merge pull request #899 from unpoller/dependabot/go_modules/all-74468f11a3 2025-12-15 05:56:36 -06:00
dependabot[bot]
0ab6e30d42 Bump github.com/DataDog/datadog-go/v5 in the all group
Bumps the all group with 1 update: [github.com/DataDog/datadog-go/v5](https://github.com/DataDog/datadog-go).


Updates `github.com/DataDog/datadog-go/v5` from 5.8.1 to 5.8.2
- [Release notes](https://github.com/DataDog/datadog-go/releases)
- [Changelog](https://github.com/DataDog/datadog-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/DataDog/datadog-go/compare/v5.8.1...v5.8.2)

---
updated-dependencies:
- dependency-name: github.com/DataDog/datadog-go/v5
  dependency-version: 5.8.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-15 02:01:23 +00:00
Cody Lee
9ba7ddcd11 Merge pull request #898 from unpoller/issue-350-counters
Add byte counters for InfluxDB and Prometheus outputs (issue #350)
v2.19.0
2025-12-11 11:02:02 -06:00
Cody Lee
a00aeb2eb5 Add byte counters for InfluxDB and Prometheus outputs (issue #350)
Track the number of bytes written per request for both InfluxDB and Prometheus outputs.

InfluxDB:
- Added bytesT counter constant
- Implemented calculateMetricBytes() to estimate line protocol size
- Updated batchV1() and batchV2() to count bytes per point
- Updated log output to display bytes written

Prometheus:
- Added Bytes field to Report struct
- Updated export() to calculate approximate metric byte size
- Updated log output to display bytes written

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-11 10:55:33 -06:00
Cody Lee
f86eb46192 Merge pull request #896 from unpoller/issue-841-fix-multi-wan-speedtests
Fix multi-WAN speed test reporting (issue #841)
v2.18.0
2025-12-09 16:53:56 -06:00
Cody Lee
0ffe6152ab Fix multi-WAN speed test reporting (issue #841)
Speed tests were not being reported correctly for multi-WAN setups
because the device-level speedtest-status field was returning zeros.
The data has moved to a new aggregated dashboard API endpoint.

Changes:
- Add GetSpeedTests() and GetSiteSpeedTests() methods to fetch from
  /v2/api/site/{site}/aggregated-dashboard endpoint
- Create SpeedTestResult data structures to capture per-WAN metrics
- Update Prometheus exporter with new speedtest_* metrics per interface
- Update InfluxDB exporter to write speedtest measurements per WAN
- Update Datadog exporter with unifi.speedtest.* metrics per WAN
- Update metrics collection to include speed test data for all sites

Metrics now include labels/tags for:
- wan_interface: Physical interface (eth8, eth9, etc.)
- wan_group: Logical WAN name (WAN, WAN2, etc.)
- site_name: Site identifier
- source: Controller URL

Gracefully handles older controllers without the new API endpoint.

Fixes #841

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 16:46:14 -06:00
Cody Lee
9b5dbef869 Merge pull request #894 from unpoller/enhance-ubb-support-409
Enhance ubb support 409
v2.17.2
2025-12-09 11:14:26 -06:00
Cody Lee
8000597fce Refactor Prometheus UBB label construction to use append
Replace manual array indexing (labels[1], labels[2], labels[3]) with
cleaner append syntax using slice notation (labels[1:]...).

This makes the code more maintainable and idiomatic Go.

Before: labelTotal := []string{"total", labels[1], labels[2], labels[3]}
After:  labelTotal := append([]string{"total"}, labels[1:]...)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 11:12:00 -06:00
Cody Lee
c61d2651a2 Enhance InfluxDB and Datadog UBB outputs with comprehensive metrics
This change significantly expands the metrics exported for UBB devices
to InfluxDB and Datadog, matching the comprehensive coverage added to
the Prometheus output.

Changes to InfluxDB (pkg/influxunifi/ubb.go):
- Added batchUBBstats() to export comprehensive statistics separated
  by radio (total, wifi0, terra2, user-wifi0, user-terra2)
- Added VAP table export via processVAPTable()
- Added Radio table export via processRadTable()
- Added P2P stats (rx_rate, tx_rate, throughput)
- Added link quality metrics (link_quality, link_quality_current,
  link_capacity)
- Comprehensive stats exported to new "ubb_stats" table with full
  breakdown of traffic per radio

Changes to Datadog (pkg/datadogunifi/ubb.go):
- Added batchUBBstats() to export comprehensive statistics separated
  by radio (total, wifi0, terra2, user-wifi0, user-terra2)
- Added VAP table export via processVAPTable()
- Added Radio table export via processRadTable()
- Added P2P stats (rx_rate, tx_rate, throughput)
- Added link quality metrics (link_quality, link_quality_current,
  link_capacity)
- Comprehensive stats exported with namespace "ubb.stats"

All implementations now fully support:
- 5GHz radio (wifi0) metrics
- 60GHz radio (terra2/ad) metrics - Full 802.11ad support!
- Per-radio RX/TX packets, bytes, errors, dropped, retries
- User-specific metrics for each radio
- Interface-specific metrics (ath0 for 5GHz, wlan0 for 60GHz)
- Point-to-point link statistics and quality metrics

Fixes: #409

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 11:04:35 -06:00
Cody Lee
ab2c677f30 uses new unifi lib 2025-12-09 10:48:45 -06:00
Cody Lee
6a135c60a7 Enhance UBB device support with comprehensive Prometheus metrics
This change significantly improves UniFi Building Bridge (UBB) device
support by adding comprehensive Prometheus metric exports.

UBB devices are point-to-point wireless bridges with dual radios:
- wifi0: 5GHz radio (802.11ac)
- terra2/wlan0/ad: 60GHz radio (802.11ad - Terragraph/WiGig)

Changes:
- Added exportUBBstats() to export UBB-specific statistics separated
  by radio (total, wifi0, terra2, user-wifi0, user-terra2)
- Added exportP2Pstats() to export point-to-point link metrics
  (rx_rate, tx_rate, throughput)
- Added VAP (Virtual Access Point) table export via existing exportVAPtable()
- Added Radio table export via existing exportRADtable() to capture
  60GHz radio metrics
- Added link quality metrics (link_quality, link_quality_current,
  link_capacity)
- Added comprehensive comments documenting UBB device characteristics
  and 60GHz band support

The implementation reuses existing UAP metric descriptors where
appropriate, allowing UBB metrics to be collected alongside UAP metrics
in Prometheus with proper labeling for differentiation.

Requires: unpoller/unifi#169 (UBB type definition fixes)
Fixes: #409

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 10:20:23 -06:00
Cody Lee
750f3f38c2 Merge pull request #893 from unpoller/fix-892-healthcheck-binding
Fix health check port binding conflict (issue #892)
2025-12-09 08:14:48 -06:00
Cody Lee
832334655c Fix health check port binding conflict (issue #892)
The Docker health check was attempting to bind to ports already in use by
the running application, causing "address already in use" errors. This fix
adds a health check mode that skips network binding operations while still
validating output configuration (listen addresses, paths, etc.).

Changes:
- Add health check mode flag in pkg/poller/outputs.go
- Update prometheus and webserver DebugOutput() to skip port binding in health check mode
- Maintain full configuration validation without network conflicts

Fixes #892

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
v2.17.1
2025-12-09 08:11:21 -06:00
Cody Lee
ae4cf462a0 Merge pull request #891 from unpoller/unifi-bump-5-2-0
bump unifi to v5.2.0
2025-12-08 13:59:37 -06:00
Cody Lee
f0ed2954b8 bump unifi to v5.2.0 2025-12-08 13:55:10 -06:00
Cody Lee
4e6ebee524 Merge pull request #890 from unpoller/docker-healthcheck
Add Docker health check support
v2.17.0
2025-12-08 13:25:57 -06:00
Cody Lee
b960695f3b Add Docker health check support
Implements #406 by adding a --health CLI flag and HEALTHCHECK instruction
to the Dockerfile. This allows Docker and container orchestration platforms
to monitor container health automatically.

Changes:
- Added --health flag that validates configuration and plugin connectivity
- Implemented HealthCheck() method in pkg/poller/commands.go
- Updated Dockerfile with HEALTHCHECK instruction (30s interval, 10s timeout)
- Updated MANUAL.md with --health flag documentation
- Added health check documentation to Docker README
- Added comments to docker-compose examples about built-in health check

The health check:
- Validates configuration file is found and parseable
- Ensures at least one input and one enabled output are configured
- Performs basic validation on enabled outputs
- Returns exit code 0 (healthy) or 1 (unhealthy)
- Runs silently for Docker compatibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-08 13:09:10 -06:00
Cody Lee
ef677c8f74 Merge pull request #887 from unpoller/dependabot/go_modules/all-2743cc9a87
Bump the all group across 1 directory with 5 updates
v2.16.0
2025-12-03 11:55:28 -06:00
Cody Lee
7e2fb0135e fix dd client interface change, update deprecated context lib in influxdb 2025-12-03 11:51:40 -06:00
dependabot[bot]
14b747cb1a Bump the all group across 1 directory with 5 updates
Bumps the all group with 3 updates in the / directory: [github.com/DataDog/datadog-go/v5](https://github.com/DataDog/datadog-go), [github.com/prometheus/common](https://github.com/prometheus/common) and [golang.org/x/crypto](https://github.com/golang/crypto).


Updates `github.com/DataDog/datadog-go/v5` from 5.7.0 to 5.8.1
- [Release notes](https://github.com/DataDog/datadog-go/releases)
- [Changelog](https://github.com/DataDog/datadog-go/blob/master/CHANGELOG.md)
- [Commits](https://github.com/DataDog/datadog-go/compare/v5.7.0...v5.8.1)

Updates `github.com/prometheus/common` from 0.66.1 to 0.67.4
- [Release notes](https://github.com/prometheus/common/releases)
- [Changelog](https://github.com/prometheus/common/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prometheus/common/compare/v0.66.1...v0.67.4)

Updates `golang.org/x/crypto` from 0.43.0 to 0.45.0
- [Commits](https://github.com/golang/crypto/compare/v0.43.0...v0.45.0)

Updates `golang.org/x/net` from 0.45.0 to 0.47.0
- [Commits](https://github.com/golang/net/compare/v0.45.0...v0.47.0)

Updates `golang.org/x/term` from 0.36.0 to 0.37.0
- [Commits](https://github.com/golang/term/compare/v0.36.0...v0.37.0)

---
updated-dependencies:
- dependency-name: github.com/DataDog/datadog-go/v5
  dependency-version: 5.8.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: github.com/prometheus/common
  dependency-version: 0.67.4
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: golang.org/x/crypto
  dependency-version: 0.45.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: golang.org/x/net
  dependency-version: 0.47.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: golang.org/x/term
  dependency-version: 0.37.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-03 17:45:00 +00:00
Cody Lee
647b3c0aea Merge pull request #888 from unpoller/dependabot/github_actions/all-14cb627f6c
Bump the all group with 2 updates
2025-12-03 11:43:49 -06:00