Skip to main content

Traefik Hub API Gateway Observability & Monitoring

Traefik Hub API Gateway provides monitoring and observability to maintain reliability and efficiency:

  • Tracing allows you to track the flow of operations within your system. Using traces and spans, you can identify performance bottlenecks and pinpoint applications causing slowdowns to optimize response times effectively.
  • Logs and AccessLogs provide real-time insight into the health of your system. It enables swift error detection and intervention through alerts. By centralizing logs, you can streamline the debugging process during incident resolution.
  • Metrics offer a comprehensive view of your infrastructure's health. They allow you to monitor critical indicators like incoming traffic volume. For instance, Hub AI Gateway enables you to dynamically scale your infrastructure based on observed traffic patterns. Additionally, metrics graphs and visualizations are helpful during incident triage in understanding the causes and implementing proactive measures.
Metrics Format

Traefik Hub API Gateway provides metrics and tracing information in the OpenTelemetry format.

In addition to supporting metrics in the OpenTelemetry format, Hub API Gateway supports the following vendor-specific metrics systems: Prometheus, Datadog, InfluxDB 2.X, and StatsD.

More information is in the dedicated section below.

OpenTelemetry in Traefik Hub API Gateway

OpenTelemetry is the next standard for observability (metrics, tracing and logs). It's an open-source project that belongs to the CNCF since 2019.

Traefik Hub API Gateway allows you to export metrics and traces in the OpenTelemetry format (support for logs will be available as soon as the official OpenTelemetry Go SDK is stable). Traefik Hub API adheres to the specified semantic conventions. These conventions tell us what data to provide based on what our software does in your setup.

Now, let's see how to set up OpenTelemetry in Traefik.

Install Traefik Hub API Gateway enabling Metrics and Tracing in the OpenTelemetry format

If the Hub API Gateway has already been installed, save the current configuration. The following command will save it to a file with the name values.yaml in your working directory.

CLI
helm get values traefik-hub -n traefik | tail -n +2 > values.yaml

Then, adjust the file, adding the following configuration that allows sending metrics and tracing data to your Opentelemetry Collector.

values.yaml
metrics:
# Disable Prometheus (enabled by default)
prometheus: null
# Enable providing OTel metrics
otlp:
enabled: true
http:
enabled: true
endpoint: http://myotlpcollector:4318/v1/metrics
# Enable providing OTel traces
tracing:
enabled: true
http:
enabled: true
endpoint: http://myotlpcollector:4318/v1/traces

Once you have the configuration adjusted to your needs, use Helm to deploy the Traefik Hub API Gateway with the new values:

Install Traefik Hub API Gateway using Helm
# Add the Helm repository
helm repo add --force-update traefik https://traefik.github.io/charts
# Install the Helm chart
helm upgrade --install traefik-hub -n traefik --wait \
--values values.yaml \
traefik/traefik

You can now provide metrics and traces to your OpenTelemetry Collector.

Advanced Configuration

Advanced options to install Hub API Gateway enabling tracing and metrics using the Helm Chart are described in the Helm Chart reference page.

More information about metrics in Hub API Gateway in the dedicated section. More information about tracing in Hub API Gateway in the dedicated section.

Install Traefik Hub API Gateway enabling AccesLogs in JSON format

If Hub API Gateway is already installed, save the current configuration. The following command will save it to a file with the name values.yaml in your working directory.

CLI
helm get values traefik-hub -n traefik | tail -n +2 > values.yaml

Then, adjust the file, adding the following configuration.

values.yaml
logs:
access:
enabled: true
format: json
filters:
statusCodes:
- "200"
- "400-404"
- "500-503"
fields:
general:
names:
ClientUsername: drop
headers:
names:
User-Agent: redact
Content-Type: keep

The configuration above enables the access logs:

  • With the JSON format (mandatory to customize the fields and filters),
  • Filtering requests using the HTTP Status codes (200, 400-404, 500-503)
  • Dropping the fields ClientUsername
  • Keeping the headers User-Agent and Content-Type

Once you have the configuration adjusted to your needs, use Helm to deploy the Traefik Hub API Gateway with the new values:

Install Traefik Hub API Gateway using Helm
# Add the Helm repository
helm repo add --force-update traefik https://traefik.github.io/charts
# Install the Helm chart
helm upgrade --install traefik-hub -n traefik --wait \
--values values.yaml \
traefik/traefik

You can now provide metrics and traces to your OpenTelemetry Collector.

Advanced Configuration

Advanced options to install Hub API Gateway customizing the logs and access logs using the Helm Chart are described in the Helm Chart reference page.

More information about the logs and access logs is in the dedicated section.