kong.cluster

Cluster-level utilities.

kong.cluster.get_id()

Returns the unique ID for this Kong cluster. If Kong is running in DB-less mode without a cluster ID explicitly defined, then this method returns nil.

For hybrid mode, all control planes and data planes belonging to the same cluster return the same cluster ID. For traditional database-based deployments, all Kong nodes pointing to the same database also return the same cluster ID.

Returns

  1. string|nil: The v4 UUID used by this cluster as its ID.

  2. string|nil: An error message.

Usage

  1. local id, err = kong.cluster.get_id()
  2. if err then
  3. -- handle error
  4. end
  5. if not id then
  6. -- no cluster ID is available
  7. end
  8. -- use id here