Skip to content

uuid - Generate a random UUID

Deprecated: use randomUuid instead

Generate a random UUID to function as an identifier for a given document.

Syntax

uuid(): string

Example - Adding an ID to a document

Consider the following document:

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

We do not have any kind of request_id available, but we can use uuid() to generate one for us.

create request_id from uuid()

After running this function, the document is now:

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