This repository provides a demonstration of integrating Moesif with Kong Konnect in a hybrid deployment setup. By following this guide, you will set up a custom Kong Konnect Self-Managed Hybrid Gateway with the Moesif plugin enabled, define services and routes, test the integration, and optionally deploy the Moesif Developer Portal.
- Docker and Docker Compose installed on your system.
- A Kong Konnect account.
- A Moesif account.
Clone this repository and its submodules:
git clone --recurse-submodules https://github.com/Moesif/moesif-kong-konnect-docker-demo.git
Navigate into the cloned directory and build the custom Kong Gateway image:
cd moesif-kong-konnect-docker-demo
docker build -t custom-kong-gateway:3.9.0.0 .
If you don't already have an account, sign up for Kong Konnect at Kong Konnect.
To integrate the Moesif plugin, we need to set up a self-managed hybrid gateway in Kong Konnect. This configuration connects the control plane in Kong Konnect to a data plane instance.
- Log in to the Kong Konnect Portal.
- Navigate to Gateway Manager.
- Click on New Gateway and select Self-Managed Hybrid.
- In the General Information section, add a name for your gateway.
- Select a version and platform for your hybrid gateway setup. Kong Konnect will provide a docker
run
command which we will need to customize in the next steps.
Update the docker run
command provided by Kong Konnect to include the following environment variables:
-e "KONG_PLUGINS=bundled,moesif" \
-e "KONG_LUA_PACKAGE_PATH=/tmp/custom_plugins/?.lua;;" \
Replace the final line of the docker run command provided by Kong Konnect with the custom built image name:
custom-kong-gateway:3.9.0.0
Paste the modified docker run
command into your terminal to start the custom Kong Gateway.
- Log in to the Kong Konnect Portal.
- Navigate to the Gateway Manager.
- Select Gateway Services from the side navigation bar.
- Click on New Gateway Service.
- In the Add a Gateway Service dialog, provide the following details:
- Name:
TestService
- Upstream URL: Enter the URL of your backend service. For example,
https://www.httpbin.org
.
- Name:
- Click Save to create the service.
- After saving the service, you'll be directed to the service's dashboard.
- Click on Add a Route.
- In the Add a Route dialog, provide the following details:
- Name:
TestRoute
- Protocols: Select
HTTP
andHTTPS
. - Paths: Enter
/test-route
.
- Name:
- Click Save to create the route.
To enable API analytics with a custom plugin, you need to add and configure the Kong Moesif plugin in your Kong Konnect data planes.
- Navigate to the Gateway Manager.
- Go to the Plugins section and click on Add Custom Plugin.
- Upload the
schema.lua
file located inkong-plugin-moesif/kong/plugins/moesif/
from the Kong Plugin Moesif repository. The latest version of this plugin is included in this repository for your convenience. - Click Save to add the custom plugin.
- Navigate back to the Plugins section, select Custom Plugins, and enable the Moesif Plugin.
- Configure the plugin with the following field:
- Application ID: Obtain your Application ID from the Moesif API Keys settings page.
- Click Save to finalize the configuration.
Test the defined service and route by sending requests to the configured endpoint.
- Ensure that your data plane node is running and connected.
- Send a request to your proxy URL appended with the route path. For example:
http://localhost:8000/test-route
. - A successful response indicates that your service and route are correctly configured.
Verify that data is being captured in your Moesif dashboard.
The repository includes a Docker Compose file to set up the Moesif Developer Portal for testing.
- Use the provided
docker-compose.yml
file as a starting point to spin up the Moesif Developer Portal. - If you would like to get started with the Moesif Developer Portal refer to the official Moesif Developer Portal documentation for detailed setup instructions.
- If you have already followed the Moesif Developer Portal guide, you can continue setting up Kong Konnect and the Moesif Developer Portal.