Skip to main content
Version: 1.4.0

Multiply

Arithmetic Data Analysis

Synopsis

Multiplies two numeric values together and returns the result.

Schema

- multiply:
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 multiplication result
left_operandY-First factor - can be a literal value or field reference
right_operandY-Second factor - can be a literal value or field reference
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue processing if multiplication fails
ignore_missingNfalseSkip if referenced fields don't exist
on_failureN-Error handling processors
on_successN-Success handling processors
tagN-Identifier

Details

Multiplies two numeric values together and stores the result in the target field. The processor can use literal values or extract values from existing fields in the log entry.

note

Numeric values are automatically converted to appropriate types for multiplication. The processor accepts both literal values and field references for operands.

The processor is useful for scaling values, performing unit conversions, calculating derived metrics, and implementing various mathematical transformations.

warning

Be aware of potential numerical precision issues when multiplying very large numbers or numbers with many decimal places. The processor uses floating-point arithmetic which has inherent precision limitations.

Examples

Basic

Multiplying two literal values...

{
"calculation": {}
}
- multiply:
field: calculation.product
left_operand: "7"
right_operand: "6"

calculates and stores the result:

{
"calculation": {
"product": 42
}
}

Units

Converting bytes to kilobytes...

{
"file": {
"size_bytes": 1536
}
}
- multiply:
field: file.size_kb
left_operand: "file.size_bytes"
right_operand: "0.001"

performs unit conversion:

{
"file": {
"size_bytes": 1536,
"size_kb": 1.536
}
}

Areas

Calculating rectangle area from dimensions...

{
"rectangle": {
"width": 4.5,
"height": 3.2
}
}
- multiply:
field: rectangle.area
left_operand: "rectangle.width"
right_operand: "rectangle.height"

computes the geometric property:

{
"rectangle": {
"width": 4.5,
"height": 3.2,
"area": 14.4
}
}

Scaling

Normalizing percentages to 0-1 scale...

{
"stats": {
"cpu_usage_percent": 72.5,
"memory_usage_percent": 45.8,
"disk_usage_percent": 63.2
}
}
- multiply:
field: stats.cpu_usage_normalized
left_operand: "stats.cpu_usage_percent"
right_operand: "0.01"
- multiply:
field: stats.memory_usage_normalized
left_operand: "stats.memory_usage_percent"
right_operand: "0.01"
- multiply:
field: stats.disk_usage_normalized
left_operand: "stats.disk_usage_percent"
right_operand: "0.01"

transforms percentage values to decimal:

{
"stats": {
"cpu_usage_percent": 72.5,
"memory_usage_percent": 45.8,
"disk_usage_percent": 63.2,
"cpu_usage_normalized": 0.725,
"memory_usage_normalized": 0.458,
"disk_usage_normalized": 0.632
}
}

Compound

Calculating volume from radius...

{
"sphere": {
"radius": 3
},
"constants": {
"pi": 3.14159
}
}
- multiply:
field: sphere.radius_squared
left_operand: "sphere.radius"
right_operand: "sphere.radius"
- multiply:
field: sphere.radius_cubed
left_operand: "sphere.radius_squared"
right_operand: "sphere.radius"
- multiply:
field: sphere.volume_factor
left_operand: "constants.pi"
right_operand: "4/3"
- multiply:
field: sphere.volume
left_operand: "sphere.volume_factor"
right_operand: "sphere.radius_cubed"

implements a multi-step formula calculation:

{
"sphere": {
"radius": 3,
"radius_squared": 9,
"radius_cubed": 27,
"volume_factor": 4.18879,
"volume": 113.097
},
"constants": {
"pi": 3.14159
}
}