Skip to content

feat(k8s): Alert on a gateway group with no first token #5999

Done

Description

@dan-petty

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-gateway in k8s/devops/monitoring/prometheus-rules-values.yaml, severity warning:
    • 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

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-gateway loads 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 LlmGatewayNoFirstToken fires for the model group deepseek-v4.1-flash-1017 with severity: 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 LlmGatewayFirstTokenSlow fires for the model group deepseek-v4.1-flash-1017 with severity: 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 LlmGatewayNoFirstToken nor LlmGatewayFirstTokenSlow fires.

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-gateway of the product rule file, and each rule carries severity: 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 as roadmap-service, crawl4ai and ai-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.
  • Which series and label name a hosted group in the two rules?: The rules read litellm_proxy_total_requests_metric_total and litellm_llm_api_time_to_first_token_metric, and group by the model label, 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 in model, 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.
  • 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_code over 30 minutes and subtracts the increase of the histogram _count of the same group. An unless arm 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 an unless arm. The incident recorded 156 samples of 202 calls, so the difference of 46 is the count that the rule must see, and the unless arm catches a group with no sample at all.
    • Rejected: An unless on 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.
  • 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 each model, and fires above 30 seconds with for: 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 subject LlmGateway and then the fault, as RoadmapServiceMemoryNearLimit names them. (best practice) [sources: k8s/devops/monitoring/prometheus-rules-values.yaml]
    • Chosen: LlmGatewayFirstTokenSlow. The file puts the subject first and the fault last, as RoadmapServiceMemoryNearLimit does.
    • Rejected: LlmGatewaySlowFirstToken. It puts the fault before the subject and breaks the naming of the file.
  • Where does the promtool test live, and how does it prove both alerts?: A new fixture tests/fixtures/prometheus_rules/llm_gateway_tests.yaml holds one case for the incident hour and one case for a healthy hour. The k8s check 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.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    scope/k8s
    source/agent
    on Nov 16, 2026
  2. dan-petty commented on Nov 16, 2026

    @dan-petty
    OwnerAuthor
  3. added
    status/new
    effort/medium
    value/high
    priority/p2-medium
    on Nov 16, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    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:

    • LiteLLM prometheus alert time to first token stalled gateway, results: 5
    • prometheus alerting rules library LLM proxy first token latency, results: 5
    • LiteLLM alerting Prometheus alert rules litellm_llm_api_time_to_first_token_metric, results: 5
    • awesome-prometheus-alerts LLM gateway alerting rules collection, results: 5
    • litellm docs prometheus metrics time_to_first_token observability, results: 5
    • github prometheus rule group generator promtool unit tests alerts, results: 5

    Sources:

  5. added
    status/ready
    and removed
    status/new
    on Nov 18, 2026
  6. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at c62c598 (see proposed design in issue body).

  7. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  8. removed
    status/in-review
    on Nov 29, 2026
  9. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 18:59 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions