Skip to main content

Kong

If you already tag your services and routes in Kong, Levo can reuse those tags as labels on the API endpoints it discovers. A route tagged team:payments in Kong labels every endpoint under that route in Levo, so you can filter your inventory by the team that owns it.

There are two ways to get your Kong tags into Levo.

Mode A — Export and upload

Available now

You run a read-only script against your Kong and upload the file it writes.

What you need

  • Python 3.8 or newer
  • Access to your Kong Admin API — the admin port, not the proxy port
  • A read-only admin token, if your Kong requires one

Steps

Download the script.

levo_kong_export.py

Install its one dependency.

pip install requests

Run it against your Kong.

python levo_kong_export.py \
--admin-url https://your-kong-admin:8444 \
--gateway-id kong-prod \
--auth-mode admin_token \
--token "$KONG_ADMIN_TOKEN"

Pick the --auth-mode that matches your Kong:

Your KongUse
Kong Enterprise — Admin API protected by RBAC--auth-mode admin_token --token <your token>
Kong Konnect — Kong's cloud version--auth-mode bearer --token <your token>
Admin API on a private network with no auth--auth-mode none

--gateway-id is a name you choose for this Kong, such as kong-prod. Keep it the same every time you export from that gateway: Levo uses it to update the same labels instead of duplicating them.

Check what it found.

INFO wrote kong-services.json: 42 routes, 18 services from kong-prod
INFO 37 of 42 routes carry at least one tag

The file is written as kong-services.json in the folder you ran the command from.

The second line matters: only tagged routes produce labels. If it says 0, your tags are not on the services or routes it reads.

Upload it.

In Levo, go to APIs → Import, choose Kong Services File as the Import Type, and select kong-services.json. Levo shows you what the file contains before anything is written. Press Save to apply the labels.

Filter by your tags.

Go to APIs → by endpoint. Your Kong tags now appear in the Tags column, and you can filter the inventory by any of them.

Keeping labels current

If your Kong configuration is version controlled, your pipeline can do this for you: see Push API specs from CI.

Otherwise, re-run the export and upload it again whenever your Kong tags change. A complete export is authoritative for the labels it created, so a tag you removed in Kong is removed in Levo on the next upload. Labels you applied by hand in Levo are never touched.

What is skipped

Kong routeWhat happens
No tagsNothing to apply
A regex path (~/v1/.*)Skipped — it cannot be matched to discovered endpoints
A route matching every path (/)Skipped, so one route cannot label your whole inventory
A tag containing ;, ~ or |Rejected — Levo labels cannot store those characters

The upload screen reports each count, so nothing is dropped silently.

All options

OptionDescription
--admin-urlYour Kong Admin API address. A bare host is treated as https; write http:// for a plaintext admin API
--gateway-idThe name you choose for this Kong
--auth-modeadmin_token, bearer, or none
--tokenYour read-only token. Not needed with none
--outWhere to write the file. Defaults to kong-services.json
--timeoutPer-request timeout in seconds. Defaults to 20
--verboseLog every route it reads

The script is read-only: every call it makes is a GET.

If it does not work

What you seeWhat it means
Connection refused or a timeoutThe machine cannot reach the Admin API. Check the host, and that it is the admin port
401 or 403The token is missing or wrong. Check --auth-mode matches your Kong
0 of N routes carry at least one tagIt worked, but your tags are not on the services or routes it reads
No file writtenThe export stopped rather than save a partial file. The error says why

Still stuck? support@levo.ai with the command you ran and its output.

Mode B — Through Satellite

Coming soon

The Levo Satellite will read your Kong tags on a schedule from inside your own network. No file to export, nothing to upload, and nothing to re-run when your tags change.

Until this is available, use Mode A.

Was this page helpful?