Repository navigation
Description
Problem or Motivation
The LiteLLM gateway series carry the labels client_ip and user_agent. client_ip changes with each pod address of a caller. When the roadmap jobs move into short pods (stage first), each unit pod adds a new address, about 1,100 a day at the end of the move. Each short pod already adds about 76 metric series, and the plan estimates about 84,000 new series a day against a head of 44,349 before a series budget.
No panel, alert or test reads client_ip or user_agent today.
Proposed Solution & Architectural Design
In k8s/llm/gateway/servicemonitor.yaml, add metricRelabelings with action: labeldrop for client_ip and user_agent.
Target Subsystem
Kubernetes & Minikube Automation (k8s/llm/gateway/, monitoring).
Existing Tool Considered
Prometheus Operator metricRelabelings (configuration of an open tool, no build). Cost: about 50,000 tokens and 1 hour; about 1,000 tokens a month to keep.
Acceptance Criteria
count by (__name__) ({__name__=~"litellm_.*", client_ip!=""})returns nothing after one scrape.- The panels of
ai-spend.jsonshow the same totals as before. - The manifest test of the gateway ServiceMonitor passes.
Dependencies
None. Merge it before "feat(roadmap): run each stage item in its own Job" and before "feat(ai): label gateway spend by repository".
Source: #4517
Proposed design
Problem statement
The LiteLLM gateway series carry the labels client_ip and user_agent. Each caller pod address adds a new client_ip value, and the move of the roadmap jobs into short pods adds about 1,100 addresses and about 84,000 series a day. No panel, alert rule or test reads the two labels: the dashboard queries group by status_code, end_user, model_id and api_base, and the alert rules name neither. The change drops the two labels at scrape time and keeps the spend totals.
Acceptance criteria
Requirement: Gateway endpoint drops the caller labels
The http endpoint of the gateway ServiceMonitor SHALL carry one metricRelabelings entry with action: labeldrop for each of client_ip and user_agent, and SHALL keep its port, path and interval.
Scenario: The endpoint holds one labeldrop rule for each label
- WHEN a check reads
k8s/llm/gateway/servicemonitor.yamland collects theregexof everymetricRelabelingsentry withaction: labeldropon thehttpendpoint - THEN the collected values are exactly
client_ipanduser_agent, and the endpoint still names porthttp, path/metrics/and interval15s
Requirement: Spend and stack queries avoid the dropped labels
Every query of k8s/monitoring/dashboards/ai-spend.json and k8s/monitoring/dashboards/llm-stack.json that reads a litellm_ series MUST NOT group by or filter on client_ip or user_agent.
Scenario: No gateway query groups or filters by the dropped labels
- WHEN a check reads every target expression of both dashboards and lists the label names in its
byclauses and its label matchers - THEN no listed name is
client_iporuser_agent
Requirement: Alert rules ignore the dropped labels
Every alert rule expression in k8s/monitoring/prometheus-values.yaml MUST NOT select or group by client_ip or user_agent.
Scenario: No alert expression holds the two names
- WHEN a check reads
serverFiles.alerting_rules.ymlfromk8s/monitoring/prometheus-values.yamland collects everyexpr - THEN no expression holds
client_iporuser_agent
Requirement: The manifest check runs in the k8s gate row
The new ServiceMonitor check MUST run in the k8s row of devops ci, which the Static Analysis check runs in CI.
Scenario: The k8s row collects the new check
- WHEN the
k8srow runs thecheck_*functions undertests/gate/k8s_checks/ - THEN the gateway ServiceMonitor label check reports a pass
Existing Tool Considered
No alternatives check has run on this issue. The Prometheus Operator covers the need: its spec.endpoints[].metricRelabelings with action: labeldrop removes client_ip and user_agent at scrape time, so the project builds no code for the drop and keeps only the manifest lines and the gate check. The tool lacks two things: it drops the labels only from the series that Prometheus stores, so the gateway still sends them in every scrape and the scrape payload stays as large; and the drop applies to every series of the endpoint, so a later item that needs caller identity must add a bounded label instead.
Key questions
- Which mechanism drops the two labels from the stored series?: Add
metricRelabelingswithaction: labeldropto thehttpendpoint of the gateway ServiceMonitor. The operator applies it after the scrape and before ingestion, and the gateway scrape config already lives in this file (k8s/llm/kustomization.yaml:12). (best practice) [sources: k8s/llm/gateway/servicemonitor.yaml, k8s/llm/kustomization.yaml:12, tests/fixtures/charts/qdrant/values.yaml:219]- Chosen: ServiceMonitor
metricRelabelings. The operator applies it after the scrape and before ingestion, and the gateway scrape config already lives in this file. - Rejected: Prometheus
additionalScrapeConfigs. It moves the gateway scrape config out ofk8s/llm/gateway/and breaks the kustomization that owns it. - Rejected: LiteLLM exporter settings. LiteLLM has no setting that drops one Prometheus label, so this needs a fork or custom code.
- Rejected: Endpoint
relabelings. It relabels the target before the scrape and cannot remove a metric label.
- Chosen: ServiceMonitor
- Does one labeldrop rule hold both names, or one rule each?: Use one
labeldroprule for each label name. (best practice) [sources: k8s/llm/gateway/servicemonitor.yaml]- Chosen: One rule for each label name. Each rule names one label, so a reader and a check find the name without a regex.
- Rejected: One rule with
regex: client_ip|user_agent. The check must parse a regex, and each name is less visible in the manifest.
- Which metric labels grow with each pod address?:
client_ipholds one value for each caller address, anduser_agentholds one value for each client release.litellm_deployment_*,litellm_proxy_total_requests_metric_*,litellm_requests_metric_*andlitellm_spend_metric_*carry both labels. [sources: tests/fixtures/metrics/litellm.yaml:43, tests/fixtures/metrics/litellm.yaml:86, tests/fixtures/metrics/litellm.yaml:103, openspec/changes/archive/2026-10-29-1668-gateway-traffic-dashboard/proposal.md:55] - Does any panel, alert rule or test read
client_iporuser_agent?: No. The queries ofai-spend.jsongroup bystatus_code,end_userand filter onroute,status_codeandprovider; thellm-stack.jsongateway query groups bymodel_idandapi_base; the alert rules ofk8s/monitoring/prometheus-values.yamlname neither label. The only test-side mentions are the metric capture fixture, which lists them as labels the gateway's endpoint serves, andmetadata.user_agentin the Collector check, which is an OpenTelemetry span attribute and not a metric label. [sources: k8s/monitoring/dashboards/ai-spend.json:1016, k8s/monitoring/dashboards/ai-spend.json:1081, k8s/monitoring/dashboards/llm-stack.json:127, k8s/monitoring/prometheus-values.yaml:436, tests/fixtures/metrics/litellm.yaml:43, tests/gate/k8s_checks/otel_collector.py:55] - Does the metric capture fixture change when the endpoint drops the labels?: No. The fixture records the families and label names that the gateway's
/metrics/endpoint serves, captured through the Kubernetes API service proxy before the ServiceMonitor relabels the samples, sometricRelabelingsdoes not change it. [sources: tests/fixtures/metrics/litellm.yaml:1, tests/fixtures/metrics/litellm.yaml:12, tests/fixtures/metrics/litellm.yaml:15] - Where does the offline check of the manifest live?: Add the check to
tests/gate/k8s_checks/llm_gateway.py, which already readsk8s/llm/gatewayand holds the gateway's manifest checks. Thek8srow runs everycheck_*function of the directory. (best practice) [sources: tests/gate/k8s_checks/llm_gateway.py:17, tests/gate/k8s.py:3, docs/TESTING.md:72, .github/workflows/ci.yml:76]- Chosen: Extend
tests/gate/k8s_checks/llm_gateway.py. The module already owns the gateway's manifest checks and readsk8s/llm/gateway, so the ServiceMonitor check sits beside the checks of the same directory. - Rejected: A new file under
tests/gate/k8s_checks/. It splits the gateway's checks across two modules and adds a file for one assertion.
- Chosen: Extend
- How does a person confirm the drop on the live cluster?: After the merge, run
count by (__name__) ({__name__=~"litellm_.*", client_ip!=""})in the cluster. It returns nothing after one scrape of 15 seconds. This is a post-merge check, not an acceptance criterion, because no offline test reaches the cluster. (best practice) [sources: k8s/llm/gateway/servicemonitor.yaml]- Chosen: A post-merge cluster query. The query needs a live Prometheus, and the offline check reads the manifest instead.
- Rejected: An acceptance criterion that runs the query. No offline test can reach the cluster, so the criterion cannot pass in CI.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Alternatives check of 2026-11-12: in-use.
The item already names this tool.
Tool: prometheus-operator/prometheus-operator (https://github.com/prometheus-operator/prometheus-operator), Apache-2.0, last activity 2026-11-12, maintained.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.(monitoring)scope of the title gives the scope.A known series budget will be exceeded in days, but nothing is broken today.Prevents series budget exhaustion that would break all gateway monitoring.Adding two labeldrop entries to an existing ServiceMonitor YAML file.Both address pod-level labels causing metric problems, but #3495 fixes counter aggregation logic while this candidate drops labels at scrape time.devops-cli-service commentedon Nov 11, 2026
Status set to Ready at 5f75d25 (see proposed design in issue body).
devops-cli-service commentedon Nov 12, 2026
Alternatives check: in-use
Reason: The issue itself already names the mechanism it needs: Prometheus Operator
spec.endpoints[].metricRelabelingswithaction: labeldrop, which dropsclient_ipanduser_agentfrom the stored series at scrape time, so only manifest lines plus a gate check are needed and no code is built. The searches returned nothing better (the search index returned unrelated pages), and the repository facts show the operator is an open, maintained Apache-2.0 project that the project already deploys for its ServiceMonitors, so this is configuration of a tool in use rather than a new tool.The item already names this tool.
Tool: prometheus-operator/prometheus-operator (https://github.com/prometheus-operator/prometheus-operator)
Covers:
client_ip,user_agent) removes them from every series of the endpointLacks:
client_ipanduser_agentin each scrape, so the scrape payload stays as largecount by (__name__) ({__name__=~"litellm_.*", client_ip!=""})needs a live Prometheus after mergeTools considered:
Searches run:
Sources:
Checked on 2026-11-12. A person decides what this means for the item. The check changes no label and closes no issue.
fix(monitoring): drop the caller labels from the gateway series (#4545)
devops-cli-service commentedon Nov 15, 2026
Released in v0.159.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.159.0
devops-cli-service commentedon Nov 15, 2026
Live since 2026-11-15 23:51 UTC
fix(monitoring): exclude caller labels at the gateway source (#6459)