Hex

Learn about the Hex OTTL converter function.

The Hex converter converts a value to its hexadecimal representation.

Syntax: Hex(value)

  • value: a literal or the bracket notation location of the string field to convert. The value type must be a float64, string, bool, int64 or []byte.

Input

{
	"_type": "log",
	"attributes": {
		"address": "0x3A28213A"
	},
	"body": "2023-12-01 12:34:56 [INFO] Memory allocation successful at address 0x3A28213A for process 1234.",
	"resource": {...}
}

Statement

set(attributes["hex_address"], Hex(attributes["address"]))

Output

{
	"_type": "log",
	"attributes": {
		"address": "0x3A28213A",
		"hex_address": "30783341323832313341"
	},
	"body": "2023-12-01 12:34:56 [INFO] Memory allocation successful at address 0x3A28213A for process 1234.",
	"resource": {...},
	"timestamp": 1733809768919
}

The memory address was converted to its hexadecimal string.