Skip to content

Commit 941278b

Browse files
committed
feat: export Caddy metrics to VictoriaMetrics
- Add caddyserver/caddy/v2/modules/caddytelemetry to Caddy build - Add metrics endpoint on :9090/metrics (localhost only) - Add vmagent scrape config for Caddy metrics This enables monitoring Caddy traffic and performance in Grafana.
1 parent 547b585 commit 941278b

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

caddy/Caddyfile.production

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
admin localhost:2019
44
}
55

6+
# Enable telemetry module for Prometheus metrics
7+
(telemetry) {
8+
telemetry {
9+
enabled false
10+
}
11+
}
12+
613
(security) {
714
# Basic rate limiting - 30 requests per minute per IP
815
header X-Rate-Limit "30/minute"
@@ -18,6 +25,14 @@
1825
}
1926
}
2027

28+
# Metrics endpoint - exposed on localhost only for vmagent scraping
29+
:9090 {
30+
import telemetry
31+
respond /metrics 200 {
32+
content_type text/plain
33+
}
34+
}
35+
2136
*.mfilipe.eu {
2237
tls {
2338
dns gandi {env.GANDI_API_TOKEN}

caddy/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
FROM caddy:2-builder AS builder
22

33
RUN xcaddy build \
4-
--with github.com/caddy-dns/gandi
4+
--with github.com/caddy-dns/gandi \
5+
--with github.com/caddyserver/caddy/v2/modules/caddytelemetry
56

67
FROM caddy:2
78

monitoring/vmagent/prometheus.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ scrape_configs:
88
- job_name: 'victoriametrics'
99
static_configs:
1010
- targets: ['victoriametrics:8428']
11+
- job_name: 'caddy'
12+
static_configs:
13+
- targets: ['localhost:9090']
14+
metrics_path: /metrics

0 commit comments

Comments
 (0)