Metric your Caddy servers using Prometheus and Grafana with this simple plugin. It provided per-host metrics for your servers and more useful metrics.
Report Bug
-
Request Feature
With this caddy module built on bases of xcaddy you can easily monitor your caddy servers using Prometheus and Grafana. It provides per-host metrics for your servers and more useful metrics. It is possible to monitor your hosts on the same Prometheus port.
- xcaddy
- Prometheus Go client library
{
order advanced_metrics before file_server
order advanced_metrics before reverse_proxy
}
:8080 {
# Enable advanced metrics on port 1234 (http://localhost:1234/metrics)
advanced_metrics {
port 1234
counter true # extension proposed by `aboisvert`
latency true # extension proposed by `aboisvert`
}
# Enable file server
file_server
}
:8081 {
# Enable advanced metrics (default port 6611)
advanced_metrics {
counter true # extension proposed by `aboisvert`
latency false # extension proposed by `aboisvert`
}
# Enable file server
file_server
}
You can download the latest build from the releases page.
- Golang
- xcaddy
- Clone the repository
git clone https://github.com/sebastianbrunnert/caddy-advanced-metrics.git
- Install Golang dependencies
go mod download
- Build custom caddy binary using xcaddy
make build
- Run custom caddy binary
Now you can run your custom caddy binary with the advanced metrics module. You can use the following command to run the binary:
./caddy run --config ./examples/Caddyfile
or you can setup the caddy service using systemd.
nano /usr/lib/systemd/system/caddy.service
[Service]
ExecStart=/path/to/caddy run --config /path/to/Caddyfile
FROM alpine:3.18.4 AS build
RUN --mount=type=cache,target=/var/cache/apk \
apk add go=1.20.10-r0 git
RUN --mount=type=cache,target=/root/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go install github.com/caddyserver/xcaddy/cmd/xcaddy@v0.3.5
RUN --mount=type=cache,target=/root/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
~/go/bin/xcaddy build v2.7.5 \
--with github.com/greenpau/caddy-security \
--with github.com/aboisvert/caddy-advanced-metrics@add-latency \
--output dist/caddy
See the open issues for a list of proposed features (and known issues).
Distributed under the MIT License. See LICENSE for more information.