Len

Learn about the Len OTTL converter function.

The Len converter returns the length of the string, list, or map.

Syntax: Len(value)

  • value: the location of the field to measure

Input

{
	"_type": "log",
	"timestamp": 1734491167973,
	"body": "time=hostname=SIMPLE|product=Firewall1",
	"resource": {...}
}

Statement

set(attributes["body_length"], Len(body))

Output

{
	"_type": "log",
	"timestamp": 1734491167973,
	"body": "time=hostname=SIMPLE|product=Firewall1",
	"resource": {...},
	"attributes": {
		"body_length": 38
	}
}

The length of the list body was calculated as 38 characters.