From 7b5657d006d8e700d7313d2d6bfc6bcf43551220 Mon Sep 17 00:00:00 2001 From: llitfkitfk Date: Fri, 11 Aug 2017 17:53:45 +0800 Subject: [PATCH 1/4] update docker-compose.yml to support swarm mode --- docker-compose.yml | 60 ++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7a1d66e..4ade879 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,38 +1,41 @@ -version: '2' +version: '3' volumes: - prometheus_data: {} - grafana_data: {} + prometheus-config: + external: + name: prometheus-config + prometheus-data: + grafana-data: + alertmanager-config: + external: + name: alertmanager-config networks: front-tier: - driver: bridge back-tier: - driver: bridge services: prometheus: image: prom/prometheus container_name: prometheus volumes: - - ./prometheus/:/etc/prometheus/ - - prometheus_data:/prometheus + - prometheus-config:/etc/prometheus/ + - prometheus-data:/prometheus command: - '-config.file=/etc/prometheus/prometheus.yml' - '-storage.local.path=/prometheus' - '-alertmanager.url=http://alertmanager:9093' - expose: - - 9090 ports: - 9090:9090 - links: - - cadvisor:cadvisor - - alertmanager:alertmanager depends_on: - cadvisor networks: - back-tier - + deploy: + placement: + constraints: + - node.role == manager + - node.hostname == node1 node-exporter: container_name: node-exporter image: prom/node-exporter @@ -45,18 +48,18 @@ services: - 9100 networks: - back-tier - alertmanager: - image: prom/alertmanager - ports: - - 9093:9093 - volumes: - - ./alertmanager/:/etc/alertmanager/ - networks: - - back-tier - command: - - '-config.file=/etc/alertmanager/config.yml' - - '-storage.path=/alertmanager' - + deploy: + # alertmanager: + # image: prom/alertmanager + # ports: + # - 9093:9093 + # volumes: + # - alertmanager-config:/etc/alertmanager/ + # networks: + # - back-tier + # command: + # - '-config.file=/etc/alertmanager/config.yml' + # - '-storage.path=/alertmanager' cadvisor: image: google/cadvisor volumes: @@ -64,11 +67,10 @@ services: - /var/run:/var/run:rw - /sys:/sys:ro - /var/lib/docker/:/var/lib/docker:ro - expose: - - 8080 networks: - back-tier - + deploy: + mode: global grafana: image: grafana/grafana depends_on: @@ -76,7 +78,7 @@ services: ports: - 3000:3000 volumes: - - grafana_data:/var/lib/grafana + - grafana-data:/var/lib/grafana env_file: - config.monitoring networks: From c5efc5517c2e381372468ade0a67e5c80309d8f6 Mon Sep 17 00:00:00 2001 From: llitfkitfk Date: Fri, 11 Aug 2017 18:24:51 +0800 Subject: [PATCH 2/4] remove unnecessary config --- docker-compose.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 4ade879..dd9c7e1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,15 +37,12 @@ services: - node.role == manager - node.hostname == node1 node-exporter: - container_name: node-exporter image: prom/node-exporter volumes: - /proc:/host/proc:ro - /sys:/host/sys:ro - /:/rootfs:ro command: '-collector.procfs=/host/proc -collector.sysfs=/host/sys -collector.filesystem.ignored-mount-points="^(/rootfs|/host|)/(sys|proc|dev|host|etc)($$|/)" collector.filesystem.ignored-fs-types="^(sys|proc|auto|cgroup|devpts|ns|au|fuse\.lxc|mqueue)(fs|)$$"' - expose: - - 9100 networks: - back-tier deploy: From 886a882a25ac2997d6b70ef6b621a3c7b97bc781 Mon Sep 17 00:00:00 2001 From: llitfkitfk Date: Wed, 16 Aug 2017 16:31:12 +0800 Subject: [PATCH 3/4] cleanup: swarm mode & single host use same docker-compose.yml --- docker-compose.yml | 58 ++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index dd9c7e1..f5f5245 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,8 @@ version: '3' volumes: - prometheus-config: - external: - name: prometheus-config - prometheus-data: - grafana-data: - alertmanager-config: - external: - name: alertmanager-config + prometheus_data: {} + grafana_data: {} networks: front-tier: @@ -19,14 +13,19 @@ services: image: prom/prometheus container_name: prometheus volumes: - - prometheus-config:/etc/prometheus/ - - prometheus-data:/prometheus + - ./prometheus/:/etc/prometheus/ + - prometheus_data:/prometheus command: - '-config.file=/etc/prometheus/prometheus.yml' - '-storage.local.path=/prometheus' - '-alertmanager.url=http://alertmanager:9093' + expose: + - 9090 ports: - 9090:9090 + links: + - cadvisor:cadvisor + - alertmanager:alertmanager depends_on: - cadvisor networks: @@ -34,29 +33,35 @@ services: deploy: placement: constraints: - - node.role == manager - - node.hostname == node1 + - node.hostname == node-exporter: + container_name: node-exporter image: prom/node-exporter volumes: - /proc:/host/proc:ro - /sys:/host/sys:ro - /:/rootfs:ro command: '-collector.procfs=/host/proc -collector.sysfs=/host/sys -collector.filesystem.ignored-mount-points="^(/rootfs|/host|)/(sys|proc|dev|host|etc)($$|/)" collector.filesystem.ignored-fs-types="^(sys|proc|auto|cgroup|devpts|ns|au|fuse\.lxc|mqueue)(fs|)$$"' + expose: + - 9100 networks: - back-tier deploy: - # alertmanager: - # image: prom/alertmanager - # ports: - # - 9093:9093 - # volumes: - # - alertmanager-config:/etc/alertmanager/ - # networks: - # - back-tier - # command: - # - '-config.file=/etc/alertmanager/config.yml' - # - '-storage.path=/alertmanager' + alertmanager: + image: prom/alertmanager + ports: + - 9093:9093 + volumes: + - ./alertmanager/:/etc/alertmanager/ + networks: + - back-tier + command: + - '-config.file=/etc/alertmanager/config.yml' + - '-storage.path=/alertmanager' + deploy: + placement: + constraints: + - node.hostname == cadvisor: image: google/cadvisor volumes: @@ -64,10 +69,13 @@ services: - /var/run:/var/run:rw - /sys:/sys:ro - /var/lib/docker/:/var/lib/docker:ro + expose: + - 8080 networks: - back-tier deploy: mode: global + grafana: image: grafana/grafana depends_on: @@ -75,9 +83,9 @@ services: ports: - 3000:3000 volumes: - - grafana-data:/var/lib/grafana + - grafana_data:/var/lib/grafana env_file: - config.monitoring networks: - back-tier - - front-tier + - front-tier \ No newline at end of file From a4f7bcea806e125477e717c80eb6944eb9f8df28 Mon Sep 17 00:00:00 2001 From: llitfkitfk Date: Wed, 16 Aug 2017 17:05:29 +0800 Subject: [PATCH 4/4] add instruction for swarm mode deploy --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index fbb2124..41293b4 100644 --- a/README.md +++ b/README.md @@ -94,3 +94,9 @@ Several projects utilize this Prometheus stack. Here's the list of projects: *Have an intersting Project which use this Repo? Submit yours to the list* +## Swarm mode Configuration + +edit file `docker-compose.yml` change `node.hostname = ` to your swarm node name for both `alertmanager` and `prometheus` +``` +docker stack deploy -c docker-compose.yml monitor +``` \ No newline at end of file