Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[exporter/elasticsearch] deprecate 'dedot' config #33780

Merged
27 changes: 27 additions & 0 deletions .chloggen/elasticsearch-deprecate-dedot.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: deprecation

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate the "dedot" configuration.

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

# (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: dedot has been deprecated, and will always be enabled in ECS mode and disabled for other modes in future

# 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]
5 changes: 3 additions & 2 deletions exporter/elasticsearchexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ behaviours, which may be configured throug the following settings:
Try to find and remove duplicate fields/attributes from events before publishing
to Elasticsearch. Some structured logging libraries can produce duplicate fields
(for example zap). Elasticsearch will reject documents that have duplicate fields.
- `dedot` (default=true): When enabled attributes with `.` will be split into
proper json objects.
- `dedot` (default=true; DEPRECATED, in future dedotting will always be enabled
for ECS mode, and never for other modes): When enabled attributes with `.`
will be split into proper json objects.

#### ECS mapping mode

Expand Down
9 changes: 9 additions & 0 deletions exporter/elasticsearchexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ type MappingsSettings struct {
// as Elasticsearch will reject documents with duplicate JSON object keys.
Dedup bool `mapstructure:"dedup"`

// Deprecated: [v0.104.0] dedotting will always be applied for ECS mode
axw marked this conversation as resolved.
Show resolved Hide resolved
// in future, and never for other modes. Elasticsearch's "dot_expander"
// Ingest processor may be used as an alternative for non-ECS modes.
Dedot bool `mapstructure:"dedot"`
}

Expand Down Expand Up @@ -319,4 +322,10 @@ func logConfigDeprecationWarnings(cfg *Config, logger *zap.Logger) {
if !cfg.Mapping.Dedup {
logger.Warn("dedup has been deprecated, and will always be enabled in future")
}
if cfg.Mapping.Dedot && cfg.MappingMode() != MappingECS {
logger.Warn("dedot has been deprecated, and will always be disabled in the future, unless in ECS mode")
}
if !cfg.Mapping.Dedot && cfg.MappingMode() == MappingECS {
logger.Warn("dedot has been deprecated, and will always be enabled in ECS mode in future")
}
axw marked this conversation as resolved.
Show resolved Hide resolved
}
43 changes: 43 additions & 0 deletions exporter/elasticsearchexporter/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func TestFactory_DedupDeprecated(t *testing.T) {
cfg := withDefaultConfig(func(cfg *Config) {
cfg.Endpoint = "http://testing.invalid:9200"
cfg.Mapping.Dedup = false
cfg.Mapping.Dedot = false // avoid dedot warnings
})

loggerCore, logObserver := observer.New(zap.WarnLevel)
Expand All @@ -126,3 +127,45 @@ func TestFactory_DedupDeprecated(t *testing.T) {
assert.Equal(t, "dedup has been deprecated, and will always be enabled in future", records[1].Message)
assert.Equal(t, "dedup has been deprecated, and will always be enabled in future", records[2].Message)
}

func TestFactory_DedotDeprecated(t *testing.T) {
loggerCore, logObserver := observer.New(zap.WarnLevel)
set := exportertest.NewNopSettings()
set.Logger = zap.New(loggerCore)

cfgNoDedotECS := withDefaultConfig(func(cfg *Config) {
cfg.Endpoint = "http://testing.invalid:9200"
cfg.Mapping.Dedot = false
cfg.Mapping.Mode = "ecs"
})

cfgDedotRaw := withDefaultConfig(func(cfg *Config) {
cfg.Endpoint = "http://testing.invalid:9200"
cfg.Mapping.Dedot = true
cfg.Mapping.Mode = "raw"
})

for _, cfg := range []*Config{cfgNoDedotECS, cfgDedotRaw} {
factory := NewFactory()
logsExporter, err := factory.CreateLogsExporter(context.Background(), set, cfg)
require.NoError(t, err)
require.NoError(t, logsExporter.Shutdown(context.Background()))

tracesExporter, err := factory.CreateTracesExporter(context.Background(), set, cfg)
require.NoError(t, err)
require.NoError(t, tracesExporter.Shutdown(context.Background()))

metricsExporter, err := factory.CreateMetricsExporter(context.Background(), set, cfg)
require.NoError(t, err)
require.NoError(t, metricsExporter.Shutdown(context.Background()))
}

records := logObserver.AllUntimed()
assert.Len(t, records, 6)
assert.Equal(t, "dedot has been deprecated, and will always be enabled in ECS mode in future", records[0].Message)
assert.Equal(t, "dedot has been deprecated, and will always be enabled in ECS mode in future", records[1].Message)
assert.Equal(t, "dedot has been deprecated, and will always be enabled in ECS mode in future", records[2].Message)
axw marked this conversation as resolved.
Show resolved Hide resolved
assert.Equal(t, "dedot has been deprecated, and will always be disabled in the future, unless in ECS mode", records[3].Message)
assert.Equal(t, "dedot has been deprecated, and will always be disabled in the future, unless in ECS mode", records[4].Message)
assert.Equal(t, "dedot has been deprecated, and will always be disabled in the future, unless in ECS mode", records[5].Message)
}
Loading