Skip to content

Commit 80c163e

Browse files
authored
OTel mappings: avoid metrics to be rejected when attributes are malformed (#114856)
1 parent 9082e02 commit 80c163e

File tree

5 files changed

+42
-17
lines changed

5 files changed

+42
-17
lines changed

docs/changelog/114856.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 114856
2+
summary: "OTel mappings: avoid metrics to be rejected when attributes are malformed"
3+
area: Data streams
4+
type: bug
5+
issues: []

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ _meta:
33
description: Default mappings for the OpenTelemetry metrics index template installed by x-pack
44
managed: true
55
template:
6+
settings:
7+
index.mapping.ignore_malformed: true
68
mappings:
79
properties:
810
start_timestamp:
@@ -19,27 +21,22 @@ template:
1921
- histogram:
2022
mapping:
2123
type: histogram
22-
ignore_malformed: true
2324
- counter_long:
2425
mapping:
2526
type: long
2627
time_series_metric: counter
27-
ignore_malformed: true
2828
- gauge_long:
2929
mapping:
3030
type: long
3131
time_series_metric: gauge
32-
ignore_malformed: true
3332
- counter_double:
3433
mapping:
3534
type: double
3635
time_series_metric: counter
37-
ignore_malformed: true
3836
- gauge_double:
3937
mapping:
4038
type: double
4139
time_series_metric: gauge
42-
ignore_malformed: true
4340
- summary:
4441
mapping:
4542
type: aggregate_metric_double

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,3 @@ template:
2727
data_stream.type:
2828
type: constant_keyword
2929
value: metrics
30-
dynamic_templates:
31-
- ecs_ip:
32-
mapping:
33-
type: ip
34-
path_match: [ "ip", "*.ip", "*_ip" ]
35-
match_mapping_type: string
36-
- all_strings_to_keywords:
37-
mapping:
38-
ignore_above: 1024
39-
type: keyword
40-
match_mapping_type: string

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: 5
4+
version: 6
55

66
component-templates:
77
- otel@mappings

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,37 @@ IP dimensions:
245245
- match: { .$idx0name.mappings.properties.metrics.properties.summary.type: 'aggregate_metric_double' }
246246
- match: { .$idx0name.mappings.properties.metrics.properties.summary_minmax.type: 'aggregate_metric_double' }
247247
- match: { .$idx0name.mappings.properties.metrics.properties.histogram.type: 'histogram' }
248+
---
249+
Empty IP field:
250+
- do:
251+
bulk:
252+
index: metrics-generic.otel-default
253+
refresh: true
254+
body:
255+
- create: {"dynamic_templates":{"metrics.foo.bar":"counter_long"}}
256+
- "@timestamp": 2024-07-18T14:48:33.467654000Z
257+
resource:
258+
attributes:
259+
host.name: localhost
260+
host.ip: ""
261+
metrics:
262+
foo.bar: 42
263+
- is_false: errors
264+
265+
- do:
266+
indices.get_data_stream:
267+
name: metrics-generic.otel-default
268+
- set: { data_streams.0.indices.0.index_name: idx0name }
269+
270+
- do:
271+
indices.get_mapping:
272+
index: $idx0name
273+
expand_wildcards: hidden
274+
- match: { .$idx0name.mappings.properties.resource.properties.attributes.properties.host\.ip.type: 'ip' }
275+
- do:
276+
search:
277+
index: metrics-generic.otel-default
278+
body:
279+
fields: ["*"]
280+
- length: { hits.hits: 1 }
281+
- match: { hits.hits.0._ignored: ["resource.attributes.host.ip"] }

0 commit comments

Comments
 (0)