Skip to main content

Integrate Treblle with Traefik Hub API Gateway

Traefik Labs has partnered with Treblle to provide advanced monitoring and observability for your API gateway. With a single click, you can access Treblle's observability and monitoring capabilities directly within the Traefik Hub dashboard, without the need to maintain a logging infrastructure. Treblle handles everything, including masking sensitive data for privacy before capturing it.

Prerequisites

Before you can get access to Treblle in the Traefik Hub dashboard, you need to have the following:

  • Set up a Hub API Gateway on Traefik Hub
  • A Treblle account (you can create this with a single click in the Traefik Hub dashboard)
  • Your Treblle API Key and Project ID
  • Install the Treblle plugin for Traefik Hub API Gateway

Configure Treblle on Traefik Hub

To get started, head over to the Traefik Online Hub Dashboard and create a new Hub gateway. You can follow any of the guides to learn how to quickly set this up.

Once your Hub gateway is configured and discovered by Hub, click on "Traffic Debugger" in the sidebar of the Hub dashboard.

"Traefik Hub Dashboard

Click on the "Configure Treblle traffic debugger" button to begin configuring Treblle with your Hub Gateway.

"Traefik Hub Dashboard

Next, you'll need to enter your Treblle Project ID and API key. If you already have a Treblle account, retrieve your API key and Project ID and enter them in the appropriate fields. Otherwise, click the "Create Treblle Account" button. This will automatically create a new Treblle account for you and populate the fields with your newly generated API key and project ID.

"Traefik Hub Dashboard

note

You will also need the newly generated API key and project ID to configure the Treblle middleware

After creating your new Treblle account, you should see your API key and Project ID auto-filled and ready for use.

"Traefik Hub Dashboard

Finally, select the API gateway you want to connect to Treblle from the list of available gateways and click on "Save".

Setting up the Treblle plugin for Traefik Hub API Gateway on Kubernetes

Before using the Treblle integration with Traefik Hub API Gateway, you need to install and configure the Treblle Plugin in your cluster. With the Helm Chart, you can paste the following into a traefik-values.yaml file and apply it:

traefik-values.yaml
# install configuration
experimental:
plugins:
treblle:
moduleName: github.com/Treblle/TreblleTraefikPluginGo
version: v1.0.5 # make sure to confirm that you're using the latest release

# configure pod security context
podSecurityContext:
fsGroup: 65532
fsGroupChangePolicy: OnRootMismatch

Upgrade your Traefik installation using the new values in your traefik-values.yaml file:

CLI
helm upgrade traefik traefik/traefik -n <your-namespace> --reuse-values -f traefik-values.yaml

You should get this output:

CLI
Release "traefik-hub" has been upgraded. Happy Helming!
NAME: traefik-hub
LAST DEPLOYED: Thu Sep 5 17:14:16 2024
NAMESPACE: traefik
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
traefik-hub with docker.io/traefik:v3.1.2 has been deployed successfully on traefik namespace !

Next, create a treblle-middleware.yaml file and paste the following in it:

apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: treblle
namespace: traefik
spec:
plugin:
treblle:
ApiKey: "your-api-key" # replace with your Treblle API key
ProjectId: "your-project-id" # replace with your Treblle project ID
note

Make sure to replace the ApiKey and ProjectId section with the API key and Project ID retrieved from Treblle in the Traefik Hub Dashboard.

Apply the middleware resource:

CLI
kubectl apply -f treblle-middleware.yaml

You should get this output

CLI
middleware.traefik.io/treblle created
note

The Treblle plugin includes the following additional configuration options:

  • AdditionalFieldsToMask - Additional sensitive fields to mask for GDPR compliance, useful for protecting GDPR-sensitive data (example: "accessToken")
  • RoutesToBlock - Paths to routes that should be hidden (example: "^/api/user/login")
  • RoutesRegex - Regex to match and hide specific routes (example: "^/api/projects")

To see the Treblle plugin in action, you need to attach it to an IngressRoute. For example:

IngressRoute.yaml
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: getting-started-apigateway
namespace: traefik
spec:
entryPoints:
- web
routes:
- match: Host(`getting-started.apigateway.docker.localhost`) && PathPrefix(`/weather`)
kind: Rule
services:
- name: weather-app
port: 3000
middlewares:
- name: stripprefix-weather
- name: treblle
namespace: traefik

Next, restart your Traefik Hub API Gateway instance, and you're all set! 🚀

After restarting, inspect the Traefik pod to confirm that the Treblle plugin has been successfully loaded.

&quot;Traefik pod logs&quot;

note

The Treblle plugin captures all API traffic with the application/json content type and does not register any other content types.

Treblle in Action

If the Treblle plugin is installed and configured correctly in your Traefik Hub instance, navigating to the "Traefik Debugger" section of the Traefik Hub dashboard should display a new dashboard with data from your API requests, populated directly from Treblle.

&quot;Traefik pod logs&quot;

You can also click on the "Filter requests" button to configure the dashboard based on the information you want to see.

&quot;Traefik Debugger Filter Menu&quot;

  • See how to expose an Ingress using Traefik Hub API Gateway in the dedicated section.
  • See how to enable Metrics and Tracing using Traefik Hub API Gateway in the dedicated section
  • See additional options for Traefik Hub API Gateway metrics in the reference docs
  • See additional options for Traefik Hub API Gateway tracing in the reference docs
  • See additional options for Traefik Hub API Gateway logs in the reference docs