-
Notifications
You must be signed in to change notification settings - Fork 681
Add Mutate event processor doc. #3234
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 32 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
bcdae54
Opening new PR for file.
carolxob 25d1500
Minor adjustements.
carolxob 8f87f99
Adjustements to tables.
carolxob ae81c0b
Removed some markdown comments.
carolxob 58cf072
Minor updates.
carolxob f18444d
Minor edit.
carolxob 755c7cf
Adjustements to tables.
carolxob 3ae7fe5
Updates based on doc review feedback.
carolxob a5ae6bf
MAde changes based on tech review feedback.
carolxob 0be3d4a
Updated text for YAML file path locations.
carolxob 7b164fd
Edits made based on technical review feedback.
carolxob 156ab94
Minor edits from tech review feedback.
carolxob 3129091
Minor edits.
carolxob 6c1b75f
Updates based on tech review feedback and formatting.
carolxob 9a88f1c
Minor upate from doc review feedback.
carolxob b4d07bb
Edits from doc review feedback.
carolxob dc7f22c
Updates based on doc review feedback.
carolxob 5a29f34
Minor updates.
carolxob d9a8dac
Minor edits.
carolxob ba2291e
Minor edits.
carolxob 901b80a
Added copy button to relevant code blocks.
carolxob 7bacf22
Minor edits.
carolxob d8e5b8a
Added links.
carolxob 169f650
Minor edits.
carolxob 54c9011
Minor edits.
carolxob 18fd978
Minor updates.
carolxob 52e1a74
Minor edits.
carolxob a865221
Minor updates.
carolxob 7bcaa95
Minor edits based on doc review.
carolxob 5167be1
Minor edits based on doc review feedback.
carolxob f98259e
Edits made based on doc review feedback.
carolxob f1ee5d9
Minor update to include key examples.
carolxob 4e34b02
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 4f76945
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 3bd9536
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 6154709
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 94e3fe1
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob ce7d1e0
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob cf16ba6
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 3762955
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 8130321
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob ae3c018
Fixing commit.
carolxob 3f64023
Minor edits.
carolxob 46ce3a7
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob c2828a4
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 6e7e912
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 3f12c9f
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob ca11e27
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob a74d6ff
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 3c9314f
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 70d7fd3
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 6e46643
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob 5d972d6
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob cabfd54
Incorporating editorial review changes.
carolxob bc17286
Incorporated the rest of editorial feedback received.
carolxob ada0724
Minor updates based on feedback comments.
carolxob 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
304 changes: 304 additions & 0 deletions
304
_data-prepper/pipelines/configuration/processors/mutate-event.md
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,304 @@ | ||
| --- | ||
| layout: default | ||
| title: Mutate event | ||
| parent: Processors | ||
| grand_parent: Pipelines | ||
| nav_order: 45 | ||
| --- | ||
|
|
||
| # Mutate event processors | ||
|
|
||
| Mutate event processors allow you to modify events in Data Prepper. The following processors are available: | ||
|
|
||
| * [AddEntries](#addentries): Allows you to add entries to an event. | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
| * [CopyValues](#copyvalues): Allows you to copy values within an event. | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
| * [DeleteEntry](#deleteentry): Allows you to delete entries from an event. | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
| * [RenameKey](#renamekey): Allows you to rename keys in an event. | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
| * [ConvertEntry](#convertentry): Allows you to convert value types in an event. | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## AddEntries | ||
|
|
||
| The `AddEntries` processor adds entries to an event. | ||
|
|
||
| ### Configuration | ||
|
|
||
| You can configure the `AddEntries` processor with the following options. | ||
|
|
||
| | Option | Required | Description | | ||
| | :--- | :--- | :--- | | ||
| | `entries` | Yes | A list of entries to add to an event. | | ||
|
carolxob marked this conversation as resolved.
|
||
| | `key` | Yes | The key of the new entry to be added. Some examples of keys include: `my_key`, `myKey`, and `object/sub_Key`. | | ||
|
carolxob marked this conversation as resolved.
Outdated
carolxob marked this conversation as resolved.
Outdated
|
||
| | `value` | Yes | The value of the new entry to be added. You can use the following data types: strings, booleans, numbers, null, nested objects, and arrays. | | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
| | `overwrite_if_key_exists` | No | When set to `true`, the existing value is overwritten if `key` already exists in the event. The default value is `false`. | | ||
|
|
||
| ### Usage | ||
|
|
||
| To get started, create the following `pipeline.yaml` file: | ||
|
carolxob marked this conversation as resolved.
|
||
|
|
||
| ```yaml | ||
| pipeline: | ||
| source: | ||
| file: | ||
| path: "/full/path/to/logs_json.log" | ||
| record_type: "event" | ||
| format: "json" | ||
| processor: | ||
| - add_entries: | ||
| entries: | ||
| - key: "newMessage" | ||
| value: 3 | ||
| overwrite_if_key_exists: true | ||
| sink: | ||
| - stdout: | ||
| ``` | ||
| {% include copy.html %} | ||
|
|
||
|
|
||
| Next, create a log file named `logs_json.log` and replace the `path` in the file source of your `pipeline.yaml` with this filepath. For more information, see [Configuring Data Prepper]({{site.url}}{{site.baseurl}}/data-prepper/getting-started/#2-configuring-data-prepper). | ||
|
carolxob marked this conversation as resolved.
Outdated
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| For example, before you run the `AddEntries` processor, if the `logs_json.log` file contains the following event record: | ||
|
|
||
| ```json | ||
|
carolxob marked this conversation as resolved.
|
||
| {"message": "hello"} | ||
| ``` | ||
|
|
||
| Then, when you run the `AddEntries` processor using the previous configuration, it adds a new entry `{"newMessage": 3}` to the existing event `{"message": "hello"}` so that the new event contains two entries in the final output: | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```json | ||
| {"message": "hello", "newMessage": 3} | ||
| ``` | ||
|
|
||
| > If `newMessage` already exists, its existing value is overwritten with a value of `3`. | ||
|
|
||
|
|
||
| ## CopyValues | ||
|
carolxob marked this conversation as resolved.
|
||
|
|
||
| The `CopyValues` processor copies the values of an existing key within an event to another key. | ||
|
|
||
| ### Configuration | ||
|
carolxob marked this conversation as resolved.
|
||
|
|
||
| You can configure the `CopyValues` processor with the following options. | ||
|
|
||
| | Option | Required | Description | | ||
| :--- | :--- | :--- | ||
| | `entries` | Yes | A list of entries to be copied in an event. | | ||
| | `from_key` | Yes | The key of the entry to be copied. | | ||
| | `to_key` | Yes | The key of the new entry to be added. | | ||
| | `overwrite_if_key_exists` | No | When set to `true`, the existing value is overwritten if `key` already exists in the event. The default value is `false`. | | ||
|
|
||
| ### Usage | ||
|
|
||
| To get started, create the following `pipeline.yaml` file: | ||
|
carolxob marked this conversation as resolved.
|
||
|
|
||
| ```yaml | ||
| pipeline: | ||
| source: | ||
| file: | ||
| path: "/full/path/to/logs_json.log" | ||
| record_type: "event" | ||
| format: "json" | ||
| processor: | ||
| - copy_values: | ||
| entries: | ||
| - from_key: "message" | ||
| to_key: "newMessage" | ||
| overwrite_if_to_key_exists: true | ||
| sink: | ||
| - stdout: | ||
| ``` | ||
| {% include copy.html %} | ||
|
|
||
| Next, create a log file named `logs_json.log` and replace the `path` in the file source of your `pipeline.yaml` with this filepath. For more information, see [Configuring Data Prepper]({{site.url}}{{site.baseurl}}/data-prepper/getting-started/#2-configuring-data-prepper). | ||
|
carolxob marked this conversation as resolved.
Outdated
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```json | ||
|
carolxob marked this conversation as resolved.
|
||
| {"message": "hello"} | ||
| ``` | ||
|
|
||
| When you run this processor, it parses the message into the following output: | ||
|
|
||
| ```json | ||
| {"message": "hello", "newMessage": "hello"} | ||
| ``` | ||
|
|
||
| > If `newMessage` already exists, its existing value is overwritten with `value`. | ||
|
|
||
|
|
||
| ## DeleteEntry | ||
|
|
||
| The `DeleteEntry` processor deletes entries from an event, such as key-value pairs. You can define the keys you want to delete in the `with-keys` field following `delete_entries` in the YAML configuration file. Those keys along with their values are deleted. | ||
|
carolxob marked this conversation as resolved.
Outdated
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### Configuration | ||
|
|
||
| You can configure the `DeleteEntry` processor with the following options. | ||
|
|
||
| | Option | Required | Description | | ||
| :--- | :--- | :--- | ||
| | `with_keys` | Yes | An array of keys of the entries to be deleted. | | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### Usage | ||
|
|
||
| To get started, create the following `pipeline.yaml` file: | ||
|
|
||
| ```yaml | ||
| pipeline: | ||
| source: | ||
| file: | ||
| path: "/full/path/to/logs_json.log" | ||
| record_type: "event" | ||
| format: "json" | ||
| processor: | ||
| - delete_entries: | ||
| with_keys: ["message"] | ||
| sink: | ||
| - stdout: | ||
| ``` | ||
| {% include copy.html %} | ||
|
|
||
| Next, create a log file named `logs_json.log` and replace the `path` in the file source of your `pipeline.yaml` with this filepath. For more information, see [Configuring Data Prepper]({{site.url}}{{site.baseurl}}/data-prepper/getting-started/#2-configuring-data-prepper). | ||
|
carolxob marked this conversation as resolved.
Outdated
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```json | ||
|
carolxob marked this conversation as resolved.
|
||
| {"message": "hello", "message2": "goodbye"} | ||
| ``` | ||
|
|
||
| When you run the `DeleteEntry` processor, it parses the message into the following output: | ||
|
|
||
| ```json | ||
| {"message2": "goodbye"} | ||
| ``` | ||
|
|
||
| > If `message` does not exist in the event, then no action occurs. | ||
|
|
||
|
|
||
| ## RenameKey | ||
|
carolxob marked this conversation as resolved.
|
||
|
|
||
| The `RenameKey` processor renames keys in an event. | ||
|
|
||
| ### Configuration | ||
|
|
||
| You can configure the `RenameKey` processor with the following options. | ||
|
|
||
| Option | Required | Description | | ||
| | :--- | :--- | :--- | | ||
| | `entries` | Yes | A list of entries to rename in an event. | | ||
|
carolxob marked this conversation as resolved.
Outdated
carolxob marked this conversation as resolved.
Outdated
|
||
| | `from_key` | Yes | The key of the entry to be renamed. | | ||
| | `to_key` | Yes | The new key of the entry. | | ||
| | `overwrite_if_to_key_exists` | No | When set to `true`, the existing value is overwritten if `key` already exists in the event. The default value is `false`. | | ||
|
|
||
| ### Usage | ||
|
|
||
| To get started, create the following `pipeline.yaml` file: | ||
|
|
||
| ```yaml | ||
| pipeline: | ||
| source: | ||
| file: | ||
| path: "/full/path/to/logs_json.log" | ||
| record_type: "event" | ||
| format: "json" | ||
| processor: | ||
| - rename_keys: | ||
| entries: | ||
| - from_key: "message" | ||
| to_key: "newMessage" | ||
| overwrite_if_to_key_exists: true | ||
| sink: | ||
| - stdout: | ||
| ``` | ||
| {% include copy.html %} | ||
|
|
||
|
|
||
| Next, create a log file named `logs_json.log` and replace the `path` in the file source of your `pipeline.yaml` with this filepath. For more information, see [Configuring Data Prepper]({{site.url}}{{site.baseurl}}/data-prepper/getting-started/#2-configuring-data-prepper). | ||
|
carolxob marked this conversation as resolved.
Outdated
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```json | ||
|
carolxob marked this conversation as resolved.
|
||
| {"message": "hello"} | ||
| ``` | ||
|
|
||
| When you run the `RenameKey` processor, it parses the message into the following "newMessage" output: | ||
|
|
||
| ```json | ||
| {"newMessage": "hello"} | ||
| ``` | ||
|
|
||
| > If `newMessage` already exists, its existing value is overwritten with `value`. | ||
|
|
||
|
|
||
|
|
||
| ### Special considerations | ||
|
|
||
| Renaming operations occur in the order that the key value pair entries are listed in the `pipeline.yaml` file. This means that chaining (where key value pairs are renamed in sequence) is implicit with the `RenameKey` processor. See the following `pipline.yaml` file example: | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```yaml | ||
| pipeline: | ||
| source: | ||
| file: | ||
| path: "/full/path/to/logs_json.log" | ||
| record_type: "event" | ||
| format: "json" | ||
| processor: | ||
| - rename_key: | ||
| entries: | ||
| - from_key: "message" | ||
| to_key: "message2" | ||
| - from_key: "message2" | ||
| to_key: "message3" | ||
| sink: | ||
| - stdout: | ||
| ``` | ||
|
|
||
| Add the following contents to the `logs_json.log` file: | ||
|
|
||
| ```json | ||
| {"message": "hello"} | ||
| ``` | ||
| {% include copy.html %} | ||
|
|
||
| After the `RenameKey` processor runs, the following output appears: | ||
|
|
||
| ```json | ||
| {"message3": "hello"} | ||
| ``` | ||
|
|
||
| ## ConvertEntry | ||
|
|
||
| The `ConvertEntry` processor converts a value type associated with the specified key in a message to the specified type. It is a casting processor that changes the types of some fields in the event or message. Some entered data needs to be converted to different types, such as an integer or a double, or a string to an integer, so that it will pass the events through condition-based processors or perform conditional routing. | ||
|
carolxob marked this conversation as resolved.
Outdated
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### Configuration | ||
|
|
||
| You can configure the `ConvertEntry` processor with the following options. | ||
|
carolxob marked this conversation as resolved.
|
||
|
|
||
| | Option | Required | Description | | ||
| | :--- | :--- | :--- | | ||
| | `key`| Yes | Keys whose value needs to be converted to a different type. | | ||
| | `type` | No | Target type for key value pair. Possible values are `integer`, `double`, `string`, and `boolean`. Default value is `integer`. | | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### Usage | ||
|
|
||
| To get started, create the following `pipeline.yaml` file: | ||
|
|
||
| ```yaml | ||
| type-conv-pipeline: | ||
| source: | ||
| file: | ||
| path: "/full/path/to/logs_json.log" | ||
| record_type: "event" | ||
| format: "json" | ||
| processor: | ||
| - convert_entry_type: | ||
| key: "response_status" | ||
| type: "integer" | ||
| sink: | ||
| - stdout: | ||
| ``` | ||
| {% include copy.html %} | ||
|
|
||
| Next, create a log file named `logs_json.log` and replace the `path` in the file source of your `pipeline.yaml` with this filepath. For more information, see [Configuring Data Prepper]({{site.url}}{{site.baseurl}}/data-prepper/getting-started/#2-configuring-data-prepper). | ||
|
carolxob marked this conversation as resolved.
Outdated
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```json | ||
|
carolxob marked this conversation as resolved.
|
||
| {"message": "value", "response_status":"200"} | ||
| ``` | ||
|
|
||
| The `ConvertEntry` processor changes the output received into the following output, where the type of `response_status` value changes from a string to an integer: | ||
|
carolxob marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```json | ||
| {"message":"value","response_status":200} | ||
| ``` | ||
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.
Uh oh!
There was an error while loading. Please reload this page.