# Transforming Kong Logs for Ingestion into Your Observability Stack
Damon Sorrentino
As a Solutions Engineer here at Kong, one question that frequently comes across my desk is “how can I transform a Kong logging plugin message into a format that my `insert-observability-stack-here` understands, (e.g., ELK, Loki, Splunk, etc.)?”
If you don’t already have an instance of Kong running in a Kubernetes cluster, connect to your cluster and run the following the commands to get one in seconds.
## text
% kubectl create ns kong
% kubectl apply -f https://bit.ly/kong-ingress-dbless
% kubectl get po -n kong -w
NAME READY STATUS RESTARTS AGE
ingress-kong-7c4b795d5d-f2lpt 0/2 ContainerCreating 0 1s
ingress-kong-7c4b795d5d-f2lpt 0/2 Running 0 1s
ingress-kong-7c4b795d5d-f2lpt 1/2 Running 0 10s
ingress-kong-7c4b795d5d-f2lpt 2/2 Running 0 20s
^C
First, create an empty Kubernetes manifest file called, `elastic-common-schema.yaml`.
Next, let’s define our KongPlugin resources. The first plugin we will create is the serverless pre-function. From the Kong plugin docs, a serverless pre-function plugin:
*Runs before other plugins run during each phase. The pre-function plugin can be applied to individual services, routes, or globally.*
The above resource definition creates a `KongPlugin` that executes before the logging phase of each plugin defined in scope. The `kong.ctx.shared.mystuff=kong.log.serialize()` is a single line of Lua code that stores the logging payload into a shared context. From the Kong docs, a shared context is:
*A [Lua] table that has the same lifetime as the current request. This table is shared between all plugins. It can be used to share data between several plugins in a given request.*
The key to doing the transformation is the `custom_fields_by_lua` configuration. From the Kong docs, the `custom_fields_by_lua` is:
*A list of key-value pairs, where the key is the name of a log field and the value is a chunk of Lua code, whose return value sets or replaces the log field value.*
## text
% kubectl create ns myblog
% kubectl apply -f https://bit.ly/k8s-httpbin -n myblog
% kubectl get po -n myblog -w
NAME READY STATUS RESTARTS AGE
httpbin-64cdb8c89c-7rxm2 1/1 Running 0 5s
^C
## text
% kubectl logs ingress-kong-7c4b795d5d-pg2c6 -n kong -c proxy -f | grep "@timestamp"
# You should see something similar to the below
{"@timestamp":"1667427319","url":{"original":"/testing/anything"},"http":{"response":{"status_code":200},"request":{"body":{"bytes":93}}},"client_ip":"10.48.0.1"}
Congratulations, you have transformed a Kong log payload into an Elastic Common Schema format ready for ingestion! This pattern can be used to easily transform Kong logging messages into any format for ingestion with any observability stack.
## Full API Observability Unveiled: Gain Complete Visibility with Konnect
Multi-agent systems are, at their core, context distribution systems. Every agent in your workflow is a consumer and producer of context. The interesting architectural questions are all about how that context moves. Two operations drive everything:
Hugo Guerrero
# Why Your Kafka Event Streams Need an Event Gateway
You wouldn't expose a REST API without a gateway. What about Kafka?
Before we talk about an event gateway, it's worth grounding ourselves on what an event is. An event is simply a record of something that happened. In modern integration, there are
Warren Vella
# AI Agent Integration: Gartner Research Confirms Need for AI Control Layer
An AI control layer is the governance and observability infrastructure that sits between AI agents and enterprise applications, handling authentication, routing, rate limiting, and auditability to ensure secure, managed access. Unlike traditional in
Heather Halenbeck
# Introducing Advanced AI Observability: See the Whole Agent Journey
When an AI application fails, knowing that an individual model call returned a 200 isn’t enough. You need to know what led to it. Kong stitches the interactions associated with an AI session together, giving developers a view across the sequence of
Alex Drag
# Kong's Named Leader in the 2026 Gartner® Magic Quadrant™ for API Management
We're thrilled to announce that Kong, the AI connectivity company, has been recognized as a Leader in the Gartner Magic Quadrant for API Management for the seventh year in a row. Plus, Kong was positioned furthest on the Completeness of Vision axis
There are two key concepts when a developer works with an API. The OpenAPI Spec describes how the API should work, and helps agents discover what is possible. The Collection and Requests help debug and verify how the endpoints currently function. P
Cameron HayGlass
# Kong API Gateway 3.16: Runtime control, API monetization, and FIPS 140-3
If you've run Kong at scale, you know the moment: a spike in 5xxs from one specific data plane node, a customer opening a ticket about intermittent failures, or a partner integration that fails calls no one else does. Debug-level logs would tell you
Zongmin Li
# The Architecture Decision Your Multi-Agent System Will Live With
Multi-agent systems are, at their core, context distribution systems. Every agent in your workflow is a consumer and producer of context. The interesting architectural questions are all about how that context moves. Two operations drive everything:
Hugo Guerrero
# Why Your Kafka Event Streams Need an Event Gateway
You wouldn't expose a REST API without a gateway. What about Kafka?
Before we talk about an event gateway, it's worth grounding ourselves on what an event is. An event is simply a record of something that happened. In modern integration, there are
Warren Vella
# AI Agent Integration: Gartner Research Confirms Need for AI Control Layer
An AI control layer is the governance and observability infrastructure that sits between AI agents and enterprise applications, handling authentication, routing, rate limiting, and auditability to ensure secure, managed access. Unlike traditional in
Heather Halenbeck
# Introducing Advanced AI Observability: See the Whole Agent Journey
When an AI application fails, knowing that an individual model call returned a 200 isn’t enough. You need to know what led to it. Kong stitches the interactions associated with an AI session together, giving developers a view across the sequence of
Alex Drag
# Kong's Named Leader in the 2026 Gartner® Magic Quadrant™ for API Management
We're thrilled to announce that Kong, the AI connectivity company, has been recognized as a Leader in the Gartner Magic Quadrant for API Management for the seventh year in a row. Plus, Kong was positioned furthest on the Completeness of Vision axis
There are two key concepts when a developer works with an API. The OpenAPI Spec describes how the API should work, and helps agents discover what is possible. The Collection and Requests help debug and verify how the endpoints currently function. P
Cameron HayGlass
# Kong API Gateway 3.16: Runtime control, API monetization, and FIPS 140-3
If you've run Kong at scale, you know the moment: a spike in 5xxs from one specific data plane node, a customer opening a ticket about intermittent failures, or a partner integration that fails calls no one else does. Debug-level logs would tell you
Zongmin Li
# The Architecture Decision Your Multi-Agent System Will Live With
Multi-agent systems are, at their core, context distribution systems. Every agent in your workflow is a consumer and producer of context. The interesting architectural questions are all about how that context moves. Two operations drive everything:
Hugo Guerrero
# Why Your Kafka Event Streams Need an Event Gateway
You wouldn't expose a REST API without a gateway. What about Kafka?
Before we talk about an event gateway, it's worth grounding ourselves on what an event is. An event is simply a record of something that happened. In modern integration, there are
Warren Vella
# AI Agent Integration: Gartner Research Confirms Need for AI Control Layer
An AI control layer is the governance and observability infrastructure that sits between AI agents and enterprise applications, handling authentication, routing, rate limiting, and auditability to ensure secure, managed access. Unlike traditional in
Heather Halenbeck
# Introducing Advanced AI Observability: See the Whole Agent Journey
When an AI application fails, knowing that an individual model call returned a 200 isn’t enough. You need to know what led to it. Kong stitches the interactions associated with an AI session together, giving developers a view across the sequence of
Alex Drag
# Kong's Named Leader in the 2026 Gartner® Magic Quadrant™ for API Management
We're thrilled to announce that Kong, the AI connectivity company, has been recognized as a Leader in the Gartner Magic Quadrant for API Management for the seventh year in a row. Plus, Kong was positioned furthest on the Completeness of Vision axis
There are two key concepts when a developer works with an API. The OpenAPI Spec describes how the API should work, and helps agents discover what is possible. The Collection and Requests help debug and verify how the endpoints currently function. P
Cameron HayGlass
# Kong API Gateway 3.16: Runtime control, API monetization, and FIPS 140-3
If you've run Kong at scale, you know the moment: a spike in 5xxs from one specific data plane node, a customer opening a ticket about intermittent failures, or a partner integration that fails calls no one else does. Debug-level logs would tell you
Zongmin Li
## Ready to see Kong in action?
Get a personalized walkthrough of Kong's platform tailored to your architecture, use cases, and scale requirements.