Kong

The Kong Metering Plugin facilitates the capture of API transaction data flowing through Kong gateways for metering, monetization and chargeback.

Building and Installation

To build and install this plugin please obtain the Revenium Metering Plugin package from your Revenium Account Team. Uncompress the package and run the following commands:

luarocks make
luarocks pack kong-plugin-revenium <RELEASE_VERSION>-1
luarocks install ./kong-plugin-revenium-<RELEASE_VERSION>-1.all.rock

RELEASE_VERSION corresponds to the version of the Kong Metering Plugin Package (ie, 1.10.1)

Enabling the Revenium Metering Plugin

Configuration

The Revenium Kong Plugin accepts the following configuration parameters

ParameterRequiredDescription

api

yes

The Revenium Asset ID of the API being metered

hcUrl

no

The URL of the Revenium Platform API (almost always https://api.revenium.io)

hcKey

yes

The Revenium Metering Beacon Key

hcProductKeyHeader

no

An alternative header to obtain evaluate the Revenium ProductKey of an API request (default is X-REVENIUM-PRODUCT-KEY)

hcProductKeyParameter

no

Evaluate the Revenium ProductKey using an HTTP query parameter instead of a header.

hcMetadataRequestHeader

no

Optional HTTP request header to insert additional billing metadata

hcMetadataResponseHeader

no

Optional HTTP response header to insert additional billing metadata

activeMode

no

If set to "true" API requests will be blocked by the plugin if the consumer is invalid, unfunded, etc.

productKeyCacheTimeout

no

When using activeMode the length of time to cache valid consumers.

The Revenium Asset ID can be obtained from the Manage -> Assets pane in the Revenium UI

You can enable the Revenium Metering Plugin on a Kong Proxy by running a curl command similar to the one below:

curl -i -X POST \
--url http://kong-proxy:8001/services/example-service/plugins/ \
--data 'name=revenium-metering' \
--data 'config.hcUrl=api.revenium.io' \
--data 'config.hcKey=hak_12348A7CC56B123472E' \
--data 'config.api=3a49abb3-93e5-495d-a49d-c6008e77c803' \
--data 'config.hcProductKeyHeader=clientId' \
--data 'config.hcMetadataResponseHeader=X-BILLING-UNITS'

Alternatively the Revenium Metering Plugin can be configured via YAML configuration:

_format_version: "2.1"

_transform: true

services:
- name: random-data
  url: https://mockbin.org/bin/b6f8fc87-5dc0-4f9a-81df-0439282ee422/
  routes:
  - name: my-route
    paths:
    - /

plugins:
- name: revenium
  service: random-data
  config:
      api: ef191e46-e9d4-4553-a724-19529427b3c8
      hcUrl: https://api.revenium.io
      hcKey: **Provided by the Revenium account team**

Last updated

© Revenium - www.revenium.io