For Each
Most recent version: v0.0.1
Last updated
Was this helpful?
Most recent version: v0.0.1
Last updated
Was this helpful?
See the changelog of this Action type .
The For Each action divides a list field with different entries into different output events, along with the position they occupy in the list (being the first position 0
).
For example, an input list containing [a,b,c]
will generate three outputs, with these fields added to the event:
elementValueOutField: a
; elementIndexOutField: 0
elementValueOutField: b
; elementIndexOutField: 1
elementValueOutField: c
; elementIndexOutField: 2
In order to configure this action, you must first link it to a Listener. Go to Building a Pipeline to learn how this works.
These are the input and output ports of this Action:
Find For Each in the Actions tab (under the Advanced group) and drag it onto the canvas.
To open the configuration, click the Action in the canvas and select Configuration.
Enter the required parameters:
Input*
Choose the field that contains the list you want to divide. Valid input types are String
, Integer
, Float
, Boolean
and Timestamp
.
Output field*
Name of the new field where each iterated element will be stored. This will be the same type as the input field list.
Index field*
Name of the new field that will show the position of each element in the list.
Click Save to complete the process.
Imagine you receive a list-type field containing a string of five IPs:
127.0.0.1
,127.0.0.2
,127.0.0.3
,127.0.0.4
,192.168.0.1
Add the For Each Action to your Pipeline and link it to your required Data sink.
Now, double-click the For Each Action to configure it. You need to set the following config:
Input
In this case, we choose the field ipsList
that contains our IP list.
Output field
We're naming the new field ipValue
.
Index field
We're naming the new field ipIndex
.
Click Save to apply the configuration.
Now link the Default output port of the Action to the input port of your Data sink.
Finally, click Publish and choose in which clusters you want to publish the Pipeline.
Click Test pipeline at the top of the area and choose a specific number of events to test if your data is transformed properly. Click Debug to proceed.
The Action will create a separate event for each element of the string, each event containing two fields (value and index).