2020-07-09 11:05:21 -07:00
|
|
|
# A example scrape configuration for running Prometheus with
|
|
|
|
# Docker Swarm.
|
|
|
|
|
|
|
|
scrape_configs:
|
|
|
|
|
|
|
|
# Make Prometheus scrape itself for metrics.
|
|
|
|
- job_name: 'prometheus'
|
|
|
|
static_configs:
|
|
|
|
- targets: ['localhost:9090']
|
|
|
|
|
2020-07-17 15:25:06 -07:00
|
|
|
# Create a job for Docker daemons.
|
|
|
|
#
|
|
|
|
# This exemple requires Docker daemons to be configured to expose
|
|
|
|
# Prometheus metrics, as documented here:
|
|
|
|
# https://docs.docker.com/config/daemon/prometheus/
|
|
|
|
- job_name: 'docker'
|
|
|
|
dockerswarm_sd_configs:
|
|
|
|
- host: unix:///var/run/docker.sock # You can also use http/https to connect to the Docker daemon.
|
|
|
|
role: nodes
|
|
|
|
relabel_configs:
|
|
|
|
# Fetch metrics on port 9323.
|
|
|
|
- source_labels: [__meta_dockerswarm_node_address]
|
|
|
|
target_label: __address__
|
|
|
|
replacement: $1:9323
|
|
|
|
|
2020-07-09 11:05:21 -07:00
|
|
|
# Create a job for Docker Swarm containers.
|
2020-07-17 15:25:06 -07:00
|
|
|
#
|
|
|
|
# This example works with cadvisor deployed with:
|
|
|
|
# docker service create --name cadvisor -l prometheus-job=cadvisor
|
|
|
|
# --mode=global --publish published=8080,target=8080,mode=host
|
|
|
|
# --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock,ro
|
|
|
|
# --mount type=bind,src=/,dst=/rootfs,ro
|
|
|
|
# --mount type=bind,src=/var/run,dst=/var/run
|
|
|
|
# --mount type=bind,src=/sys,dst=/sys,ro
|
|
|
|
# --mount type=bind,src=/var/lib/docker,dst=/var/lib/docker,ro
|
|
|
|
# google/cadvisor -docker_only
|
2020-07-09 11:05:21 -07:00
|
|
|
- job_name: 'dockerswarm'
|
|
|
|
dockerswarm_sd_configs:
|
2020-07-17 15:25:06 -07:00
|
|
|
- host: unix:///var/run/docker.sock # You can also use http/https to connect to the Docker daemon.
|
2020-07-09 11:05:21 -07:00
|
|
|
role: tasks
|
|
|
|
relabel_configs:
|
|
|
|
# Only keep containers that should be running.
|
|
|
|
- source_labels: [__meta_dockerswarm_task_desired_state]
|
|
|
|
regex: running
|
|
|
|
action: keep
|
|
|
|
# Only keep containers that have a `prometheus-job` label.
|
|
|
|
- source_labels: [__meta_dockerswarm_service_label_prometheus_job]
|
|
|
|
regex: .+
|
|
|
|
action: keep
|
|
|
|
# Use the task labels that are prefixed by `prometheus-`.
|
|
|
|
- regex: __meta_dockerswarm_service_label_prometheus_(.+)
|
|
|
|
action: labelmap
|
|
|
|
replacement: $1
|
|
|
|
|