Skip to content

Commit a21a31f

Browse files
committed
fix: Configuration issues
Signed-off-by: Kemal Akkoyun <[email protected]>
1 parent f404d19 commit a21a31f

File tree

7 files changed

+349
-119
lines changed

7 files changed

+349
-119
lines changed

demo/infrastructure/docker-compose/Makefile

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,33 @@ pull: ## Pull latest images
144144

145145
update: pull restart ## Update images and restart services
146146

147-
validate: ## Validate docker-compose configuration
147+
validate-docker-compose: ## Validate docker-compose configuration
148148
@echo "$(BLUE)Validating configuration...$(NC)"
149149
@docker-compose config > /dev/null && echo "$(GREEN)✓ Configuration valid$(NC)" || echo "$(RED)✗ Configuration invalid$(NC)"
150150

151+
validate-otel: ## Validate OpenTelemetry Collector configuration
152+
@echo "$(BLUE)Validating OTel Collector configuration...$(NC)"
153+
@docker-compose exec -T otel-collector /otelcol-contrib validate --config=/etc/otelcol-contrib/config.yaml && \
154+
echo "$(GREEN)✓ OTel Collector configuration valid$(NC)" || \
155+
echo "$(RED)✗ OTel Collector configuration invalid$(NC)"
156+
157+
validate-otel-local: ## Validate OTel Collector config locally (requires otelcol-contrib binary)
158+
@echo "$(BLUE)Validating OTel Collector configuration locally...$(NC)"
159+
@if command -v otelcol-contrib > /dev/null 2>&1; then \
160+
otelcol-contrib validate --config=otel-collector/config.yaml && \
161+
echo "$(GREEN)✓ Configuration valid$(NC)"; \
162+
else \
163+
echo "$(YELLOW)! otelcol-contrib not found. Install from: https://github.com/open-telemetry/opentelemetry-collector-releases$(NC)"; \
164+
fi
165+
166+
validate-prometheus: ## Validate Prometheus configuration
167+
@echo "$(BLUE)Validating Prometheus configuration...$(NC)"
168+
@docker-compose exec -T prometheus promtool check config /etc/prometheus/prometheus.yml && \
169+
echo "$(GREEN)✓ Prometheus configuration valid$(NC)" || \
170+
echo "$(RED)✗ Prometheus configuration invalid$(NC)"
171+
172+
validate: validate-docker-compose validate-otel validate-prometheus ## Validate all configurations (docker-compose, OTel, Prometheus)
173+
151174
metrics-otel: ## Show OpenTelemetry Collector metrics
152175
@echo "$(BLUE)OpenTelemetry Collector Metrics:$(NC)"
153176
@curl -s http://localhost:8888/metrics | grep -E "^(otelcol_receiver_accepted|otelcol_exporter_sent)" | head -20

demo/infrastructure/docker-compose/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,81 @@ grafana:
465465
- Go to Dashboards → Import
466466
- Upload JSON file from `grafana/dashboards/dashboards/`
467467

468+
## Configuration Validation
469+
470+
### Built-in Validation Tools
471+
472+
The observability stack includes several validation tools to check configurations before deployment:
473+
474+
#### Validate All Configurations
475+
476+
```bash
477+
make validate-all
478+
```
479+
480+
This runs validation for:
481+
482+
- Docker Compose configuration
483+
- OpenTelemetry Collector configuration
484+
- Prometheus configuration
485+
486+
#### Individual Validation
487+
488+
**Docker Compose:**
489+
490+
```bash
491+
make validate
492+
# Or manually:
493+
docker-compose config
494+
```
495+
496+
**OpenTelemetry Collector:**
497+
498+
```bash
499+
make validate-otel
500+
# Or manually:
501+
docker-compose exec otel-collector /otelcol-contrib validate --config=/etc/otelcol-contrib/config.yaml
502+
```
503+
504+
**Prometheus:**
505+
506+
```bash
507+
make validate-prometheus
508+
# Or manually:
509+
docker-compose exec prometheus promtool check config /etc/prometheus/prometheus.yml
510+
```
511+
512+
### External Validation Tools
513+
514+
For more comprehensive validation and best practices checking:
515+
516+
1. **otel-config-validator** (by Lightstep/AWS):
517+
- GUI: <https://github.com/lightstep/otel-config-validator>
518+
- Validates OTel configurations
519+
- Identifies common misconfigurations
520+
521+
2. **OTelBin** (online tool):
522+
- URL: <https://www.otelbin.io/>
523+
- Visualizes OTel Collector pipelines
524+
- YAML linting and syntax highlighting
525+
526+
3. **CoGuard CLI**:
527+
- Security-focused configuration scanner
528+
- Detects misconfigurations and vulnerabilities
529+
- Install: <https://www.coguard.io/>
530+
531+
### Best Practice: Validate Before Deploy
532+
533+
Always validate configurations before deploying:
534+
535+
```bash
536+
# Before starting services
537+
make validate-all
538+
539+
# If validation passes, then start
540+
make start
541+
```
542+
468543
## Maintenance
469544

470545
### Update Images

demo/infrastructure/docker-compose/docker-compose.yml

Lines changed: 77 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ services:
1111
command:
1212
- --set=receivers.otlp.protocols.grpc.endpoint=0.0.0.0:4317
1313
- --set=receivers.otlp.protocols.http.endpoint=0.0.0.0:4318
14+
- --feature-gates=-telemetry.UseLocalHostAsDefaultMetricsAddress # Expose telemetry on 0.0.0.0:8888
1415
ports:
1516
- "16686:16686" # Jaeger UI
16-
- "4317" # OTLP gRPC (internal)
17-
- "4318" # OTLP HTTP (internal)
17+
- "4317" # OTLP gRPC (internal)
18+
- "4318" # OTLP HTTP (internal)
19+
- "14269:8888" # Internal telemetry metrics (Jaeger's port 8888 mapped to host 14269)
1820
environment:
1921
- COLLECTOR_OTLP_ENABLED=true
2022
networks:
@@ -54,26 +56,25 @@ services:
5456
otel-collector:
5557
image: otel/opentelemetry-collector-contrib:0.139.0
5658
container_name: otel-collector
57-
command: ["--config=/etc/otelcol-contrib/config.yaml"]
59+
command:
60+
- "--config=/etc/otelcol-contrib/config.yaml"
61+
- "--feature-gates=-telemetry.UseLocalHostAsDefaultMetricsAddress" # Expose metrics on 0.0.0.0
5862
volumes:
5963
- ./otel-collector/config.yaml:/etc/otelcol-contrib/config.yaml:ro
6064
ports:
61-
- "4317:4317" # OTLP gRPC receiver
62-
- "4318:4318" # OTLP HTTP receiver
63-
- "8888:8888" # Collector metrics
64-
- "8889:8889" # Prometheus exporter
65+
- "4317:4317" # OTLP gRPC receiver
66+
- "4318:4318" # OTLP HTTP receiver
67+
- "8888:8888" # Collector internal telemetry metrics
68+
- "8889:8889" # Application metrics + spanmetrics
69+
- "13133:13133" # Health check endpoint
6570
networks:
6671
- observability
6772
depends_on:
6873
jaeger:
6974
condition: service_healthy
7075
prometheus:
7176
condition: service_healthy
72-
healthcheck:
73-
test: ["CMD", "wget", "--spider", "-q", "http://localhost:13133/"]
74-
interval: 10s
75-
timeout: 5s
76-
retries: 5
77+
restart: unless-stopped
7778

7879
# Grafana - Visualization and dashboards
7980
grafana:
@@ -117,8 +118,7 @@ services:
117118
networks:
118119
- observability
119120
depends_on:
120-
otel-collector:
121-
condition: service_healthy
121+
- otel-collector
122122
restart: unless-stopped
123123

124124
# gRPC Client - Demo client making requests to server
@@ -128,7 +128,6 @@ services:
128128
dockerfile: demo/grpc/client/Dockerfile
129129
container_name: grpc-client
130130
environment:
131-
- GRPC_SERVER_ADDRESS=grpc-server:50051
132131
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
133132
- OTEL_EXPORTER_OTLP_PROTOCOL=grpc
134133
- OTEL_SERVICE_NAME=grpc-client
@@ -141,21 +140,80 @@ services:
141140
- otel-collector
142141
restart: unless-stopped
143142

144-
# k6 - Load testing (optional, comment out if not needed)
145-
k6:
143+
# HTTP Server - Demo HTTP application with compile-time instrumentation
144+
http-server:
145+
build:
146+
context: ../../..
147+
dockerfile: demo/http/server/Dockerfile
148+
container_name: http-server
149+
ports:
150+
- "8080:8080"
151+
environment:
152+
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
153+
- OTEL_EXPORTER_OTLP_PROTOCOL=grpc
154+
- OTEL_SERVICE_NAME=http-server
155+
- OTEL_RESOURCE_ATTRIBUTES=service.namespace=demo,service.version=1.0.0
156+
- OTEL_LOG_LEVEL=info
157+
networks:
158+
- observability
159+
depends_on:
160+
- otel-collector
161+
restart: unless-stopped
162+
163+
# HTTP Client - Demo client making requests to HTTP server
164+
http-client:
165+
build:
166+
context: ../../..
167+
dockerfile: demo/http/client/Dockerfile
168+
container_name: http-client
169+
command: ["-addr", "http://http-server:8080", "-count", "10000", "-method", "GET"]
170+
environment:
171+
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
172+
- OTEL_EXPORTER_OTLP_PROTOCOL=grpc
173+
- OTEL_SERVICE_NAME=http-client
174+
- OTEL_RESOURCE_ATTRIBUTES=service.namespace=demo,service.version=1.0.0
175+
- OTEL_LOG_LEVEL=info
176+
networks:
177+
- observability
178+
depends_on:
179+
- http-server
180+
- otel-collector
181+
restart: unless-stopped
182+
183+
# k6 gRPC Load Testing - Generates continuous load against gRPC server
184+
k6-grpc:
146185
image: grafana/k6:1.3.0
147-
container_name: k6
186+
container_name: k6-grpc
148187
command: run --quiet /scripts/grpc-load-test.js
149188
volumes:
150189
- ./k6:/scripts:ro
190+
- ../../grpc/server/greeter.proto:/proto/greeter.proto:ro
151191
networks:
152192
- observability
153193
depends_on:
154194
- grpc-server
155195
profiles:
156196
- load-testing
157197
environment:
158-
- K6_OUT=json=/tmp/k6-results.json
198+
- K6_OUT=json=/tmp/k6-grpc-results.json
199+
restart: unless-stopped
200+
201+
# k6 HTTP Load Testing - Generates continuous load against HTTP server
202+
k6-http:
203+
image: grafana/k6:1.3.0
204+
container_name: k6-http
205+
command: run --quiet /scripts/http-load-test.js
206+
volumes:
207+
- ./k6:/scripts:ro
208+
networks:
209+
- observability
210+
depends_on:
211+
- http-server
212+
profiles:
213+
- load-testing
214+
environment:
215+
- K6_OUT=json=/tmp/k6-http-results.json
216+
restart: unless-stopped
159217

160218
networks:
161219
observability:

0 commit comments

Comments
 (0)