Skip to content

randomUuid

Description

Returns a randomly generated UUIDv4, useful for assigning identifiers to documents.

Syntax

randomUuid(): string

Example

Use case: Add unique identifiers to documents

Suppose you have log documents that do not include a request_id. You can generate one automatically. Consider this document:

{
"path": "/home",
"domain": "coralogix.com",
"full_url_encoded": "aHR0cHM6Ly9jb3JhbG9naXguY29tL2hvbWU="
}

You can assign a new UUID with:

create request_id from randomUuid()

Output

{
"path": "/home",
"domain": "coralogix.com",
"full_url_encoded": "aHR0cHM6Ly9jb3JhbG9naXguY29tL2hvbWU=",
"request_id": "37367559-35f4-459c-943e-19025765da15"
}