Uncloud Prometheus, part II
Had some fun playing with my fork of Uncloud. And making metrics work.
Metrics are now part of Uncloud proper - uncloudplus can now drop it.
In prometheus we use dns_sd_configs to pick up new things automatically:
- job_name: uncloud
dns_sd_configs:
- names: ["m.internal"]
type: A
port: 51090
- job_name: caddy
dns_sd_configs:
- names: ["caddy.internal"]
type: A
port: 2019
For caddy metrics, we hack around a little… in the x-caddy file we deploy for Caddy add:
metrics {
per_host
}
But this serves metrics on localhost inside the container. So we need to export this, we can’t add this snippet:
http://:2019 {
handle {
metrics
}
}
Because this is something that does not belong in the global block.
So, we add another service that only adds this:
services:
caddy-metrics:
image: registry.science.ru.nl/cncz/sys/image/debug:v0.1.14
x-caddy: |
http://:2019 {
handle {
metrics
}
}
And deploy this do-nothing-but-update-caddy service. And voila, we have metrics finally.
You can scrape this with a Promethues snippet like:
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- localhost:9090
- job_name: uncloud
dns_sd_configs:
- names: ["m.internal"]
type: A
port: 51004
- job_name: caddy
dns_sd_configs:
- names: ["caddy.internal"]
type: A
port: 2019
Note the m.internal namespace needs this PR.
Read other posts