Skip to content

Commit

Permalink
feat: add health checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dy0gu committed Nov 26, 2024
1 parent e8bdcc4 commit 8362857
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
40 changes: 33 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# https://docs.docker.com/reference/compose-file/version-and-name
# https://docs.docker.com/reference/compose-file/services
# https://docs.docker.com/reference/compose-file/volumes

name: monitoring

services:
Expand All @@ -15,6 +11,13 @@ services:
volumes:
- ./loki.yaml:/etc/loki/loki.yaml
- loki-data:/loki
healthcheck:
test: ["CMD", "curl", "http://localhost:3100/ready"]
interval: 30s
timeout: 5s
retries: 3
start_period: 5s

node-exporter:
image: prom/node-exporter:v1.8.2
container_name: node-exporter
Expand All @@ -28,26 +31,43 @@ services:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/host:ro
healthcheck:
test: ["CMD", "curl", "http://localhost:9100/metrics"]
interval: 30s
timeout: 5s
retries: 3
start_period: 5s

prometheus:
image: prom/prometheus:v3.0.0
container_name: prometheus
restart: unless-stopped
env_file: .env
depends_on:
- node-exporter
node-exporter:
condition: service_healthy
expose:
- 9090
volumes:
- ./prometheus.yaml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
healthcheck:
test: ["CMD", "curl", "http://localhost:9090/-/ready"]
interval: 30s
timeout: 5s
retries: 3
start_period: 5s

grafana:
image: grafana/grafana-oss:11.3.1
container_name: grafana
restart: unless-stopped
env_file: .env
depends_on:
- loki
- prometheus
loki:
condition: service_healthy
prometheus:
condition: service_healthy
ports:
- ${GRAFANA_PORT}:3000
volumes:
Expand All @@ -56,6 +76,12 @@ services:
- ./grafana-metrics-dashboard.json:/var/lib/grafana/dashboards/metrics.json
- ./grafana-logs-dashboard.json:/var/lib/grafana/dashboards/logs.json
- grafana-data:/var/lib/grafana
healthcheck:
test: ["CMD", "curl", "http://localhost:3000/api/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 5s

volumes:
loki-data:
Expand Down
2 changes: 1 addition & 1 deletion grafana-datasources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ datasources:
access: proxy

url: http://prometheus:9090
- name: Loki
- name: DS_LOKI
type: loki
access: proxy

Expand Down

0 comments on commit 8362857

Please sign in to comment.