Container and Proxy Metrics
Use these patterns when you need container-level stats or reverse-proxy metrics. Both examples forward into the shared relabel pipeline defined in 01-global.alloy.
Example: Docker Metrics (cAdvisor)
04-docker-metrics.alloy
prometheus.exporter.cadvisor "local" {
docker_host = "unix:///var/run/docker.sock"
docker_only = true
disable_root_cgroup_stats = true
storage_duration = "5m"
}
prometheus.scrape "scraper" {
targets = prometheus.exporter.cadvisor.local.targets
forward_to = [ prometheus.relabel.common_labels.receiver ]
}
note
The Alloy service needs access to the Docker socket. Ensure the user running Alloy has permission to read /var/run/docker.sock.
Example: Traefik Metrics (Static Target + Relabel)
05-traefik.alloy
// Discovery block to set the address
discovery.relabel "traefik_node" {
targets = [{
__address__ = "localhost:8080",
}]
// Set a clean instance name
rule {
target_label = "instance"
replacement = "traefik-proxy"
}
}
// Scraper block
prometheus.scrape "traefik" {
targets = discovery.relabel.traefik_node.output
// Pointing to your global standardization gate
forward_to = [prometheus.relabel.common_labels.receiver]
job_name = "traefik"
}