Back to Elasticsearch

Append processor [append-processor]

docs/reference/enrich-processor/append-processor.md

9.4.03.2 KB
Original Source

Append processor [append-processor]

Appends one or more values to an existing array if the field already exists and it is an array. Converts a scalar to an array and appends one or more values to it if the field exists and it is a scalar. Creates an array containing the provided values if the field doesn’t exist. Accepts a single value or an array of values.

$$$append-options$$$

NameRequiredDefaultDescription
fieldyes-The field to be appended to. Supports template snippets.
valueyes*-The value to be appended. Supports template snippets. May specify only one of value or copy_from.
copy_from {applies_to}stack: ga 9.2no-The origin field which will be appended to field, cannot set value simultaneously.
allow_duplicatesnotrueIf false, the processor does not appendvalues already present in the field.
ignore_empty_values {applies_to}stack: ga 9.2nofalseIf true, the processor does not append values that resolve to null or an empty string.
media_typenoapplication/jsonThe media type for encoding value. Applies only when value is a template snippet. Must be one of application/json, text/plain, orapplication/x-www-form-urlencoded.
descriptionno-Description of the processor. Useful for describing the purpose of the processor or its configuration.
ifno-Conditionally execute the processor. See Conditionally run a processor.
ignore_failurenofalseIgnore failures for the processor. See Handling pipeline failures.
on_failureno-Handle failures for the processor. See Handling pipeline failures.
tagno-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": {
    "field": "tags",
    "value": ["production", "{{{app}}}", "{{{owner}}}"]
  }
}

% NOTCONSOLE

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
  }
}

% NOTCONSOLE