kong.telemetry.log

Uses: Kong Gateway

The telemetry module provides capabilities for telemetry operations.

kong.telemetry.log(plugin_name, plugin_config, message_type, message, attributes)

Records a structured log entry, to be reported via the OpenTelemetry plugin.

This function has a dependency on the OpenTelemetry plugin, which must be configured to report OpenTelemetry logs.

Phases

  • rewrite, access, balancer, timer, header_filter, response, body_filter, log

Parameters

  • plugin_name (string): the name of the plugin
  • plugin_config (table): the plugin configuration
  • message_type (string): the type of the log message, useful to categorize the log entry
  • message (string): the log message
  • attributes (table): structured information to be included in the attributes field of the log entry

Usage

local attributes = {
  http_method = kong.request.get_method()
  ["node.id"] = kong.node.get_id(),
  hostname = kong.node.get_hostname(),
}

local ok, err = kong.telemetry.log("my_plugin", conf, "result", "successful operation", attributes)
Something wrong?

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!