Skip to content

expose Prometheus metrics and health endpoints #111

Description

@lenny-ts

Summary

Add an optional HTTP server exposing Prometheus metrics and Kubernetes-friendly health endpoints.

Caddy already provides application/server metrics, but caddy-analyzer can expose security-specific operational metrics that Caddy itself does not provide.

Proposed CLI

caddy-analyze guard   --metrics-listen :9090

Possible endpoints:

GET /metrics
GET /healthz
GET /readyz

Proposed Metrics

caddy_analyzer_requests_total

caddy_analyzer_detections_total{
  category="sql_injection"
}

caddy_analyzer_guard_blocks_total{
  reason="scanner"
}

caddy_analyzer_guard_blocked_ips

caddy_analyzer_suppressed_detections_total{
  category="sql_injection"
}

caddy_analyzer_guard_errors_total

caddy_analyzer_rule_matches_total{
  rule="SQLI-0042"
}

Health Endpoints

/healthz

Should indicate whether the process is alive.

/readyz

Should validate that required runtime dependencies are operational, for example:

  • log source can be read;
  • Guard state can be accessed;
  • firewall backend is available when Guard is enabled;
  • rule configuration is valid.

Security

The metrics endpoint should listen on localhost by default unless explicitly configured otherwise.

Optional support:

--metrics-listen 127.0.0.1:9090

Acceptance Criteria

  • /metrics exposes Prometheus-compatible metrics.
  • /healthz returns process health.
  • /readyz performs basic readiness checks.
  • Metrics HTTP server is disabled by default.
  • Listen address is configurable.
  • Security metrics do not duplicate unrelated Caddy metrics.
  • Helm chart can use the health endpoints for probes.
  • Documentation includes a Prometheus scrape example.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions