diff --git a/internal/pkg/agent/application/monitoring/v1_monitor.go b/internal/pkg/agent/application/monitoring/v1_monitor.go index 55e9a4dc3f9..bb3bd43a487 100644 --- a/internal/pkg/agent/application/monitoring/v1_monitor.go +++ b/internal/pkg/agent/application/monitoring/v1_monitor.go @@ -424,6 +424,13 @@ func (b *BeatsMonitor) injectLogsInput(cfg map[string]interface{}, components [] "to": "data_stream.dataset_original", }, }, + "when": map[string]any{ + "not": map[string]any{ + "has_fields": []any{ + "data_stream.dataset_original", + }, + }, + }, }, }, // drop the dataset field so following copy_field can copy to it @@ -443,6 +450,13 @@ func (b *BeatsMonitor) injectLogsInput(cfg map[string]interface{}, components [] "to": "data_stream.dataset", }, }, + "when": map[string]any{ + "not": map[string]any{ + "has_fields": []any{ + "data_stream.dataset", + }, + }, + }, "fail_on_error": false, "ignore_missing": true, }, @@ -450,6 +464,13 @@ func (b *BeatsMonitor) injectLogsInput(cfg map[string]interface{}, components [] // possible it's a log message from agent itself (doesn't have component.dataset) map[string]interface{}{ "copy_fields": map[string]interface{}{ + "when": map[string]any{ + "not": map[string]any{ + "has_fields": []any{ + "data_stream.dataset", + }, + }, + }, "fields": []interface{}{ map[string]interface{}{ "from": "data_stream.dataset_original", @@ -471,6 +492,13 @@ func (b *BeatsMonitor) injectLogsInput(cfg map[string]interface{}, components [] // update event.dataset with the now used data_stream.dataset map[string]interface{}{ "copy_fields": map[string]interface{}{ + "when": map[string]any{ + "not": map[string]any{ + "has_fields": []any{ + "event.dataset", + }, + }, + }, "fields": []interface{}{ map[string]interface{}{ "from": "data_stream.dataset",