Built-in Transforms
Catalogue of the transforms shipped with Prelude Collector — string, time, IP, BGP, SNMP, units, and MIB enum conversions.
Built-in transforms are implemented in Go and registered when Prelude Collector starts. They are available to every data model without any additional configuration. After this first mention, the rest of this page refers to Prelude Collector as "the collector".
The Name column is the string you put in the transforms list
of a field mapping. Every function takes a single value and returns
a single value.
Error behaviour
When a built-in transform receives an unsupported type, the
standalone Apply helper logs a warning and lets the value pass
through. The live collection path is stricter — the field is
dropped and a parse error is recorded on the snapshot. See
Error handling for the full contract.
Calling these from Starlark
Every name on this page is also exposed as a callable global to
Custom transforms. A Starlark transform can wrap or
compose any built-in by name, plus the Starlark-only round
helper. See Custom transforms — Available globals.
strings
General-purpose string operations.
| Name | Input | Output | Description | Example |
|---|---|---|---|---|
trim_whitespace |
string | string | Removes leading and trailing whitespace. | " hello " → "hello" |
lowercase |
string | string | Converts to lowercase. | "HELLO" → "hello" |
uppercase |
string | string | Converts to uppercase. | "hello" → "HELLO" |
hex_to_int |
string | int64 | Parses a hex string (with or without 0x prefix) to an integer. |
"0x1f" → 31 |
int_to_hex |
numeric | string | Formats an integer as a lowercase hex string with 0x prefix. |
31 → "0x1f" |
base64_decode |
string | string | Decodes a Base64-encoded string. | "aGVsbG8=" → "hello" |
truncate_256 |
string | string | Truncates a string to 256 characters; non-strings pass through unchanged. | a 300-char string → its first 256 chars |
time
Timestamp and duration conversions.
| Name | Input | Output | Description | Example |
|---|---|---|---|---|
unix_to_iso |
numeric / string | string | Converts a Unix timestamp (seconds since epoch) to RFC 3339 / ISO 8601. | 1700000000 → "2023-11-14T22:13:20Z" |
unix_ms_to_iso |
numeric / string | string | Converts a Unix timestamp in milliseconds to RFC 3339 / ISO 8601. | 1700000000000 → "2023-11-14T22:13:20Z" |
seconds_to_duration |
numeric / string | string | Converts a duration in seconds to a human-readable string. | 90061 → "1d 1h 1m 1s" |
ip
IP address and subnet operations.
| Name | Input | Output | Description | Example |
|---|---|---|---|---|
ip_with_prefix |
numeric / 4-byte bytes / dotted-quad string | string | Converts a packed 32-bit IPv4 address to dotted-quad notation. Accepts any signed/unsigned integer width, a 4-byte bytes value, or a string that is either dotted-quad text or 4 raw bytes. |
0xC0000201 → "192.0.2.1" |
ip_with_netmask |
numeric / 4-byte bytes / string | string | Converts a packed 32-bit subnet mask to prefix-length notation. Accepts the same input shapes as ip_with_prefix. |
0xFFFFFF00 → "/24" |
netmask_to_prefix |
string | int | Converts a dotted-quad subnet mask to an integer prefix length. | "255.255.255.0" → 24 |
ipv6_compress |
string | string | Parses an IPv6 address and returns its compressed form. | "2001:0db8:0000:0000:0000:0000:0000:0001" → "2001:db8::1" |
ipv6_expand |
string | string | Parses an IPv6 address and returns its fully expanded form (8 groups of 4 hex). | "2001:db8::1" → "2001:0db8:0000:0000:0000:0000:0000:0001" |
mac_to_eui48 |
string | string | Normalises any MAC format (:, -, or Cisco .) to lowercase EUI-48 notation. |
"AABB.CCDD.EEFF" → "aa:bb:cc:dd:ee:ff" |
bgp
BGP-specific format conversions.
| Name | Input | Output | Description | Example |
|---|---|---|---|---|
as_plain |
string / numeric | string / numeric | Converts an ASN from asdot+ notation ("X.Y") to plain decimal. Integer inputs and plain-decimal strings (no dot) pass through unchanged. |
"1.0" → "65536" |
as_dot |
numeric / string | string | Converts an ASN integer to asdot+ notation. | 65536 → "1.0" |
bgp_community |
numeric / string | string | Formats a uint32 as a BGP standard community string HI:LO. |
131072 → "2:0" |
bgp_ext_community |
numeric / string | string | Formats a uint64 as a BGP extended community string TYPE:HI:LO. |
0x0002000100000064 → "2:1:100" |
snmp
SNMP-specific type conversions.
| Name | Input | Output | Description | Example |
|---|---|---|---|---|
timeticks_to_seconds |
numeric | float64 | Converts SNMP TimeTicks (1/100 seconds) to seconds. | 36000 → 360.0 |
timeticks_to_uptime |
numeric | string | Converts SNMP TimeTicks to a human-readable uptime string. | 360000 → "0d 1h 0m 0s" |
octetstring_to_hex |
bytes / string | string | Converts raw bytes to a colon-separated lowercase hex string. | \xaa\xbb → "aa:bb" |
octetstring_to_mac |
bytes / string (6 bytes) | string | Converts a 6-byte octet string to a MAC address. | \xaa\xbb\xcc\xdd\xee\xff → "aa:bb:cc:dd:ee:ff" |
strip_null_bytes |
string | string | Removes null bytes (\x00) from a string. |
"hello\x00" → "hello" |
oid_last_segment |
string | string | Returns everything after the last dot in an OID string. | "1.3.6.1.2.1.1.5.0" → "0" |
units
Numeric unit conversions. All functions accept any numeric type or a numeric string.
| Name | Input | Output | Description | Example |
|---|---|---|---|---|
speed_to_human |
numeric | string | Converts a raw bps value to a human-readable string with SI suffix. | 1000000000 → "1G", 1000 → "1K" |
mul_8 |
numeric | float64 | Multiplies by 8 — bytes-to-bits conversion. | 125000000 → 1000000000.0 |
to_mbps |
numeric | float64 | Divides by 1,000,000 — converts bps to Mbps. | 1000000000 → 1000.0 |
to_gbps |
numeric | float64 | Divides by 1,000,000,000 — converts bps to Gbps. | 1000000000 → 1.0 |
bytes_to_mb |
numeric | float64 | Converts bytes to megabytes (÷ 1,048,576). | 1048576 → 1.0 |
bytes_to_gb |
numeric | float64 | Converts bytes to gigabytes (÷ 1,073,741,824). | 1073741824 → 1.0 |
div_10 |
numeric | float64 | Divides by 10. | 100 → 10.0 |
div_100 |
numeric | float64 | Divides by 100. | 100 → 1.0 |
div_1000 |
numeric | float64 | Divides by 1000 — milli-units to units. | 1000 → 1.0 |
celsius_to_fahrenheit |
numeric | float64 | Converts Celsius to Fahrenheit. | 100 → 212.0 |
enum
Maps integer MIB codes to human-readable string names. All functions accept any numeric type or a numeric string.
Interface (IF-MIB)
| Name | Input | Output | Description | Mapping |
|---|---|---|---|---|
if_admin_status |
numeric | string | Maps IF-MIB ifAdminStatus integer to name. |
1=up, 2=down, 3=testing |
if_oper_status |
numeric | string | Maps IF-MIB ifOperStatus integer to name. |
1=up, 2=down, 3=testing, 4=unknown, 5=dormant, 6=notPresent, 7=lowerLayerDown |
BGP (RFC 4271)
| Name | Input | Output | Description | Mapping |
|---|---|---|---|---|
bgp_state |
numeric | string | Maps the BGP FSM state integer to its name. | 1=Idle, 2=Connect, 3=Active, 4=OpenSent, 5=OpenConfirm, 6=Established |
IS-IS (ISIS-MIB)
| Name | Input | Output | Description | Mapping |
|---|---|---|---|---|
isis_adj_state |
numeric | string | Maps ISIS-MIB isisISAdjState to name. |
1=down, 2=initializing, 3=up |
OSPF (OSPF-MIB)
| Name | Input | Output | Description | Mapping |
|---|---|---|---|---|
ospf_neighbor_state |
numeric | string | Maps OSPF-MIB ospfNbrState to name. |
1=Down, 2=Attempt, 3=Init, 4=2-Way, 5=ExStart, 6=Exchange, 7=Loading, 8=Full |
Quick reference
| Module | Transform names |
|---|---|
| strings | trim_whitespace, lowercase, uppercase, hex_to_int, int_to_hex, base64_decode, truncate_256 |
| time | unix_to_iso, unix_ms_to_iso, seconds_to_duration |
| ip | ip_with_prefix, ip_with_netmask, netmask_to_prefix, ipv6_compress, ipv6_expand, mac_to_eui48 |
| bgp | as_plain, as_dot, bgp_community, bgp_ext_community |
| snmp | timeticks_to_seconds, timeticks_to_uptime, octetstring_to_hex, octetstring_to_mac, strip_null_bytes, oid_last_segment |
| units | speed_to_human, mul_8, to_mbps, to_gbps, bytes_to_mb, bytes_to_gb, div_10, div_100, div_1000, celsius_to_fahrenheit |
| enum | if_admin_status, if_oper_status, bgp_state, isis_adj_state, ospf_neighbor_state |