How Dash0 Processes JSON Logs
Preconditions
Dash0 only scans a log record for nested JSON payloads if certain preconditions are met:
- The log record does not have a severity number or severity text yet.
- The log record body is either a string (which contains the JSON payload) or a map.
- If the log record body is a string, it must contain a valid JSON object. After leading and trailing whitespace is removed, it must start with
{and end with}. - The JSON object contains a message field (see Message), or Dash0 can determine a log level from it (see Log Level), or both.
If none of these fields is found, Dash0 leaves the log record unchanged.
If Dash0 processed nested structured data within a log record, it will add a log record attribute named dash0.log.processor.type with the value json.
Other Fields
What happens to the remaining fields depends on whether Dash0 finds a message field:
- With a message field: The log record body is replaced with the message. Every other top-level field is copied to a log record attribute with the same name. Fields whose names are OpenTelemetry resource semantic convention attributes (for example
service.versionork8s.namespace.name) are set on the resource instead. This also applies to their underscore variants: a field namedhost_namebecomes the resource attributehost.name. A nested JSON object becomes a single attribute with a map value. - Without a message field: The body keeps the full JSON payload, and the remaining fields are not copied to attributes.
In both cases, Dash0 still maps the log level, timestamp, trace context, and the other fields described on this page. Fields that Dash0 has already mapped (such as the level, timestamp, or trace ID field) are not copied again as attributes.
Example
Take this JSON log line:
{"time":"2026-11-27T10:15:30.123Z","level":"WARN","msg":"Payment retry scheduled","trace_id":"4bf92f3577b34da6a3ce929d0e0e4736","span_id":"00f067aa0ba902b7","service.version":"1.4.2","order":{"id":"A-1001","attempt":2}}Dash0 turns it into a log record with:
| Log record field | Value | Source |
|---|---|---|
| Body | Payment retry scheduled | msg |
| Severity number | 13 (Warn) | level |
| Timestamp | 2026-11-27T10:15:30.123Z | time |
| Trace ID | 4bf92f3577b34da6a3ce929d0e0e4736 | trace_id |
| Span ID | 00f067aa0ba902b7 | span_id |
Resource attribute service.version | 1.4.2 | service.version |
Log record attribute order | Map with id and attempt | order |
Log record attribute dash0.log.processor.type | json | Added by Dash0 |
Message
The following keys are mapped to the log record body (first match wins):
@mmsgMESSAGEMessagemessagelogoutputlogmessage
The value must be a string.
Log Level
The following keys are mapped to the log record severity number (first match wins):
log.levelLEVELLevellevelspriority@l_logLevel
The value must be a string. It is matched case-insensitively against the values in Severity Mapping, so WARN and warn both map to 13 (Warn). Numeric levels are not mapped. If a value is not in the table, Dash0 tries the next key.
The log.level key also matches a nested object, as in {"log": {"level": "info"}}.
If no key matches, Dash0 recognizes the JSON log format of Kubernetes components . A log with a numeric ts, a string msg, a numeric verbosity v between 0 and 10, and no err maps to 9 (Info). A log with a numeric ts, a string msg, and a string err but no v maps to 17 (Error).
Severity Mapping
The severity in the previously listed fields is mapped to the log record severity number as follows:
Trace
| Value | Severity Number |
|---|---|
finest | 1 (Trace) |
t | 1 (Trace) |
trace | 1 (Trace) |
loglevel.trace | 1 (Trace) |
Debug
| Value | Severity Number |
|---|---|
v | 5 (Debug) |
verbose | 5 (Debug) |
d | 5 (Debug) |
d1 | 5 (Debug) |
d2 | 6 (Debug2) |
d3 | 7 (Debug3) |
d4 | 8 (Debug4) |
d5 | 8 (Debug4) |
dbg | 5 (Debug) |
debug | 5 (Debug) |
finer | 5 (Debug) |
fine | 6 (Debug2) |
config | 7 (Debug3) |
loglevel.debug | 5 (Debug) |
Info
| Value | Severity Number |
|---|---|
i | 9 (Info) |
inf | 9 (Info) |
info | 9 (Info) |
information | 9 (Info) |
informational | 9 (Info) |
loglevel.information | 9 (Info) |
notice | 10 (Info2) |
Warn
| Value | Severity Number |
|---|---|
w | 13 (Warn) |
wrn | 13 (Warn) |
warn | 13 (Warn) |
warning | 13 (Warn) |
loglevel.warning | 13 (Warn) |
Error
| Value | Severity Number |
|---|---|
e | 17 (Error) |
err | 17 (Error) |
error | 17 (Error) |
severe | 17 (Error) |
loglevel.error | 17 (Error) |
critical | 18 (Error2) |
dpanic | 18 (Error2) |
alert | 19 (Error3) |
panic | 19 (Error3) |
Fatal
| Value | Severity Number |
|---|---|
f | 21 (Fatal) |
fatal | 21 (Fatal) |
emergency | 21 (Fatal) |
loglevel.critical | 21 (Fatal) |
Service Name
The following keys are mapped to the service.name attribute (first match wins):
service_nameserviceNameotelServiceName
Kubernetes Pod Name
If the JSON contains a kubernetes object with a string pod_name field, as in {"kubernetes": {"pod_name": "checkout-7d9f8b6c5-x2x4k"}}, its value is mapped to the k8s.pod.name attribute.
Event Name
The otel.event.name key is mapped to the log record event name. The value must be a string.
Timestamp
The following keys are mapped to the log record time (first match wins):
@timestampTIMESTAMPTimestamptimestamp@ttimetsdate_timedate
The following values are accepted:
- RFC 3339 string: A string with a UTC offset, such as
2026-11-27T10:15:30Zor2026-11-27T10:15:30.123+01:00. Fractional seconds are allowed. - Unix epoch: A number or a numeric string. Dash0 first reads the value as milliseconds. If that gives a date before 1971, Dash0 reads it as seconds instead, so both
1795774530123and1795774530.123work.
A value in any other format is ignored, and Dash0 tries the next key. For example, a string without a UTC offset, such as 2026-11-27T10:15:30, is ignored. If no key has an accepted value, the log record keeps its original timestamp.
For MongoDB logs , Dash0 also reads an RFC 3339 string from t.$date, as in {"t": {"$date": "2026-11-27T10:15:30.123+00:00"}}.
Trace ID
The following keys are mapped to the Trace ID (first match wins):
trace_idtrace.idtraceIdTraceIdTraceID@trotelTraceID
Note: Only hex-encoded strings with exactly 16 bytes (32 hex characters) are eligible as Trace ID.
Span ID
The following keys are mapped to the Span ID (first match wins):
span_idspan.idspanIdSpanIdSpanID@spotelSpanID
Note: Only hex-encoded strings with exactly 8 bytes (16 hex characters) are eligible as Span ID.
Trace Sampling
The following keys are used to set the trace flag SAMPLED (first match wins):
otelTraceSampledsampled
The value must be a boolean, or a string that represents a boolean, such as "true" or "false".
Trace Context From Log Attributes
This mapping applies to every log record, whether its body is JSON or not.
If a log record has no trace ID or no span ID yet, Dash0 looks for a log record attribute whose name is one of the Trace ID or Span ID keys listed above. If the attribute holds a valid ID, Dash0 copies it into the log record's own trace ID or span ID field. The attribute itself is kept.
A span ID is only set when the log record has a trace ID, or gets one from its attributes.
If the JSON body (or the Java MDC) also contains a trace ID or span ID, the value from the JSON takes precedence.
journald (systemd)Release historyThis feature was introduced by Journald Log Support on December 18, 2024.
If a journal entry is detected (includes a key named __CURSOR), the following keys are mapped to their corresponding log record attribute according to the OpenTelemetry Semantic Conventions:
| Key | OpenTelemetry Attribute |
|---|---|
_HOSTNAME | host.name |
_MACHINE_ID | host.id |
_PID | process.pid |
_COMM | process.executable.name |
_EXE | process.executable.path |
_CMD | process.command |
_CMDLINE | process.command_line |
_UID | process.owner |
_TRANSPORT | log.iostream |
_SYSTEMD_CGROUP | process.linux.cgroup |
The _SOURCE_REALTIME_TIMESTAMP key is also mapped to the log record timestamp if it exists and contains an integer number of microseconds since the Unix epoch, as a string.
journald Severity Mapping
The priority in the PRIORITY field of a journal entry is mapped to log record severity number as follows:
| Priority | Severity Number | Description |
|---|---|---|
| 0 | 24 (Fatal4) | Emergency: system is unusable |
| 1 | 21 (Fatal) | Alert: action must be taken immediately |
| 2 | 18 (Error2) | Critical: critical conditions |
| 3 | 17 (Error) | Error: error conditions |
| 4 | 13 (Warn) | Warning: warning conditions |
| 5 | 10 (Info2) | Notice: normal but significant condition |
| 6 | 9 (Info) | Informational: informational messages |
| 7 | 5 (Debug) | Debug: debug-level messages |
pino
For pino , the following nested keys under the err key are mapped. This only happens when err.message, err.type, and err.stack are all present and are strings.
| Key | OpenTelemetry Attribute |
|---|---|
err.message | exception.message |
err.type | exception.type |
err.stack | exception.stacktrace |
See also: https://getpino.io/#/docs/api?id=errors
Java (MDC)
The contents of the mdc key are lifted to the root level of log record attributes.
For example, mdc.loggerName would be available as an attribute with the key loggerName.
A trace ID, span ID, or sampled flag inside mdc is mapped like a top-level one (see Trace ID, Span ID, and Trace Sampling) and is not lifted to the attributes. If both mdc and the top level contain one, the top-level value wins.
See also:
- https://www.slf4j.org/api/org/slf4j/MDC.html
- https://logback.qos.ch/manual/mdc.html
- https://logging.apache.org/log4j/1.x/apidocs/org/apache/log4j/MDC.html
- https://logging.apache.org/log4j/2.x/manual/thread-context.html
- https://github.com/logfellow/logstash-logback-encoder?tab=readme-ov-file#mdc-fields
Last updated: