Repository navigation
Description
Problem Description
Since 2026-11-15T23:26Z, Prometheus refuses about 8 % of the samples that Alloy sends to it by remote write. Each refusal drops a full batch of up to 2,000 samples, so the series of unrelated targets get gaps. On 2026-11-19, 7,372,993 of 90,762,413 samples failed in 24 h (8.1 %).
Cause. #5896 (merged 2026-11-15T22:58:41Z, closes #4545) adds two labeldrop rules for client_ip and user_agent to the gateway ServiceMonitor (k8s/llm/gateway/servicemonitor.yaml:20-24). LiteLLM writes these two labels on litellm_deployment_total_requests and on six other metric families (LiteLLM Prometheus documentation). After the drop, two series that differ only in client_ip or user_agent have the same label set and different values at one timestamp. Alloy sends both samples. The remote-write receiver of Prometheus answers HTTP 400 "duplicate sample for timestamp", and Alloy drops the full batch as a non-recoverable error. The first refusal comes 28 minutes after the merge of #5896. Since 2026-11-12, each non-recoverable remote-write error in the Alloy log is of this kind.
The loss grows each day. Failed samples: 0.5 % (24 h to 2026-11-16T14:53Z), 1.6 % (11-17), 5.7 % (11-18), 8.1 % (11-19). Lines with "duplicate sample" in the Alloy log: 19 (2026-11-15), 218 (11-16), 647 (11-17), 1,129 (11-18). The growth agrees with LiteLLM keeping each caller pod address as a new series until the gateway restarts.
Effects. Samples of up in 2 h (expected 120 at a 60 s interval, 480 for the gateway at 15 s):
| Job | 2 h to 2026-11-15T12:00Z | 2 h to 2026-11-19T14:50Z |
|---|---|---|
llm-gateway |
480 | 242 |
roadmap-service |
120 | 60.5 |
valkey-devops |
120 | 79 |
integrations/kubernetes/resources |
120 | 96.2 |
valkey |
120 | 120 |
- The status audit of tracker feat(roadmap): track the project brain #4624 read the
valkey-devopsgap from 2026-11-19T11:18Z as a stopped scrape. The series came back at about 12:48Z. The podvalkey-devops-5fb6cb5956-p5bghgets 0 to 30 of 30 samples per 30 min since its start at 00:28Z. Its annotations, exporter and NetworkPolicy (k8s/llm/valkey-devops.yaml:37-39,:213-220) are the same as those ofvalkey, which keeps 30 of 30. - The GitHub request measure of feat(roadmap): track the project brain #4624 and the counters of the brain children read series with these gaps.
- The alert
AlloyRemoteWriteSamplesFailed(k8s/monitoring/prometheus-values.yaml:552-560, from feat(k8s): the alloy collectors, grafana and pyroscope are scraped through chart integrations, and a dropped sample or log entry alerts #1131) fires now. It first fired in the 6 h window to 2026-11-16T02:51Z and fired in each window after it. No item tracks it.
Reproduction Steps
- In Grafana Explore on the Prometheus data source, run
sum(increase(prometheus_remote_storage_samples_failed_total{job="integrations/alloy"}[24h])) / sum(increase(prometheus_remote_storage_samples_total{job="integrations/alloy"}[24h])). The result is above 0. - In Loki, run
sum(count_over_time({namespace="monitoring", container="alloy"} |= "duplicate sample" [1d])). The count is above 0 on each day since 2026-11-15. - Take the "existing" value of one refusal, for example
1.79485251474689e+09. Runlitellm_deployment_total_requests_created > 1794852514 < 1794852515. The result is ajob="llm-gateway"series with noclient_iplabel. - Run
sum by(job)(count_over_time(up[2h])) / on(job) group_left count by(job)(max_over_time(up[2h])).llm-gateway,roadmap-serviceandvalkey-devopsare below their expected counts.
Expected vs Actual Behavior
- Expected: Prometheus stores each sample that Alloy sends,
AlloyRemoteWriteSamplesFailedis quiet, and each target keeps all of its scrapes. - Actual: Prometheus refuses about 8 % of all samples in batches of 2,000, the alert fires, and targets that have no fault, such as
valkey-devopsandroadmap-service, lose up to half of their samples.
Environment Diagnostics
- DevOps CLI Version: 0.180.0 (origin/main 0d90de5)
- LiteLLM image:
ghcr.io/berriai/litellm:v1.103.11(k8s/llm/gateway/deployment.yaml:46) - Collector: the
alloy-metricsStatefulSet of the k8s-monitoring chart, one replica, remote write to the Prometheus server - Scrape: the
llm-gatewayServiceMonitor, interval 15s, path/metrics/
Logs, Traces, or Terminal Output
ts=2026-11-15T23:26:16.623Z level=error msg="non-recoverable error" component_id=prometheus.remote_write.localprometheus failedSampleCount=2000 err="server returned HTTP status 400 Bad Request: duplicate sample for timestamp 1794785174253; overrides not allowed: existing 1.7947618562847917e+09, new value 1.7947848863663995e+09"
ts=2026-11-19T14:44:40.782Z level=error msg="non-recoverable error" component_id=prometheus.remote_write.localprometheus failedSampleCount=2000 err="server returned HTTP status 400 Bad Request: duplicate sample for timestamp 1795099476547; overrides not allowed: existing 1.79485251474689e+09, new value 1.7949222435950286e+09"The most frequent value pairs in 24 h: "existing 13, new value 7" (29 times), "existing 4, new value 1" (28 times). These are counter values of the same families.
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Acceptance Criteria
- The gateway writes no
client_ipand nouser_agentlabel at the source, so no two series collide. The LiteLLM Prometheus documentation nameslitellm_settings.prometheus_exclude_labelsand theinclude_labelsofprometheus_metrics_config. The builder confirms which key LiteLLM 1.103.11 reads, or names the release that adds it. - The two
labeldroprules leavek8s/llm/gateway/servicemonitor.yaml, and the checkcheck_the_gateway_endpoint_drops_the_caller_labels(tests/gate/k8s_checks/llm_gateway.py:196) changes with them. count({job="llm-gateway", client_ip!=""})returns no series.- 24 h after the rollout,
sum(increase(prometheus_remote_storage_samples_failed_total{job="integrations/alloy"}[24h]))is 0, andAlloyRemoteWriteSamplesFailedis resolved. - 24 h after the rollout, the Loki count of step 2 is 0, and the query of step 4 gives 120 for
roadmap-serviceandvalkey-devops.
Dependencies
None. Related: #4545 and #5896 (the label drop), #1131 (the alert), #4624 (its measures read the series with gaps).
Proposed design
Problem statement
The gateway ServiceMonitor drops client_ip and user_agent after scrape. LiteLLM writes those labels on several metric families. The drop makes distinct series identical, so Prometheus rejects duplicate samples and Alloy drops full batches. The fix removes the two labeldrop rules and updates the k8s check. Source-level label exclusion is deferred.
Acceptance criteria
Requirement: Gateway ServiceMonitor drops no caller labels
The gateway ServiceMonitor SHALL NOT hold a labeldrop rule for client_ip or user_agent.
Scenario: k8s row accepts the ServiceMonitor without caller-label drops
- WHEN
uv run devops ci --check --only k8sruns on the change - THEN the k8s row passes and
check_the_gateway_endpoint_drops_the_caller_labelsreports nolabeldroprule forclient_iporuser_agent.
Requirement: Gateway scrape endpoint unchanged
The gateway ServiceMonitor SHALL keep port http, path /metrics/ and interval 15s.
Scenario: k8s row accepts the gateway scrape endpoint
- WHEN
uv run devops ci --check --only k8sruns on the change - THEN the k8s row passes and reports port
http, path/metrics/and interval15s.
Requirement: No failed remote-write samples after rollout
Prometheus MUST store every sample that Alloy sends to it after the change.
Scenario: 24 h remote-write check
- WHEN the live check runs
sum(increase(prometheus_remote_storage_samples_failed_total{job="integrations/alloy"}[24h]))24 h after the rollout - THEN the query returns 0 and
AlloyRemoteWriteSamplesFailedis resolved.
Requirement: No duplicate sample log lines after rollout
Alloy MUST log no duplicate sample error after the change.
Scenario: 24 h Alloy log check
- WHEN the live check runs
sum(count_over_time({namespace="monitoring", container="alloy"} |= "duplicate sample" [1d]))24 h after the rollout - THEN the query returns 0.
Requirement: Targets keep their scrapes after rollout
The roadmap-service and valkey-devops targets MUST keep their expected up samples after the change.
Scenario: 2 h scrape coverage check
- WHEN the live check runs
sum by(job)(count_over_time(up[2h])) / on(job) group_left count by(job)(max_over_time(up[2h]))24 h after the rollout - THEN the query returns 120 for
roadmap-serviceandvalkey-devops.
Existing Tool Considered
No alternatives check has run. Prometheus Operator's ServiceMonitor relabeling covers the removal of the two labeldrop rules, and the LiteLLM gateway covers source-level label exclusion. The plan builds no code. The immediate change uses the ServiceMonitor; the LiteLLM key for image 1.103.11 is unconfirmed, so source-level exclusion is deferred.
Key questions
- What causes Prometheus to reject whole Alloy batches?: The two
labeldroprules removeclient_ipanduser_agentfrom every gateway series. LiteLLM writes both labels on several metric families. Two series that differ only in those labels become identical with different values. Prometheus answers HTTP 400duplicate sample for timestamp, and Alloy treats that as non-recoverable and drops the full batch. [sources: k8s/llm/gateway/servicemonitor.yaml:20-24, tests/gate/k8s_checks/llm_gateway.py:196, openspec/specs/gateway-caller-telemetry/spec.md:85] - Which change stops the duplicate series?: Remove both
labeldroprules from the gateway ServiceMonitor. Keep the labels in the scraped series so their label sets stay distinct. Do not deduplicate in Alloy or retry the batch, because the receiver rejects the duplicate sample as non-recoverable. (best practice) [sources: k8s/llm/gateway/servicemonitor.yaml:20-24, openspec/specs/gateway-caller-telemetry/spec.md:85]- Chosen: Remove both labeldrop rules. The scraped series keep distinct label sets, so the receiver accepts them. This is the smallest change that stops the loss.
- Rejected: Keep the rules and add source exclusion in the same change. The LiteLLM key for image 1.103.11 is not confirmed. The rules still collide until that key works.
- Rejected: Drop only client_ip. user_agent still creates duplicate series, so the loss continues.
- Should source-level label exclusion ship with this fix?: No. Defer it. Removing the
labeldroprules stops the sample loss. Source-level exclusion needs a confirmed LiteLLM key or a named release, and the issue leaves that fact open. (best practice) [sources: k8s/llm/gateway/deployment.yaml:46, k8s/llm/gateway/config.yaml, k8s/llm/gateway/servicemonitor.yaml:20-24]- Chosen: Defer source-level exclusion. The rest of the fix is workable now. The deferred issue can confirm the LiteLLM key or release.
- Rejected: Ship source exclusion now. The LiteLLM 1.103.11 key is not sourced. A wrong key leaves the labels in place and does not fix the loss.
- Rejected: Keep labeldrop until source exclusion ships. The loss continues while the source change waits.
- Which check must change?:
check_the_gateway_endpoint_drops_the_caller_labelsintests/gate/k8s_checks/llm_gateway.pymust assert that the gateway endpoint has nolabeldroprule forclient_iporuser_agent. The k8s row runs it. [sources: tests/gate/k8s_checks/llm_gateway.py:196, k8s/llm/gateway/servicemonitor.yaml:20-24] - Does the alert
AlloyRemoteWriteSamplesFailedneed a change?: No. The alert is generic and fires on failed remote-write samples. It should resolve when the duplicate sample errors stop. The change keeps the alert. [sources: k8s/monitoring/prometheus-values.yaml:552-560, k8s/README.md:641] - Which spec must change?: The
gateway-caller-telemetryspec at line 85 requires thelabeldroprules. The change must update that requirement and its scenario to match the ServiceMonitor without caller-label drops. [sources: openspec/specs/gateway-caller-telemetry/spec.md:85, openspec/specs/gateway-caller-telemetry/spec.md:87]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 19, 2026
Sample loss is growing from 0.5% to 8.1% in four days, an alert fires continuously, and multiple targets lose up to half their scrapes.Both items touch the gateway ServiceMonitor label handling, but #4545 delivers the labeldrop and the candidate fixes the duplicate-sample rejection that the labeldrop introduced.devops-cli-service commentedon Nov 19, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
dan-petty commentedon Nov 19, 2026
Design change: exclude the caller labels at the LiteLLM source
The refine block defers source-level exclusion because the LiteLLM key for image v1.103.11 was not confirmed. That reason is gone. The build uses the source key, as the first acceptance criterion asks.
The key exists in LiteLLM v1.103.11
litellm/__init__.py:477-478declaresprometheus_exclude_metricsandprometheus_exclude_labels.litellm/integrations/prometheus.py:275reads the setting into the logger, and:897-919checks each name against the defined labels.:1158-1178makes each metric without the excluded label names._ExcludedLabelMetric.labels()(:163-184) drops the excluded values, so LiteLLM adds the counts of all callers into one series before exposition.get_labels_for_metric(:1188-1204) and_inc_labeled_counter(:1304-1317) are the increment path of all seven families.The change
k8s/llm/gateway/config.yaml: addprometheus_exclude_labels: ["client_ip", "user_agent"]underlitellm_settings, beforecallbacks: ["prometheus", "otel"]. Key order has mattered for other Prometheus settings (proxy_server.py:5857-5860), so the key comes first.k8s/llm/gateway/servicemonitor.yaml: remove the comment and themetricRelabelingsblock with its twolabeldroprules.tests/gate/k8s_checks/llm_gateway.py: removecheck_the_gateway_endpoint_drops_the_caller_labels. It asserts manifest values, whichdocs/TESTING.mdforbids. No check replaces it. The two reader checks stay: no dashboard query and no alert expression may use the two labels.gateway-caller-telemetryspec changes through an OpenSpec change folder. The live check after the Argo CD sync is the proof:count({job="llm-gateway", client_ip!=""})andcount({job="llm-gateway", user_agent!=""})return no series, andlitellm_deployment_total_requests_total{job="llm-gateway"}still exists (about 15 series, not 323).Why the other options lose
labeldroprules only (the refine design): it stops the collisions but gives up the fix(monitoring): drop per-pod labels from gateway spend series #4545 bound. The deployment families have noend_userlabel, so the TTL never removes their series (about 1,330 to 1,500 extra series after 3 days).prometheus_metrics_configwithinclude_labels: it is include-based (prometheus.py:1150-1156), so each family that is not listed stops.prometheus_metrics_max_series_per_metric: not in v1.103.11, and it keeps the labels, so readers still read split values.use_x_forwarded_forand a user agent without the release: each caller must comply, and the header can bypass the rate limit by source.Out of scope here (a person decides): the runbook and description of
AlloyRemoteWriteSamplesFailed, and a mark on the wrong gateway history from 2026-11-15T23Z to the rollout.fix(ci): fail-to-pass needs no proof for a deleted gate check (#6465)
docs(openspec): plan the gateway caller label exclusion at the source
1 remaining item
docs(openspec): name the real exclusion path and the live checks of #…
docs(openspec): archive the gateway caller label exclusion of #6439
docs(openspec): plan the gateway caller label exclusion at the source
fix(monitoring): remove the labeldrop rules of the gateway scrape
docs(openspec): name the real exclusion path and the live checks of #…
docs(openspec): archive the gateway caller label exclusion of #6439
dan-petty commentedon Nov 19, 2026
Live check after the merge of #6459 (bc57c1e). Argo CD synced Application
llmat 2026-11-19T22:41:49Z. The sync made a new gateway pod at 22:41:48Z, with the ConfigMapllm-gateway-config-4cfcbcbd7d. I read these values at 23:21Z, 39 minutes after the rollout. All checks are read only.client_ip=oruser_agent=on the raw/metrics/of the gatewaylitellm_lines on the raw/metrics/count({job="llm-gateway", __name__="litellm_deployment_total_requests_total"})max(scrape_samples_scraped{job="llm-gateway"})increase(prometheus_remote_storage_samples_failed_total[36m])/api/v1/write, 36 minALERTS{alertname="AlloyRemoteWriteSamplesFailed"}The new gateway has fewer
litellm_deployment_total_requests_totalseries because the counters start again at the restart. A series comes back when a model gets its first request.These checks need a full day after the rollout (from 2026-11-20T22:42Z):
[24h]: each must be 0.roadmap-serviceandvalkey-devops, and 480 forllm-gateway.sum(increase(litellm_deployment_total_requests_total[1d])) / sum(increase(litellm_llm_api_latency_metric_count[1d]))comes back to the band before 2026-11-15 (about 1.0 to 1.6).devops-cli-service commentedon Nov 20, 2026
Released in v0.182.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.182.0
devops-cli-service commentedon Nov 20, 2026
Live since 2026-11-20 00:02 UTC
dan-petty commentedon Nov 20, 2026
24-hour live check of the fix of this issue (PR #6459, merge bc57c1e). Argo CD synced Application
llmat 2026-11-19T22:41:49Z. I read these values at 2026-11-20T22:47Z, so each 24 h window starts after the rollout. All reads are read only, through short port-forwards to Prometheus and Loki.increase(prometheus_remote_storage_samples_failed_total{job="integrations/alloy"}[24h])/api/v1/write, 24 hcount_over_time(up[2h])by joblitellm_deployment_total_requests_total/litellm_llm_api_latency_metric_count, 1 dmax_over_time(max(scrape_samples_scraped{job="llm-gateway"})[24h:5m])The alert
AlloyRemoteWriteSamplesFailedhas no series. The value 479 of check 5 is one sample short of 480 because the 2 h window starts between two scrapes; the 15 s scrape ofllm-gatewaygives 480 in a full window.Before the fix, Alloy lost 10.7 % of its samples and Prometheus refused about 10 % of the remote writes (see the first check of 2026-11-19). The window from 2026-11-15T23:26Z to the rollout stays wrong in the stored data (#6457).