From b44a842d088241cab8539213c383fe9de3d1a4fa Mon Sep 17 00:00:00 2001 From: Alexandru Giurgiu Date: Thu, 30 Mar 2017 13:03:28 +0300 Subject: [PATCH] added some information to the README and added Swarm placement constraints to the compose file --- README.md | 19 ++++++++++++++++++- docker-compose.yaml | 10 ++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cc552fe..faaf67b 100644 --- a/README.md +++ b/README.md @@ -1 +1,18 @@ -# prometheus-swarm-discovery +# Prometheus-Swarm service discovery + +This is POC that demonstrates Prometheus service discovery in Docker Swarm. It is implemented as a standalone tool +that writes the scrape targets to a file, that is then read by Prometheus. This uses the `` config +directive available in Prometheus. + +The discovery tool expects to have access to the Swarm API using `/var/run/docker.sock`. The provided `docker-compose.yaml` +is configured to mount the `docker.sock` file inside the container, and this requires that the `swarm-discover` container +is placed on the Swarm manager node. + +## Run Prometheus and the Swarm discovery tool + +The only thing required to run Prometheus and the discovery tool is to launch a Swarm stack using the provided docker-compose.yaml +file. + +``` +$ docker stack deploy -c docker-compose.yaml prometheus +``` diff --git a/docker-compose.yaml b/docker-compose.yaml index 9133e0b..63c0a19 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,6 +9,9 @@ services: - swarm-endpoints:/swarm-endpoints/ labels: prometheus.ignore: "true" + placement: + constraints: + - node.role == manager prometheus: image: prom/prometheus:v1.5.2 ports: @@ -16,7 +19,10 @@ services: volumes: - ./prometheus-configs/:/etc/prometheus - swarm-endpoints:/etc/swarm-endpoints/ - command: ["-storage.local.retention=48h", "-storage.local.memory-chunks=1048576", "-config.file=/etc/prometheus/prometheus.yaml"] + command: ["-storage.local.retention=2h", "-storage.local.memory-chunks=1048576", "-config.file=/etc/prometheus/prometheus.yaml"] + placement: + constraints: + - node.role == manager volumes: - swarm-endpoints: \ No newline at end of file + swarm-endpoints: