Commit Graph

67 Commits

Author SHA1 Message Date
Cody Lee
6c5ff5482d feat(promunifi): add unifi_controller_up gauge metric (closes #356) (#974)
Add a per-controller `<namespace>_controller_up` Prometheus GaugeVec with
a `source` label (controller URL or configured ID). The gauge is set to 1
after each successful poll and 0 on failure, giving operators a standard
metric to alert on controller connectivity issues.

Changes:
- pkg/poller/config.go: add ControllerStatus type and ControllerStatuses
  field to Metrics so any output plugin can consume per-controller health.
- pkg/poller/inputs.go: merge ControllerStatuses when AppendMetrics is
  called (multiple input sources).
- pkg/inputunifi/interface.go: populate ControllerStatuses with Up=true
  on success and Up=false (while still continuing) on per-controller error.
- pkg/promunifi/collector.go: declare and register a prometheus.GaugeVec
  `<namespace>_controller_up`; set the gauge for each controller status
  after every Collect cycle.

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 15:25:00 -05:00
brngates98
ca568384d1 feat: add controller sysinfo metrics (unpoller#927)
- Add Sysinfo collection from stat/sysinfo endpoint
- Export controller_info, uptime, update_available, data retention, ports
- Hostname fallback: name, then site_name when API omits hostname
- Apply site name override to Sysinfo for remote/cloud
- Add Discover/Discoverer for endpoint discovery
- Require unpoller/unifi v5.15.0

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-01-31 20:25:56 -05:00
brngates98
9cfb732c11 Replace Python endpoint-discovery with --discover flag (replaces #936)
- Add --discover and --discover-output to unpoller; uses first unifi
  controller from config to probe known API endpoints and write a
  shareable markdown report.
- Add Discoverer interface and RunDiscover(); inputunifi implements
  Discoverer via unifi.DiscoverEndpoints.
- Remove tools/endpoint-discovery/ (Python/Playwright).
- Add docs/PR_936_REPLACEMENT.md. .gitignore: test config and report.

Requires unpoller/unifi with DiscoverEndpoints (replace in go.mod until
unifi release).
2026-01-30 20:17:00 -05:00
brngates98
aac4917da7 feat: Add WAN metrics export to Prometheus
Add comprehensive WAN metrics support to unpoller:

WAN Configuration Metrics:
- wan_failover_priority: WAN failover priority
- wan_load_balance_weight: Load balancing weight
- wan_provider_download_kbps: Configured ISP download speed
- wan_provider_upload_kbps: Configured ISP upload speed
- wan_smartq_enabled: SmartQueue QoS status
- wan_magic_enabled: Magic WAN status
- wan_vlan_enabled: VLAN configuration status

WAN Statistics Metrics:
- wan_uptime_percentage: WAN uptime percentage
- wan_peak_download_percent: Peak download utilization
- wan_peak_upload_percent: Peak upload utilization
- wan_max_rx_bytes_rate: Maximum receive rate
- wan_max_tx_bytes_rate: Maximum transmit rate

WAN Service Provider Metrics:
- wan_service_provider_asn: ISP autonomous system number

Labels include:
- wan_id, wan_name, wan_networkgroup
- wan_type (dhcp, static, pppoe)
- wan_load_balance_type (weighted, failover-only)
- isp_name, isp_city (service provider metrics)
- site_name, source

Changes:
- pkg/poller/config.go: Add WANConfigs field to Metrics struct
- pkg/poller/inputs.go: Append WAN configs in metric aggregation
- pkg/inputunifi/input.go: Add WANConfigs field to Metrics struct
- pkg/inputunifi/collector.go: Fetch WAN enriched configuration
- pkg/promunifi/wan.go: New WAN metrics exporter
- pkg/promunifi/collector.go: Initialize and export WAN metrics

Depends on: unpoller/unifi PR (WAN API support)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-01-29 17:24:12 -05:00
brngates98
74c30eabe6 feat: Add DHCP lease metrics export to Prometheus
- Add DHCP lease fetching in inputunifi collector
- Create promunifi/dhcp_leases.go with network-level and per-lease metrics
- Network-level metrics: pool_size, active_leases, utilization_percent, free_percent, available_ips
- Per-lease metrics: is_static, lease_end, lease_start, lease_time
- Separate network-level pool metrics from per-lease metrics
2026-01-28 21:42:44 -05:00
Cody Lee
07781214c3 Add config option to suppress unknown device type messages
Adds log_unknown_types config option (default: false) to control logging
of unknown UniFi device types. When disabled (default), unknown devices
are silently ignored to reduce log volume. When enabled, they are logged
as DEBUG messages instead of ERROR. Addresses issue #912.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-25 11:24:33 -06:00
aharper343
f7d488a887 Lint and format cleanup 2025-12-24 12:09:19 -05:00
aharper343
0b9d3de5cc First working version DPI metrics and traffic exported 2025-12-24 00:23:00 -05: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
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>
2025-12-09 08:11:21 -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
6f4384c18d fix linting 2025-12-03 11:40:21 -06:00
Cody Lee
4b19b873ab address issue 2025-04-04 08:33:58 -05:00
Cody Lee
7e87e7f4fb rename package per per comment, add comments, and drop unnecessary compile time check 2023-08-03 09:27:09 -05:00
Cody Lee
ffb8579369 add integration test guard;
datadog integration test works

influx package tests

update unifi version

golanglint-ci and address *all* issues.

all tests pass

bump unifi version
2023-07-31 14:40:33 -05:00
Cody Lee
c002283387 fixes the webserver default file path issues 2023-04-13 09:56:24 -05:00
Cody Lee
3768c53512 CLI works 2022-12-22 18:16:43 -06:00
Cody Lee
db9bcd5687 add new interface for testing 2022-12-22 17:44:39 -06:00
Cody Lee
ea64bbad45 parallize input initialization to speed up startup time for large number of inputs 2022-12-18 09:00:55 -06:00
Cody Lee
fded91ce40 fixed start loop 2022-12-11 13:00:40 -06:00
Cody Lee
4259d4f396 fix the default missing config based off example config, this was affecting #443 2022-12-09 10:01:47 -06:00
Cody Lee
bd51cf59f3 move to a common pattern on output plugins to catch common issues 2022-12-05 22:00:48 -06:00
Cody Lee
247cc868b3 go 1.19 interface{} -> any 2022-12-03 16:32:12 -06:00
Cody Lee
1900e69d7a all to pkg 2022-12-02 20:48:01 -05:00
davidnewhall2
5e203701b5 initial 2019-12-28 17:08:16 -08:00
davidnewhall2
bd0680b92a Add DPI collection 2019-12-27 23:59:16 -08:00
davidnewhall2
6facff1337 deps 2019-12-25 01:02:36 -08:00
davidnewhall2
84edadaa94 Make a new docker image 2019-12-24 23:43:49 -08:00
davidnewhall2
de16ba2399 fixes 2019-12-20 02:44:53 -08:00
davidnewhall2
17e7c8edb3 allow dynamic controller scrapes 2019-12-19 19:59:51 -08:00
davidnewhall2
1dd5b4761c Update deps 2019-12-19 00:29:56 -08:00
davidnewhall2
9022ab288d allow pulling specific sites through output plugins 2019-12-17 02:39:36 -08:00
davidnewhall2
da75406310 fixes 2019-12-17 02:09:30 -08:00
davidnewhall2
d3d420597e make dumper work 2019-12-17 01:31:30 -08:00
davidnewhall2
44c544d8e1 Add dynamic plugin support 2019-12-16 03:11:40 -08:00
davidnewhall2
0b8473657e convert input to plugin 2019-12-15 20:56:42 -08:00
davidnewhall2
4e48247f54 fix tests 2019-12-15 13:15:00 -08:00
davidnewhall2
1def43a4be trimming 2019-12-15 03:27:34 -08:00
davidnewhall2
072d0689d0 fix import 2019-12-15 02:57:08 -08:00
davidnewhall2
ac39d1727f make output plugins call in to initialize 2019-12-15 02:52:43 -08:00
davidnewhall2
60d645c1a7 re-do re-auth 2019-12-14 20:01:51 -08:00
davidnewhall2
0462bb7669 remove naked return 2019-12-14 19:42:03 -08:00
davidnewhall2
510251252b update docs 2019-12-14 19:37:41 -08:00
davidnewhall2
4f987d3225 fixes 2019-12-14 18:55:10 -08:00
davidnewhall2
062fb797de should be good 2019-12-14 18:31:13 -08:00
davidnewhall2
e220610df7 nearly there 2019-12-14 18:10:35 -08:00
davidnewhall2
e421306b3e Merge remote-tracking branch 'origin/master' into dn2_multi_controller 2019-12-14 16:29:45 -08:00
davidnewhall2
f4ae4fc5e5 switch to config package 2019-12-14 16:29:29 -08:00
Ben Kochie
e575ee51ec Use the same namespace for collector and version.
Signed-off-by: Ben Kochie <superq@gmail.com>
2019-12-14 10:02:45 +01:00
Ben Kochie
e21c3de5a2 Add a build info metric to Prometheus
Include `unifi_poller_build_info` as a Prometheus metric.

Signed-off-by: Ben Kochie <superq@gmail.com>
2019-12-13 23:56:14 +01:00