feat: Add monitoring services.

This commit is contained in:
William 2022-12-29 19:26:41 +01:00
commit b01a573d16
6 changed files with 99 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.env

2
monitoring/.env.example Normal file
View File

@ -0,0 +1,2 @@
GRAFANA_HOST=grafana.example.org
PROMETHEUS_HOST=prometheus.example.org

View File

@ -0,0 +1,45 @@
version: '3.8'
networks:
web:
external: true
monitoring:
driver: bridge
volumes:
grafana-data:
prometheus-data:
services:
grafana:
image: grafana/grafana-oss:8.2.0
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.grafana.entrypoints=http"
- "traefik.http.routers.grafana.rule=Host(`${GRAFANA_HOST}`)"
- "traefik.http.services.grafana.loadbalancer.server.port=3000"
networks:
- web
- monitoring
volumes:
- grafana-data:/var/lib/grafana
prometheus:
image: prom/prometheus:v2.41.0
restart: unless-stopped
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=365d'
labels:
- "traefik.enable=true"
- "traefik.http.routers.prometheus.entrypoints=http"
- "traefik.http.routers.prometheus.rule=Host(`${PROMETHEUS_HOST}`)"
- "traefik.http.services.prometheus.loadbalancer.server.port=9090"
networks:
- web
- monitoring

17
monitoring/prometheus.yml Normal file
View File

@ -0,0 +1,17 @@
global:
scrape_interval: 15s
external_labels:
monitor: codelab-monitor
scrape_configs:
- job_name: 'node'
scheme: https
basic_auth:
username: username
password: password
tls_config:
insecure_skip_verify: true
static_configs:
- targets:
- 'server.example.com:9100'

View File

@ -0,0 +1,19 @@
version: '3'
networks:
web:
external: true
services:
traefik:
image: traefik:2.9
restart: unless-stopped
networks:
- web
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- './traefik.yml:/etc/traefik/traefik.yml'
- '/var/run/docker.sock:/var/run/docker.sock:ro'

15
traefik/traefik.yml Normal file
View File

@ -0,0 +1,15 @@
entryPoints:
http:
address: ':80'
https:
address: ':443'
api:
dashboard: true
insecure: true
providers:
docker:
network: 'web'
endpoint: 'unix:///var/run/docker.sock'
exposedByDefault: false