Integrating Moesif and Kong Konnect

When it comes to integrating Moesif with Kong Konnect, this can be done in a few simple steps. In this guide, we will go over how to use the Kong-Moesif Plugin for Konnect to get API analytics flowing through into Moesif. We will cover adding Moesif as a Custom Plugin to your Kong Konnect control and data planes.

To get started, you will need the following:

  • An active Kong Konnect Account
  • An active Moesif account
  • The ability to run docker containers (via docker desktop, etc.)

Add the Kong-Moesif Plugin to Your Konnect Data Plane(s)

First, we must bring up a new Konnect Data Plane with Moesif installed and enabled. For this, in the Konnect UI, click on Data Plane Nodes in the left-side menu, and on the screen that appears, click Create a New Data Plane Node.

Kong add data plane

On the next screen, we will select the applicable Gateway Version (the default is fine if you have no particular version you want to run) and select our platform as Linux (Docker). This will allow us to run the gateway on our local machine or another server using docker.

With these options selected, scroll down to the setup script pane and click Generate certificate. This will create a docker command we can run in our terminal. Let’s copy the docker command.

Kong create data plane

Next, we will add a few lines to the command to install and enable the Moesif plugin. Bring up a text editor (or you can do this directly in the terminal) so that we can edit the initial command output in the Konnect UI.

In a text editor, paste the Konnect docker command and add the following:

-v "/{PATH_TO_DIR}/kong:/tmp/custom_plugins/kong" \
-e "KONG_PLUGINS=bundled,moesif" \
-e "KONG_LUA_PACKAGE_PATH=/tmp/custom_plugins/?.lua;;" \

The {PATH_TO_DIR} is the path to the Kong-Moesif plugin repository on your local machine (or server). You’ll need to ensure you’ve downloaded the repository and fill in this argument in the command.

The amended command will look like this:

docker run -d \
-e "KONG_ROLE=data_plane" \
-e "KONG_DATABASE=off" \
-e "KONG_VITALS=off" \
-e "" \
-e "" \
-e "" \
-e "" \
-----END CERTIFICATE-----" \
-----END PRIVATE KEY-----" \

-v "{PATH_TO_DIR}/kong:/tmp/custom_plugins/kong" \
-e "KONG_PLUGINS=bundled,moesif" \
-e "KONG_LUA_PACKAGE_PATH=/tmp/custom_plugins/?.lua;;" \

-p 8000:8000 \
-p 8443:8443 \

Ensure that the {PATH_TO_DIR} contains the path to your Kong-Moesif repo cloned on your local system.

As you can see, we’ve added additional commands to the initial docker script to install and enable the Moesif plugin on the Konnect data plane instance.

If you’re running multiple data planes, you must run this command on each.

Then, run the amended docker command in a terminal to bring up the data plane instance and enable Moesif. Once the command has executed successfully, you should see a response in the UI showing “Data Plane Node has been found.”.

Kong data plane connected message

Then, click Done in the top right corner of the screen. We now have our data planes up and running with Moesif enabled.

Add the Kong-Moesif Plugin to the Konnect Control Plane

Next, we will add our Moesif plugin to the control plane. This will allow us to configure the plugin in the Konnect UI and have that config cascaded out to each data plane running the Moesif plugin. To do this, go to the Gateway Manager menu option in Konnect** **and click on **default **(or another control plane if you’ve already created one).

Kong control plane

Then, navigate to the Plugins page from the side menu and click New Plugin.

Kong plugins screen

Then, select Custom Plugins.

Kong custom plugin add

Next, we will upload the schema.lua file to define the custom plugin. This can be found in the Kong-Moesif plugin repo under kong/plugins/moesif/schema.lua. Alternatively, you can download the schema.lua file for the Moesif Plugin directly. Add the file to the Upload Schema File input and click Save in the top right corner.

Kong create custom plugin - upload

On the Custom Plugins page, locate the Moesif plugin and click enable to enable the plugin on the control plane.

On the Moesif config page that appears, let’s add our application ID into the application ID field.

Moesif Kong plugin config

To get the required value, your Moesif Application ID can be retrieved from Moesif by going to Settings > API Keys.

Moesif API keys

Copy the value in Your Collector Application Id for {App Name} and back in the Konnect UI, add the value to the configuration in the Application Id input. Once complete, scroll to the bottom of the screen and click** Save**.

At this point, Moesif will be installed on each data plane and added to the control plane, along with any configuration.

Test the Integration

To ensure the integration is working correctly, we will create a new service and route if you don’t have an existing route/service to send traffic to.

Create a Service in Kong Konnect

First, in Konnect, under Gateway Manager > Gateway Services, create a new service named “TestService.” For the Service Endpoint, select Full URL and add “” as the Upstream URL. Once complete, save the service.

Kong add new service

Create a Route in Kong Konnect

Next, add a new route in the Gateway Manager > Routes screen. Name the route “TestRoute”, set the Service as the “TestService” we just set up, and under HTTP / HTTPS Routing Rules, put in a path of “/test-service”. Once complete, save the route.

Kong add new route

Send Some Test Traffic

With our route defined, we can now send through some traffic. You’ll want to use Insomnia or Postman to send a [GET] request to the /test-service endpoint. For instance, depending on what port your data plane is running on, your request might look like this:

[GET] localhost:8000/test-service

Once your requests have been sent, You’ll check in with Moesif to see if they were correctly picked up. To do this, log into Moesif, click the New button (in the top left corner), and select Live Event Log.

Moesif menu - live event log

This will then show a real-time stream of events coming into Moesif from our Kong Konnect instance. If the events were picked up (which may take up to 5 minutes), you will see something similar to the screen below.

Moesif live event log screen

With this, you have Moesif and Kong Konnect configured successfully and ready to tackle your API analytics and monetization use cases!