Observability & Monitoring
The Advanced Echo Server supports observability through Prometheus metrics, structured logging, and dedicated health check endpoints.
Prometheus Metrics
The server exposes metrics at the /metrics endpoint.
echo_requests_total
Counter of total HTTP requests
Labels: method, path, status
echo_request_duration_seconds
Histogram of request latency in seconds
No labels
echo_chaos_errors_total
Counter of chaos-induced errors
Labels: type
Health Checks
Use these endpoints to check server status:
Liveness Check
# Simple liveness check
curl http://localhost:8080/health
Readiness Check
# Readiness probe for Kubernetes
curl http://localhost:8080/ready
Server Info
# Inspect request and server metadata
curl http://localhost:8080/info
# {"server": {"hostname": "...", "version": "1.0.0", "uptime": "..."}, "request_id": "..."}
Structured Logging
| Environment Variable | Description | Default | Options |
|---|---|---|---|
LOG_REQUESTS |
Log basic request and completion lines: remote method path and remote method path - status duration |
true |
true, false |
LOG_HEADERS |
Include request headers (exact key: value pairs as received) | false |
true, false |
LOG_BODY |
Include request body in logs (skipped for /sse; truncated by MAX_LOG_BODY_SIZE) |
false |
true, false |
LOG_TRANSACTION |
Log a consolidated transaction block with request and response details (headers optional; bodies follow LOG_BODY/LOG_RESPONSE_BODY and are truncated by MAX_LOG_BODY_SIZE; SSE bodies omitted) | false |
true, false |
LOG_RESPONSE |
Log response completion summary and, if enabled below, headers and/or body | false |
true, false |
LOG_RESPONSE_HEADERS |
Include response headers in logs | false |
true, false |
LOG_RESPONSE_BODY |
Include response body in logs (skipped for /sse; truncated by MAX_LOG_BODY_SIZE) |
false |
true, false |
MAX_LOG_BODY_SIZE |
Max bytes to log for request/response bodies (truncation) | 2048 |
integer |
Tip: Use X-Request-ID (auto-generated when absent) to correlate request and response logs. Completion lines include status and duration.
Sample log output
# LOG_REQUESTS=true, LOG_HEADERS=true, LOG_BODY=true, LOG_TRANSACTION=true, LOG_RESPONSE=true,
# LOG_RESPONSE_HEADERS=true, LOG_RESPONSE_BODY=true (bodies truncated by MAX_LOG_BODY_SIZE)
127.0.0.1:54321 POST /api/orders
Headers: map[Content-Type:[application/json] X-Request-Id:[abc123]]
Body: {"id":42,"item":"widget"}
cURL: curl -X POST -H "Content-Type: application/json" -H "X-Request-Id: abc123" --data '{"id":42,"item":"widget"}' http://localhost:8080/api/orders
127.0.0.1:54321 POST /api/orders - 200 12.3ms
Response headers: map[Content-Type:[application/json] X-Request-Id:[abc123]]
Response body: {"id":42,"item":"widget","echo":true}