Skip to content

Comments

feat: add group_count metric and status file to health endpoint#26

Closed
wolffcatskyy wants to merge 1 commit intomainfrom
feat/health-improvements
Closed

feat: add group_count metric and status file to health endpoint#26
wolffcatskyy wants to merge 1 commit intomainfrom
feat/health-improvements

Conversation

@wolffcatskyy
Copy link
Owner

Summary

  • Add group_count field to health endpoint JSON response
  • Add HEALTH_STATUS_FILE env var for writing status to a JSON file (for file-based monitors)

Closes #6

New health response

{
  "status": "healthy",
  "version": "1.5.0",
  "uptime_seconds": 3600,
  "crowdsec_connected": true,
  "unifi_connected": true,
  "last_sync_time": 1706500000.123,
  "last_sync_ips": 4521,
  "group_count": 5,
  "last_error": null,
  "memory_mb": 45.2
}

New env var

Variable Default Description
HEALTH_STATUS_FILE (empty) Path to write status JSON file (e.g., /tmp/bouncer-status.json)

Test plan

  • Check /health endpoint includes group_count field
  • Set HEALTH_STATUS_FILE=/tmp/bouncer-status.json, verify file is written after sync
  • Verify status file contains valid JSON with all metrics
  • Without HEALTH_STATUS_FILE set, verify no file is written (no errors)

Generated with Claude Code

Closes #6

- Add group_count to health status JSON response
- Add HEALTH_STATUS_FILE env var for writing status to a JSON file
- Status file written after each sync for file-based monitoring tools
- HealthStatus.set_last_sync() now accepts group_count parameter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@wolffcatskyy
Copy link
Owner Author

Closing: this PR modifies bouncer.py which was removed in the v2.0 rewrite (commit 9c124fc). The project has moved from a Python Docker-based bouncer to the native CrowdSec firewall bouncer running directly on UniFi OS with ipset/iptables.

Health endpoint improvements are no longer applicable — the native Go bouncer does not use a Python HTTP health endpoint. Health monitoring in v2.0 is done via systemd service status (systemctl status crowdsec-firewall-bouncer) and ensure-rules.sh cron checks.

@wolffcatskyy wolffcatskyy deleted the feat/health-improvements branch February 4, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Health monitoring endpoint

1 participant