-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
173 lines (163 loc) · 6.26 KB
/
docker-compose.yml
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# Service Architecture and Data Flow:
#
# ┌───────────────┐
# │ Grafana │ [Metrics Visualization]
# └───────┬───────┘
# │ reads metrics
# ┌───────┴───────┐
# │ Prometheus │ [Metrics Storage]
# └───────┬───────┘
# │ collects metrics
# ▼
# ┌───────────────┐
# │ App │ [Main Service]
# └───┬─────┬─────┘
# │ │ │
# caches data │ │ │ stores logs
# ┌─────────────┘ │ └──────────┐
# ▼ │ ┌──▼──────────┐
# ┌─────────────┐ stores │ │ Logstash │ [Log Pipeline]
# │ Redis │ data │ └──────┬──────┘
# └─────────────┘ │ │ forwards logs
# [Cache Layer] ▼ ▼
# ┌───────────────┐ ┌────────────────┐
# │ PostgreSQL │ │ Elasticsearch │ [Log Storage]
# └───────┬───────┘ └───────┬────────┘
# │ │
# manages│ │visualizes logs
# ▼ ▼
# ┌───────────────┐ ┌────────────────┐
# │ PGAdmin │ │ Kibana │ [Log Visualization]
# └───────────────┘ └────────────────┘
# [DB Management]
#
# ┌────────────────┐
# │ OpenTelemetry │ [Distributed Tracing]
# └────────────────┘
# monitors all services
#
# Database Services:
# - PostgreSQL: Main relational database
# - Redis: In-memory cache database
# - Elasticsearch: Search engine and log storage
# - Prometheus: Time-series metrics database optimized for storing and querying time-based data like
# application metrics. Unlike traditional DBs like PostgreSQL, it efficiently handles:
# 1. High write throughput of frequent metric updates
# 2. Time-based data retention and downsampling
# 3. Time-range queries for visualizing metric trends
# 4. Built-in support for rate calculations and aggregations
#
# Non-Database Services:
# - App: Main Flask application
# - PGAdmin: PostgreSQL admin interface
# - Kibana: Elasticsearch visualization
# - Logstash: Log processing pipeline
# - Grafana: Metrics visualization
# - OpenTelemetry: Distributed tracing and metrics collection
#
services:
db:
image: postgres:15
environment:
- POSTGRES_DB=travelapp
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./sql-practice.sql:/docker-entrypoint-initdb.d/init.sql
pgadmin:
image: dpage/pgadmin4
environment:
- PGADMIN_DEFAULT_PASSWORD=admin
ports:
- "5050:80"
depends_on:
- db
redis:
image: redis:latest
ports:
- "6379:6379"
volumes:
- redis_data:/data
command: redis-server --appendonly yes
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.9
environment:
- discovery.type=single-node
- ES_JAVA_OPTS=-Xms512m -Xmx512m
ports:
- "9200:9200"
volumes:
- elasticsearch_data:/usr/share/elasticsearch/data
logstash:
image: docker.elastic.co/logstash/logstash:7.17.9
ports:
- "5044:5044"
volumes:
- ./logstash/pipeline:/usr/share/logstash/pipeline
depends_on:
- elasticsearch
kibana:
image: docker.elastic.co/kibana/kibana:7.17.9
ports:
- "5601:5601"
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
depends_on:
- elasticsearch
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
depends_on:
- prometheus
otel-collector:
image: otel/opentelemetry-collector:latest
command: ["--config=/etc/otel-collector-config.yaml"]
volumes:
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
ports:
- "4317:4317" # OTLP gRPC receiver
- "4318:4318" # OTLP http receiver
- "8888:8888" # Prometheus metrics exposed by the collector
- "8889:8889" # Prometheus exporter metrics
depends_on:
- prometheus
- elasticsearch
app:
build: .
ports:
- "5000:5000"
volumes:
- ./app.py:/app/app.py
depends_on:
- db
- redis
- elasticsearch
- otel-collector
environment:
- FLASK_ENV=development
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
- OTEL_SERVICE_NAME=flask-app
restart: unless-stopped
volumes:
postgres_data:
redis_data:
elasticsearch_data:
prometheus_data:
grafana_data: