Prompt
How do I normalize logs from different apps into one schema?
Latest observation
Oct 28, 2026
OpenAI APIWeb search: off
A good way to normalize logs from different apps into one schema is to define a common event model and then build per-app mappings into it.
1) Pick a canonical schema
Use a standard if possible instead of inventing one. Good options:
- OpenTelemetry Logs
- Elastic Common Schema (ECS)
- CloudEvents for event-style logs
A common normalized log record usually includes:
timestampseverity/levelmessageservice.nameservice.versionenvironmenthost/container/podtrace_idspan_idrequest_iduser.idsource.filesource.lineevent.categoryevent.actionerror.typeerror.messagelabels/attributesfor extra fields
2) Identify shared concepts across apps
Different apps may call the same thing by different names:
ts,time,timestamp→@timestamplvl,severity,logLevel→log.levelmsg,message,log_message→messageapp,service,component→service.name
Create a mapping table for each app.
3) Parse logs into structured fields first
If some apps emit plain text, parse them before normalization.
Examples:
- JSON logs: parse directly
- Regex/grok for text logs
- Multiline handling for stack traces
- Extract key-value pairs where possible
4) Use a transformation layer
Normalize in a central place such as:
- Log shipper: Fluent Bit, Logstash, Vector, Filebeat
- Stream processor: Kafka Streams, Flink
- Ingestion pipeline: custom ETL
This layer should:
- Parse raw log
- Map fields to canonical schema
- Enrich with metadata
- Drop or preserve unknown fields in
labels
5) Keep raw data too
Don’t lose the original log. Store:
raw_messageraw_fieldssource_app
This helps debugging mappings and future schema changes.
6) Version your schema
Treat the schema like an API:
schema_version- backward-compatible changes only when possible
- document field definitions and data types
7) Handle app-specific extras
For fields that don’t fit the common schema:
- keep them under
labels.*,attributes.*, orcustom.* - avoid inventing new top-level fields unless reused broadly
Example normalized record
{
"@timestamp": "2026-10-28T12:34:56.789Z",
"log.level": "error",
"message": "Payment failed",
"service.name": "checkout-api",
"service.version": "1.8.2",
"environment": "prod",
"trace.id": "abc123",
"span.id": "def456",
"error.type": "TimeoutError",
"error.message": "Upstream payment service timed out",
"labels": {
"customer_tier": "gold",
"region": "us-east-1"
},
"raw_message": "{\"ts\":\"...\",\"lvl\":\"ERR\",...}"
}
Recommended practical approach
If you want a simple path:
- Choose ECS or OpenTelemetry Logs
- Require new apps to emit structured JSON
- Add a transformer for legacy apps
- Store raw logs plus normalized fields
- Validate schema with tests
If you want, I can also provide:
- a sample mapping table
- an example Fluent Bit / Logstash / Vector pipeline
- a canonical log schema you can adopt directly