← Back to Pull requests

Collect metrics from every inference cluster #470

Closed
unknown closed this pull request without merging on Oct 02, 2026 18:49 UTC
View on GitHub
unknown unknown commented on Sep 28, 2026 15:44 UTC
Author

Description of your changes

#363 described how a fleet's metrics get off its clusters and onto one surface. Nothing implemented it, so a platform engineer had no way to read an engine, a gateway or a GPU across clusters, and the names they would read differed per engine anyway.

This composes an OpenTelemetry collector onto every InferenceCluster and gives it two kinds to read. A MetricMapping says what a component emits and what Modelplane calls it: from, to, fromUnit where the source is measured in something other than the target name claims, and labels and part for the series that need several of a component's metrics to become one of Modelplane's. A TelemetryDestination says where it goes: name, type, endpoint, secretRef and auth are fields, and everything else an exporter takes passes through unread, because that schema is OpenTelemetry's and moves on its own schedule. Several can exist and their sinks are concatenated, so a second backend is a new object rather than an edit to one somebody else owns, and the credential named by a secretRef is copied from the control plane to each cluster that mounts it.

The function compiles a mapping to OTTL rather than an operator writing it, which keeps the collector's configuration language out of a Modelplane API and leaves room to render something else later. Five built-in mappings carry 32 metrics off vLLM, SGLang, the gateway, the picker and DCGM. Only modelplane_ leaves a cluster. The collector does not count towards a ServingStack's readiness: nothing serving depends on it, and a destination pointing somewhere unreachable should not stop the scheduler placing replicas.

Each replica publishes its own series, told apart by a replica label, and a query over a deployment combines them - sum by (deployment) for anything counted, avg for a ratio. The collector does not combine them, because a scrape of one replica is one batch and adding two cumulative readings taken at different moments is not the traffic that happened. The label is the replica's index rather than its pod, so it is bounded by the replica count and survives a restart and a rolling update.

That is 23 of the 50 metrics #363 describes, which is everything reachable by renaming one metric to one name. #476 lists the rest; most of it needs per-object state from resource-state-metrics rather than anything here.

The endpoint picker, the credential path and multiple destinations are verified on that cluster too: modelplane_route_decision_seconds arrives labelled role=picker once the gateway routes a request, a sink's secretRef Secret written only on the control plane turns up in modelplane-system on the GPU cluster with the collector mounting it, and two TelemetryDestinations render one config carrying both sinks.

It also fixes cross-cluster routing on GKE, because the gateway metrics depend on it. A cluster gateway's name was published as a headless Service and an EndpointSlice, and kube-dns builds its records from the Endpoints API and was never taught the slice one. GKE runs kube-dns, so the name answered NXDOMAIN, Envoy resolved no address for the backend, and every cross-cluster request was refused with no healthy upstream. kind runs CoreDNS, which reads the slice, which is why CI has never seen it. #486 has the detail.

Verification

Run on a GKE cluster with two L4s, vLLM serving Qwen2.5-0.5B, two replicas, loaded to saturation, and later alongside SGLang on the second GPU. Everything here is modelplane_ arriving through the composed collector.

!Modelplane telemetry in Grafana

Each layer caught what the one before it couldn't. The collector's own validate caught a value rewrite rendered into a context that cannot reach values. The local two-cluster e2e, which --verify now gates on, caught an engine scrape job matching a label value that never existed, an unnamed engine port, a gateway job asking Envoy for a path it 404s on, a substrate job ignoring prometheus.io/port beside the annotation it honoured, and every series labelled with a generated name rather than the cluster's. Real GPU hardware caught every modelplane_gpu_* series arriving empty, because nothing annotates DCGM for scraping and GKE runs its own. A second replica caught two replicas colliding into one series: the engines held 300 and 4640 prefix-cache lookups and the series read 300. Reading a Grafana dashboard caught Prometheus receiving every series stripped of its identity, since that identity is resource attributes and the remote-write exporter drops those unless asked. Running the collector against a rendered config caught scale_metric refusing an integer factor, which would have stopped it starting on any fleet converting mebibytes; feeding it a histogram in milliseconds confirmed the sum, the bounds and the bucket counts all come out converted, which the previous datapoint rewrite never reached.

Running a second engine found more. SGLang v0.4.9.post2 on the same cluster publishes three of the eight metrics its built-in named and no others: sglang:queue_time_seconds and both retraction counters don't exist at that version, or at v0.4.6 or v0.5.0, so those mappings could never match. Its two token histograms are real but need --collect-tokens-histogram beside --enable-metrics, which the guide didn't say. And a MetricMapping stored before a field became required took the whole ServingStack to ReconcileError: a CRD validates on write, not on what it already holds, so the stale object parses straight into a ValidationError and fails the pipeline step. A telemetry object now gets dropped with a warning rather than stopping the fleet placing replicas.

labels and part have no built-in using them, but both are exercised on a cluster. A mapping folding SGLang's prompt and generation counters onto one name gives modelplane_tokens_total{direction="input"} 398 and {direction="output"} 607; part: Count over its latency histogram gives modelplane_engine_requests_total 12, matching the requests sent; and a values remap turns engine_type="unified" into engine_kind="Unified" and drops the original. They are what the counters in #363 need - tokens by direction, responses by reason, requests by status.

One thing I have not done: the gateway's time-to-first-token and time-per-output-token exist only for streaming requests, and I have not driven one.

I have: <!-- You MUST either [x] check or [ ] ~strike through~ every item. -->

  • Read and followed Modelplane's contribution process.

  • Run nix flake check (or ./nix.sh flake check) and made sure it passes.

  • Added or updated tests covering any composition function changes.

  • Signed off every commit with git commit -s.
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: lsviben Review duration: 5944m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #470"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%