[feature] add prometheus and node_exporter services, remove default values from docker-compose.yml

add simple config for prometheus
This commit is contained in:
2023-04-21 10:16:36 +07:00
parent 62f969fa28
commit 4017fcc471
5 changed files with 80 additions and 11 deletions

View File

@@ -1,4 +1,13 @@
COMPOSE_PROFILES=grafana,promtail COMPOSE_PROFILES=grafana
GRAFANA_VERSION=9.1.7 GRAFANA_VERSION=9.1.7
LOKI_STACK_VERSION=2.6.0 GRAFANA_HOST=grafana.docker.localhost
LOKI_STACK_VERSION=2.6.0
LOKI_HOST=loki.docker.localhost
LOKI_PROMTAIL_HOST=promtail.docker.localhost
PROMETHEUS_VERSION=v2.43.0
PROMETHEUS_NODE_EXPORTER_VERSION=v1.5.0
PROMETHEUS_HOST=prometheus.docker.localhost
PROMETHEUS_RETENTION_TIME=10d

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
/.idea/ /.idea/
/.vscode/
/.env /.env
/docker-compose.override.yml /docker-compose.override.yml

View File

@@ -4,9 +4,9 @@ version: "3.9"
services: services:
grafana: grafana:
image: grafana/grafana:${GRAFANA_VERSION:-latest} image: grafana/grafana:${GRAFANA_VERSION:-latest}
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.grafana.rule=Host(`grafana.docker.localhost`)" - "traefik.http.routers.grafana.rule=Host(`${GRAFANA_HOST}`)"
- "traefik.http.services.grafana.loadbalancer.server.port=3000" - "traefik.http.services.grafana.loadbalancer.server.port=3000"
expose: expose:
- 3000 - 3000
@@ -17,10 +17,10 @@ services:
- grafana - grafana
loki: loki:
image: grafana/loki:${LOKI_STACK_VERSION:-2.6.0} image: grafana/loki:${LOKI_STACK_VERSION}
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.loki.rule=Host(`loki.docker.localhost`)" - "traefik.http.routers.loki.rule=Host(`${LOKI_HOST}`)"
- "traefik.http.services.loki.loadbalancer.server.port=3100" - "traefik.http.services.loki.loadbalancer.server.port=3100"
expose: expose:
- 3100 - 3100
@@ -29,12 +29,12 @@ services:
command: --config.file=/loki/config/config.yml command: --config.file=/loki/config/config.yml
profiles: profiles:
- grafana - grafana
promtail: promtail:
image: grafana/promtail:${LOKI_STACK_VERSION:-2.6.0} image: grafana/promtail:${LOKI_STACK_VERSION}
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.grafana.rule=Host(`promtail.docker.localhost`)" - "traefik.http.routers.grafana.rule=Host(`${LOKI_PROMTAIL_HOST}`)"
- "traefik.http.services.grafana.loadbalancer.server.port=9080" - "traefik.http.services.grafana.loadbalancer.server.port=9080"
expose: expose:
- 9080 - 9080
@@ -46,5 +46,43 @@ services:
profiles: profiles:
- promtail - promtail
prometheus:
image: prom/prometheus:${PROMETHEUS_VERSION}
labels:
- "traefik.enable=true"
- "traefik.http.routers.prometheus.rule=Host(`${PROMETHEUS_HOST}`)"
- "traefik.http.services.prometheus.loadbalancer.server.port=9090"
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=${PROMETHEUS_RETENTION_TIME:-10d}'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
expose:
- 9090
volumes:
- ./prometheus/:/etc/prometheus/
- prometheus-data:/prometheus
profiles:
- prometheus
node-exporter:
image: prom/node-exporter:${PROMETHEUS_NODE_EXPORTER_VERSION}
restart: on-failure
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
- --collector.filesystem.ignored-mount-points
- "^/(sys|proc|dev|host|etc|rootfs/var/lib/docker/containers|rootfs/var/lib/docker/overlay2|rootfs/run/docker/netns|rootfs/var/lib/docker/aufs)($$|/)"
expose:
- 9100
profiles:
- prometheus
volumes: volumes:
grafana-storage: grafana-storage:
prometheus-data:

19
prometheus/prometheus.yml Normal file
View File

@@ -0,0 +1,19 @@
---
global:
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
monitor: 'dev-prometheus'
scrape_config_files:
- /etc/prometheus/scrapes/*.yml
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 15s
static_configs:
- targets: ['localhost:9090']
- job_name: 'node-exporter'
scrape_interval: 15s
static_configs:
- targets: ['node-exporter:9100']

2
prometheus/scrapes/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/*
!/.gitignore