Skip to main content

Metrics and Monitoring

Caddy exposes Prometheus metrics for monitoring server health, performance, and operational statistics. Metrics are available through both the admin API and a configurable handler.

Admin Metrics Endpoint

By default, metrics are available on the admin endpoint:
The admin metrics endpoint is enabled by default and requires no configuration.

Metrics Handler

Expose metrics on a public endpoint:

Disable OpenMetrics

If your monitoring system doesn’t support OpenMetrics format:

Available Metrics

HTTP Metrics

Request Count
Request Duration
Request Size
Response Size
Requests In Flight

Reverse Proxy Metrics

Upstream Request Count
Upstream Healthy
Upstream Request Duration

TLS Metrics

Handshakes Total
Client Certificates

Admin API Metrics

Request Count
Request Errors

Prometheus Configuration

Configure Prometheus to scrape Caddy metrics:
prometheus.yml

Grafana Dashboard

Example Grafana queries:

Request Rate

Error Rate

Response Time (95th percentile)

Upstream Health

Securing Metrics

Protect your metrics endpoint:

Alert Rules

Example Prometheus alert rules:

Custom Metrics

Register custom metrics in Caddy modules:

Complete Example

Monitoring Stack

Typical monitoring setup:

Performance Impact

Metrics collection has minimal performance overhead. Caddy uses efficient Prometheus client libraries with lock-free operations where possible.

Best Practices

Combine metrics with structured logging for complete observability. Use correlation IDs to trace requests across both systems.