Skip to content

fix(monitoring): exclude caller labels at the gateway source - #6459

Merged
dan-petty merged 5 commits into
mainfrom
fix/6439-exclude-gateway-caller-labels
Nov 19, 2026
Merged

dan-petty merged 5 commits into
mainfrom
fix/6439-exclude-gateway-caller-labels

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The gateway now excludes client_ip and user_agent at the source with LiteLLM's own litellm_settings.prometheus_exclude_labels, set before callbacks. LiteLLM v1.103.11 reads the key (litellm/integrations/prometheus.py:275, :1188-1204) and adds the counts of all callers into one series before exposition. The two labeldrop rules leave the gateway ServiceMonitor, and the gate check that asserted them leaves the k8s row.

The labeldrop rules of #5896 made two series that differ only in these labels identical. Prometheus refused the remote write of Alloy with "duplicate sample for timestamp", and Alloy dropped full batches: 8.1 % of all samples on 2026-11-19, with gaps in targets that have no fault. Exclusion at the source stops the collisions and keeps the bound on the series count of #4545.

Closes #6439

Change: openspec/changes/archive/2026-11-19-6439-exclude-gateway-caller-labels/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/monitoring Grafana, Prometheus, Loki, alerts and dashboards labels Nov 19, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Fail-to-Pass Check: expected red

This change deletes the gate check check_the_gateway_endpoint_drops_the_caller_labels and adds no check, so no gate case can fail on the base and pass on the head. uv run devops ci fail-to-pass --base origin/main gives:

k8s gate row: 0 of 177 cases failed on base, 0 of 177 on head (tests/gate/k8s_checks/llm_gateway.py).
No case of a changed gate check fails on base and passes on head (tests/gate/k8s_checks/llm_gateway.py).

Exit status 1. docs/TESTING.md says that a deletion gets no test and that no rule asks for a test of a manifest value, so this change adds no such test. #6456 asks that a gate check module that only loses checks need no proof. The check is not required (ADR 0004). A person decides whether to merge with the red check or to wait for #6456.

Live check after the merge and the Argo CD sync of Application llm

All queries are read only.

  1. count({job="llm-gateway", __name__="litellm_deployment_total_requests_total"}) gives a number above 0 (about 15 at first), so the callback still loads.
  2. count({job="llm-gateway", client_ip!=""}) and count({job="llm-gateway", user_agent!=""}) return no series.
  3. max(scrape_samples_scraped{job="llm-gateway"}) falls from 2,940 to about 1,600 or less, and max_over_time of it over 3 days stays below about 2,000.
  4. After about 30 min, ALERTS{alertname="AlloyRemoteWriteSamplesFailed"} returns no series.
  5. After 24 h, sum(increase(prometheus_remote_storage_samples_failed_total{job="integrations/alloy"}[24h])) gives 0, and the Loki query sum(count_over_time({namespace="monitoring", container="alloy"} |= "duplicate sample" [24h])) gives 0.
  6. After 24 h, sum by(job)(count_over_time(up[2h])) / on(job) group_left count by(job)(max_over_time(up[2h])) gives 120 for roadmap-service and valkey-devops, and 480 for llm-gateway.
  7. sum(increase(litellm_deployment_total_requests_total[1d])) / sum(increase(litellm_llm_api_latency_metric_count[1d])) goes back to about 1.0 to 1.6 (0.16 to 0.53 before this change).

dan-petty added a commit that referenced this pull request Nov 19, 2026
A fix that removes a manifest rule also deletes the gate check of the
rule. `devops ci fail-to-pass` then replayed the gate row of that
module. The base run uses the tests of the head, so the deleted check
ran on neither tree, and no case could prove the fix (see #6459).

A changed gate check module now only loses checks when its head keeps
the top-level statements of its base in the same order, by syntax tree,
and leaves out at least one `def check_*` and only names that the head
does not use and that run no code at import. A fix that changes no
source code, and whose gate check modules only lose checks or are
deleted, passes with no replay. The report names each deleted check as
`<module>.<check>`. A fix that adds or changes a gate case still needs a
case that fails on its base.

On the branch of #6439, the command now exits 0 and names the deleted
check.

Closes #6456

Change:
`openspec/changes/archive/2026-11-19-6456-deleted-gate-check-needs-no-proof/`
@dan-petty
dan-petty force-pushed the fix/6439-exclude-gateway-caller-labels branch from 920cbe8 to 369d165 Compare November 19, 2026 22:15
@dan-petty

dan-petty commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner Author

Check results

Head commit: 09687531b20f51b759ecbb054c2c0dfadb632d28

Check Conclusion Link
Tests & Coverage success run
devops-cli success run
zizmor success run
trivy-config success run
CodeQL success run
Plan Check skipped run
Dependency Freshness skipped run
Tests on Main skipped run
Test Job Duration skipped run
Service Image success run
Changed-Test Independence success run
Tests & Coverage (shard 5 of 5) success run
Tests & Coverage (shard 4 of 5) success run
Static Analysis success run
Runner Image success run
MCP Server Image success run
Tests & Coverage (shard 1 of 5) success run
Tests & Coverage (shard 2 of 5) success run
Image Pins success run
Tests & Coverage (shard 3 of 5) success run
Fail-to-Pass Check success run
Design Tokens success run
Analyze (actions) success run
Analyze (python) success run
Semantic PR title success run

Fail-to-pass run: https://github.com/dan-petty/devops-cli/actions/runs/44628265777/job/135927758675

Skipped check: Plan Check
Skipped check: Dependency Freshness
Skipped check: Tests on Main
Skipped check: Test Job Duration

Plan #6439 as an OpenSpec change. LiteLLM v1.103.11 reads
litellm_settings.prometheus_exclude_labels (litellm/__init__.py:477-478,
litellm/integrations/prometheus.py:275, :897-919, :1158-1178), so the
gateway excludes client_ip and user_agent before exposition. The two
labeldrop rules of the ServiceMonitor and the value check of the k8s row
go. The spec delta removes the labeldrop requirements and adds the
source-exclusion requirement with a validator command and live checks.
Set litellm_settings.prometheus_exclude_labels to client_ip and
user_agent, before callbacks. LiteLLM v1.103.11 removes the two labels
before exposition and adds the callers into one series
(litellm/integrations/prometheus.py:897-919, :1158-1178), so no two
series collide in Prometheus. The comment says why the key comes first.
The gateway now excludes client_ip and user_agent at the source, so the
ServiceMonitor keeps no metricRelabelings. The labeldrop rules dropped
the labels after LiteLLM had split the counts, so series with the same
labels and different values collided in Prometheus (#6439).

Delete the gate check that asserted the labeldrop list, the port, the
path and the interval of the ServiceMonitor. docs/TESTING.md forbids a
check of a manifest value, so no check of the new key replaces it. The
two checks that no dashboard query and no alert expression reads the
labels stay.
…6439

The design named _ExcludedLabelMetric as the path that removes the
caller labels. At v1.103.11, get_labels_for_metric and the label
factory do this work for the seven families. Add the Loki and up
coverage checks of the issue as a scenario, and name the open
follow-up issues #6457 and #5471.
@dan-petty
dan-petty force-pushed the fix/6439-exclude-gateway-caller-labels branch from 369d165 to 0968753 Compare November 19, 2026 22:24
@dan-petty
dan-petty marked this pull request as ready for review November 19, 2026 22:37
@dan-petty
dan-petty merged commit bc57c1e into main Nov 19, 2026
25 checks passed
@dan-petty
dan-petty deleted the fix/6439-exclude-gateway-caller-labels branch November 19, 2026 22:38
dan-petty-release Bot added a commit that referenced this pull request Nov 19, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.182.0](v0.181.1...v0.182.0)
(2026-11-19)


### Features

* **roadmap:** Post delivery PR evidence before ready
([#6426](#6426))
([a3891c0](a3891c0))


### Bug Fixes

* **ci:** fail-to-pass needs no proof for a deleted gate check
([#6465](#6465))
([52e50f7](52e50f7))
* **deps:** ignore GHSA-qx49-fqc8-xw99 of mcp 1.29.0 until 2026-11-22
([#6482](#6482))
([99434a9](99434a9)),
closes [#6481](#6481)
* **monitoring:** exclude caller labels at the gateway source
([#6459](#6459))
([bc57c1e](bc57c1e))
* **security:** Keep host-only SSH keys off GitHub
([#6473](#6473))
([65771a4](65771a4))

---
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

scope/monitoring Grafana, Prometheus, Loki, alerts and dashboards type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(monitoring): stop the gateway labeldrop losing samples

1 participant