Skip to content

Commit 3933d6a

Browse files
author
elasticsearchmachine
committed
Merge remote-tracking branch 'origin/main' into lucene_snapshot
2 parents fc31076 + e221c03 commit 3933d6a

File tree

6 files changed

+85
-16
lines changed

6 files changed

+85
-16
lines changed

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ template:
1414
attributes:
1515
type: passthrough
1616
dynamic: true
17-
priority: 10
18-
time_series_dimension: true
17+
priority: 20
1918
properties:
2019
exception.type:
2120
type: keyword
@@ -40,13 +39,28 @@ template:
4039
log.level:
4140
type: alias
4241
path: severity_text
43-
body_text:
44-
type: match_only_text
42+
body:
43+
type: object
44+
properties:
45+
text:
46+
type: match_only_text
47+
flattened:
48+
# this is used for complex bodies of regular log records
49+
# using the flattened field type avoids mapping issues which can be caused by logs containing arbitrary JSON objects
50+
# the tradeoff is that the flattened field type is currently not supported well by Kibana and has other limitations
51+
type: flattened
52+
structured:
53+
# this is used for events
54+
# events are also represented as log records
55+
# the event.name attribute uniquely identifies event structure / type of the payload (body)
56+
# see also https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/events.md
57+
# this makes them less prone to mapping issues, which is why we're enabling dynamic mappings
58+
type: passthrough
59+
dynamic: true
60+
priority: 10
4561
message:
4662
type: alias
47-
path: body_text
48-
body_structured:
49-
type: flattened
63+
path: body.text
5064
trace_id:
5165
type: keyword
5266
trace.id:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ template:
1010
metrics:
1111
type: passthrough
1212
dynamic: true
13-
priority: 1
13+
priority: 10
1414
unit:
1515
type: keyword
1616
time_series_dimension: true

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ template:
2020
attributes:
2121
type: passthrough
2222
dynamic: true
23-
priority: 10
23+
priority: 20
2424
time_series_dimension: true
2525
dropped_attributes_count:
2626
type: long
@@ -39,7 +39,7 @@ template:
3939
attributes:
4040
type: passthrough
4141
dynamic: true
42-
priority: 20
42+
priority: 30
4343
time_series_dimension: true
4444
resource:
4545
properties:
@@ -51,7 +51,7 @@ template:
5151
attributes:
5252
type: passthrough
5353
dynamic: true
54-
priority: 30
54+
priority: 40
5555
time_series_dimension: true
5656
dynamic_templates:
5757
- complex_attributes:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ template:
1111
attributes:
1212
type: passthrough
1313
dynamic: true
14-
priority: 30
14+
priority: 40
1515
time_series_dimension: true
1616
properties:
1717
host.name:

x-pack/plugin/otel-data/src/main/resources/resources.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# "version" holds the version of the templates and ingest pipelines installed
22
# by xpack-plugin otel-data. This must be increased whenever an existing template is
33
# changed, in order for it to be updated on Elasticsearch upgrade.
4-
version: 4
4+
version: 5
55

66
component-templates:
77
- otel@mappings

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

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ setup:
1111
refresh: true
1212
body:
1313
- create: {}
14-
- '{"@timestamp":"2024-07-18T14:48:33.467654000Z","data_stream":{"dataset":"generic.otel","namespace":"default"}, "attributes": { "foo": "bar"}, "body_text":"Error: Unable to connect to the database.","severity_text":"ERROR","severity_number":3,"trace_id":"abc123xyz456def789ghi012jkl345"}'
14+
- '{"@timestamp":"2024-07-18T14:48:33.467654000Z","data_stream":{"dataset":"generic.otel","namespace":"default"}, "attributes": { "foo": "bar"}, "body":{"text":"Error: Unable to connect to the database."},"severity_text":"ERROR","severity_number":3,"trace_id":"abc123xyz456def789ghi012jkl345"}'
1515
- is_false: errors
1616
- do:
1717
search:
@@ -39,7 +39,8 @@ setup:
3939
attributes:
4040
foo: [3, 2, 1]
4141
bar: [b, c, a]
42-
body_text: "Error: Unable to connect to the database."
42+
body:
43+
text: "Error: Unable to connect to the database."
4344
severity_text: ERROR
4445
- is_false: errors
4546
- do:
@@ -78,7 +79,7 @@ setup:
7879
refresh: true
7980
body:
8081
- create: {}
81-
- '{"@timestamp":"2024-07-18T14:49:33.467654000Z","data_stream":{"dataset":"generic.otel","namespace":"default"}, "body_text":"error1"}'
82+
- '{"@timestamp":"2024-07-18T14:49:33.467654000Z","data_stream":{"dataset":"generic.otel","namespace":"default"}, "body": {"text":"error1"}}'
8283
- is_false: errors
8384
- do:
8485
indices.get_data_stream:
@@ -90,3 +91,57 @@ setup:
9091
- is_true: $datastream-backing-index
9192
- match: { .$datastream-backing-index.settings.index.sort.field.0: "resource.attributes.host.name" }
9293
- match: { .$datastream-backing-index.settings.index.sort.field.1: "@timestamp" }
94+
---
95+
Event body:
96+
- do:
97+
bulk:
98+
index: logs-generic.otel-default
99+
refresh: true
100+
body:
101+
- create: {}
102+
- "@timestamp": 2024-07-18T14:48:33.467654000Z
103+
resource:
104+
attributes:
105+
service.name: my-service
106+
attributes:
107+
event.name: foo
108+
body:
109+
structured:
110+
foo:
111+
bar: baz
112+
- is_false: errors
113+
- do:
114+
indices.get_data_stream:
115+
name: logs-generic.otel-default
116+
- set: { data_streams.0.indices.0.index_name: datastream-backing-index }
117+
- do:
118+
indices.get_mapping:
119+
index: $datastream-backing-index
120+
- is_true: $datastream-backing-index
121+
- match: { .$datastream-backing-index.mappings.properties.body.properties.structured.properties.foo\.bar.type: "keyword" }
122+
---
123+
Structured log body:
124+
- do:
125+
bulk:
126+
index: logs-generic.otel-default
127+
refresh: true
128+
body:
129+
- create: {}
130+
- "@timestamp": 2024-07-18T14:48:33.467654000Z
131+
resource:
132+
attributes:
133+
service.name: my-service
134+
body:
135+
flattened:
136+
foo:
137+
bar: baz
138+
- is_false: errors
139+
- do:
140+
indices.get_data_stream:
141+
name: logs-generic.otel-default
142+
- set: { data_streams.0.indices.0.index_name: datastream-backing-index }
143+
- do:
144+
indices.get_mapping:
145+
index: $datastream-backing-index
146+
- is_true: $datastream-backing-index
147+
- match: { .$datastream-backing-index.mappings.properties.body.properties.flattened.type: "flattened" }

0 commit comments

Comments
 (0)