Skip to main content
Version: 1.2.0

Add

Arithmetic Data Analysis

Adds two numeric values and stores the result in a field.

Schema

- add:
field: <ident>
left_operand: <string>
right_operand: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

The following fields are used to define the processor:

FieldRequiredDefaultDescription
fieldY-Target field to store the addition result
left_operandY-First operand in the addition (numeric literal or field reference)
right_operandY-Second operand in the addition (numeric literal or field reference)
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue processing if calculation fails
ignore_missingNfalseUse 0 for missing fields instead of failing
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier

Details

Adds two numeric values and stores the result in a specified field. This processor supports arithmetic addition between numeric literals, field values, or a combination of both.

note

The processor automatically converts string representations of numbers to their numeric values before performing addition. This makes it flexible when working with different data types or values extracted from text fields.

The processor evaluates both operands, performs the addition operation, and sets the result in the target field. If operand fields don't exist and ignore_missing is enabled, the processor will substitute a value of 0 for the missing field.

warning

If either operand cannot be converted to a number, the processor will fail unless ignore_failure is set to true. For missing fields, use ignore_missing: true to substitute zeros instead of failing.

Examples

Basic

Adding two numeric values...

{
"x": 5,
"y": 10
}
- add:
field: sum
left_operand: "{{x}}"
right_operand: "{{y}}"

stores the result in a new field:

{
"x": 5,
"y": 10,
"sum": 15
}

Using Literals

Adding a field value to a constant...

{
"base_value": 100
}
- add:
field: adjusted_value
left_operand: "{{base_value}}"
right_operand: "25"

adds the constant to the field value:

{
"base_value": 100,
"adjusted_value": 125
}

In-Place

Incrementing a field's value...

{
"counter": 42
}
- add:
field: counter
left_operand: "{{counter}}"
right_operand: "1"

updates the existing field:

{
"counter": 43
}

Handling Missing Fields

Adding with missing field protection...

{
"available": 75
}
- add:
field: total
left_operand: "{{available}}"
right_operand: "{{missing}}"
ignore_missing: true

treats missing fields as zero:

{
"available": 75,
"total": 75
}

Nested Fields

Adding values from nested fields...

{
"metrics": {
"sent": 150,
"received": 125
}
}
- add:
field: metrics.total
left_operand: "{{metrics.sent}}"
right_operand: "{{metrics.received}}"

stores result in a nested field:

{
"metrics": {
"sent": 150,
"received": 125,
"total": 275
}
}