-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
174 lines (166 loc) · 6.08 KB
/
docker-compose.yml
File metadata and controls
174 lines (166 loc) · 6.08 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
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
174
services:
# Gateway Service
gateway-service:
build:
context: .
dockerfile: gateway-service/Dockerfile
image: observability/gateway-service-python:1.0.0
ports:
- "9980:9980"
depends_on:
kafka:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
postgres:
condition: service_healthy
elasticsearch:
condition: service_healthy
environment:
- OTEL_SERVICE_NAME=gateway-service
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-test-collector:5318/v1/traces
- OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://otel-test-collector:5318/v1/metrics
- OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://otel-test-collector:5318/v1/logs
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf
- OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf
- OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf
- OTEL_RESOURCE_ATTRIBUTES=service.name=gateway-service,service.version=1.0.0,service.namespace=observability
- OTEL_PROPAGATORS=tracecontext,baggage
- OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=asgi
- KAFKA_BOOTSTRAP_SERVERS=kafka:29092
- DATABASE_URL=postgresql://observability:observability@postgres:5432/observability
- ELASTICSEARCH_URL=http://elasticsearch:9200
networks:
- observability-network
# Processor Service
processor-service:
build:
context: .
dockerfile: processor-service/Dockerfile
image: observability/processor-service-python:1.0.0
ports:
- "9981:9981"
- "9090:9090" # gRPC port
depends_on:
kafka:
condition: service_healthy
kafka-init:
condition: service_completed_successfully
environment:
- OTEL_SERVICE_NAME=processor-service
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://otel-test-collector:5318/v1/traces
- OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://otel-test-collector:5318/v1/metrics
- OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://otel-test-collector:5318/v1/logs
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf
- OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=http/protobuf
- OTEL_EXPORTER_OTLP_LOGS_PROTOCOL=http/protobuf
- OTEL_RESOURCE_ATTRIBUTES=service.name=processor-service,service.version=1.0.0,service.namespace=observability
- OTEL_PROPAGATORS=tracecontext,baggage
- OTEL_PYTHON_DISABLED_INSTRUMENTATIONS=asgi
- KAFKA_BOOTSTRAP_SERVERS=kafka:29092
networks:
- observability-network
# Kafka with KRaft (no Zookeeper)
kafka:
image: confluentinc/cp-kafka:7.4.0
environment:
KAFKA_NODE_ID: 1
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT,CONTROLLER:PLAINTEXT
KAFKA_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://0.0.0.0:9092,CONTROLLER://kafka:29093
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_PROCESS_ROLES: broker,controller
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@kafka:29093
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_LOG_DIRS: /tmp/kraft-combined-logs
CLUSTER_ID: MkU3OEVBNTcwNTJENDM2Qk
# Logging Configuration - Only show WARN and ERROR levels
KAFKA_LOG4J_ROOT_LOGLEVEL: WARN
KAFKA_LOG4J_LOGGERS: "kafka=WARN,kafka.controller=WARN,kafka.log.LogCleaner=WARN,state.change.logger=WARN,kafka.coordinator=WARN,kafka.network=WARN,kafka.request.logger=WARN"
ports:
- "9092:9092"
healthcheck:
test: ["CMD", "kafka-topics", "--bootstrap-server", "kafka:29092", "--list"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- observability-network
# Kafka Topic Initialization
kafka-init:
image: confluentinc/cp-kafka:7.4.0
depends_on:
kafka:
condition: service_healthy
command: >
bash -c "
kafka-topics --bootstrap-server kafka:29092 --create --if-not-exists --topic gateway-processor-request --partitions 1 --replication-factor 1 &&
kafka-topics --bootstrap-server kafka:29092 --create --if-not-exists --topic gateway-processor-reply --partitions 1 --replication-factor 1 &&
echo 'All Kafka topics created successfully'
"
networks:
- observability-network
# Test OpenTelemetry Collector
otel-test-collector:
image: otel/opentelemetry-collector-contrib:latest
container_name: otel-test-collector
command: ["--config=/etc/otel-collector-config.yaml"]
user: "1000:1000"
volumes:
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
- ./otel-logs:/var/log/otel
ports:
- "5318:5318" # OTLP HTTP receiver
networks:
- observability-network
# PostgreSQL Database
postgres:
image: postgres:15-alpine
container_name: observability-postgres
environment:
- POSTGRES_DB=observability
- POSTGRES_USER=observability
- POSTGRES_PASSWORD=observability
ports:
- "5432:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U observability"]
interval: 5s
timeout: 5s
retries: 5
networks:
- observability-network
# Elasticsearch
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.16.0
container_name: elasticsearch
ports:
- "9200:9200"
- "9300:9300"
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
networks:
- observability-network
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:9200/_cluster/health || exit 1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
observability-network:
driver: bridge
volumes:
postgres-data:
elasticsearch-data: