Metering Policy Configuration (Flex Gateway)

Revenium uses a lightweight custom policy to asynchronously send metering metadata to a Metering Beacon.

Please contact your Revenium account team for the Flex Gateway installation package

Installing the Revenium Flex Gateway Metering Policy

Installing the Revenium Flex Gateway Metering Policy requires creating a Policy asset in Exchange. Login to https://anypoint.mulesoft.com and navigate to APIs -> Exchange:

Next select "Publish a new asset", select "Policy" as the Asset Type and click on "Publish":

Populate the fields as follows:

  • Name: "Revenium Metering (Flex GW)"

  • Asset Types: Policy

  • JSON Schema file: schema.json (upload from the installation package)

  • Metadata file: definition.yaml (upload from the installation package)

  • Lifecycle state: Stable

Click on Publish and then select "Add Implementation":

Now you configure and upload the WASM binary containing the policy implementation:

  • Name: revenium_flex_gw_policy

  • Binary file: revenium_flex_gw_policy.wasm

  • Metadata file: implementation.yaml

Configuring External Service Access for Revenium Metering

To enable the Flex Gateway metering policy to communicate with the Revenium platform API, you must define an external service within the registration.yaml configuration file. This is accomplished by adding a Service resource that specifies the endpoint address for the Revenium metering infrastructure. The Service definition acts as a service discovery entry point, allowing the Envoy-based Flex Gateway to resolve and route metering traffic to the Revenium platform API at https://api.revenium.io:443. By declaring this service in the gateway configuration, the metering policy can establish outbound connections to transmit usage events, token counts, and API metrics in real time without requiring additional network routing configuration or DNS resolution at the gateway level.

Add the following YAML block to registration.yaml and restart the Flex GW.

---
apiVersion: gateway.mulesoft.com/v1alpha1
kind: Service
metadata:
  name: revenium-platform-api
spec:
  address: https://api.revenium.io:443

Configuring the Revenium Flex Gateway Metering Policy

Once the policy is registered in Exchange you can apply it to a Flex GW managed API in the API Manager. Select the API you'd like to meter, select "Policies", click on "Add Inbound Policy" and select the "Revenium Metering (Flex GW)" Policy:

You can now configure the metering policy:

  • Revenium Platform API Key: Your Revenium Platform API Key is available from this link: https://app.revenium.io/api-keys

  • The header containing the client identifier: The header identifying the API client

  • The amount of time (seconds) to cache valid applications: The eviction time for cached applications/clients in the policy

  • Allow requests without client identification header: Determines whether or not to return a 402 "Payment Required" HTTP response for client request with invalid subscriptions

Last updated

Was this helpful?