Skip to content

feat(monitoring): the ai spend dashboard counts gateway traffic from the gateway's own series, shows failed attempts and names each caller - #2584

Merged
dan-petty merged 2 commits into
mainfrom
feat/1668-gateway-traffic-dashboard
Oct 29, 2026
Merged

dan-petty merged 2 commits into
mainfrom
feat/1668-gateway-traffic-dashboard

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The AI spend dashboard read only devops_cli_ai_*, which only devops-cli writes. A call that another client sent through the LLM gateway did not show, and neither did an attempt that failed. The gateway could not name its callers either: every caller sends the one master key, and its series carried no caller.

Callers name themselves

  • Each devops-cli call to the gateway sends x-litellm-end-user-id with the process's OTel service name (devops-cli, devops-cli-job or roadmap-service), and User-Agent: devops-cli/<release>.
    • Chat calls: set them through the OpenAI client's default_headers.
    • Embedding calls: set them on the engine's client.
    • A pydantic-ai model sent to the gateway (refine's investigation): sets them in a request hook, because pydantic-ai sets its own User-Agent on each request.
    • Calls to other providers: name no end user.
  • otel_service_name() and user_agent() are the one source of each value. The HTTP broker's User-Agent names the installed release in place of devops-cli/0.2.9.
  • The gateway config sets enable_end_user_cost_tracking_prometheus_only, so LiteLLM 1.103.0 writes the caller as the end_user label of its request and token series.
  • Open WebUI names no Ollama URL, so the chart sets ENABLE_OLLAMA_API=False and all its model calls go through the gateway.

The dashboard counts every caller

  • AI Requests in Range and Tokens Processed in Range take a call through the gateway from the gateway's own series: its 2xx chat and embedding requests, and their tokens. devops-cli's series add only the calls that bypassed the gateway, so no call is counted twice.
  • A new row, Gateway Traffic from Every Caller, shows:
    • the gateway's attempts by status, so 408, 499 and 5xx replies are visible;
    • its requests and tokens by end_user;
    • the share of the gateway's replied requests that devops-cli's own series count.
  • The legends of Ollama Slot Wait by Priority (p95) now name the priority with one pair of braces.

Tests

  • Every gateway series that the dashboard reads must be in the LiteLLM capture, with each label that it matches or groups by, and must be read as a counter.
  • The rule that a panel states the limits of devops-cli's delta series now applies only to panels that read such a series. Prometheus scrapes the gateway's counters whole.

Docs: k8s/README.md describes the gateway counts, and both READMEs say that Open WebUI uses no Ollama Service.

Closes #1668

Change: openspec/changes/archive/2026-10-29-1668-gateway-traffic-dashboard/

…the gateway's own series, shows failed attempts and names each caller

Each devops-cli call to the LLM gateway names its caller: the OTel
service name of the process in `x-litellm-end-user-id`, and
`devops-cli/<release>` as its User-Agent. Chat calls set them through
the OpenAI client's default headers, embedding calls on the engine's
client, and a pydantic-ai model sent to the gateway in a request hook.
The gateway config sets `enable_end_user_cost_tracking_prometheus_only`,
so LiteLLM writes the caller as the `end_user` label of its series.
Open WebUI names no Ollama URL, so all its model calls go through the
gateway.

The request and token stats of the AI spend dashboard take a call
through the gateway from the gateway's own series, whoever sent it, and
add from devops-cli's series only the calls that bypassed the gateway.
A new row shows the gateway's attempts by status, its requests and
tokens by caller, and devops-cli's coverage of its requests. The
broker's User-Agent names the installed release in place of 0.2.9.
@dan-petty

Copy link
Copy Markdown
Owner Author

Test evidence:

  • uv run devops ci fail-to-pass --base origin/main: 12 tests fail on the base and pass on the branch (180 passed on the base in the 5 changed test files). On the base, a gateway chat call named OpenAI/Python 3.26.1, an embedding call python-httpx2/2.13.1 and a pydantic-ai call pydantic-ai/2.54.0, each with no end user. The broker named devops-cli/0.2.9.
  • After the rebase onto 97ed0ea9: the 310 tests of the changed test files, tests/test_grafana_dashboards.py and tests/invariants pass.
  • Before the rebase: 12,471 tests passed across the AI client, embedding, pydantic-ai, HTTP, telemetry, refine, spend and gateway suites. ruff and mypy pass on the changed source, and devops docs check passes.

Read-only checks on 2026-10-29:

  • Live gateway /metrics (LiteLLM v1.103.0): the label names of the request and token families match the capture. 7-day counts:
    • 3,291 chat requests with status 200 and 138 failed (104 status 499, 30 status 500, 4 status 408);
    • 7,898 embedding requests with 200 and 114 with 499;
    • devops-cli's own series counted about 1,785 gateway chat calls.
  • Label rename: the old k8s_cluster_name label set ends 120 s before the new one starts. Both are present in one 5-minute step only, so the sums count each request once.

Pending a person:

  • Under Open WebUI's Admin Panel > Settings > Connections, turn off the Ollama API. Open WebUI keeps the setting in its database.
  • After Argo CD redeploys the gateway and a workstation runs a model call, sum by (end_user) (increase(litellm_input_tokens_metric_total[1h])) shows devops-cli, and the Gateway Traffic from Every Caller row shows data in Grafana.
  • Review the diff in tuicr (tuicr -r origin/main..HEAD).

@dan-petty
dan-petty marked this pull request as ready for review October 29, 2026 01:10
@dan-petty
dan-petty merged commit 33491ca into main Oct 29, 2026
17 checks passed
@dan-petty
dan-petty deleted the feat/1668-gateway-traffic-dashboard branch October 29, 2026 01:17
dan-petty pushed a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.13.0](v0.12.0...v0.13.0)
(2026-10-29)


### Features

* **gh:** devops gh issues close records the close reason and a comment
([#2575](#2575))
([97ed0ea](97ed0ea)),
closes [#1658](#1658)
* **monitoring:** the ai spend dashboard counts gateway traffic from the
gateway's own series, shows failed attempts and names each caller
([#2584](#2584))
([33491ca](33491ca))
* **roadmap:** refine writes each criterion as an OpenSpec requirement
([#2591](#2591))
([d9a869f](d9a869f))
* **sandbox:** sandbox commands take a seccomp profile file
([#2588](#2588))
([46958d4](46958d4))


### Bug Fixes

* **monitoring:** RoadmapServiceGitHubWritesHigh counts a request with
no method label as a write, so it fired on 341 reads
([#2583](#2583))
([6dc3aa7](6dc3aa7)),
closes [#2574](#2574)


### Performance Improvements

* **ci:** the gate writes no coverage XML, and the clean-up keeps the
combined data
([#2582](#2582))
([ae9ebb2](ae9ebb2)),
closes [#1743](#1743)
* **roadmap:** intake's embeddings are cached in a password-protected
Valkey in the cluster
([#2578](#2578))
([bfe8a0c](bfe8a0c))


### Code Refactoring

* **devcontainer:** remove the DEVOPS_CLI_SKIP_TOOL_BOOTSTRAP test
switch from product code
([#2580](#2580))
([7e7272e](7e7272e))
* **lint:** lazy exports import names under TYPE_CHECKING
([#2590](#2590))
([c96dbfe](c96dbfe)),
closes [#2010](#2010)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(monitoring): the ai-spend dashboard counts gateway traffic from the gateway's own series, shows failed attempts and names each caller

1 participant