Introduction
If you've worked with APIs at any level, you know how important it is to understand what's happening under the hood.
Observability is a lifeline for debugging, monitoring, and improving APIs.
With Treblle 3.0, we’ve taken a significant step forward by introducing integration support for WSO2, one of the most popular API gateways.
What is WSO2?
WSO2 API Manager is an open-source API gateway that’s widely used in enterprises for creating, publishing, and managing APIs. It supports the entire API lifecycle and integrates well with existing enterprise systems.
If your organization uses WSO2, you’re likely already aware of its robust API governance features and capability to scale with your needs. However, while WSO2 excels at API management, it doesn’t natively offer the level of observability that modern developers demand.
What Does WSO2 Integration with Treblle Mean?
What’s especially exciting about this integration is how easy it is to get started. Treblle now supports WSO2 API Manager versions 3.2.0 and 4.3.0, so you can adopt it using an older or latest setup. Within minutes, you can start collecting insights about your APIs, which might take days or weeks to configure manually.
How Will This Integration Optimize Your API Gateway?
The core value here is simplicity and visibility. With this integration, you can:
- Monitor Requests in Real Time: The Treblle dashboard lets you see every request and response in detail, including headers, payloads, and execution times.
- Detect Problems Faster: Spot misconfigured endpoints, missing parameters, or failing requests without sifting through server logs.
- Improve API Compliance: Treblle checks your APIs against best practices, highlighting areas where you might fall short, like missing documentation or improper status codes.
- Customize Insights: You control what data you track, ensuring it’s relevant to your team without adding unnecessary noise.
- API Governance and Security: With Treblle's built-in governance and security features, you can enforce API policies, ensure compliance, and protect sensitive data.
This means developers no longer rely solely on WSO2 logs or third-party tools that require complex setups.
Step-by-Step Guide: WSO2 Integration with Treblle 3.0
Prerequisites
Before beginning, make sure you have the following:
- Java 8 or later (check with
java -version
). - Maven 3.6.0 or later (check with
mvn -version
).
Step 1: Installing WSO2 API Manager
- Download the latest version of WSO2 API Manager 4.3.0 from here.
- After downloading, unzip the archive to your desired directory.
unzip wso2am-4.3.0.zip
cd /path/wso2am-4.3.0/bin/
./api-manager.sh
- Once the server runs, open your web browser and go to the Admin Console.
Login with the default credentials:
- URL:
https://localhost:9443/carbon
- Username:
admin
- Password:
admin
This will log you into the WSO2 Admin Console, where you can manage your APIs.
Step 2: Create a New API in the WSO2 API Manager
Log in to the WSO2 Publisher Portal
- Go to the Publisher portal at:
https://localhost:9443/publisher
- Log in using the following credentials:
- Username:
admin
- Password:
admin
Create a New API
- Choose the type of API you want to create (e.g., REST API, SOAP API).
- You can create an API from scratch, import your OpenAPI specification, or use a sample API.
Fill in the API details, such as:
- API Name
- Context Path
- Version
- Endpoint URL
Publish the API
- Once your API is created, click Publish to make it available for testing.
Step 3: Test the API
- Log in to the Developer Portal at
https://localhost:9443/devportal
- Once logged in, you will see the published API listed.
- Click on the API, then navigate to the Subscription section.
- Subscribe to the API, and use the Subscription and Key Generation Wizard to generate an access token.
- Provide details like application name, description, and shared quota.
- Generate and copy the access token.
Define API Resources
- Go to the Resources section in the Publisher.
- Define endpoints for your API, such as /users, and specify the method type (e.g., GET, POST), parameter names, data types, and whether the parameters are required.
- Once the API Resources are created, click the Try Out option to test your API.
- In the "Try Out" section, select the key type. Here, we are choosing Sandbox to test the API within the platform itself. If you’re ready to use the API in production, you can select Production.
- Select the method you want to test (e.g., GET) and execute the request.
- Example: API is working.
Step 4: Set Up Treblle
Treblle allows you to track and analyze API requests and responses directly. Here's how to integrate Treblle with your WSO2 API Manager:
Create a New Project in Treblle
- Visit Treblle's website and sign up for a new account if you haven't already.
- After logging in, create a new project. Enter details like:
- API Name
- Base URL
- Environment
- Platform
- Your API Key and Project ID will be generated, which you will need to integrate with WSO2.
Install and Configure the Treblle Data Publisher Extension for the WSO2 API Manager
To install and configure the Treblle Data Publisher extension, follow these steps:
Clone the Treblle Data Publisher Repository:
- Go to the Treblle WSO2 GitHub repository and download the source code for the version corresponding to your WSO2 API Manager (v4.3.0).
git clone https://github.com/Treblle/treblle-wso2.git
cd /path/treblle-wso2/wso2am-4.3.0
Build the Source Code:
- Open a terminal and navigate to the project's root directory (where the pom.xml file is located).
- Run the following Maven command to build the project:
mvn clean install
- This will generate the necessary
.jar
file for the Treblle Data Publisher extension.
Install the Built JAR in the WSO2 API Manager
- After building the project, find the generated JAR file in the target directory of your project folder (e.g.,
treblle-wso2/wso2am-4.3.0/target/treblle-data-publisher-*.jar
). - Copy this
.jar
file into the following directory of your WSO2 API Manager:
cp treblle-data-publisher-*.jar /path/wso2am-4.3.0/repository/components/lib
Configure deployment.toml:
- Open the deployment.toml file located at:
/path/wso2am-4.3.0/repository/conf/deployment.toml
- Add the following configuration at the top of the file:
[synapse_handlers.treblle_publisher]
enabled=true
class="com.treblle.wso2publisher.handlers.APILogHandler"
Configure log4j2.properties:
- Open the log4j2.properties file located at:
/path/wso2am-4.3.0/repository/conf/log4j2.properties
- Add the following configuration to enable logging for the Treblle publisher:
loggers = treblle_publisher, AUDIT_LOG, ...
logger.treblle_publisher.name = com.treblle.wso2publisher
logger.treblle_publisher.level = INFO
logger.treblle_publisher.appenderRef.CARBON_LOGFILE.ref = CARBON_LOGFILE
Set Environment Variables
Before starting the WSO2 server, set the required environment variables on your machine:
- Open a terminal and add the following environment variables:
export TREBLLE_API_KEY=<your-api-key>
export TREBLLE_PROJECT_ID=<your-project-id>
export TREBLLE_GATEWAY_URL="https://your-wso2-gateway-url"
export TREBLLE_QUEUE_SIZE=20000
export TREBLLE_WORKER_THREADS=1
export ADDITIONAL_MASK_KEYWORDS="testkey,Authorization,token"
export TREBLLE_ENABLED_TENANT_DOMAINS="carbon.super,abc.com"
- Alternatively, set these variables in your .bash_profile or .bashrc to make them persistent across sessions.
Step 4. Configure OAuth2 Authentication
- Log in to the Developer Portal:
https://localhost:9443/devportal
- Select the API for which you need the token.
- Generate an OAuth2 token by clicking on your created application under the Subscription section and selecting Production or Sandbox.
- Select the Key: Click the Production.
- Copy the generated access token.
Step 5. Test Your API
Restart the WSO2 API Manager to ensure all configurations and the Treblle Data Publisher extension are loaded:
cd /path/to/wso2am-4.3.0/bin
./api-manager.sh restart
Using cURL:
curl -k -X GET "https://localhost:8243/<>/version" -H "Authorization: Bearer <access_token>"
Replace <access_token>
with a valid OAuth2 token.
Example:
API Observability in Treblle
The Treblle dashboard provides real-time insights into API requests, compliance checks, and potential issues in your APIs.
Use Treblle's customization features from TOP RIGHT to tailor the displayed information to your needs.
This section shows a detailed list of API requests, including key data like request origins, execution time, and status.
Click on a specific API request to view comprehensive details, such as the request payload, response data, and additional diagnostics.
Conclusion
Integrating Treblle and WSO2 API Manager makes tracking and monitoring your APIs much easier. It lets you see what’s happening with your API requests and responses in real-time.
Treblle helps you spot issues immediately, giving you a clear picture of what’s working and where attention needs to be given.
What stands out the most is how much time it saves. Instead of sifting through data manually, Treblle gives you the key insights you need right on the dashboard.
Stay tuned for more updates as we continue building tools to make your API development journey smoother, faster, and more transparent.