WHY GARTNER’S “CONTEXT MESH” CHANGES EVERYTHING AI CONNECTIVITY: THE ROAD AHEAD DON’T MISS API + AI SUMMIT 2026 SEPT 30 – OCT 1
  • [Why Kong](/company/why-kong)Why Kong
    • Explore the unified API Platform
        • BUILD APIs
        • [
          Kong Insomnia](/products/kong-insomnia)
          Kong Insomnia
        • [
          API Design](/products/kong-insomnia/api-design)
          API Design
        • [
          API Mocking](/products/kong-insomnia/api-mocking)
          API Mocking
        • [
          API Testing and Debugging](/products/kong-insomnia/api-testing-and-debugging)
          API Testing and Debugging
        • [
          MCP Client](/products/kong-insomnia/mcp-client)
          MCP Client
        • RUN APIs
        • [
          API Gateway](/products/kong-gateway)
          API Gateway
        • [
          Context Mesh](/products/kong-konnect/features/context-mesh)
          Context Mesh
        • [
          AI Gateway](/products/kong-ai-gateway)
          AI Gateway
        • [
          Event Gateway](/products/event-gateway)
          Event Gateway
        • [
          Kubernetes Operator](/products/kong-gateway-operator)
          Kubernetes Operator
        • [
          Service Mesh](/products/kong-mesh)
          Service Mesh
        • [
          Ingress Controller](/products/kong-ingress-controller)
          Ingress Controller
        • [
          Runtime Management](/products/kong-konnect/features/runtime-management)
          Runtime Management
        • DISCOVER APIs
        • [
          Developer Portal](/products/kong-konnect/features/developer-portal)
          Developer Portal
        • [
          Service Catalog](/products/kong-konnect/features/api-service-catalog)
          Service Catalog
        • [
          MCP Registry](/products/mcp-registry)
          MCP Registry
        • GOVERN APIs
        • [
          Metering and Billing](/products/kong-konnect/features/usage-based-metering-and-billing)
          Metering and Billing
        • [
          APIOps and Automation](/products/apiops-automation)
          APIOps and Automation
        • [
          API Observability](/products/kong-konnect/features/api-observability)
          API Observability
        • [Why Kong?](/company/why-kong)Why Kong?
      • CLOUD
      • [Cloud API Gateways](/products/kong-konnect/features/dedicated-cloud-gateways)Cloud API Gateways
      • [Need a self-hosted or hybrid option?](/products/kong-enterprise)Need a self-hosted or hybrid option?
      • COMPARE
      • [Considering AI Gateway alternatives? ](/performance-comparison/ai-gateway-alternatives)Considering AI Gateway alternatives?
      • [Kong vs. Postman](/performance-comparison/kong-vs-postman)Kong vs. Postman
      • [Kong vs. MuleSoft](/performance-comparison/kong-vs-mulesoft)Kong vs. MuleSoft
      • [Kong vs. Apigee](/performance-comparison/kong-vs-apigee)Kong vs. Apigee
      • [Kong vs. IBM](/performance-comparison/ibm-api-connect-vs-kong)Kong vs. IBM
      • GET STARTED
      • [Sign Up for Kong Konnect](/products/kong-konnect/register)Sign Up for Kong Konnect
      • [Documentation](https://developer.konghq.com/)Documentation
      • FOR PLATFORM TEAMS
      • [Developer Platform](/solutions/building-developer-platform)Developer Platform
      • [Kubernetes and Microservices](/solutions/build-on-kubernetes)Kubernetes and Microservices
      • [Observability](/solutions/observability)Observability
      • [Service Mesh Connectivity ](/solutions/service-mesh-connectivity)Service Mesh Connectivity
      • [Kafka Event Streaming](/solutions/kafka-stream-api-management)Kafka Event Streaming
      • FOR EXECUTIVES
      • [AI Connectivity](/ai-connectivity)AI Connectivity
      • [Open Banking](/solutions/open-banking)Open Banking
      • [Legacy Migration](/solutions/legacy-api-management-migration)Legacy Migration
      • [Platform Cost Reduction](/solutions/api-platform-consolidation)Platform Cost Reduction
      • [Kafka Cost Optimization](/solutions/reduce-kafka-cost)Kafka Cost Optimization
      • [API Monetization](/solutions/api-monetization)API Monetization
      • [AI Monetization](/solutions/ai-monetization)AI Monetization
      • [AI FinOps](/solutions/ai-cost-governance-finops)AI FinOps
      • FOR AI TEAMS
      • [AI Governance](/solutions/ai-governance)AI Governance
      • [AI Security](/solutions/ai-security)AI Security
      • [AI Cost Control](/solutions/ai-cost-optimization-management)AI Cost Control
      • [Agentic Infrastructure](/solutions/agentic-ai-workflows)Agentic Infrastructure
      • [MCP Production](/solutions/mcp-production-and-consumption)MCP Production
      • [MCP Traffic Gateway](/solutions/mcp-governance)MCP Traffic Gateway
      • FOR DEVELOPERS
      • [Mobile App API Development](/solutions/mobile-application-api-development)Mobile App API Development
      • [GenAI App Development](/solutions/power-openai-applications)GenAI App Development
      • [API Gateway for Istio](/solutions/istio-gateway)API Gateway for Istio
      • [Decentralized Load Balancing](/solutions/decentralized-load-balancing)Decentralized Load Balancing
      • BY INDUSTRY
      • [Financial Services](/solutions/financial-services-industry)Financial Services
      • [Healthcare](/solutions/healthcare)Healthcare
      • [Higher Education](/solutions/api-platform-for-education-services)Higher Education
      • [Insurance](/solutions/insurance)Insurance
      • [Manufacturing](/solutions/manufacturing)Manufacturing
      • [Retail](/solutions/retail)Retail
      • [Software & Technology](/solutions/software-and-technology)Software & Technology
      • [Transportation](/solutions/transportation-and-logistics)Transportation
      • [See all Solutions](/solutions)See all Solutions
  • [Pricing](/pricing)Pricing
      • DOCUMENTATION
      • [Kong Konnect](https://developer.konghq.com/konnect/)Kong Konnect
      • [Kong Gateway](https://developer.konghq.com/gateway/)Kong Gateway
      • [Kong Mesh](https://developer.konghq.com/mesh/)Kong Mesh
      • [Kong AI Gateway](https://developer.konghq.com/ai-gateway/)Kong AI Gateway
      • [Kong Event Gateway](https://developer.konghq.com/event-gateway/)Kong Event Gateway
      • [Kong Insomnia](https://developer.konghq.com/insomnia/)Kong Insomnia
      • [Plugin Hub](https://developer.konghq.com/plugins/)Plugin Hub
      • EXPLORE
      • [Blog](/blog)Blog
      • [Learning Center](/blog/learning-center)Learning Center
      • [eBooks](/resources/e-book)eBooks
      • [Reports](/resources/reports)Reports
      • [Demos](/resources/demos)Demos
      • [Customer Stories](/customer-stories)Customer Stories
      • [Videos](/resources/videos)Videos
      • EVENTS
      • [API + AI Summit](/events/conferences/api-ai-summit)API + AI Summit
      • [Agentic Era World Tour](/agentic-era-world-tour)Agentic Era World Tour
      • [Webinars](/events/webinars)Webinars
      • [User Calls](/events/user-calls)User Calls
      • [Workshops](/events/workshops)Workshops
      • [Meetups](/events/meetups)Meetups
      • [See All Events](/events)See All Events
      • FOR DEVELOPERS
      • [Get Started](https://developer.konghq.com/)Get Started
      • [Community](/community)Community
      • [Certification](/academy/certification)Certification
      • [Training](https://education.konghq.com)Training
      • COMPANY
      • [About Us](/company/about-us)About Us
      • [We're Hiring!](/company/careers)We're Hiring!
      • [Press Room](/company/press-room)Press Room
      • [Contact Us](/company/contact-us)Contact Us
      • [Kong Partner Program](/partners)Kong Partner Program
      • [Enterprise Support Portal](https://support.konghq.com/s/)Enterprise Support Portal
      • [Documentation](https://developer.konghq.com/?_gl=1*tphanb*_gcl_au*MTcxNTQ5NjQ0MC4xNzY5Nzg4MDY0LjIwMTI3NzEwOTEuMTc3MzMxODI2MS4xNzczMzE4MjYw*_ga*NDIwMDU4MTU3LjE3Njk3ODgwNjQ.*_ga_4JK9146J1H*czE3NzQwMjg1MjkkbzE4OSRnMCR0MTc3NDAyODUyOSRqNjAkbDAkaDA)Documentation
  • [](/search)
  • [Login](https://cloud.konghq.com/login)Login
  • [Book Demo](/contact-sales)Book Demo
  • [Get Started](/products/kong-konnect/register)Get Started
[Blog](/blog)Blog
  • [AI Gateway](/blog/tag/ai-gateway)AI Gateway
  • [AI Security](/blog/tag/ai-security)AI Security
  • [AIOps](/blog/tag/aiops)AIOps
  • [API Security](/blog/tag/api-security)API Security
  • [API Gateway](/blog/tag/api-gateway)API Gateway
|
    • [API Management](/blog/tag/api-management)API Management
    • [API Development](/blog/tag/api-development)API Development
    • [API Design](/blog/tag/api-design)API Design
    • [Automation](/blog/tag/automation)Automation
    • [Service Mesh](/blog/tag/service-mesh)Service Mesh
    • [Insomnia](/blog/tag/insomnia)Insomnia
    • [Event Gateway](/blog/tag/event-gateway)Event Gateway
    • [View All Blogs](/blog/page/1)View All Blogs
We're Entering the Age of AI Connectivity [Read more](/blog/news/the-age-of-ai-connectivity)Read moreProducts & Agents:
    • [Kong AI Gateway](/products/kong-ai-gateway)Kong AI Gateway
    • [Kong API Gateway](/products/kong-gateway)Kong API Gateway
    • [Kong Event Gateway](/products/event-gateway)Kong Event Gateway
    • [Kong Metering & Billing](/products/usage-based-metering-and-billing)Kong Metering & Billing
    • [Kong Insomnia](/products/kong-insomnia)Kong Insomnia
    • [Kong Konnect](/products/kong-konnect)Kong Konnect
  • [Documentation](https://developer.konghq.com)Documentation
  • [Book Demo](/contact-sales)Book Demo
  1. Home
  2. Blog
  3. Engineering
  4. Bringing Event Hooks to Your Kong Plugins
[Engineering](/blog/engineering)Engineering
October 26, 2021
3 min read

# Bringing Event Hooks to Your Kong Plugins

Steve Young

[Event Hooks](https://docs.konghq.com/enterprise/latest/admin-api/event-hooks/reference/?_ga=2.36365410.358764617.1632704366-1884338168.1597190394)Event Hooks is a new Kong Enterprise feature launched in the [Kong Gateway 2.5 Release](https://konghq.com/blog/kong-gateway-2-5)Kong Gateway 2.5 Release. This feature sends you notifications when certain events happen on your Kong Gateway deployment. Kong Gateway listens for events, like routes, services, consumers, certificates, plugins, workspaces and RBAC roles created, updated or removed.

You can also create or extend Kong Plugins and add the Event Hooks functionality for custom use cases. Businesses can use Event Hooks to bring enhanced awareness of change in a fully automated fashion, which ultimately increases enterprise visibility and reduces risk.

## Event Hooks Use Case

A customer is utilizing [Kong Workspaces](https://konghq.com/products/kong-enterprise/workspaces)Kong Workspaces to provide a logical separation between the management and configuration of their APIs with various teams. Each team uses a different logging tool or endpoint. By configuring the HTTP Log plugin with different logging endpoints for each Workspace, each team's API traffic is logged to separate logging endpoints. But what if a customer wants a global view of all API traffic without configuring another plugin?

### *By adding Event Hooks to the HTTP Log plugin, we can easily solve this problem, with the added benefit of not affecting existing functionality. *

With just a few lines of code, it is possible to extend the HTTP Log plugin to provide the functionality required.

## Kong Plugin Development Refresher

A Kong plugin allows you to inject custom logic in Lua, Go or JavaScript at several entry points in the lifecycle of a request and response or a TCP stream connection as it is proxied by Kong.

Plugins consist of Lua modules interacting with the request and response objects or streams via the Plugin Development Kit (or "PDK") to implement arbitrary logic. The Lua-based Plugin Development Kit (or "PDK") is a set of Lua functions and variables that plugins can use to implement their own logic. Refer to the [Kong Plugin Development Guide](https://docs.konghq.com/enterprise/latest/plugin-development)Kong Plugin Development Guide for more information. Or follow along in our [Lua](https://konghq.com/blog/custom-lua-plugin-kong-gateway)Lua and [JavaScript](https://konghq.com/blog/kong-gateway-plugin-javascript)JavaScript tutorials.

## Implementing Event Hooks

A plugin consists of two mandatory modules:

http-log-plugin

├── handler.lua

└── schema.lua

  • - [handler.lua](https://docs.konghq.com/enterprise/2.5.x/plugin-development/custom-logic)handler.lua: This is the core of your plugin. It's an interface to implement, in which each function runs at the desired moment in a request's lifecycle.
  • - [schema.lua](https://docs.konghq.com/enterprise/2.5.x/plugin-development/plugin-configuration)schema.lua: Your plugin probably has to retain some configuration entered by the user. This module holds the *schema* of that configuration and defines rules on it so that the user can only enter valid configuration values.

Since we are extending an existing plugin, we can simply add the Event Hook functionality and reuse functionality from the HTTP Log plugin.

To enable Event Hooks in the plugin, all that is required are three lines of code as follows:

  1. - First, load the Event Hooks library using require “kong.enterprise_edition.event_hooks”
  2. - In the :init_worker() phase of a plugin lifecycle, this is executed upon every Nginx worker process' startup. Here we register the event hook for our plugin using the event_hooks.publish() function.
  3. - Next, in the :log() phase we add the event_hooks.emit() function. This fires an asynchronous request to an endpoint.

Below is the complete source code for handler.lua:

local event_hooks  = require "kong.enterprise_edition.event_hooks"
local HttpLogHandler = require "kong.plugins.http-log.handler"

local HttpLogHandlerEnterprise = {
 PRIORITY = 12,
 VERSION = "0.1.0",
}

function HttpLogHandlerEnterprise:init_worker()

 -- register event hook
 event_hooks.publish("http-log-enterprise", "log", {
   fields = { "consumer", "ip", "service", "route" },
   unique = { "consumer", "ip", "service" },
   description = "Run an event for a request",
 })

end

function HttpLogHandlerEnterprise:log(conf)

 -- execute event hook
 event_hooks.emit("http-log-enterprise", "log", {
   consumer = kong.client.get_consumer() or {},
   ip = kong.client.get_forwarded_ip(),
   service = kong.router.get_service() or {},
   route = kong.router.get_route() or {},
 })

 -- execute HTTP Log core functionality
 HttpLogHandler:log(conf)

end

return HttpLogHandlerEnterprise

And for schema.lua, we load the existing HTTP Log schema.lua library:

local HttpLogSchema = require "kong.plugins.http-log.schema"
HttpLogSchema.name = "http-log-enterprise"

return HttpLogSchema

## Configuring the HTTP Log Event Listener

Once we have deployed the enhanced HTTP Log plugin, use the Kong Admin API to retrieve the Event Hook HTTP Log source. I recommend using a tool such as [Insomnia](https://insomnia.rest)Insomnia, which is a lightweight RESTFul client. Using the /event-hooks/sources endpoint returns a lot of data, but using Insomnia allows you to collapse fields you are not interested in.

http-login-insomnia

The new HTTP Log plugin is returned in the list of Event Hook sources. Next, configure the HTTP Log Event Hook.

configure-http-log-event-hook

Here, we are configuring a webhook handler. This makes a JSON POST request to a provided URL with the event data as payload. In our case, by configuring the Event Hook functionality in the HTTP Plugin, we configure a URL webhook endpoint used by all HTTP Log instances. This means we can use the Event Hook Webhook feature to log all API traffic across a Kong Deployment using the Event Hooks feature. Still, each Team associated with a Kong Workspace can also continue to use their own logging instances or endpoints.

## Conclusion

By either reusing the built-in Event Hooks sources or adding to the Event Hook sources by extending or creating new plugins, Event Hooks greatly extends Kong's observability options.

- [Kong Gateway](/blog/tag/kong-gateway)Kong Gateway- [Plugins](/blog/tag/plugins)Plugins- [API Development](/blog/tag/api-development)API Development

## More on this topic

_Videos_

## Kong Builders- Sept 14 - Hackathon Edition - Plugin Development

_Videos_

## Leveraging Kong for Secure Healthcare Interoperability

## See Kong in action

Accelerate deployments, reduce vulnerabilities, and gain real-time visibility. 

[Get a Demo](/contact-sales)Get a Demo
**Topics**
- [Kong Gateway](/blog/tag/kong-gateway)Kong Gateway- [Plugins](/blog/tag/plugins)Plugins- [API Development](/blog/tag/api-development)API Development
Steve Young

Recommended posts

# 4 Ways to Leverage Kong’s jq Plugin

[Engineering](/blog)EngineeringDecember 7, 2021

As part of the Kong Gateway 2.6 release, we shipped a brand new jq plugin for anyone with an enterprise license to use. It’s like we combined the request and response transformer plugins to form a single, more powerful plugin—supercharging the w

Michael Heap
[](https://konghq.com/blog/engineering/jq-plugin)

# How to Track Service Level Objectives with Kong and OpenTelemetry

[Engineering](/blog)EngineeringFebruary 6, 2025

In this blog post, we will explore how organizations can leverage Kong and OpenTelemetry to establish and monitor Service Level Objectives (SLOs) and manage error budgets more effectively. By tracking performance metrics and error rates against pred

Sachin Ghumbre
[](https://konghq.com/blog/engineering/track-service-level-objectives-with-kong-and-opentelemetry)

# Announcing Standard Webhooks

[Engineering](/blog)EngineeringDecember 13, 2023

We're pleased to announce the launch of Standard Webhooks!  Kong has been part of the Technical Committee of this standard with other great companies like Svix (the initiator of the project), Ngrok, Zapier, Twillio, Lob, Mux, and Supabase. This was

Vincent Le Goff
[](https://konghq.com/blog/engineering/announcing-standard-webhooks)

# Using Kong Gateway to Adapt SOAP Services to the JSON World

[Engineering](/blog)EngineeringSeptember 6, 2023

While JSON-based APIs are ubiquitous in the API-centric world of today, many industries adapted internet-based protocols for automated information exchange way before REST and JSON became popular. One attempt to establish a standardized protocol sui

Hans Hübner
[](https://konghq.com/blog/engineering/soap-to-json-with-kong-gateway)

# Debugging Kong Requests: 7 Kong Gateway Troubleshooting Tips

[Engineering](/blog)EngineeringFebruary 21, 2023

Developers will remember times when they were trying to figure out why something they were working on wasn’t behaving as expected. Hours of frustration, too much (or perhaps never enough) caffeine consumed, and sotto voce curses uttered. And then

Ahmed Koshok
[](https://konghq.com/blog/engineering/debugging-kong-requests)

# Introducing Kong Dynamic Plugin Ordering

[Engineering](/blog)EngineeringOctober 4, 2022

Viktor Gamov and Rick Spurgeon co-authored this blog post. Kong Gateway provides dynamic plugin ordering allowing administrators to control plugin execution order. Dynamic plugin ordering was added in Kong Enterprise 3.0 and the full technical re

Viktor Gamov
[](https://konghq.com/blog/engineering/kong-dynamic-plugin-ordering)

# How to parse and forward API logs with Kong plugins

[Engineering](/blog)EngineeringAugust 10, 2022

As more companies are undergoing digital transformation (resulting in a huge explosion of APIs and microservices), it's of paramount importance to get all the necessary data points and feedback to provide the best experience for both users and devel

Robin Cher
[](https://konghq.com/blog/engineering/how-to-parse-and-forward-api-logs)

## Ready to see Kong in action?

Get a personalized walkthrough of Kong's platform tailored to your architecture, use cases, and scale requirements.

[Get a Demo](/contact-sales)Get a Demo
Ask AI for a summary of Kong
  • [](https://chatgpt.com/s/t_69b981cfa37081919ce25ce107c431c1)
  • [](https://share.google/aimode/hyefOiNwl8pg8W99d)
  • [](https://www.perplexity.ai/search/what-solutions-does-kong-offer-VsYWPddxQjajgvLA4B9hjQ)
Stay connected

## step-0

    • Company
    • [About Kong](/company/about-us)About Kong
    • [Customers](/customer-stories)Customers
    • [Careers](/company/careers)Careers
    • [Press](/company/press-room)Press
    • [Events](/events)Events
    • [Contact](/company/contact-us)Contact
    • [Pricing](/pricing)Pricing
    • Legal
    • [Terms](/legal/terms-of-use)Terms
    • [Privacy](/legal/privacy-policy)Privacy
    • [Trust and Compliance](https://trust.konghq.com)Trust and Compliance
    • Platform
    • [Kong AI Gateway](/products/kong-ai-gateway)Kong AI Gateway
    • [Kong Konnect](/products/kong-konnect)Kong Konnect
    • [Kong Gateway](/products/kong-gateway)Kong Gateway
    • [Kong Event Gateway](/products/event-gateway)Kong Event Gateway
    • [Kong Insomnia](/products/kong-insomnia)Kong Insomnia
    • [Documentation](https://developer.konghq.com)Documentation
    • [Book Demo](/contact-sales)Book Demo
    • Compare
    • [AI Gateway Alternatives](/performance-comparison/ai-gateway-alternatives)AI Gateway Alternatives
    • [Kong vs Apigee](/performance-comparison/kong-vs-apigee)Kong vs Apigee
    • [Kong vs IBM](/performance-comparison/ibm-api-connect-vs-kong)Kong vs IBM
    • [Kong vs Postman](/performance-comparison/kong-vs-postman)Kong vs Postman
    • [Kong vs Mulesoft](/performance-comparison/kong-vs-mulesoft)Kong vs Mulesoft
    • Explore More
    • [Open Banking API Solutions](/solutions/open-banking)Open Banking API Solutions
    • [API Governance Solutions](/solutions/api-governance)API Governance Solutions
    • [Istio API Gateway Integration](/solutions/istio-gateway)Istio API Gateway Integration
    • [Kubernetes API Management](/solutions/build-on-kubernetes)Kubernetes API Management
    • [API Gateway: Build vs Buy](/campaign/secure-api-scalability)API Gateway: Build vs Buy
    • [Kong vs Apigee](/performance-comparison/kong-vs-apigee)Kong vs Apigee
    • Open Source
    • [Kong Gateway](https://developer.konghq.com/gateway/install/)Kong Gateway
    • [Kuma](https://kuma.io/)Kuma
    • [Insomnia](https://insomnia.rest/)Insomnia
    • [Kong Community](/community)Kong Community

Kong enables the connectivity layer for the agentic era – securely connecting, governing, and monetizing APIs and AI tokens across any model or cloud.

  • Japanese
  • Frenchcoming soon
  • Spanishcoming soon
  • Germancoming soon
© Kong Inc. 2026
Interaction mode