feat(traefik): add traefik annotation

This commit is contained in:
nyyu 2022-04-24 10:38:47 +02:00
parent 40d9875388
commit bf23c5b182
2 changed files with 31 additions and 9 deletions

View file

@ -11,13 +11,16 @@
## Prerequisites ## Prerequisites
* docker * docker
* docker compose * docker compose
* traefik with network
## Steps ## Steps
1. Create .env file 1. Create .env file
> EXTERNAL_IP=XXX.XXX.XXX.XXX ```bash
> GRAFANA_PASSWORD=SECURE_PASSWORD
> GRAFANA_PASSWORD=SECURE_PASSWORD HOST_SUFFIX=xxx.local
TZ=Europe/Paris
```
2. Copy alertmanager.tmpl to alertmanager.yml 2. Copy alertmanager.tmpl to alertmanager.yml
* Set telegram bot_token and chat_id * Set telegram bot_token and chat_id

View file

@ -3,6 +3,8 @@ version: '3.8'
networks: networks:
monitoring: monitoring:
driver: bridge driver: bridge
traefik:
external: true
services: services:
grafana: grafana:
@ -21,8 +23,13 @@ services:
- GF_USERS_ALLOW_SIGN_UP=false - GF_USERS_ALLOW_SIGN_UP=false
networks: networks:
- monitoring - monitoring
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.grafana.rule=Host(`grafana.${HOST_SUFFIX}`)"
- "traefik.http.routers.grafana.entrypoints=web"
prometheus: prometheus:
image: prom/prometheus image: prom/prometheus:v2.35.0
container_name: prometheus container_name: prometheus
restart: unless-stopped restart: unless-stopped
volumes: volumes:
@ -36,30 +43,42 @@ services:
- '--web.console.libraries=/etc/prometheus/console_libraries' - '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles' - '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle' - '--web.enable-lifecycle'
- "--web.external-url=http://${EXTERNAL_IP}:9090" - "--web.external-url=http://prometheus.${HOST_SUFFIX}"
expose: expose:
- 9090 - 9090
networks: networks:
- monitoring - monitoring
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.prometheus.rule=Host(`prometheus.${HOST_SUFFIX}`)"
- "traefik.http.routers.prometheus.entrypoints=web"
alertmanager: alertmanager:
image: prom/alertmanager image: prom/alertmanager:v0.24.0
container_name: alertmanager container_name: alertmanager
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./conf/alertmanager:/etc/alertmanager - ./conf/alertmanager:/etc/alertmanager
- ./data/alertmanager:/alertmanager - ./data/alertmanager:/alertmanager
environment:
- TZ=${TZ}
ports: ports:
- 9093:9093 - 9093:9093
command: command:
- '--config.file=/etc/alertmanager/alertmanager.yml' - '--config.file=/etc/alertmanager/alertmanager.yml'
- '--storage.path=/alertmanager' - '--storage.path=/alertmanager'
- "--web.external-url=http://${EXTERNAL_IP}:9093" - "--web.external-url=http://alertmanager.${HOST_SUFFIX}"
expose: expose:
- 9093 - 9093
networks: networks:
- monitoring - monitoring
- traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.alertmanager.rule=Host(`alertmanager.${HOST_SUFFIX}`)"
- "traefik.http.routers.alertmanager.entrypoints=web"
node-exporter: node-exporter:
image: prom/node-exporter image: prom/node-exporter:v1.3.1
container_name: node-exporter container_name: node-exporter
restart: unless-stopped restart: unless-stopped
volumes: volumes:
@ -76,7 +95,7 @@ services:
networks: networks:
- monitoring - monitoring
blackbox_exporter: blackbox_exporter:
image: prom/blackbox-exporter image: prom/blackbox-exporter:v0.20.0
container_name: blackbox container_name: blackbox
restart: unless-stopped restart: unless-stopped
expose: expose: