-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[apm-data] Set event.dataset if empty for logs #129074
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
71b8459
[apm-data] Set event.dataset if empty for logs
carsonip f63e462
Merge branch 'main' into apm-logs-event-dataset
carsonip 0923bcd
Update docs/changelog/129074.yaml
carsonip 7add32d
Introduce logs-apm@pipeline
carsonip 48b569b
Add test
carsonip 4bab03d
Fix test
carsonip 309d0df
Merge branch 'main' into apm-logs-event-dataset
carsonip b584c7f
Bump version after rebase
carsonip 57fe0ea
Fix typo in test
carsonip a0ec35a
Fix tests again
carsonip a4c1f16
Use copy_from and ignore_empty_value
carsonip 957d9ef
Add tests for missing data_stream.dataset
carsonip 6be45d2
Merge branch 'main' into apm-logs-event-dataset
carsonip 4099dbe
Merge branch 'main' into apm-logs-event-dataset
carsonip ce4c9bd
Merge branch 'main' into apm-logs-event-dataset
carsonip 74f6949
Bump version
carsonip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 129074 | ||
| summary: "[apm-data] Set `event.dataset` if empty for logs" | ||
| area: Data streams | ||
| type: bug | ||
| issues: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
x-pack/plugin/apm-data/src/main/resources/ingest-pipelines/[email protected]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| version: ${xpack.apmdata.template.version} | ||
| _meta: | ||
| managed: true | ||
| description: Built-in ingest pipeline for logs-apm.*-* data streams | ||
| processors: | ||
| # Set event.dataset if unset to meet Anomaly Detection requirements | ||
| - set: | ||
| if: "ctx.data_stream?.dataset != null" | ||
| field: event.dataset | ||
| value: "{{{data_stream.dataset}}}" | ||
| override: false | ||
| - pipeline: | ||
| name: apm@pipeline | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_logs_pipeline.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| --- | ||
| setup: | ||
| - do: | ||
| cluster.health: | ||
| wait_for_events: languid | ||
| --- | ||
| "Test logs-apm.error-* event.dataset field": | ||
| - do: | ||
| bulk: | ||
| index: logs-apm.error-eventdataset | ||
| refresh: true | ||
| body: | ||
| - create: {} | ||
| - '{"@timestamp": "2017-06-22", "data_stream": {"type": "logs", "dataset": "apm.error", "namespace": "eventdataset"}, "log": {"level": "error"}, "error": {"log": {"message": "loglevel"}, "exception": [{"message": "exception_used"}]}}' | ||
|
|
||
| - create: {} | ||
| - '{"@timestamp": "2017-06-22", "data_stream": {"type": "logs", "dataset": "apm.error", "namespace": "eventdataset"}, "event": {"dataset": "foo"}, "log": {"level": "error"}, "error": {"log": {"message": "loglevel"}, "exception": [{"message": "exception_used"}]}}' | ||
|
|
||
| - is_false: errors | ||
|
|
||
| - do: | ||
| search: | ||
| index: logs-apm.error-eventdataset | ||
| body: | ||
| fields: ["event.dataset"] | ||
| - length: { hits.hits: 2 } | ||
| - match: { hits.hits.0.fields: { "event.dataset": ["apm.error"] } } | ||
| - match: { hits.hits.1.fields: { "event.dataset": ["foo"] } } | ||
| --- | ||
| "Test logs-apm.app.*-* event.dataset field": | ||
| - do: | ||
| bulk: | ||
| index: logs-apm.app.foo-eventdataset | ||
| refresh: true | ||
| body: | ||
| - create: {} | ||
| - '{"@timestamp": "2017-06-22", "data_stream": {"type": "logs", "dataset": "apm.app.foo", "namespace": "eventdataset"}, "message": "foo"}' | ||
|
|
||
| - create: {} | ||
| - '{"@timestamp": "2017-06-22", "data_stream": {"type": "logs", "dataset": "apm.app.foo", "namespace": "eventdataset"}, "event": {"dataset": "foo"}, "message": "foo"}' | ||
|
|
||
| - is_false: errors | ||
|
|
||
| - do: | ||
| search: | ||
| index: logs-apm.app.foo-eventdataset | ||
| body: | ||
| fields: ["event.dataset"] | ||
| - length: { hits.hits: 2 } | ||
| - match: { hits.hits.0.fields: { "event.dataset": ["apm.app.foo"] } } | ||
| - match: { hits.hits.1.fields: { "event.dataset": ["foo"] } } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: should we use
copy_fromandignore_empty_value, and remove theifandvalue?(See https://www.elastic.co/docs/reference/enrich-processor/set-processor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will
data_stream.datasetbe automatically set for thelogs-apm.*data stream documents, if they're not specified in_source? If that's the case, I'm not sure they will be inctx.*, and we may need to have a fallback.Can you add test cases for that?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, at least not visible to the log ingest pipeline.
Correct, they will not be in ctx.
Do you mean a fallback to a non-null
event.datasetin the case where both data_stream.dataset and event.dataset is missing? I'm inclined to not perform any special case handling to make things up because it sounds more like a misconfiguration issue. Unless the user explicitly remove the DS fields in an intermediate ingest pipeline, DS fields should always be present in docs from apm-server (even if reroute processor is used).In any case, I've added test in 957d9ef to confirm this behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with this. I don't think it's a real thing we need to handle, even if it's technically possible.