Skip to content

Caddy

Prometheus Metrics

Caddy is a powerful, extensible web server with automatic HTTPS.

Caddy 2 includes native Prometheus support, but metrics must be explicitly enabled.

Option 1: Using the Caddyfile

Add the metrics directive inside your servers block:

{
servers {
metrics
}
}

Option 2: Using the command-line flag

Start Caddy with the --metrics flag:

Terminal window
caddy run --metrics

Once enabled, metrics are available at http://localhost:2019/metrics.

Terminal window
sudo tee /etc/glouton/conf.d/99-caddy.conf > /dev/null << 'EOF'
metric:
prometheus:
targets:
- url: "http://localhost:2019/metrics"
name: "caddy"
allow_metrics:
- "caddy_http_requests_total"
- "caddy_http_request_duration_seconds*"
- "caddy_http_response_size_bytes*"
- "caddy_reverse_proxy_upstreams_healthy"
EOF

Glouton automatically detects configuration changes.

Metric Description
caddy_http_requests_total Total number of HTTP requests handled by Caddy
caddy_http_request_duration_seconds Histogram of HTTP request durations in seconds
caddy_http_response_size_bytes Histogram of HTTP response body sizes in bytes
caddy_reverse_proxy_upstreams_healthy Number of healthy upstream backends for the reverse proxy