tcp-logger

This provides the ability to send log data requests as JSON objects to monitoring tools and other TCP servers.

This plugin also allows to push logs as a batch to your external TCP server. It might take some time to receive the log data. It will be automatically sent after the timer function in the expires.

Attributes

You can also set the format of the logs by configuring the Plugin metadata. The following configurations are available:

NameTypeRequiredDefaultDescription
log_formatobjectFalse{“host”: “$host”, “@timestamp”: “$time_iso8601”, “client_ip”: “$remote_addr”}Log format declared as key value pairs in JSON format. Values only support strings. APISIX or variables can be used by prefixing the string with .
IMPORTANT

Configuring the Plugin metadata is global in scope. This means that it will take effect on all Routes and Services which use the tcp-logger Plugin.

With this configuration, your logs would be formatted as shown below:

Enabling the Plugin

The example below shows how you can enable the tcp-logger Plugin on a specific Route:

Disable Plugin

To disable the Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.