Last active
September 17, 2023 20:13
-
-
Save ulexxander/b4554a95f3e8140a508779ee337c1b41 to your computer and use it in GitHub Desktop.
Prometheus docker_sd relabel configs to be able to use prometheus.io scrape, path and port container labels, just like we do in Kubernetes!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global: | |
scrape_interval: 10s | |
scrape_configs: | |
- job_name: docker_sd | |
docker_sd_configs: | |
- host: unix:///var/run/docker.sock | |
refresh_interval: 10s | |
relabel_configs: | |
- action: keep | |
source_labels: | |
- __meta_docker_container_label_prometheus_io_scrape | |
regex: true | |
- source_labels: | |
- __meta_docker_container_label_prometheus_io_path | |
regex: (.+) | |
target_label: __metrics_path__ | |
- source_labels: | |
- __address__ | |
- __meta_docker_container_label_prometheus_io_port | |
regex: (.*):(\d+);(\d+) | |
replacement: ${1}:${3} | |
target_label: __address__ | |
- source_labels: | |
- __meta_docker_container_id | |
target_label: container_id | |
- source_labels: | |
- __meta_docker_container_name | |
target_label: container_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example Docker Compose: