- Notifications
You must be signed in to change notification settings - Fork 25.6k
[Logs+] Default pipeline for logs data streams #95971
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
felixbarny merged 20 commits into elastic:main from eyalkoren:default-timestamp-for-logs May 12, 2023
Merged
Changes from all commits
Commits
Show all changes
20 commits Select commit Hold shift + click to select a range
8934c9e Adding ability to auto-install ingest pipelines through index templates
eyalkoren 4aaa1ff Merge remote-tracking branch 'upstream/main' into ingest-pipeline-reg…
eyalkoren 8d09963 Update docs/changelog/95782.yaml
eyalkoren 0240b07 Update changelog summary
eyalkoren 5354b7c Guarding from nulls
eyalkoren ddef98e Avoid using forbidden API
eyalkoren 7ee1694 Fixing AnalyticsTemplateRegistryTests to pass index template validation
eyalkoren e82e135 Merge remote-tracking branch 'upstream/main' into ingest-pipeline-reg…
eyalkoren 481f132 Fixing validation when IngestMetadata is null in cluster state
eyalkoren 3f89462 Merge remote-tracking branch 'upstream/main' into ingest-pipeline-reg…
eyalkoren 0688915 Merge remote-tracking branch 'upstream/main' into default-timestamp-f…
eyalkoren e361eb8 [Logs+] adding defalut pipeline for logs data streams
eyalkoren 4cd492b Update docs/changelog/95971.yaml
eyalkoren 1b9afc1 Fix StackTemplateRegistryTests and verify that StackTemplateRegistry …
eyalkoren ba72cdb Merge remote-tracking branch 'eyalkoren/default-timestamp-for-logs' i…
eyalkoren 0e8400c Update changelog summary
eyalkoren 2eef78e Fixing CoreWithSecurityClientYamlTestSuiteIT
eyalkoren 011f627 Verify that valid timestamp is not being overridden
eyalkoren b711cb1 Use _ingest.timestamp field directly in set processor
eyalkoren c0d6864 Improve description for custom pipeline
felixbarny 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,7 @@ | ||
| pr: 95971 | ||
| summary: "Set `@timestamp` for documents in logs data streams if missing and add support for custom pipeline" | ||
| area: Data streams | ||
| type: enhancement | ||
| issues: | ||
| - 95537 | ||
| - 95551 |
95 changes: 95 additions & 0 deletions 95 ...s/src/yamlRestTest/resources/rest-api-spec/test/data_stream/220_logs_default_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,95 @@ | ||
| --- | ||
| Test default logs-*-* pipeline: | ||
| - do: | ||
| # setting up a custom field mapping, to test custom pipeline | ||
| cluster.put_component_template: | ||
| name: logs@custom | ||
| body: | ||
| template: | ||
| mappings: | ||
| properties: | ||
| custom_timestamp: | ||
| type: date | ||
| | ||
| - do: | ||
| ingest.put_pipeline: | ||
| # testing custom pipeline - setting a custom timestamp with the same value used to set the `@timestamp` field when missing | ||
| id: "logs@custom" | ||
| body: > | ||
| { | ||
| "processors": [ | ||
| { | ||
| "set" : { | ||
| "field": "custom_timestamp", | ||
| "copy_from": "_ingest.timestamp" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| | ||
| - do: | ||
| indices.create_data_stream: | ||
| name: logs-generic-default | ||
| - is_true: acknowledged | ||
| | ||
| - do: | ||
| indices.get_data_stream: | ||
| name: logs-generic-default | ||
| - set: { data_streams.0.indices.0.index_name: idx0name } | ||
| | ||
| - do: | ||
| indices.get_mapping: | ||
| index: logs-generic-default | ||
| - match: { .$idx0name.mappings.properties.@timestamp.type: "date" } | ||
| | ||
| - do: | ||
| index: | ||
| index: logs-generic-default | ||
| refresh: true | ||
| body: | ||
| # no timestamp - testing default pipeline's @timestamp set processor | ||
| message: 'no_timestamp' | ||
| - match: {result: "created"} | ||
| | ||
| - do: | ||
| search: | ||
| index: logs-generic-default | ||
| body: | ||
| query: | ||
| term: | ||
| message: | ||
| value: 'no_timestamp' | ||
| fields: | ||
| - field: '@timestamp' | ||
| - field: 'custom_timestamp' | ||
| - length: { hits.hits: 1 } | ||
| - match: { hits.hits.0._source.@timestamp: '/[0-9-]+T[0-9:.]+Z/' } | ||
| - set: {hits.hits.0._source.custom_timestamp: custom_timestamp_source } | ||
| - match: { hits.hits.0._source.@timestamp: $custom_timestamp_source } | ||
| - match: { hits.hits.0.fields.@timestamp.0: '/[0-9-]+T[0-9:.]+Z/' } | ||
| - set: {hits.hits.0.fields.custom_timestamp.0: custom_timestamp_field } | ||
| - match: { hits.hits.0.fields.@timestamp.0: $custom_timestamp_field } | ||
| | ||
| # verify that when a document is ingested with a timestamp, it does not get overridden | ||
| - do: | ||
| index: | ||
| index: logs-generic-default | ||
| refresh: true | ||
| body: | ||
| '@timestamp': '2023-05-10' | ||
| message: 'with_timestamp' | ||
| - match: {result: "created"} | ||
| | ||
| - do: | ||
| search: | ||
| index: logs-generic-default | ||
| body: | ||
| query: | ||
| term: | ||
| message: | ||
| value: 'with_timestamp' | ||
| fields: | ||
| - field: '@timestamp' | ||
| - length: { hits.hits: 1 } | ||
| - match: { hits.hits.0.fields.@timestamp.0: '2023-05-10T00:00:00.000Z' } | ||
| |
24 changes: 24 additions & 0 deletions 24 x-pack/plugin/core/src/main/resources/logs-default-pipeline.json
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,24 @@ | ||
| { | ||
| "processors": [ | ||
| { | ||
| "set": { | ||
| "description": "If '@timestamp' is missing, set it with the ingest timestamp", | ||
| "field": "@timestamp", | ||
| "override": false, | ||
| "copy_from": "_ingest.timestamp" | ||
| } | ||
| }, | ||
| { | ||
| "pipeline" : { | ||
| "name": "logs@custom", | ||
| "ignore_missing_pipeline": true, | ||
| "description": "A custom pipeline for logs data streams, which does not exist by default, but can be added if additional processing is required" | ||
| } | ||
| } | ||
| ], | ||
| "_meta": { | ||
| "description": "default pipeline for the logs index template installed by x-pack", | ||
| "managed": true | ||
| }, | ||
| "version": ${xpack.stack.template.version} | ||
| } | ||
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 |
|---|---|---|
| | @@ -11,7 +11,8 @@ | |
| }, | ||
| "mapping": { | ||
| "ignore_malformed": true | ||
| } | ||
| }, | ||
| "default_pipeline": "logs-default-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
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
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.
@joegallo FYI this is how we're setting a default timestamp. We'll want to have millisecond precision so we're not truncating here. As the
@timestampfield is mapped as adate, notdate_nanos, we don't need to truncate microseconds and nanoseconds, I think.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.
A
setw/copy_fromis very fast. 👍 and ❤️