Skip to main content

Set Up Analytics in the Administration UI

The Cost, Performance, and Security pages of the Administration UI read the metrics your gateway sends over OpenTelemetry Protocol (OTLP) to a metrics store. A metrics store is a database that receives and serves metrics, such as Prometheus or Grafana Mimir. Any store that serves the Prometheus HTTP API works. The Administration UI doesn't read traces, so the pages don't depend on trace sampling.

This guide configures your gateway to send metrics to the store, turns on the detailed metrics of your AI middlewares so that the Cost page can display spend and token usage, and connects the Administration UI to the store.

Prerequisites​

  • The Administration UI, installed and running.
  • A metrics store that accepts OTLP metrics and serves the Prometheus HTTP API, reachable from the gateway and from the Administration UI pod. The examples on this page use Prometheus with its OTLP receiver enabled (the --web.enable-otlp-receiver flag) in the namespace monitoring.
  • An AI route on your gateway, so that the Cost page has spend and token usage to display.

Step 1: Send gateway metrics to your metrics store​

  1. Save the following as analytics-values.yaml:

    analytics-values.yaml
    metrics:
    otlp:
    enabled: true
    addRoutersLabels: true
    http:
    enabled: true
    endpoint: http://prometheus.monitoring.svc:9090/api/v1/otlp/v1/metrics # Replace with the OTLP metrics endpoint of your store.
  2. Replace endpoint with the OTLP metrics endpoint of your store. The example is the endpoint of the Prometheus OTLP receiver.

  3. Upgrade the Helm release. The --reuse-values flag keeps your current values and applies only analytics-values.yaml:

    helm upgrade traefik traefik/traefik --namespace traefik --reuse-values --values analytics-values.yaml

addRoutersLabels: true labels the metrics by router. Without it, the Performance and Security pages can't show traffic, latency, or errors per route, and the Overview page shows no success rate for the routes.

Step 2: Enable detailed metrics on your AI middlewares​

The spend, token usage, and model data on the Cost page come from the gen_ai.* metrics, which the gateway emits only at the detailed level. Set observability.metrics.level to detailed on every AI middleware whose traffic you want to measure: Chat Completion, Responses API, and Messages API.

The following example sets the level on a chat-completion middleware:

chat-completion.yaml
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: chat-completion # Replace with the name of your middleware.
namespace: default # Replace with the namespace of your middleware.
spec:
plugin:
chat-completion:
model: gpt-4o # Replace with the model of your route.
observability:
metrics:
level: detailed

The guardrail counters on the Security page need only the metrics.otlp settings from step 1.

Step 3: Connect the Administration UI to the metrics store​

  1. Add the following environment variable to the admin-ui container in your admin-ui.yaml:

    admin-ui.yaml
    - name: TRAEFIK_HUB_DASHBOARD_ANALYTICS_MIMIR_URL
    value: http://prometheus.monitoring.svc:9090 # Replace with the URL of the Prometheus HTTP API of your metrics store.
  2. Replace the value with the URL of the Prometheus HTTP API of your metrics store. For Grafana Mimir, use the URL that ends in /prometheus, and set TRAEFIK_HUB_DASHBOARD_ANALYTICS_MIMIR_TENANTID if Mimir is multi-tenant.

  3. Apply the manifest and wait for the traefik-hub-admin-ui deployment:

    kubectl apply -f admin-ui.yaml
    kubectl -n traefik rollout status deploy/traefik-hub-admin-ui

The Administration UI enables the Analytics pages when it starts with this variable set. The variable name contains MIMIR, but it accepts the URL of any store that serves the Prometheus HTTP API, including Prometheus. For the other settings of the store connection, see the configuration reference.

Step 4: Verify Analytics​

  1. Send requests to an AI route on your gateway.

  2. In the Administration UI, open the Cost page under Analytics, and select a time range that includes the requests.

  3. Check the data on each page under Analytics:

    • Cost: the estimated spend, the tokens used, and the number of AI requests.
    • Performance: the traffic, latency, and errors per route.
    • Security: the refused requests and the guardrail decisions.

The pages compute their data from the metrics of the selected time range, which can span up to 31 days. Keep the following in mind when you read them:

  • Estimated spend uses the cost the gateway estimates for each response, in USD. Models that report tokens but no cost appear as unpriced.
  • Requests sent before the second metrics export of a new counter aren't counted. A counter starts when the first request reaches a new route, model, or gateway pod, and the first value of a counter isn't included in the totals. The first requests after you create an AI route, or after the gateway restarts, can be missing from the page. Send additional requests and wait for the next export.

Troubleshooting​

The Analytics pages display "Analytics isn't enabled on this gateway"

Error: Every page under Analytics displays a message that the gateway isn't connected to a metrics store.

Cause: The Administration UI started without TRAEFIK_HUB_DASHBOARD_ANALYTICS_MIMIR_URL.

Solution: Complete step 3.

The Analytics pages show no data

Problem: The pages load, but they show zero or no data after you send requests.

Possible causes:

  • The metrics don't reach the store.
  • The AI middlewares don't set observability.metrics.level: detailed.
  • The requests are the first requests of a new counter.

Solutions:

  • Query your store for gen_ai_client_token_usage_count. If the store returns no series, check the endpoint in step 1 and the network path from the gateway to the store.
  • Set observability.metrics.level: detailed as described in step 2.
  • Send more requests and wait for the next export.

Next steps​