UUIDv7

Learn about the UUIDv7 OTTL converter function.

The UUIDv7 converter creates a v7 Universally Unique Identifier that includes a timestamp component, making it sortable and more suitable for database indexing than UUIDv4.

Syntax: UUIDv7()

Input

{
	"_type": "log",
	"timestamp": 1735885742146,
	"body": "Creating time-ordered identifier",
	"resource": {...}
}

Statement

set(attributes["event_id"], UUIDv7())

Output

{
	"_type": "log",
	"timestamp": 1735885768037,
	"body": "Creating time-ordered identifier",
	"resource": {...},
	"attributes": {
		"event_id": "018d4b9c-5a3b-7c8e-9f2a-123456789abc"
	}
}

UUIDv7 includes a timestamp prefix making it naturally sortable by creation time.