Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5cbbd5e
Add option for Append Processor to skip/allow empty values
limotova Feb 14, 2024
d624991
Change allow_empty_values to ignore_empty_values
limotova Mar 9, 2024
c961392
Update docs/changelog/105718.yaml
limotova Jan 30, 2025
4e50ac7
Merge branch 'main' into add-allow-empty-values-append-processor
joegallo Sep 5, 2025
27c4e9a
Handle nulls as well
joegallo Sep 5, 2025
661766e
Rewrite setFieldValue in terms of valueNotEmpty
joegallo Sep 5, 2025
bea6446
Rewrite another setFieldValue arity, too
joegallo Sep 5, 2025
1675b1f
Verify an invariant
joegallo Sep 5, 2025
15123c9
This test can't handle nulls anymore
joegallo Sep 5, 2025
d46e6bc
Fix a typo
joegallo Sep 5, 2025
920fe67
Declare these once
joegallo Sep 5, 2025
6225a8b
Add some empty values into this test
joegallo Sep 5, 2025
fd0e386
Merge branch 'main' into add-allow-empty-values-append-processor
joegallo Sep 9, 2025
7eaaa20
Merge branch 'main' into add-allow-empty-values-append-processor
joegallo Sep 29, 2025
c103a7b
Ignore empty values with getFieldValue and copy_from
joegallo Sep 29, 2025
e2d5d76
Re-add the ignore_empty_values docs
joegallo Sep 29, 2025
a71ac87
It seems conventional to just label these '9.2'
joegallo Sep 29, 2025
d9d5753
Add an example
joegallo Sep 29, 2025
3161607
Better quoting
joegallo Sep 29, 2025
5ba1426
Add a test-only feature
joegallo Sep 29, 2025
6361a9e
Add some rest tests
joegallo Sep 29, 2025
f0b86a7
Fix typos
joegallo Sep 30, 2025
29a566a
Merge branch 'main' into add-allow-empty-values-append-processor
joegallo Sep 30, 2025
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
6 changes: 6 additions & 0 deletions docs/changelog/105718.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 105718
summary: Add option for Append Processor to skip/allow empty values
area: Ingest Node
type: enhancement
issues:
- 104813
27 changes: 26 additions & 1 deletion docs/reference/enrich-processor/append-processor.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,22 @@ $$$append-options$$$
| --- | --- | --- | --- |
| `field` | yes | - | The field to be appended to. Supports [template snippets](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#template-snippets). |
| `value` | yes* | - | The value to be appended. Supports [template snippets](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#template-snippets). May specify only one of `value` or `copy_from`. |
| `copy_from` {applies_to}`stack: ga 9.2.0` | no | - | The origin field which will be appended to `field`, cannot set `value` simultaneously. |
| `copy_from` {applies_to}`stack: ga 9.2` | no | - | The origin field which will be appended to `field`, cannot set `value` simultaneously. |
| `allow_duplicates` | no | true | If `false`, the processor does not appendvalues already present in the field. |
| `ignore_empty_values` {applies_to}`stack: ga 9.2` | no | false | If `true`, the processor does not append values that resolve to `null` or an empty string.
| `media_type` | no | `application/json` | The media type for encoding `value`. Applies only when `value` is a [template snippet](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#template-snippets). Must be one of `application/json`, `text/plain`, or`application/x-www-form-urlencoded`. |
| `description` | no | - | Description of the processor. Useful for describing the purpose of the processor or its configuration. |
| `if` | no | - | Conditionally execute the processor. See [Conditionally run a processor](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#conditionally-run-processor). |
| `ignore_failure` | no | `false` | Ignore failures for the processor. See [Handling pipeline failures](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#handling-pipeline-failures). |
| `on_failure` | no | - | Handle failures for the processor. See [Handling pipeline failures](docs-content://manage-data/ingest/transform-enrich/ingest-pipelines.md#handling-pipeline-failures). |
| `tag` | no | - | Identifier for the processor. Useful for debugging and metrics. |

## Examples [append-processor-examples]

### Simple example [append-processor-simple-example]

Here is an `append` processor definition that adds the string `"production"` as well as the values of the `app` and `owner` fields to the `tags` field:

```js
{
"append": {
Expand All @@ -33,3 +40,21 @@ $$$append-options$$$
}
```

### Example using `allow_duplicates` and `ignore_empty_values` [append-processor-example-using-allow-duplicates-and-ignore-empty-values]

```{applies_to}
stack: ga 9.2
```

By using `allow_duplicates` and `ignore_empty_values`, it is possible to only append the `host.name` to the `related.hosts` if the `host.name` is not empty and if the value is not already present in `related.hosts`:

```js
{
"append": {
"field": "related.hosts",
"copy_from": "host.name",
"allow_duplicates": false,
"ignore_empty_values": true
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,23 @@ public final class AppendProcessor extends AbstractProcessor {
private final ValueSource value;
private final String copyFrom;
private final boolean allowDuplicates;
private final boolean ignoreEmptyValues;

AppendProcessor(
String tag,
String description,
TemplateScript.Factory field,
ValueSource value,
String copyFrom,
boolean allowDuplicates
boolean allowDuplicates,
boolean ignoreEmptyValues
) {
super(tag, description);
this.field = field;
this.value = value;
this.copyFrom = copyFrom;
this.allowDuplicates = allowDuplicates;
this.ignoreEmptyValues = ignoreEmptyValues;
}

public TemplateScript.Factory getField() {
Expand All @@ -68,10 +71,10 @@ public String getCopyFrom() {
public IngestDocument execute(IngestDocument document) throws Exception {
String path = document.renderTemplate(field);
if (copyFrom != null) {
Object fieldValue = document.getFieldValue(copyFrom, Object.class);
document.appendFieldValue(path, IngestDocument.deepCopy(fieldValue), allowDuplicates);
Object fieldValue = document.getFieldValue(copyFrom, Object.class, ignoreEmptyValues);
document.appendFieldValue(path, IngestDocument.deepCopy(fieldValue), allowDuplicates, ignoreEmptyValues);
} else {
document.appendFieldValue(path, value, allowDuplicates);
document.appendFieldValue(path, value, allowDuplicates, ignoreEmptyValues);
}
return document;
}
Expand Down Expand Up @@ -116,9 +119,17 @@ public AppendProcessor create(
}
}
boolean allowDuplicates = ConfigurationUtils.readBooleanProperty(TYPE, processorTag, config, "allow_duplicates", true);
boolean ignoreEmptyValues = ConfigurationUtils.readBooleanProperty(TYPE, processorTag, config, "ignore_empty_values", false);
TemplateScript.Factory compiledTemplate = ConfigurationUtils.compileTemplate(TYPE, processorTag, "field", field, scriptService);

return new AppendProcessor(processorTag, description, compiledTemplate, valueSource, copyFrom, allowDuplicates);
return new AppendProcessor(
processorTag,
description,
compiledTemplate,
valueSource,
copyFrom,
allowDuplicates,
ignoreEmptyValues
);
}
}
}
Loading
Loading