ADR 0023: Structured Logging, Request Correlation, and Local Elasticsearch

Ratification

Context

Why this matters: Plain text logs are fine for a single terminal but do not scale to centralized search, dashboards, or joining logs with future distributed traces. Large teams standardize on structured logs (JSON), request correlation (X-Request-Id), and optional trace/span ids once OpenTelemetry is adopted.

Elasticsearch and Kibana are widely used for log search and analytics. Elastic publishes Docker images that are free to run locally for development and learning; production licensing and support are separate commercial decisions. This ADR covers local optional Compose only—not a commitment to Elastic Cloud or a paid tier.

Decision

Implementation

Kibana index pattern (important)

Create the data view with index pattern *study-app-logs*, not only study-app-logs-*. Otherwise Discover may target no indices: Elasticsearch 8 often writes Filebeat output to data stream backing indices named .ds-study-app-logs-…, which do not match a prefix of study-app-logs-. A symptom is “No results” for valid request_id queries even though documents exist in logs/app.log. Filebeat is configured with setup.template.type: legacy so new daily indices align with study-app-logs-*; the broad pattern still matches old and new names.

JSON lines must follow ECS shapes where the index template expects objects: use service.name (nested under service), not a string at service. Otherwise bulk indexing can fail with mapper_parsing_exception and indices show docs.count: 0 while logs/app.log still grows on disk.

Consequences

Positive

Trade-offs

Related

Page history

Date Change Author
Added Page history section (repository baseline). Ivan Boyarkin