Skip to content

Commit fdab1ff

Browse files
authored
Consistent mapping for OTel log and event bodies (#120547)
1 parent b3a032c commit fdab1ff

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

docs/changelog/120547.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 120547
2+
summary: Consistent mapping for OTel log and event bodies
3+
area: Data streams
4+
type: enhancement
5+
issues: []

x-pack/plugin/otel-data/src/main/resources/component-templates/[email protected]

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,11 @@ template:
4747
properties:
4848
text:
4949
type: match_only_text
50-
flattened:
51-
# this is used for complex bodies of regular log records
50+
structured:
51+
# this is used for complex bodies of log records (including events)
5252
# using the flattened field type avoids mapping issues which can be caused by logs containing arbitrary JSON objects
5353
# the tradeoff is that the flattened field type is currently not supported well by Kibana and has other limitations
5454
type: flattened
55-
structured:
56-
# this is used for events
57-
# events are also represented as log records
58-
# the event.name attribute uniquely identifies event structure / type of the payload (body)
59-
# see also https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/events.md
60-
# this makes them less prone to mapping issues, which is why we're enabling dynamic mappings
61-
type: passthrough
62-
dynamic: true
63-
priority: 10
6455
message:
6556
type: alias
6657
path: body.text

x-pack/plugin/otel-data/src/yamlRestTest/resources/rest-api-spec/test/20_logs_tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Event body:
119119
indices.get_mapping:
120120
index: $datastream-backing-index
121121
- is_true: $datastream-backing-index
122-
- match: { .$datastream-backing-index.mappings.properties.body.properties.structured.properties.foo\.bar.type: "keyword" }
122+
- match: { .$datastream-backing-index.mappings.properties.body.properties.structured.type: "flattened" }
123123
- match: { .$datastream-backing-index.mappings.properties.event_name.type: "keyword" }
124124
---
125125
Structured log body:
@@ -134,7 +134,7 @@ Structured log body:
134134
attributes:
135135
service.name: my-service
136136
body:
137-
flattened:
137+
structured:
138138
foo:
139139
bar: baz
140140
- is_false: errors
@@ -146,7 +146,7 @@ Structured log body:
146146
indices.get_mapping:
147147
index: $datastream-backing-index
148148
- is_true: $datastream-backing-index
149-
- match: { .$datastream-backing-index.mappings.properties.body.properties.flattened.type: "flattened" }
149+
- match: { .$datastream-backing-index.mappings.properties.body.properties.structured.type: "flattened" }
150150
---
151151
"event.dataset alias must point to data_stream.dataset":
152152
- do:

0 commit comments

Comments
 (0)