Repository navigation
fix(shell): Label shell-session metrics by project, not namespace - #668
Merged
Merged
Conversation
The project label on compute_shell_sessions_created_total and compute_shell_sessions_open names the session's namespace. Every project keeps its sessions in its default namespace, so two projects count as one series. This test is red until the label names the project. Refs #667
compute_shell_sessions_created_total and compute_shell_sessions_open labelled each session with its namespace under the name project. Every project keeps its sessions in its default namespace, so in production every series read project="default", and the runbook's "Which projects" query for ComputeShellSessionVolumeUnusual could not name a project. Both series now take the project's cluster name from the reconcile request. In Milo mode it is the project's name, and other controllers here use it as the project ID. The number of series stays bounded by the number of projects. The open-sessions update moves out of Reconcile into trackOpenSession, which takes the cluster name. Fixes #667
ecv
approved these changes
Nov 25, 2026
ecv
left a comment
Contributor
There was a problem hiding this comment.
Approve.
The project label now carries the project's cluster name on both the created counter and the open gauge, and the new test proves two projects with same-named namespaces become separate series. Reconcile returns early on an empty cluster name (controller.go:97), so the label is never empty, and a delete and an end both go through the same tracker, which recomputes the gauge from stored series, so the gauge cannot drift from the counter's label.
- Every consumer in this repo already queries
project(shell-sessions dashboard jsonnet and generated JSON, volume-unusual runbook'ssum by (project)) and none filters on a namespace value, so nothing needs changing. Alerts aggregate bylocationonly. A search of datum-cloud/infra found nocompute_shell_sessions_*references. - Cardinality is bounded by project count times locations, same as before in kind, and the tracker deletes series with no sessions left.
Follow-ups:
- Existing series history flips meaning at deploy (namespace value to project name), so a dashboard range spanning the roll shows both. Worth a line in the release note.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The shell-session metrics label each session with its namespace, under the label name
project. Every project keeps its sessions in itsdefaultnamespace, so the label does not tell one project from another. The "Which projects" query in theComputeShellSessionVolumeUnusualrunbook cannot answer its question.This change labels
compute_shell_sessions_created_totalandcompute_shell_sessions_openwith the project's cluster name, which the reconciler gets with each request. With the Milo provider, the cluster name is the project's name: the provider keys each cluster by project name, and the Internal DNS publisher uses it as the project ID. The number of series stays bounded by the number of projects.projectlabel on the counter and the open-sessions gaugedefaultThe runbook's query and the dashboard's project filter read this label. The alert reads a recording rule that sums the label away, so the alert does not change.
Test.
TestInstanceConsoleSessionMetricsLabelTheProjectdelivers one session in each of two projects, in namespaces with the same name. It reads two series of each metric. When one project's session goes, only that project's open series goes. Onmainthe test reads one series.The open-sessions update moves out of
ReconcileintotrackOpenSession, which takes the cluster name.Draft #465 changes the same line in
deliver: it puts thesessionsCreatedincrement underif firstDelivery. The second of the two to merge resolves that one conflict and keeps both changes:Fixes #667