Skip to content

feat(gateway): add engine-agnostic observability metrics and overhaul Grafana dashboard - #2392

Merged
varungup90 merged 5 commits into
vllm-project:mainfrom
varungup90:feat/refine-metrics-dashboard
Jul 23, 2026
Merged

feat(gateway): add engine-agnostic observability metrics and overhaul Grafana dashboard#2392
varungup90 merged 5 commits into
vllm-project:mainfrom
varungup90:feat/refine-metrics-dashboard

Conversation

@varungup90

Copy link
Copy Markdown
Collaborator

Pull Request Description

Summary

  • Add gateway-level gauges and counters for operational visibility: per-model in-flight requests (gateway_model_in_flight_requests), global in-flight (gateway_in_flight_requests), PD prefill outstanding (gateway_prefill_outstanding_requests), summable token usage (gateway_input_tokens_total, gateway_output_tokens_total, gateway_requests_with_usage_total), and ready engine replica counts (model_replicas).
  • Improve latency metric accuracy for streaming: record first-token time on the initial response chunk, use it for TTFT buckets, emit TPOT buckets, and apply coarser end-to-end total-time bucketing.
  • Overhaul the Grafana dashboard into an engine-agnostic SLO view with $model filtering, parameterized datasource, and collapsed developer internals; remove unused metrics (gateway_e2e_duration_seconds, aggregate success/fail counters, gateway_decode_outstanding_requests).

Details

Gateway Plugin

  • Track and emit global and per-model in-flight request gauges for the lifetime of each request.
  • Emit input/output token counters and a has_usage counter when usage is present in responses.
  • Fix streaming TTFT by setting RoutingContext.FirstTokenTime on the first streamed body chunk and propagating Stream from the request body handler.
  • Emit TPOT bucket metrics for PD and non-PD streaming paths.
  • Use role-name pod label (fallback: ROLE_NAME env) for metric labels.

Cache

  • Emit model_replicas=1 for each ready, routable engine pod (HTTP server on pod group index 0), with stale-series cleanup when pods leave the cache.

PD Disaggregation

  • Track and emit gateway_prefill_outstanding_requests around prefill RPCs.

Prefix Cache

  • Use _init_ instead of an empty model label for indexer status metrics.

Grafana

  • Reorganize panels into Service Health, Latency SLOs, Token Throughput, Prefix Cache, PD Disaggregation, and collapsed Engine Internals / Gateway Infrastructure sections.
  • Wire panels to the new and existing gateway metrics with $model template variable support.

Related Issues

Resolves: #[Insert issue number(s)]

Important: Before submitting, please complete the description above and review the checklist below.

Contribution Guidelines (Expand for Details)

We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:

Pull Request Title Format

Your PR title should start with one of these prefixes to indicate the nature of the change:

  • [Bug]: Corrections to existing functionality
  • [CI]: Changes to build process or CI pipeline
  • [Docs]: Updates or additions to documentation
  • [API]: Modifications to aibrix's API or interface
  • [CLI]: Changes or additions to the Command Line Interface
  • [Misc]: For changes not covered above (use sparingly)

Note: For changes spanning multiple categories, use multiple prefixes in order of importance.

Submission Checklist

  • PR title includes appropriate prefix(es)
  • Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several enhancements to the gateway and model metrics tracking, including the addition of model replica metrics, in-flight request tracking per model, and token usage counters. It also improves the accuracy of streaming metrics like Time to First Token (TTFT) and Time Per Output Token (TPOT). The review feedback highlights two potential metric leak issues: one where a model name change during the request lifecycle could leak in-flight counts, and another where a panic during a prefill request could prevent the outstanding prefill counter from being decremented. Robust code suggestions using dynamic tracking and defer blocks are provided to address these concerns.

Comment thread pkg/plugins/gateway/gateway.go
Comment thread pkg/plugins/gateway/algorithms/pd_disaggregation.go Outdated
@varungup90
varungup90 force-pushed the feat/refine-metrics-dashboard branch 2 times, most recently from 2899419 to eef85c3 Compare June 25, 2026 05:36

@Jeffwan Jeffwan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Jeffwan

Jeffwan commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

@varungup90 there's some conflicts needs to be resolved

… Grafana dashboard

Signed-off-by: varungupta <varungup90@gmail.com>
Signed-off-by: varungupta <varungup90@gmail.com>
Signed-off-by: varungupta <varungup90@gmail.com>
@varungup90
varungup90 force-pushed the feat/refine-metrics-dashboard branch from eef85c3 to 4874145 Compare July 23, 2026 21:30
- Replace atomic-counter + Set() snapshots for gateway_in_flight_requests
  and gateway_model_in_flight_requests with direct IncGaugeMetric/
  DecGaugeMetric calls, matching the prefill-outstanding gauge and
  avoiding stale-snapshot races under concurrency.
- Fix streaming PD decode_time collapsing to ~0: the caller was passing
  FirstTokenTime itself as requestEndHelper's arrival, so
  arrival.Sub(FirstTokenTime) always computed zero. Pass the real final
  chunk arrival instead; TTFT already derives from routingCtx.FirstTokenTime
  internally.
- Emit gateway_tpot_bucket_total for the PD streaming path, which
  previously only the non-PD branch reported.

Signed-off-by: varungupta <varungup90@gmail.com>
@varungup90
varungup90 force-pushed the feat/refine-metrics-dashboard branch from 8c07d93 to e16d514 Compare July 23, 2026 21:47
Signed-off-by: varungupta <varungup90@gmail.com>
@varungup90
varungup90 merged commit eb47500 into vllm-project:main Jul 23, 2026
13 checks passed
@varungup90
varungup90 deleted the feat/refine-metrics-dashboard branch July 23, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants