How to log the pod name of the Kong Gateway node that processed a request

TL;DR

How do I add the data plane pod name to the log produced by a Kong Gateway logging plugin to identify which Kong Gateway pod processed the request?

In a Kubernetes environment, the container exposes a HOSTNAME variable set to the pod the container runs on. Using the environment variable Vault secret management backend, add this variable to the log plugin output by adding a new field to the plugin’s config.custom_fields_by_lua property.

Steps

In a Kubernetes environment, a container has a HOSTNAME variable set to the name of the pod it runs on. Using the environment variable Vault secret management backend, you can expose this variable in log plugin output by adding a field to the plugin’s config.custom_fields_by_lua property.

The following examples use the File Log plugin.

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!