Commit Graph

22 Commits

Author SHA1 Message Date
aharper343 0b9d3de5cc First working version DPI metrics and traffic exported 2025-12-24 00:23:00 -05: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
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
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 cba1111f29
add support for api-key auth 2025-01-10 15:19:30 -06:00
Cody Lee b372198840
painful upgrade for dumb go versioning 2024-12-31 14:44:10 -06:00
Cody Lee 9bdc6e8d0f
auto fix lint rules 2024-09-09 08:55:12 -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 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 0e5d743182
Add support to completely remove PII
https://github.com/unpoller/unifi/issues/56
2022-12-21 20:34:32 -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
Cody Lee 06594f67eb
move to the pkg dir 2022-12-02 20:46:16 -05:00
davidnewhall2 5e203701b5 initial 2019-12-28 17:08:16 -08:00
davidnewhall2 ed3bed4c7b rename some things 2019-12-20 03:19:00 -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 9022ab288d allow pulling specific sites through output plugins 2019-12-17 02:39:36 -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