Sqrt
Synopsis
Calculates the square root of a numeric value.
Schema
- sqrt:
field: <ident>
value: <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:
| Field | Required | Default | Description |
|---|---|---|---|
field | Y | - | Target field to store the square root result |
value | Y | - | Value to process - can be a literal value or field reference |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if square root calculation fails |
ignore_missing | N | false | Skip if referenced fields don't exist |
on_failure | N | - | Error handling processors |
on_success | N | - | Success handling processors |
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 |
This operand is resolved by getNumericValue, which accepts exactly two forms: a numeric literal such as 3600, or a bare field path such as stats.total. Nothing else is evaluated.
There is no expression evaluator here, and no template expansion. "a / b" is looked up as a field literally named a / b, and "{{price}}" as a field literally named {{price}} — both fail with field does not exist. To compute a value first, use a math processor and reference the field it writes.
Details
Calculates the square root of a numeric value and stores the result in the target field. The processor can extract values from existing fields or use literal numeric values.
The square root calculation uses the math.Sqrt function from Go's standard library, which provides accurate results for all non-negative numbers.
The processor is useful for mathematical transformations, statistical calculations, and implementing various formulas that require square root operations.
Attempting to calculate the square root of a negative number will result in an error unless ignore_failure is set to true. Real-valued square roots are only defined for non-negative numbers.
Examples
Basic
Calculating the square root of a literal value... | |
calculates and stores the result: | |
Field-Based
Calculating square root of a field value... | |
computes radius from area: | |
Statistical
Calculating standard deviation from variance... | |
derives standard deviation: | |
Distances
Calculating Euclidean distance... | |
implements the distance formula: | |
Error Handling
Handling potential negative values... | |
continues execution: | |