Data Size
Synopsis
Parses human-readable data sizes (e.g., "1kb") to byte values.
Schema
- data_size:
field: <ident>
target_field: <ident>
output_format: <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 | - | Source field containing human-readable data size |
target_field | N | Same as field | Target field to store parsed byte value |
output_format | N | bytes | bytes writes the byte count as a number; detailed writes an object. Any other value fails the processor |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if parsing fails |
ignore_missing | N | false | Skip processing if referenced field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
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 |
Details
Converts human-readable data size strings to numerical byte values. Supports B, KB, MB, GB, TB and PB, and the binary equivalents KiB, MiB, GiB, TiB and PiB. Long forms are accepted too — megabyte, megabytes, mbyte, mbytes and their siblings all normalize.
The processor recognizes 1.5GB, 512 MB, 2TB and a bare number, which is read as bytes. Decimal units are 1000-based and binary units 1024-based. The source field must be a string — a numeric field fails with field is not a string. A fractional result is rounded to the nearest byte.
The processor supports both decimal units (KB, MB, GB using 1000-based calculations) and binary units (KiB, MiB, GiB using 1024-based calculations). Units are case-insensitive.
When output_format is detailed the processor writes an object with five keys — bytes, value, unit, unit_type and original_size. unit is the normalized spelling (GiB, not gib), and unit_type is binary or decimal.
If the input string cannot be parsed as a valid data size, the processor will fail unless ignore_failure is set to true. Invalid units or malformed size strings will trigger errors.
Examples
Basic Size Parsing
Converting readable size to bytes... | |
converts to byte value: | |
Binary Units
Using binary (1024-based) units... | |
calculates using 1024-based units: | |
Detailed Output
Getting detailed parsing information... | |
returns detailed breakdown: | |
Mixed Case Units
Processing case-insensitive units... | |
replacing the source value, since | |