# 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
Agent spend grows quietly. Usage shows up as an item line on a shared cloud or model invoice, long after the agents that caused it have run, and most teams cannot tell which team, harness, or app drove it. AI Cost Management solves this with brand
Alex Drag
# AI Observability Starts Where API Observability Stops
A call comes in, a response goes out, and you measure status, latency, and error rate. That works because "did the service do its job" maps cleanly onto one exchange. AI goes beyond the simplistic and requires a deeper perspective. Where API observ
Dan Temkin
# AI Observability: Monitoring and Troubleshooting Your LLM Infrastructure
Traditional observability shows whether infrastructure and services are available, responsive, and error-free. AI observability retains those signals, then adds context ordinary APM often lacks. This includes models, tokens, retrieval results, evalu
Kong
# 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
# 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
Agent spend grows quietly. Usage shows up as an item line on a shared cloud or model invoice, long after the agents that caused it have run, and most teams cannot tell which team, harness, or app drove it. AI Cost Management solves this with brand
Alex Drag
# AI Observability Starts Where API Observability Stops
A call comes in, a response goes out, and you measure status, latency, and error rate. That works because "did the service do its job" maps cleanly onto one exchange. AI goes beyond the simplistic and requires a deeper perspective. Where API observ
Dan Temkin
# AI Observability: Monitoring and Troubleshooting Your LLM Infrastructure
Traditional observability shows whether infrastructure and services are available, responsive, and error-free. AI observability retains those signals, then adds context ordinary APM often lacks. This includes models, tokens, retrieval results, evalu
Kong
# 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
# 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
Agent spend grows quietly. Usage shows up as an item line on a shared cloud or model invoice, long after the agents that caused it have run, and most teams cannot tell which team, harness, or app drove it. AI Cost Management solves this with brand
Alex Drag
# AI Observability Starts Where API Observability Stops
A call comes in, a response goes out, and you measure status, latency, and error rate. That works because "did the service do its job" maps cleanly onto one exchange. AI goes beyond the simplistic and requires a deeper perspective. Where API observ
Dan Temkin
# AI Observability: Monitoring and Troubleshooting Your LLM Infrastructure
Traditional observability shows whether infrastructure and services are available, responsive, and error-free. AI observability retains those signals, then adds context ordinary APM often lacks. This includes models, tokens, retrieval results, evalu
Kong
# 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
## Ready to see Kong in action?
Get a personalized walkthrough of Kong's platform tailored to your architecture, use cases, and scale requirements.