Data Size
Synopsis
Parses human-readable data sizes (e.g., "1kb") to byte values.
Schema
- data_size:
field: <ident>
target_field: <string>
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 | Output format: bytes (number) or detailed (object) |
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 |
Details
Converts human-readable data size strings to numerical byte values. Supports common size units including bytes (B), kilobytes (KB), megabytes (MB), gigabytes (GB), terabytes (TB), and their binary equivalents (KiB, MiB, GiB, TiB).
The processor recognizes various formats including "1.5GB", "512 MB", "2TB", and handles both decimal (1000-based) and binary (1024-based) calculations depending on the unit suffix.
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 set to "detailed", the processor returns an object containing both the original value, parsed number, unit, and calculated bytes.
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... |
|
handles case variations: |
|