Skip to content
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 Mar 6, 2023
25d1500
Minor adjustements.
carolxob Mar 7, 2023
8f87f99
Adjustements to tables.
carolxob Mar 7, 2023
ae81c0b
Removed some markdown comments.
carolxob Mar 7, 2023
58cf072
Minor updates.
carolxob Mar 7, 2023
f18444d
Minor edit.
carolxob Mar 8, 2023
755c7cf
Adjustements to tables.
carolxob Mar 8, 2023
3ae7fe5
Updates based on doc review feedback.
carolxob Mar 8, 2023
a5ae6bf
MAde changes based on tech review feedback.
carolxob Mar 9, 2023
0be3d4a
Updated text for YAML file path locations.
carolxob Mar 13, 2023
7b164fd
Edits made based on technical review feedback.
carolxob Mar 13, 2023
156ab94
Minor edits from tech review feedback.
carolxob Mar 13, 2023
3129091
Minor edits.
carolxob Mar 13, 2023
6c1b75f
Updates based on tech review feedback and formatting.
carolxob Mar 14, 2023
9a88f1c
Minor upate from doc review feedback.
carolxob Mar 16, 2023
b4d07bb
Edits from doc review feedback.
carolxob Mar 16, 2023
dc7f22c
Updates based on doc review feedback.
carolxob Mar 17, 2023
5a29f34
Minor updates.
carolxob Mar 17, 2023
d9a8dac
Minor edits.
carolxob Mar 17, 2023
ba2291e
Minor edits.
carolxob Mar 17, 2023
901b80a
Added copy button to relevant code blocks.
carolxob Mar 17, 2023
7bacf22
Minor edits.
carolxob Mar 17, 2023
d8e5b8a
Added links.
carolxob Mar 17, 2023
169f650
Minor edits.
carolxob Mar 17, 2023
54c9011
Minor edits.
carolxob Mar 20, 2023
18fd978
Minor updates.
carolxob Mar 20, 2023
52e1a74
Minor edits.
carolxob Mar 20, 2023
a865221
Minor updates.
carolxob Mar 23, 2023
7bcaa95
Minor edits based on doc review.
carolxob Mar 29, 2023
5167be1
Minor edits based on doc review feedback.
carolxob Mar 29, 2023
f98259e
Edits made based on doc review feedback.
carolxob Mar 29, 2023
f1ee5d9
Minor update to include key examples.
carolxob Mar 31, 2023
4e34b02
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
4f76945
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
3bd9536
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
6154709
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
94e3fe1
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
ce7d1e0
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
cf16ba6
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
3762955
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
8130321
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
ae3c018
Fixing commit.
carolxob Mar 31, 2023
3f64023
Minor edits.
carolxob Mar 31, 2023
46ce3a7
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
c2828a4
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
6e7e912
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
3f12c9f
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
ca11e27
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
a74d6ff
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
3c9314f
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
70d7fd3
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
6e46643
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
5d972d6
Update _data-prepper/pipelines/configuration/processors/mutate-event.md
carolxob Mar 31, 2023
cabfd54
Incorporating editorial review changes.
carolxob Mar 31, 2023
bc17286
Incorporated the rest of editorial feedback received.
carolxob Mar 31, 2023
ada0724
Minor updates based on feedback comments.
carolxob Apr 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
304 changes: 304 additions & 0 deletions _data-prepper/pipelines/configuration/processors/mutate-event.md
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.
Comment thread
carolxob marked this conversation as resolved.
Outdated
Comment thread
carolxob marked this conversation as resolved.
Outdated
* [CopyValues](#copyvalues): Allows you to copy values within an event.
Comment thread
carolxob marked this conversation as resolved.
Outdated
* [DeleteEntry](#deleteentry): Allows you to delete entries from an event.
Comment thread
carolxob marked this conversation as resolved.
Outdated
* [RenameKey](#renamekey): Allows you to rename keys in an event.
Comment thread
carolxob marked this conversation as resolved.
Outdated
* [ConvertEntry](#convertentry): Allows you to convert value types in an event.
Comment thread
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. |
Comment thread
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`. |
Comment thread
carolxob marked this conversation as resolved.
Outdated
Comment thread
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. |
Comment thread
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:
Comment thread
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).
Comment thread
carolxob marked this conversation as resolved.
Outdated
Comment thread
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
Comment thread
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:
Comment thread
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
Comment thread
carolxob marked this conversation as resolved.

The `CopyValues` processor copies the values of an existing key within an event to another key.

### Configuration
Comment thread
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:
Comment thread
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).
Comment thread
carolxob marked this conversation as resolved.
Outdated
Comment thread
carolxob marked this conversation as resolved.
Outdated

```json
Comment thread
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.
Comment thread
carolxob marked this conversation as resolved.
Outdated
Comment thread
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. |
Comment thread
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).
Comment thread
carolxob marked this conversation as resolved.
Outdated
Comment thread
carolxob marked this conversation as resolved.
Outdated

```json
Comment thread
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
Comment thread
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. |
Comment thread
carolxob marked this conversation as resolved.
Outdated
Comment thread
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).
Comment thread
carolxob marked this conversation as resolved.
Outdated
Comment thread
carolxob marked this conversation as resolved.
Outdated

```json
Comment thread
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:
Comment thread
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.
Comment thread
carolxob marked this conversation as resolved.
Outdated
Comment thread
carolxob marked this conversation as resolved.
Outdated

### Configuration

You can configure the `ConvertEntry` processor with the following options.
Comment thread
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`. |
Comment thread
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).
Comment thread
carolxob marked this conversation as resolved.
Outdated
Comment thread
carolxob marked this conversation as resolved.
Outdated

```json
Comment thread
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:
Comment thread
carolxob marked this conversation as resolved.
Outdated

```json
{"message":"value","response_status":200}
```