Skip to content
27 changes: 27 additions & 0 deletions .chloggen/elasticsearchexporter_mapping-mode-default-otel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: elasticsearchexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Change default `mapping::mode` config to `otel`

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [37241]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: To retain the old behavior, explicitly set `mapping::mode` to `none`.

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: [user]
13 changes: 8 additions & 5 deletions exporter/elasticsearchexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ The Elasticsearch exporter supports several document schemas and preprocessing
behaviours, which may be configured through the following settings:

- `mapping`:
- `mode` (default=none): The default mapping mode. Valid modes are:
- `mode` (default=otel): The default mapping mode. Valid modes are:
- `none`
- `ecs`
- `otel`
Expand All @@ -177,7 +177,12 @@ See below for a description of each mapping mode.

#### OTel mapping mode

Requires Elasticsearch 8.12 or above.
The default and recommended "OTel-native" mapping mode.

Requires Elasticsearch 8.12 or above[^1], works best with Elasticsearch 8.16 or above[^2].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a user that uses the Elasticsearch exporter with Elasticsearch < 8.12 and the default mapping mode, they will stop seeing their data in Elasticsearch, and start seeing rejection logs in the collector. This is not ideal.

On the other hand, 8.12 is over a year old (January 2024) and the officially supported versions of Elasticsearch are currently 8.16 and 8.17.

I'm on board with this change as it makes new users' experience much better. Also the remediation is easy for affected users: add a configuration flag, as described in the changelog entry.


[^1]: as it uses the undocumented `require_data_stream` bulk API parameter supported from Elasticsearch 8.12
[^2]: Elasticsearch 8.16 contains a built-in `otel-data` plugin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, Is there a link to the relevant introduction?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a link to the initial PR: elastic/elasticsearch#111091


In `otel` mapping mode, the Elasticsearch Exporter stores documents in Elastic's preferred
"OTel-native" schema. In this mapping mode, documents use the original attribute names and
Expand All @@ -188,9 +193,7 @@ and `data_stream.namespace`. Instead of serializing these values under the `*att
they are put at the root of the document, to conform with the conventions of the data stream naming
scheme that maps these as `constant_keyword` fields.

`data_stream.dataset` will always be appended with `.otel`. It is recommended to use with
`*_dynamic_index::enabled: true` (e.g. `logs_dynamic_index::enabled`) to route documents to data stream
`${data_stream.type}-${data_stream.dataset}-${data_stream.namespace}`.
`data_stream.dataset` will always be appended with `.otel` if [dynamic data stream routing mode](#elasticsearch-document-routing) is active.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expecting a conflict with #38500 . Can be resolved once either PR is merged.


Span events are stored in separate documents. They will be routed with `data_stream.type` set to
`logs` if `traces_dynamic_index::enabled` is `true`.
Expand Down
6 changes: 3 additions & 3 deletions exporter/elasticsearchexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestConfig(t *testing.T) {
RetryOnStatus: []int{http.StatusTooManyRequests, http.StatusInternalServerError},
},
Mapping: MappingsSettings{
Mode: "none",
Mode: "otel",
AllowedModes: []string{"bodymap", "ecs", "none", "otel", "raw"},
},
LogstashFormat: LogstashFormatSettings{
Expand Down Expand Up @@ -184,7 +184,7 @@ func TestConfig(t *testing.T) {
RetryOnStatus: []int{http.StatusTooManyRequests, http.StatusInternalServerError},
},
Mapping: MappingsSettings{
Mode: "none",
Mode: "otel",
AllowedModes: []string{"bodymap", "ecs", "none", "otel", "raw"},
},
LogstashFormat: LogstashFormatSettings{
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestConfig(t *testing.T) {
RetryOnStatus: []int{http.StatusTooManyRequests, http.StatusInternalServerError},
},
Mapping: MappingsSettings{
Mode: "none",
Mode: "otel",
AllowedModes: []string{"bodymap", "ecs", "none", "otel", "raw"},
},
LogstashFormat: LogstashFormatSettings{
Expand Down
2 changes: 2 additions & 0 deletions exporter/elasticsearchexporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ func TestExporterLogs(t *testing.T) {
})

exporter := newTestLogsExporter(t, server.URL, func(cfg *Config) {
cfg.Mapping.Mode = "none"
cfg.LogsDynamicIndex.Enabled = true
})
logs := newLogsWithAttributes(
Expand Down Expand Up @@ -1733,6 +1734,7 @@ func TestExporterTraces(t *testing.T) {
})

exporter := newTestTracesExporter(t, server.URL, func(cfg *Config) {
cfg.Mapping.Mode = "none"
cfg.TracesDynamicIndex.Enabled = true
})

Expand Down
2 changes: 1 addition & 1 deletion exporter/elasticsearchexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func createDefaultConfig() component.Config {
},
},
Mapping: MappingsSettings{
Mode: "none",
Mode: "otel",
AllowedModes: slices.Sorted(maps.Keys(canonicalMappingModes)),
},
LogstashFormat: LogstashFormatSettings{
Expand Down
Loading