number

Parses message contents into a 64-bit floating point number and performs an operator on it. In order to execute this processor on a sub field of a document use it with the process_field processor.

# Common config fields, showing default values
number:
operator: add
value: 0

The value field can either be a number or a string type. If it is a string type then this processor will interpolate functions within it, you can find a list of functions here.

For example, if we wanted to subtract the current unix timestamp from the field 'foo' of a JSON document {"foo":1561219142} we could use the following config:

process_field:
path: foo
result_type: float
processors:
- number:
operator: subtract
value: "${!timestamp_unix}"

Value interpolations are resolved once per message batch, in order to resolve it for each message of the batch place it within a for_each processor.

Operators

add

Adds a value.

subtract

Subtracts a value.

Fields

operator

The operator to apply.

Type: string
Default: "add"

value

A value used by the operator. This field supports interpolation functions that are resolved batch wide.

Type: number
Default: 0

parts

An optional array of message indexes of a batch that the processor should apply to. If left empty all messages are processed. This field is only applicable when batching messages at the input level.

Indexes can be negative, and if so the part will be selected from the end counting backwards starting from -1.

Type: array
Default: []