LogoLogo
  • User Guide
    • Getting Started
      • Building a Usage-Based Product in Revenium
      • Setting Up & Using API Analytics & Observability
      • Setting Up & Using Product Analytics
      • Sending Data to Revenium's Metering API
      • Key Concepts & Relationships
    • Connect Your Data
      • cURL Commands for Testing
      • Container-Native Metering
      • Kong
        • Kubernetes Installation
      • Salesforce
        • Revenium Unmanaged Package
          • Anypoint API Experience Hub (AEH)
            • Anypoint API Experience Hub Unmanaged Package Post Installation Instructions
          • Anypoint Community Manager (ACM)
            • Anypoint Community Manager Package Post Installation Instructions
        • Revenium Lightning Web Components
          • Add Components to Experience Cloud site
          • Drop-In Storefront
          • Product Card
          • Product Card (Anypoint)
          • Product Checkout
          • Product Details Button
          • Usage History
          • API Access Requester
      • MuleSoft
        • Metering Policy Configuration
        • Offline Metering Policy Configuration
        • Anypoint API & API Group Synchronization
        • Revenium Connector
        • Disable Default Anypoint Community Manager (ACM) Email Notifications
      • Gravitee
      • Istio
      • Envoy
      • AWS API Gateway
      • Python & Django
      • Golang
      • Spring Boot
      • .Net
      • NodeJs
      • Java/JVM
      • Snowflake
      • Azure API Management
      • IBM
      • Custom Integrations Using Metering Beacons
        • JWT Enrichment
      • Offline Metering via Log Parsing
    • Sources
      • Metering Elements
      • Alerts
        • Alert History
    • API Keys
    • Products & Pricing
      • Product Lines
      • Pricing Rules
        • Revenium Scripting Language
          • RSL Reference
        • Execution Logs
      • SLA Definitions
      • SLA Violation Review
    • Customers
      • Customers
      • Subscribers
      • Subscriptions
      • Subscribers Credentials
      • Subscribers Notifications
    • Billing and Invoicing
      • Manage Refunds
    • Analytics
      • Revenue Analytics
      • Product Analytics
        • Custom Reports (Products)
      • Subscriber Analytics
        • New Subscribers
        • (Daily/Weekly/Monthly) Active Subscribers
        • Most Engaged Subscribers & Customers
        • Historical Usage
      • API Analytics
        • Performance & Availability
        • Compare Periods
        • Traffic by Geography
        • Advanced Search
        • Custom Reports
    • Profile
      • Profile
      • Revenium API Documentation
    • Settings
      • Revenium Users & Organizations
        • Access Permissions by User Type
      • Revenium Subscription
      • Revenium Organizations
      • Notification Templates
      • Transactions Logs
        • Analytics Transaction Log
        • Product Transaction Log
        • Subscription Audit Log
        • No Code Transaction Testing
      • Integrations
        • Data Sync
        • Export Configurations
        • Notification Providers
        • Payment Configurations
          • Customer VAT ID Support
        • ERP Configurations
        • External Integration Logs
        • Identity Providers
      • System Logs
      • Default Configuration Limits
Powered by GitBook

© Revenium - www.revenium.io

On this page
  • Installing the Revenium Metering Policy
  • Configuring the Revenium Metering Policy
  • Configuring Revenium Metering as an Automated Policy
  • Configuring Metering Elements
  1. User Guide
  2. Connect Your Data
  3. MuleSoft

Metering Policy Configuration

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

The Revenium metering policy relies on DataWeave expressions, which are only available in MuleSoft Enterprise Edition.

Installing the Revenium Metering Policy

The Revenium Metering Policy can be obtained from "Connect Data" section in the Revenium UI. Once you’ve obtained the policy, you can uncompress it and follow these steps:

  1. Open the pom.xml file and replace the two instances of the "ANYPOINT_GROUPID" placeholder with your Anypoint Organization ID:

    1. "groupId" field

    2. “exchange.url” field

  2. Ensure your Maven settings.xml file has an "exchange-server" defined along with the MuleSoft Enterprise repository with appropriate access credentials. Here is a minimal settings.xml file to publish a Custom Policy:

Run the following command:

mvn --settings hc-settings.xml clean deploy \
-Dapplication.groupId=292a3440-884f-49d7-8c82-b1a1d3641367 \
-Dexchange.username=YOUR_EXCHANGE_USERNAME \
-Dexchange.password=YOUR_EXCHANGE_PASSWORD \
-Dmule.username=MULE_NEXUS_REPO_USERNAME \
-Dmule.password=MULE_NEXUS_REPO_PASSWORD

To use a different control plane, such as the EU control plane, you can pass a base platform URL using the mule.platform.baseUrl variable. For example:

mvn --settings hc-settings.xml clean deploy \
-Dapplication.groupId=292a3440-884f-49d7-8c82-b1a1d3641367 \
-Dexchange.username=YOUR_EXCHANGE_USERNAME \
-Dexchange.password=YOUR_EXCHANGE_PASSWORD \
-Dmule.username=MULE_NEXUS_REPO_USERNAME \
-Dmule.password=MULE_NEXUS_REPO_PASSWORD \
-Dmule.platform.baseUrl=eu1.anypoint.mulesoft.com

Specifically you must:

  • set "exchange.user" to ~~client~~~

  • set "exchange.password" to CLIENT_ID~?~CLIENT_SECRET

The Exchange Maven plugin requires Java 8 to run properly. You can set your JAVA_HOME for Maven like this:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

The Revenium Metering Policy should now be available in the Anypoint Platform Exchange:

Configuring the Revenium Metering Policy

In the Anypoint API Manager, navigate to the API to be metered:

Navigate to “Policies” and then “Apply New Policy”:

Select the Revenium Metering Policy:

The Metering Policy takes the following configuration parameters:

  • Revenium Platform URL: Base URL of the Revenium platform API

  • Revenium Source ID: The ID of the API. Use the ID of the API we copied earlier from the Revenium User Interface.

  • Metering Expression: An optional DataWeave expression that determines whether or not an API request should be metered. The default behavior is to meter any request that has a 2xx series (successful) response from the API implementation.

  • Subscription Expression: An optional DataWeave expression to extract the Revenium Subscription from the API request. The default behavior is to determine the header from either the X-REVENIUM-PRODUCT-KEY __ or, if its not present, using the "client_id" header.

  • Metadata Expression: An optional DataWeave expression to extract arbitrary metadata from the API request.

  • Metering Header Name: An optional backend-provided header that contains a dynamic call count for metering

  • Reject Requests with Invalid Subscriptions: If a request contains an invalid Subscription (ie, the key is expired, its quota has been exceeded, etc) then the policy will block the request and return a 402 "Payment Required" response.

  • Subscription Cache TTL (Minutes): If Reject Requests with Invalid Subscriptions is enabled the amount of time to cache invalid keys.

The Policy should now be applied and your API is now ready to be metered.

Configuring Revenium Metering as an Automated Policy

Revenium Metering Policy can be configured as an Automated Policy to ensure that all APIs registered with the Anypoint Platform are metered.

To configure an Automated Policy navigate to "Automated Policies" and click on "Add Automated Policy".

You can then configure the policy as defined in the previous step making sure to leave the "Revenium Source ID" to be blank.

API URL/URIs must be unique for the Revenium Metering Policy to function correctly when applied automatically. The Revenium Source ID must be set in APIs with non-unique URLs.

Configuring Metering Elements

Last updated 6 months ago

If you are using MFA then you will need to create a Connected App within Anypoint Platform () and follow the instructions here: .

In order to configure the policy we need to have created a Source, a Product, a Subscription, and Credentials, which are described in depth .

Revenium API Key: The Revenium API integration key. This is obtained via Manage -> External Configurations -> .

Subscription Credential Expression: An optional DataWeave expression to extract the Anypoint Client ID from the API request. The default behavior is to use the "client_id" header. For more information on linking Anypoint Client IDs to Revenium please see the documentation .

When handling API traffic that includes , a DataWeave expression is used to extract the map of element key value pairs from the API transaction. The expression can be applied to the API request, response or both. In the following example a metering element called "country_code" is populated by the "country" header in the HTTP request.

https://docs.mulesoft.com/access-management/connected-apps-overview
https://docs.mulesoft.com/exchange/connected-app-authentication
here
API Integration Keys
here
metering elements
Selecting the API to be metered
Configure the Revenium Metering Policy
Use the value of the "country_code" header as a metering element