mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 05:04:05 -08:00
Add Docker Swarm configuration example (#7542)
Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
parent
d017777985
commit
be96951c56
|
@ -576,6 +576,9 @@ basic_auth:
|
|||
[ bearer_token_file: <filename> ]
|
||||
```
|
||||
|
||||
See [this example Prometheus configuration file](/documentation/examples/prometheus-dockerswarm.yml)
|
||||
for a detailed example of configuring Prometheus for Docker Swarm.
|
||||
|
||||
### `<dns_sd_config>`
|
||||
|
||||
A DNS-based service discovery configuration allows specifying a set of DNS
|
||||
|
|
39
documentation/examples/prometheus-dockerswarm.yml
Normal file
39
documentation/examples/prometheus-dockerswarm.yml
Normal file
|
@ -0,0 +1,39 @@
|
|||
# A example scrape configuration for running Prometheus with
|
||||
# Docker Swarm.
|
||||
#
|
||||
# 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
|
||||
|
||||
scrape_configs:
|
||||
|
||||
# Make Prometheus scrape itself for metrics.
|
||||
- job_name: 'prometheus'
|
||||
static_configs:
|
||||
- targets: ['localhost:9090']
|
||||
|
||||
# Create a job for Docker Swarm containers.
|
||||
- job_name: 'dockerswarm'
|
||||
dockerswarm_sd_configs:
|
||||
- host: http://127.0.0.1:2375
|
||||
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
|
||||
|
Loading…
Reference in a new issue