Repository navigation
Expand file tree
/
Copy pathdocker-compose.monitoring.yml
More file actions
113 lines (104 loc) · 3.21 KB
/
Copy pathdocker-compose.monitoring.yml
File metadata and controls
113 lines (104 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Optional monitoring stack for Shared Shopping List application
# Run with: docker-compose -f docker-compose.prod.yml -f docker-compose.monitoring.yml up -d
version: '3.8'
services:
# Prometheus for metrics collection
prometheus:
image: prom/prometheus:latest
container_name: shopping-list-prometheus
ports:
- "9090:9090"
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
- ./monitoring/alert_rules.yml:/etc/prometheus/alert_rules.yml
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
restart: unless-stopped
networks:
- shopping-network
# Grafana for visualization
grafana:
image: grafana/grafana:latest
container_name: shopping-list-grafana
ports:
- "3001:3000"
volumes:
- grafana_data:/var/lib/grafana
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning
environment:
- GF_SECURITY_ADMIN_USER=${GRAFANA_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
- GF_USERS_ALLOW_SIGN_UP=false
restart: unless-stopped
networks:
- shopping-network
# AlertManager for alert handling
alertmanager:
image: prom/alertmanager:latest
container_name: shopping-list-alertmanager
ports:
- "9093:9093"
volumes:
- ./monitoring/alertmanager.yml:/etc/alertmanager/alertmanager.yml
- alertmanager_data:/alertmanager
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
- '--storage.path=/alertmanager'
- '--web.external-url=http://localhost:9093'
restart: unless-stopped
networks:
- shopping-network
# cAdvisor for container metrics
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
container_name: shopping-list-cadvisor
ports:
- "8081:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:rw
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
privileged: true
restart: unless-stopped
networks:
- shopping-network
# PostgreSQL Exporter for database metrics
postgres-exporter:
image: prometheuscommunity/postgres-exporter:latest
container_name: shopping-list-postgres-exporter
ports:
- "9187:9187"
environment:
DATA_SOURCE_NAME: "postgresql://${POSTGRES_USER:-shopping_user}:${POSTGRES_PASSWORD:-shopping_pass}@postgres:5432/${POSTGRES_DB:-shopping_lists}?sslmode=disable"
depends_on:
- postgres
restart: unless-stopped
networks:
- shopping-network
# Nginx Prometheus Exporter
nginx-exporter:
image: nginx/nginx-prometheus-exporter:latest
container_name: shopping-list-nginx-exporter
ports:
- "9113:9113"
command:
- '-nginx.scrape-uri=http://frontend:8080/nginx_status'
depends_on:
- frontend
restart: unless-stopped
networks:
- shopping-network
volumes:
prometheus_data:
grafana_data:
alertmanager_data:
networks:
shopping-network:
external: true