Skip to content

Commit

Permalink
Consistent mapping for OTel log and event bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbarny committed Jan 21, 2025
1 parent 1d9acc1 commit b7ce50e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,11 @@ template:
properties:
text:
type: match_only_text
flattened:
# this is used for complex bodies of regular log records
structured:
# this is used for complex bodies of log records (including events)
# using the flattened field type avoids mapping issues which can be caused by logs containing arbitrary JSON objects
# the tradeoff is that the flattened field type is currently not supported well by Kibana and has other limitations
type: flattened
structured:
# this is used for events
# events are also represented as log records
# the event.name attribute uniquely identifies event structure / type of the payload (body)
# see also https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/events.md
# this makes them less prone to mapping issues, which is why we're enabling dynamic mappings
type: passthrough
dynamic: true
priority: 10
message:
type: alias
path: body.text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Event body:
indices.get_mapping:
index: $datastream-backing-index
- is_true: $datastream-backing-index
- match: { .$datastream-backing-index.mappings.properties.body.properties.structured.properties.foo\.bar.type: "keyword" }
- match: { .$datastream-backing-index.mappings.properties.body.properties.structured.type: "flattened" }
- match: { .$datastream-backing-index.mappings.properties.event_name.type: "keyword" }
---
Structured log body:
Expand All @@ -134,7 +134,7 @@ Structured log body:
attributes:
service.name: my-service
body:
flattened:
structured:
foo:
bar: baz
- is_false: errors
Expand All @@ -146,7 +146,7 @@ Structured log body:
indices.get_mapping:
index: $datastream-backing-index
- is_true: $datastream-backing-index
- match: { .$datastream-backing-index.mappings.properties.body.properties.flattened.type: "flattened" }
- match: { .$datastream-backing-index.mappings.properties.body.properties.structured.type: "flattened" }
---
"event.dataset alias must point to data_stream.dataset":
- do:
Expand Down

0 comments on commit b7ce50e

Please sign in to comment.