Added initial infrastructure for declarative prometheus configs and established alloy integration for Traefik

This commit is contained in:
Root User 2026-02-14 18:49:10 +01:00
parent d5920fb8fa
commit 2665a2c0e5
Signed by: root
GPG key ID: 087F0A95E5766D72
3 changed files with 178 additions and 0 deletions

View file

@ -93,10 +93,47 @@ in {
};
};
services.alloy = {
enable = true;
};
# See: https://github.com/grafana/alloy/blob/bbe11b0f6a3bd3391108b2d27122c654c535dd8d/docs/sources/set-up/migrate/from-promtail.md
environment.etc."alloy/config.alloy" = {
text = ''
discovery.relabel "metrics_integrations_integrations_traefik" {
targets = [{
__address__ = "localhost:8080",
}]
rule {
target_label = "instance"
replacement = constants.hostname
}
}
prometheus.scrape "metrics_integrations_integrations_traefik" {
targets = discovery.relabel.metrics_integrations_integrations_traefik.output
forward_to = [prometheus.remote_write.metrics_service.receiver]
job_name = "integrations/traefik"
}
'';
group = "root";
mode = "0644";
};
services.traefik = {
enable = true;
group = "acme";
staticConfigOptions = {
metrics = {
prometheus = {
addEntryPointsLabels = true;
addRoutersLabels = true;
addServicesLabels = true;
entryPoint = "metrics";
};
};
entryPoints = {
web = {
# Bind on IPv6 as well as IPv4 by using [::]:80