Repository navigation
Description
Problem
No metric or alert names a stalled gateway group. On 2026-11-16 the median time to the first token of deepseek-v4.1-flash-1017 went from 2 s to 150 s to no token, and nothing reacted for more than 5 hours. LiteLLM's failure counters miss in-stream errors: from 10:30Z to 15:30Z the gateway took 202 calls of the group, counted 27 failures, and recorded 156 first-token samples (design of #5990, comment 6922318562).
Expected behavior
- A new rule group
llm-gatewayink8s/devops/monitoring/prometheus-rules-values.yaml, severitywarning:LlmGatewayNoFirstToken: 3 or more calls of a hosted group in 30 min (litellm_proxy_total_requests_metric_total) with no time-to-first-token sample.- A slow median time to the first token of a hosted group (
litellm_llm_api_time_to_first_token_metric) above a limit for 15 min.
- A promtool test that fires both alerts on the recorded data of 2026-11-16 and stays quiet on a healthy hour.
Related
- feat(ai): Route around a stalled or offline model provider #5990 (step 2 of its build plan), feat(ai): Route DeepSeek calls around a stalled provider #5995.
Alternatives check of 2026-11-24: none.
Tool: none found.
Reason: Searches found only generic Prometheus stack and operator images plus the LiteLLM repository itself; none ships rules for a hosted group with calls and no first-token sample, so the rule group and promtool fixture must be written.
Lacks:
- No rule for calls of a group with no first-token sample
- No LiteLLM-specific alert rules in generic Prometheus charts
- No promtool fixture on recorded gateway stall data
Proposed design
Problem statement
On 2026-11-16 the median time to the first token of deepseek-v4.1-flash-1017 went from 2 s to 150 s. Then it went to no token. No alert reacted for over 5 hours. The failure counters of LiteLLM miss in-stream errors: the gateway took 202 calls, counted 27 failures and recorded 156 first-token samples in 5 hours. This item adds the rule group llm-gateway with two warning rules and a promtool test on that data.
Acceptance criteria
Requirement: The gateway alerts have their own rule group
The two gateway alert rules SHALL live in a new rule group llm-gateway of k8s/devops/monitoring/prometheus-rules-values.yaml, and each rule MUST carry severity: warning.
Scenario: The k8s check accepts the new group
- WHEN The operator runs
uv run devops ci --check --only k8s. - THEN The check reports success, and the group
llm-gatewayloads with its two rules and no error.
Requirement: A group with calls and no first token warns
The rule LlmGatewayNoFirstToken SHALL fire when a hosted group has 3 or more calls with no first-token sample in 30 minutes.
Scenario: The recorded incident fires the no-token alert
- WHEN The operator runs
uv run devops ci --check --only k8s, which runs the promtool test on the recorded samples of 2026-11-16. - THEN The test passes, and
LlmGatewayNoFirstTokenfires for the model groupdeepseek-v4.1-flash-1017withseverity: warning.
Requirement: A slow median time to the first token warns
The rule LlmGatewayFirstTokenSlow MUST fire when the median time to the first token of a hosted group stays above 30 seconds for 15 minutes.
Scenario: The recorded incident fires the slow alert
- WHEN The operator runs
uv run devops ci --check --only k8s, which runs the promtool test on the recorded samples of 2026-11-16. - THEN The test passes, and
LlmGatewayFirstTokenSlowfires for the model groupdeepseek-v4.1-flash-1017withseverity: warning.
Requirement: A healthy hour stays quiet
The two gateway rules SHALL stay quiet on an hour in which each call of a hosted group records a first-token sample below the limit.
Scenario: The healthy hour fires no alert
- WHEN The operator runs
uv run devops ci --check --only k8s, which runs the promtool test on the healthy hour of the fixture. - THEN The test passes, and neither
LlmGatewayNoFirstTokennorLlmGatewayFirstTokenSlowfires.
Existing Tool Considered
The alternatives check of 2026-11-17 in the issue body gives the verdict none with no tool: no open, maintained tool ships first-token-stall alerts for a LiteLLM gateway. The block of the check states what such a tool lacks. The change therefore writes the rule group and the promtool fixture as repository config. Written cost: about 15k output tokens to build the two rules and the fixture, about 2k tokens each month to keep them, and about 3 hours elapsed.
Key questions
- Which rule group holds the two gateway alerts, and at which severity?: The two rules go in a new group
llm-gatewayof the product rule file, and each rule carriesseverity: warning. The issue states this group and this severity. (best practice) [sources: k8s/devops/monitoring/prometheus-rules-values.yaml]- Chosen: A new group
llm-gateway. The file keeps one group for each subject, such asroadmap-service,crawl4aiandai-spend. - Rejected: Add the rules to
roadmap-service. The gateway is not the roadmap Service, and a group of its own keeps its runbook and its selectors apart.
- Chosen: A new group
- Which series and label name a hosted group in the two rules?: The rules read
litellm_proxy_total_requests_metric_totalandlitellm_llm_api_time_to_first_token_metric, and group by themodellabel, which holds the model group that the gateway serves. (best practice) [sources: k8s/README.md:352, k8s/devops/monitoring/prometheus-rules-values.yaml]- Chosen: Group by
model. The gateway names each model group inmodel, and the first-token histogram carries the same label. - Rejected: Group by
api_base. One provider serves many model groups, so a stall of one group hides in the provider sum. - Rejected: Group by
end_user. That label names a person, not a model group, so it reports the wrong subject.
- Chosen: Group by
- How does the no-first-token rule count a call that recorded no sample?: The rule sums the increase of the requests with a 2xx
status_codeover 30 minutes and subtracts the increase of the histogram_countof the same group. Anunlessarm covers a group whose histogram has no series in the window, which is a full stall. (best practice) [sources: k8s/README.md:352, k8s/devops/monitoring/prometheus-rules-values.yaml]- Chosen: 2xx requests minus the histogram
_count, with anunlessarm. The incident recorded 156 samples of 202 calls, so the difference of 46 is the count that the rule must see, and theunlessarm catches a group with no sample at all. - Rejected: An
unlesson the histogram alone. The incident recorded 156 samples, so a group with any sample never fires, and the stall stays quiet. - Rejected: The failure counter of LiteLLM. That counter misses the in-stream errors, as the problem statement of the issue shows.
- Chosen: 2xx requests minus the histogram
- Which limit and window does the slow-median rule use?: The rule takes
histogram_quantile(0.5, sum by (le) (rate(litellm_llm_api_time_to_first_token_metric_bucket[5m])))for eachmodel, and fires above 30 seconds withfor: 15m. (best practice) [sources: k8s/devops/monitoring/prometheus-rules-values.yaml]- Chosen: 30 seconds. The normal median is 2 s and the incident median was 150 s, so 30 s separates them with margin.
- Rejected: 5 seconds. A normal median of 2 s with jitter reaches 5 s, so the rule would fire on a healthy hour.
- Rejected: 120 seconds. It fires only near the top of the incident and misses a stall between 30 s and 120 s.
- Which name does the slow-median rule take?:
LlmGatewayFirstTokenSlow, after the subjectLlmGatewayand then the fault, asRoadmapServiceMemoryNearLimitnames them. (best practice) [sources: k8s/devops/monitoring/prometheus-rules-values.yaml]- Chosen:
LlmGatewayFirstTokenSlow. The file puts the subject first and the fault last, asRoadmapServiceMemoryNearLimitdoes. - Rejected:
LlmGatewaySlowFirstToken. It puts the fault before the subject and breaks the naming of the file.
- Chosen:
- Where does the promtool test live, and how does it prove both alerts?: A new fixture
tests/fixtures/prometheus_rules/llm_gateway_tests.yamlholds one case for the incident hour and one case for a healthy hour. Thek8scheck runs it with the rule file. (best practice) [sources: tests/fixtures/prometheus_rules/llm_gateway_db_tests.yaml, tests/fixtures/prometheus_rules/ai_spend_tests.yaml]- Chosen: A new fixture
llm_gateway_tests.yaml. The new group gets a fixture of its own, as each other group has one. - Rejected: Add the cases to
llm_gateway_db_tests.yaml. Its name ties it to the gateway DB rules, so the new cases belong in a file for the new group.
- Chosen: A new fixture
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 16, 2026
Both address stalled gateway groups, but #5990 delivers routing logic while the candidate adds Prometheus alert rules to detect the stall.devops-cli-service commentedon Nov 17, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (6)
Searches run:
Sources:
devops-cli-service commentedon Nov 18, 2026
Status set to Ready at c62c598 (see proposed design in issue body).