Skip to content

Commit

Permalink
OTel mappings: avoid metrics to be rejected when attributes are malfo…
Browse files Browse the repository at this point in the history
…rmed
  • Loading branch information
felixbarny committed Oct 15, 2024
1 parent 5e59ab5 commit 4fe285b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ _meta:
description: Default mappings for the OpenTelemetry metrics index template installed by x-pack
managed: true
template:
settings:
index.mapping.ignore_malformed: true
mappings:
properties:
start_timestamp:
Expand All @@ -19,27 +21,22 @@ template:
- histogram:
mapping:
type: histogram
ignore_malformed: true
- counter_long:
mapping:
type: long
time_series_metric: counter
ignore_malformed: true
- gauge_long:
mapping:
type: long
time_series_metric: gauge
ignore_malformed: true
- counter_double:
mapping:
type: double
time_series_metric: counter
ignore_malformed: true
- gauge_double:
mapping:
type: double
time_series_metric: gauge
ignore_malformed: true
- summary:
mapping:
type: aggregate_metric_double
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,3 @@ template:
data_stream.type:
type: constant_keyword
value: metrics
dynamic_templates:
- ecs_ip:
mapping:
type: ip
path_match: [ "ip", "*.ip", "*_ip" ]
match_mapping_type: string
- all_strings_to_keywords:
mapping:
ignore_above: 1024
type: keyword
match_mapping_type: string
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,37 @@ IP dimensions:
- match: { .$idx0name.mappings.properties.metrics.properties.summary.type: 'aggregate_metric_double' }
- match: { .$idx0name.mappings.properties.metrics.properties.summary_minmax.type: 'aggregate_metric_double' }
- match: { .$idx0name.mappings.properties.metrics.properties.histogram.type: 'histogram' }
---
Empty IP field:
- do:
bulk:
index: metrics-generic.otel-default
refresh: true
body:
- create: {"dynamic_templates":{"metrics.foo.bar":"counter_long"}}
- "@timestamp": 2024-07-18T14:48:33.467654000Z
resource:
attributes:
host.name: localhost
host.ip: ""
metrics:
foo.bar: 42
- is_false: errors

- do:
indices.get_data_stream:
name: metrics-generic.otel-default
- set: { data_streams.0.indices.0.index_name: idx0name }

- do:
indices.get_mapping:
index: $idx0name
expand_wildcards: hidden
- match: { .$idx0name.mappings.properties.resource.properties.attributes.properties.host\.ip.type: 'ip' }
- do:
search:
index: metrics-generic.otel-default
body:
fields: ["*"]
- length: { hits.hits: 1 }
- match: { hits.hits.0._ignored: ["resource.attributes.host.ip"] }

0 comments on commit 4fe285b

Please sign in to comment.