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-receiverflag) in the namespacemonitoring. - 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
-
Save the following as
analytics-values.yaml:analytics-values.yamlmetrics:otlp:enabled: trueaddRoutersLabels: truehttp:enabled: trueendpoint: http://prometheus.monitoring.svc:9090/api/v1/otlp/v1/metrics # Replace with the OTLP metrics endpoint of your store. -
Replace
endpointwith the OTLP metrics endpoint of your store. The example is the endpoint of the Prometheus OTLP receiver. -
Upgrade the Helm release. The
--reuse-valuesflag keeps your current values and applies onlyanalytics-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:
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
-
Add the following environment variable to the
admin-uicontainer in youradmin-ui.yaml:admin-ui.yaml- name: TRAEFIK_HUB_DASHBOARD_ANALYTICS_MIMIR_URLvalue: http://prometheus.monitoring.svc:9090 # Replace with the URL of the Prometheus HTTP API of your metrics store. -
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 setTRAEFIK_HUB_DASHBOARD_ANALYTICS_MIMIR_TENANTIDif Mimir is multi-tenant. -
Apply the manifest and wait for the
traefik-hub-admin-uideployment:kubectl apply -f admin-ui.yamlkubectl -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
-
Send requests to an AI route on your gateway.
-
In the Administration UI, open the Cost page under Analytics, and select a time range that includes the requests.
-
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:
Next steps
- Administration UI configuration reference for the store connection settings.
- Track AI costs to attribute AI spend by team.
