From bf23c5b1825da00018500957d5ba4df2575b8e66 Mon Sep 17 00:00:00 2001 From: nyyu Date: Sun, 24 Apr 2022 10:38:47 +0200 Subject: [PATCH] feat(traefik): add traefik annotation --- README.md | 9 ++++++--- docker-compose.yml | 31 +++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c4d5f98..013f30d 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,16 @@ ## Prerequisites * docker * docker compose +* traefik with network ## Steps 1. Create .env file - > EXTERNAL_IP=XXX.XXX.XXX.XXX - > - > GRAFANA_PASSWORD=SECURE_PASSWORD + ```bash + GRAFANA_PASSWORD=SECURE_PASSWORD + HOST_SUFFIX=xxx.local + TZ=Europe/Paris + ``` 2. Copy alertmanager.tmpl to alertmanager.yml * Set telegram bot_token and chat_id diff --git a/docker-compose.yml b/docker-compose.yml index 7919e80..81ad269 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,8 @@ version: '3.8' networks: monitoring: driver: bridge + traefik: + external: true services: grafana: @@ -21,8 +23,13 @@ services: - GF_USERS_ALLOW_SIGN_UP=false networks: - monitoring + - traefik + labels: + - "traefik.enable=true" + - "traefik.http.routers.grafana.rule=Host(`grafana.${HOST_SUFFIX}`)" + - "traefik.http.routers.grafana.entrypoints=web" prometheus: - image: prom/prometheus + image: prom/prometheus:v2.35.0 container_name: prometheus restart: unless-stopped volumes: @@ -36,30 +43,42 @@ services: - '--web.console.libraries=/etc/prometheus/console_libraries' - '--web.console.templates=/etc/prometheus/consoles' - '--web.enable-lifecycle' - - "--web.external-url=http://${EXTERNAL_IP}:9090" + - "--web.external-url=http://prometheus.${HOST_SUFFIX}" expose: - 9090 networks: - monitoring + - traefik + labels: + - "traefik.enable=true" + - "traefik.http.routers.prometheus.rule=Host(`prometheus.${HOST_SUFFIX}`)" + - "traefik.http.routers.prometheus.entrypoints=web" alertmanager: - image: prom/alertmanager + image: prom/alertmanager:v0.24.0 container_name: alertmanager restart: unless-stopped volumes: - ./conf/alertmanager:/etc/alertmanager - ./data/alertmanager:/alertmanager + environment: + - TZ=${TZ} ports: - 9093:9093 command: - '--config.file=/etc/alertmanager/alertmanager.yml' - '--storage.path=/alertmanager' - - "--web.external-url=http://${EXTERNAL_IP}:9093" + - "--web.external-url=http://alertmanager.${HOST_SUFFIX}" expose: - 9093 networks: - monitoring + - traefik + labels: + - "traefik.enable=true" + - "traefik.http.routers.alertmanager.rule=Host(`alertmanager.${HOST_SUFFIX}`)" + - "traefik.http.routers.alertmanager.entrypoints=web" node-exporter: - image: prom/node-exporter + image: prom/node-exporter:v1.3.1 container_name: node-exporter restart: unless-stopped volumes: @@ -76,7 +95,7 @@ services: networks: - monitoring blackbox_exporter: - image: prom/blackbox-exporter + image: prom/blackbox-exporter:v0.20.0 container_name: blackbox restart: unless-stopped expose: