Repeat
Synopsis
Repeats the string in a field a given number of times, optionally joining the copies with a delimiter.
Schema
- repeat:
field: <ident>
count: <numeric>
delimiter: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
target_field: <ident>
Configuration
The following fields are used to define the processor:
| Field | Required | Default | Description |
|---|---|---|---|
field | Y | - | Field containing the string to repeat |
count | Y | - | Number of copies. Must be between 0 and 1024; 0 is accepted and yields an empty string |
delimiter | N | - | String inserted between copies. Empty by default, so the copies are concatenated |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | See Handling Failures |
ignore_missing | N | false | If true, quietly exit if field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
disabled | N | false | When true, the processor is skipped and the event continues to the next one. Lets you take a processor out of the path without removing its configuration |
target_field | N | field | Field to store the result. Defaults to field, replacing the original |
Details
The delimiter goes between copies, not after each one, so n copies carry n - 1 delimiters and the result never ends with a trailing separator.
Two counts are worth knowing:
count: 0produces an empty string rather than leaving the field alone. It is a valid setting, not a no-op.- A negative count is an error, as is anything above 1024. The cap is a guard against a configuration that would otherwise build an arbitrarily large string in memory.
The field must hold a string. An array, a number or an object is an error.
Examples
Simple Repetition
Repeating a string with no delimiter... | |
concatenates the copies: | |
With a Delimiter
A delimiter is placed between copies, never after the last... | |
giving two delimiters for three copies: | |
Zero Copies
A count of zero is legitimate and produces an empty string... | |
rather than leaving the target unset: | |