Skip to content

Commit 862a7e1

Browse files
authored
Add _metric_names_hash field to OTel metric mappings (elastic#120952) (elastic#122879)
If metrics that have the same timestamp and dimensions aren't grouped into the same document, ES will consider them to be a duplicate. The _metric_names_hash field will be set by the OTel ES exporter. As it's mapped as a time_series_dimensions, it creates a different _tsid for documents with different sets of metrics. The tradeoff is that if the composition of the metrics grouping changes over time, a different _tsid will be created. That has an impact on the rate aggregation for counters.
1 parent a632634 commit 862a7e1

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

docs/changelog/120952.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 120952
2+
summary: Add `_metric_names_hash` field to OTel metric mappings
3+
area: Data streams
4+
type: bug
5+
issues: []

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ template:
1414
type: passthrough
1515
dynamic: true
1616
priority: 10
17+
# workaround for https://github.com/elastic/elasticsearch/issues/99123
18+
_metric_names_hash:
19+
type: keyword
20+
time_series_dimension: true
1721
unit:
1822
type: keyword
1923
time_series_dimension: true

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,26 @@ Metrics with different scope names are not duplicates:
302302
metrics:
303303
foo.bar: 42
304304
- is_false: errors
305+
306+
---
307+
Metrics with different metric name hashes are not duplicates:
308+
- do:
309+
bulk:
310+
index: metrics-generic.otel-default
311+
refresh: true
312+
body:
313+
- create: {"dynamic_templates":{"metrics.foo":"counter_long"}}
314+
- "@timestamp": 2024-07-18T14:00:00Z
315+
attributes:
316+
foo: bar
317+
metrics:
318+
foo: 42
319+
_metric_names_hash: a9f37ed7
320+
- create: {"dynamic_templates":{"metrics.bar":"counter_long"}}
321+
- "@timestamp": 2024-07-18T14:00:00Z
322+
attributes:
323+
foo: bar
324+
metrics:
325+
bar: 42
326+
_metric_names_hash: 76b77d1a
327+
- is_false: errors

0 commit comments

Comments
 (0)