Skip to content

Commit ffd32bf

Browse files
github-actions[bot]kolchfa-awsnatebower
committed
Update documentation for delete_entries and select_entries processors (#11476)
* Update delete_entries processor to add new features Signed-off-by: Kennedy Onyia <[email protected]> * update select_entries processor documentation to account for new include_keys_regex feature Signed-off-by: Kennedy Onyia <[email protected]> * fix style check errors and include additional pipeline configurations to clarify new features. Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/delete-entries.md Co-authored-by: kolchfa-aws <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/select-entries.md Co-authored-by: kolchfa-aws <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/delete-entries.md Co-authored-by: kolchfa-aws <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/select-entries.md Co-authored-by: kolchfa-aws <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/select-entries.md Co-authored-by: kolchfa-aws <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/delete-entries.md Co-authored-by: kolchfa-aws <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/select-entries.md Co-authored-by: kolchfa-aws <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/select-entries.md Co-authored-by: kolchfa-aws <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/delete-entries.md Co-authored-by: kolchfa-aws <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/delete-entries.md Co-authored-by: kolchfa-aws <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> * Update _data-prepper/pipelines/configuration/processors/delete-entries.md Signed-off-by: kolchfa-aws <[email protected]> * Update _data-prepper/pipelines/configuration/processors/delete-entries.md Signed-off-by: kolchfa-aws <[email protected]> * Update _data-prepper/pipelines/configuration/processors/delete-entries.md Signed-off-by: kolchfa-aws <[email protected]> * Apply suggestions from code review Signed-off-by: Nathan Bower <[email protected]> --------- Signed-off-by: Kennedy Onyia <[email protected]> Signed-off-by: Kennedy Onyia <[email protected]> Signed-off-by: kolchfa-aws <[email protected]> Signed-off-by: Nathan Bower <[email protected]> Co-authored-by: kolchfa-aws <[email protected]> Co-authored-by: Nathan Bower <[email protected]> (cherry picked from commit 1d239cc) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 5fa81ab commit ffd32bf

File tree

2 files changed

+131
-16
lines changed

2 files changed

+131
-16
lines changed

_data-prepper/pipelines/configuration/processors/delete-entries.md

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ parent: Processors
55
grand_parent: Pipelines
66
nav_order: 110
77
---
8-
8+
99
# Delete entries processor
1010

11-
The `delete_entries` processor deletes entries, such as key-value pairs, from an event. You can define the keys you want to delete in the `with-keys` field following `delete_entries` in the YAML configuration file. Those keys and their values are deleted.
11+
The `delete_entries` processor removes entries, such as key-value pairs, from an event. Use the `with_keys` field to specify
12+
the exact keys to delete. To delete keys that match a regular expression pattern, use the `with_keys_regex` field. You can
13+
prevent deletion of specific events when using regular expressions by configuring the `exclude_from_regex` field.
14+
15+
The only way to configure both `with_keys` and `with_keys_regex` in the same `delete_entries` processor is by using the `entries` field.
1216

1317
## Configuration
1418

@@ -21,22 +25,27 @@ This table is autogenerated. Do not edit it.
2125
- source: https://github.com/opensearch-project/data-prepper/blob/c4455a7785bc2da4358067c217be7085e0bc8d0f/data-prepper-plugins/mutate-event-processors/src/main/java/org/opensearch/dataprepper/plugins/processor/mutateevent/DeleteEntryProcessorConfig.java
2226
-->
2327

24-
| Option | Required | Description |
25-
:--- | :--- | :---
26-
| `with_keys` | Yes | An array of keys for the entries to be deleted. |
28+
| Option | Required | Description |
29+
:--- |:---------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
30+
| `with_keys` | No | An array that specifies the keys of the entries to delete. |
31+
| `with_keys_regex` | No | An array of regular expression (regex) patterns used to match the keys of entries to delete. |
32+
| `exclude_from_delete` | No | A set of entries to exclude from deletion when using the `with_keys_regex` configuration. |
33+
| `entries` | No | A list of entries to delete from the event. |
34+
| `delete_when` | No | Defines the condition under which the deletion is performed. For example, `value="/some_key == null"` deletes the key only if `/some_key` is null or does not exist. |
35+
|`delete_from_element_when` | No | Defines the condition that determines whether a key–value pair should be removed from each element in the list specified by `iterate_on`. The condition is evaluated for each element, and deletion occurs only if the element's key matches one defined in `with_keys` or `with_keys_regex` and satisfies the condition. |
36+
| `iterate_on` | No | Specifies the key of the list field that contains objects to iterate over. The processor applies any configured deletion rules, such as `with_keys`, `with_keys_regex`, or `delete_from_element_when`, to each element in the list. |
2737

2838
## Usage
29-
3039
To get started, create the following `pipeline.yaml` file:
3140

3241
```yaml
3342
pipeline:
3443
source:
3544
...
36-
....
45+
....
3746
processor:
3847
- delete_entries:
39-
with_keys: ["message"]
48+
with_keys: [ "message" ]
4049
sink:
4150
```
4251
{% include copy.html %}
@@ -52,7 +61,68 @@ For example, before you run the `delete_entries` processor, if the `logs_json.lo
5261
When you run the `delete_entries` processor, it parses the message into the following output:
5362

5463
```json
55-
{"message2": "goodbye"}
64+
{"message2": "goodbye", "message3": "test"}
65+
```
66+
67+
68+
### Deleting keys that match a pattern
69+
70+
First, create the following `pipeline.yaml` file:
71+
72+
```yaml
73+
pipeline:
74+
source:
75+
...
76+
....
77+
processor:
78+
- delete_entries:
79+
with_keys_regex: [ "^tes.*" ]
80+
exclude_from_delete: [ "test" ]
81+
sink:
82+
```
83+
{% include copy.html %}
84+
85+
If your `logs_json.log` file contains the following event record:
86+
87+
```json
88+
{"test": "friends", "test2": "are", "test3": "kind"}
89+
```
90+
91+
When you run the `delete_entries` processor, it parses the message into the following output:
92+
93+
```json
94+
{"test": "friends"}
95+
```
96+
97+
### Combining multiple deletion rules
98+
99+
First, create the following `pipeline.yaml` file:
100+
101+
```yaml
102+
pipeline:
103+
source:
104+
...
105+
....
106+
processor:
107+
- delete_entries:
108+
entries:
109+
- with_keys: [ "message" ]
110+
- with_keys_regex: [ "^tes.*" ]
111+
exclude_from_delete: [ "test" ]
112+
sink:
113+
```
114+
{% include copy.html %}
115+
116+
If your `logs_json.log` file contains the following event record:
117+
118+
```json
119+
{"message": "hello", "message2": "goodbye", "test": "friends", "test2": "are", "test3": "kind"}
120+
```
121+
122+
When you run the `delete_entries` processor, it parses the message into the following output:
123+
124+
```json
125+
{"message2": "goodbye","test": "friends"}
56126
```
57127

58-
> If `message` does not exist in the event, then no action occurs.
128+
> If the `with_keys`, `with_keys_regex`, or `exclude_from_delete` values do not match any event keys, then no action occurs.

_data-prepper/pipelines/configuration/processors/select-entries.md

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ Only the selected entries remain in the processed event and while all other entr
1616
You can configure the `select_entries` processor using the following options.
1717

1818
| Option | Required | Description |
19-
| :--- | :--- | :--- |
20-
| `include_keys` | Yes | A list of keys to be selected from an event. |
21-
| `select_when` | No | A [conditional expression]({{site.url}}{{site.baseurl}}/data-prepper/pipelines/expression-syntax/), such as `/some-key == "test"'`, that will be evaluated to determine whether the processor will be run on the event. If the condition is not met, then the event continues through the pipeline unmodified with all the original fields present. |
19+
| :--- |:---------| :--- |
20+
| `include_keys` | No | A list of keys to be selected from an event. |
21+
| `include_keys_regex` | No | A regular expression (regex) pattern that matches the keys to be selected from an event. |
22+
| `select_when` | No | A [conditional expression]({{site.url}}{{site.baseurl}}/data-prepper/pipelines/expression-syntax/), such as `/some-key == "test"`, that is evaluated to determine whether the processor will be executed on the event. If the condition is not met, then the event continues through the pipeline unmodified, with all the original fields present. |
2223

2324
## Usage
2425

25-
The following example shows how to configure the `select_entries` processor in the `pipeline.yaml` file:
26+
First, create the following `pipeline.yaml` file:
2627

2728
```yaml
2829
pipeline:
@@ -41,15 +42,59 @@ pipeline:
4142
For example, when your source contains the following event record:
4243
4344
```json
44-
{"message": "hello", "key1" : "value1", "key2" : "value2", "some_key" : "test"}
45+
{
46+
"message": "hello",
47+
"key1" : "value1",
48+
"key2" : "value2",
49+
"some_key" : "test"
50+
}
4551
```
4652

47-
The `select_entries` processor includes only `key1` and `key2` in the processed output:
53+
After processing, only the keys listed in `include_keys` are retained in the event; all other keys are removed:
4854

4955
```json
5056
{"key1": "value1", "key2": "value2"}
5157
```
5258

59+
### Selecting keys using a regex
60+
61+
The following example shows how to configure the `include_keys_regex` field in the `pipeline.yaml` file:
62+
63+
```yaml
64+
pipeline:
65+
source:
66+
...
67+
....
68+
processor:
69+
- select_entries:
70+
include_keys: [ "key1", "key2" ]
71+
include_keys_regex: ["^ran.*"]
72+
select_when: '/some_key == "test"'
73+
sink:
74+
```
75+
{% include copy.html %}
76+
77+
For example, when your source contains the following event record:
78+
79+
```json
80+
{
81+
"message": "hello",
82+
"key1" : "value1",
83+
"key2" : "value2",
84+
"some_key" : "test",
85+
"random1": "another",
86+
"random2" : "set",
87+
"random3": "of",
88+
"random4": "values"
89+
}
90+
```
91+
92+
The processor retains keys explicitly listed in `include_keys` and any keys matching the` include_keys_regex` pattern, removing all other keys from the event:
93+
94+
```json
95+
{"key1": "value1", "key2": "value2", "random1": "another", "random2" : "set", "random3": "of", "random4": "values"}
96+
```
97+
5398
### Accessing nested fields
5499

55100
Use `/` to access nested fields.

0 commit comments

Comments
 (0)