Skip to content

feat(cli): devops-cli dashboards chart the metrics the cli sends and the grafana sidecar provisions them #692

Closed

Description

@dan-petty

Context & Rationale

devops-cli already ships two dashboards for itself, k8s/monitoring/dashboards/devops-cli.json and ai-spend.json. It also ships the devops grafana dashboards commands list, export, import, sync and lint (src/devops_cli/commands/grafana.py:81, 120, 165, 226, 308).

devops-cli sends eight delta counters and histograms, called INSTRUMENTS (src/devops_cli/telemetry/instruments.py:96-105). Only these may appear in a dashboard query (instruments.py:5-6). The collector's deltatocumulative processor adds each series' deltas up before Prometheus stores them (k8s/otel/values.yaml:58-62, 79-84).

Everything else devops-cli sends is a single-point gauge, sent through record_metric (src/devops_cli/telemetry/tracer.py:909-925). Examples:

  • devops_cli_subcommand_seconds (src/devops_cli/core/cli.py:26-71)
  • cli.command.total (core/command_decorator.py:24-51)
  • devops_cli_embedding_cache_hits_total (ai/rag/embeddings.py:567-568)
  • devops_cli_llm_cache_hits (ai/response_cache.py:217, 232)

Each command runs as its own short-lived process, so a gauge holds only the last process's value and can't be added up across runs. No dashboard reads one.

Measured against that code:

  • Sent but never charted.

    • Every command run sends devops_cli_command_duration_seconds (src/devops_cli/main.py:141, 157, 175), except --help (main.py:91-97) and global --dry-run (core/cli.py:129-134). No panel reads it.
    • The status label on devops_cli_command_total (main.py:133-140) is never charted.
    • The severity label on devops_cli_findings_total (src/devops_cli/ai/review/runner.py:2000-2007) is never charted.
    • Review volume by target_type (devops_cli_review_duration_seconds_count, runner.py:1999) is never charted.
    • Review time and RAG time are histograms (instruments.py:43-45), but the dashboard shows only their means (devops-cli.json:59, 82).
  • "Lifetime" totals aren't lifetime totals. Seven panels sum a raw counter:

    • in devops-cli.json: "Findings by Persona", "Findings by Status" and "Total Lifetime AI Spend" (devops-cli.json:112, 135, 178);
    • in ai-spend.json: "Total Lifetime Spend", "Total AI Requests", "Total Tokens Processed" and "Cumulative Spend by Backend Server" (ai-spend.json:82, 129, 176, 324).

    A series that sits idle for an hour starts again from zero (k8s/otel/values.yaml:58-62). These panels therefore show the count since the last reset.

  • devops-cli's own dashboards are never provisioned.

    • Only the four k8s-views-* dashboards are packaged for the Grafana sidecar. They sit in two hand-made ConfigMaps (k8s/monitoring/k8s-global-dashboards-configmap.yaml, k8s-node-dashboards-configmap.yaml, 395 KB together). Each value matches its JSON file except for the file's trailing newline. Both ConfigMaps carry three labels: grafana_dashboard, app.kubernetes.io/name and app.kubernetes.io/part-of (k8s-global-dashboards-configmap.yaml:6-9).
    • Only k8s/monitoring/kustomization.yaml:8-9 lists those ConfigMaps, and nothing applies that file. devops k8s deploy-stack runs kubectl apply -k <k8s_dir> on the root kustomization, which holds only namespaces, cloudflared and registry (k8s/kustomization.yaml:4-7; src/devops_cli/commands/k8s/stack_lifecycle.py:740). It also runs kubectl apply -f on _MANIFESTS_BY_STACK (stack_lifecycle.py:130-146, 531-535). The ArgoCD path is broken too (feat(k8s): argo cd keeps the homelab cluster at the current release branch, with automated sync, prune and self-heal that never delete data #755).
    • devops-cli.json and ai-spend.json reach Grafana only when someone runs devops grafana dashboards sync with a token.
  • sync hides failures. When a file fails, sync prints an error and moves on. At the end it prints "completed" and exits 0 (grafana.py:274-281), so a run in which every file failed looks like a success.

  • lint checks one file at a time (grafana.py:344). It reports a missing uid (src/devops_cli/grafana/linter.py:30-38), but two files with the same uid overwrite each other in Grafana without any warning. lint --json also returns before the error check (grafana.py:346-347, against the exit at :369), so it exits 0 whatever it finds.

Most of the requested portfolio has no data source (see Key question 1), so this item is cut to the slice the code can feed today.

Scope & Deliverables

  • Deliverable:
    • New and changed panels in devops-cli.json. Each new time series uses a 1h window (Key question 4).
      • Command latency p50, p95 and p99 by command: histogram_quantile(q, sum by (le, command) (increase(devops_cli_command_duration_seconds_bucket[1h]))).
      • Error share by command: sum by (command) (increase(devops_cli_command_total{status="error"}[1h])) / sum by (command) (increase(devops_cli_command_total[1h])).
      • Review volume by target_type (branch, pr or path, runner.py:2017): sum by (target_type) (increase(devops_cli_review_duration_seconds_count[1h])).
      • Findings by severity as a stacked time series: sum by (severity) (increase(devops_cli_findings_total[1h])).
      • "AI Review Duration" (devops-cli.json:54-59) becomes review p50 and p95 by target_type, over devops_cli_review_duration_seconds_bucket.
      • "RAG Query Latency" (:77-82) becomes RAG p50 and p95, over devops_cli_rag_query_duration_ms_bucket.
      • Both rebuilt panels keep their place on the grid.
    • The seven raw-counter panels listed above change in two ways.
      • The four stat totals become increase(...[$__range]) and are retitled "in range" instead of "lifetime".
      • The three time series become per-hour increase(...[1h]).
    • Panel descriptions. Every new or changed panel states the limits listed under Constraint.
    • Provisioning.
      • A new k8s/monitoring/dashboards/kustomization.yaml has a configMapGenerator:
        • in namespace monitoring, with disableNameSuffixHash: true;
        • carrying the same three labels as today's ConfigMaps: grafana_dashboard: "1", app.kubernetes.io/name: grafana and app.kubernetes.io/part-of: devops-cli-stack.
      • It generates grafana-k8s-global-dashboards (k8s-views-global, k8s-views-pods) and grafana-k8s-node-dashboards (k8s-views-nodes, k8s-views-namespaces), with the same names and groupings as today. It adds a new grafana-devops-cli-dashboards (devops-cli, ai-spend).
      • The two hand-copied ConfigMap YAMLs are deleted, and k8s/monitoring/kustomization.yaml lists dashboards in their place.
      • The root k8s/kustomization.yaml lists monitoring/dashboards. deploy-stack's existing kubectl apply -k <k8s_dir> step (stack_lifecycle.py:740) then applies the ConfigMaps in the same run that creates the monitoring namespace (k8s/namespaces.yaml:14-22). Teardown already removes them, by delete -k for all or by deleting the namespace for infra (stack_lifecycle.py:810-835). No deploy-stack code changes (Key question 8).
    • devops grafana dashboards sync.
      • It still tries every file, and exits 1 if any file failed.
      • A dashboard that Grafana refuses to overwrite because it is provisioned counts as skipped, not failed. When a post fails with HTTP 400, sync reads GET /api/dashboards/uid/<uid>. If meta.provisioned is true, it reports the file as skipped.
      • The summary line gives the synced, skipped and failed counts. It exits 0 when the only files not synced were skipped.
    • devops grafana dashboards lint.
      • When two dashboards in the set being checked share a uid, each file's report gets an error that names the other file.
      • lint --json exits 1 when any report has an error, as the table output already does.
    • Docs and records.
      • In k8s/README.md, the monitoring/ subtree (k8s/README.md:249-253) is rewritten to match the directory after this change, including dashboards/ and its kustomization.yaml.
      • A short section says how dashboards reach Grafana: the sidecar label for the six provisioned files, and sync for the rest.
      • The two vLLM lines in the tree (k8s/README.md:267-268) are deleted. vLLM was removed in ea49d6e (v0.2.23), and k8s/llm/vllm/ doesn't exist. The GPU-placement section at :120-126 belongs to fix(k8s): deploy-stack applies the llm gateway policy and narrows its egress #795.
      • The ROADMAP entry (docs/ROADMAP.md:655-664) and the task file are rewritten to this scope at Priority P2 (Key question 16).
      • CHANGELOG gets an [Unreleased] entry, and devops docs generate --sync-readme is re-run.
  • Acceptance criteria:
    • test_every_dashboard_query_names_a_metric_devops_cli_sends (tests/test_telemetry_instruments.py:47-58) gets its list of files by globbing k8s/monitoring/dashboards/*.json and keeping each file with a devops_cli_ query. Today that selects exactly devops-cli.json and ai-spend.json, and both pass with the new panels.
    • A test checks the series named in devops-cli.json and ai-spend.json. These are each instrument's series: the counter names and each histogram's _bucket, _sum and _count. Wherever one appears, it is the first argument of rate( or increase(.
    • A test asserts that each of these appears in a panel query:
      • devops_cli_command_duration_seconds_bucket
      • devops_cli_command_total{status="error"}
      • devops_cli_review_duration_seconds_count, grouped by target_type
      • devops_cli_review_duration_seconds_bucket
      • devops_cli_findings_total, grouped by severity
      • devops_cli_rag_query_duration_ms_bucket
    • devops grafana dashboards lint k8s/monitoring/dashboards reports 0 errors, and tests/test_grafana_dashboards.py:195 still passes.
    • A test parses k8s/monitoring/dashboards/kustomization.yaml in Python, without kustomize. It checks that:
      • the generator produces the three named ConfigMaps from exactly the six files above;
      • each is in namespace monitoring with the three labels;
      • every other *.json in the directory is llm-stack.json or otel-collector.json, so a new dashboard can't be left out by accident;
      • each generated ConfigMap object, serialised as compact JSON, is under 262,144 bytes. That is how kubectl's last-applied annotation stores it, and 262,144 bytes is the annotation limit f93231b split the views for. The proposed groups measure 166,909, 198,264 and 19,753 bytes today.
    • A test asserts that k8s/kustomization.yaml lists monitoring/dashboards, and that every resource it lists exists on disk. tests/test_k8s_cloudflared.py:34-35 is the precedent.
    • A reviewer runs kubectl kustomize k8s/monitoring. The two existing ConfigMaps keep their names and labels, and each data value parses to the same JSON as today. grafana-devops-cli-dashboards is there too, and kubectl kustomize k8s includes all three.
    • Three sync tests:
      • Against a stub client that fails one post with a 500, sync exits 1, and the other files are still posted.
      • Against a stub that answers one post with a 400 and the matching GET with meta.provisioned: true, sync exits 0 and reports that file as skipped.
      • When every post succeeds, sync exits 0, and tests/test_grafana.py:42 passes unchanged. Its stub has no get, and get is called only after a 400.
    • dashboards lint on a temporary directory holding two files with the same uid exits 1 and names both files. With --json it also exits 1, and the error appears under both files.
    • uv run devops ci passes.
    • Manual check, when the cluster is available. Run devops k8s deploy-stack --stack infra, devops telemetry connect and one command. Then devops prometheus query 'devops_cli_command_total' returns a series, and Grafana lists "devops-cli Telemetry" and "AI Spend & LLM Usage Telemetry" without anyone running sync. If the query comes back empty, first suspect the collector's remote-write target (k8s/otel/values.yaml:80, Alloy on port 9090). The repo can't confirm that Alloy listens on that port, and fixing it is a follow-up, not this PR.
  • Key questions:
    1. Which of the requested dashboards get built? (proposed) None of the four new files (ai-constellation.json, ai-review.json, github-agentic.json, loki-incident-triage.json). Each asks mostly for data that nothing produces:

      • Slot leases and priority queues live only in per-process dicts that nothing reads (src/devops_cli/ai/client/network.py:31-41, 239-248).
      • The constellation is now only a quiesce flag (adf7d96, feat(telemetry): harness, constellation and telemetry profile report only what actually ran #710).
      • TTFT is a span attribute, not a metric (ai/client/unified.py:758-759).
      • Vector-cache hits exist only as gauges (ai/rag/embeddings.py:567-568, ai/rag/cache.py:51, 54), which dashboards may not query.
      • The LLM response-cache hit share would always read 0, because cached="true" is never sent:
        • A cache hit returns at unified.py:694-696, before _record_response_telemetry_and_spend. That is the only call that passes cached=res.cached to track_request_spend (unified.py:441-449).
        • The stream path and ai/direct.py:118, 163 never pass it (unified.py:836-844).
      • Review classification context is not a metric label (ai/review/classification.py:121-122).
      • INVALIDATED findings are dropped before metrics are recorded (ai/review/pipeline.py:2840-2846).
      • GitHub quota is kept in a local JSON file (github/rate_limiter.py:320-345).
      • devops-cli exports no logs, only /v1/metrics and /v1/traces (telemetry/tracer.py:890, 1128).

      The parts that do have data become panels in the two existing dashboards. The rest are split off.

    2. How are "exit code distributions" charted? (proposed) As status (ok or error), the only outcome label devops_cli_command_total carries (main.py:133-140). Exit codes stay on the cli.exit_code span attribute (main.py:126).

    3. What about "subcommand invocation frequency"? The command label holds the top-level group (core/cli.py:123, 139). Per-leaf data exists only as the devops_cli_subcommand_seconds gauge, keyed by the leaf name (core/cli.py:26-71, 158), and dashboards may not query gauges (instruments.py:5-6). (proposed) Chart by group. Adding a leaf label to devops_cli_command_total is outside this item.

    4. What window do the new panels use? (proposed) 1h. increase() needs two samples of a series inside its window, and devops-cli sends a point only when a command runs (instruments.py:1-7), so a 5m window over a workstation's occasional runs is mostly empty. The existing 5m rate panels (devops-cli.json:201; ai-spend.json:223, 280, 381, 426) stay as they are.

    5. Is there a severity heatmap? (proposed) No, a stacked time series by severity. Severity is a counter label, not a histogram bucket, so there is nothing to draw as a heatmap.

    6. Do the mean panels stay next to the new percentiles? (proposed) No. p50 and p95 replace the means in place, which keeps the panel count and layout.

    7. Do dashboards need ${DS_PROMETHEUS}/${DS_LOKI} parameters? (proposed) No. Grafana provisions Prometheus, Loki and Jaeger with the fixed uids prometheus, loki and jaeger (k8s/monitoring/grafana-values.yaml:36-59), and the devops dashboards bind uid: prometheus. The k8s-views dashboards keep their own datasource template variable.

    8. Where is provisioning applied from? (proposed) From the root kustomization, which deploy-stack already applies with --k8s-dir honoured (stack_lifecycle.py:740).

    9. Why keep the two existing ConfigMap groups instead of one ConfigMap per file? (proposed) With the same names, a re-apply updates them in place. New names would leave the old ConfigMaps behind, and the sidecar would load the same uids twice.

    10. Which dashboards are provisioned? (proposed) The four k8s-views, devops-cli.json and ai-spend.json. Both of the others stay reachable through sync:

    11. Should there be a validate command or just lint? (proposed) Keep lint (grafana.py:308) and add no alias, since there are no shims before 1.0. It already checks uid presence, panel ids, grid fit and overlap, PromQL, refIds and datasource binding (linter.py:30-136). This item adds the cross-file uid check and the --json exit code.

    12. Is there a span-waterfall panel? (proposed) No. The linter rejects a target without expr (linter.py:110). devops telemetry profile already reads traces back from Jaeger (telemetry/waterfall.py:165), and Grafana's Jaeger datasource is provisioned.

    13. What happens to "Findings by Persona"? (proposed) It stays, with its query changed to increase. Until fix(review): review pr --post --no-reporting posts zero findings and metrics lose the persona #791 lands, it puts every finding under the requested persona, or under devsecops by default (runner.py:2084, 2095). This item adds no persona panel, so fix(review): review pr --post --no-reporting posts zero findings and metrics lose the persona #791 is not a dependency.

    14. How does sync treat provisioned dashboards? grafana-values.yaml:85-92 doesn't set sidecar.dashboards.provider.allowUiUpdates, so the chart default (off) applies. With it off, Grafana refuses an API save over a provisioned uid. Without handling, the new exit-1 rule would make every sync against the stack's Grafana fail. (proposed) Skip by meta.provisioned, not by matching the error text. Don't turn on allowUiUpdates, because then the ConfigMap and the API would both be sources of truth.

    15. Does docs/TELEMETRY.md change? (proposed) No. It is generated from INSTRUMENTS (src/devops_cli/docs/generator.py:884-919, 1007), and tests/test_docs.py:433-442 pins its table. This item adds no instrument.

    16. What Priority does the item have? (proposed) P2 (medium), to match Value Medium. It is a feature, not a Critical fix (CONTEXT.md:75-77). Three records still say P0 and change in this refinement: the priority/p0-critical label, the ROADMAP heading's "(P0 - Critical)" (docs/ROADMAP.md:655) and the task file's Priority line (docs/agent/tasks/task-692-comprehensive-devops-cli-grafana-observability-dashboard-sui.md:6-7).

  • Constraint:
    • Every new or changed panel reads only series listed in INSTRUMENTS (instruments.py:96-105).
    • No panel or ConfigMap covers a removed component: vLLM, LightLLM, Squid or kube-prometheus-stack. The sidecar is configured in grafana-values.yaml:85-92. prometheus-values.yaml is now the plain Prometheus server chart (prometheus-values.yaml:1-3).
    • Tests never run kustomize, kubectl, helm or Grafana, and never touch the network.
    • Panel descriptions say the values are approximate and undercount sparse series, for three reasons:
    • A quantile past the top bucket comes out as that bucket's bound: 600 s for commands, 7200 s for reviews and 5000 ms for RAG (instruments.py:43-45). Bucket bounds stay as they are, and each latency panel's description states its cap.
    • The item is delivered in exactly one PR.

Strategic Alignment

Activity

  1. added this to the v0.2.24 milestone on Sep 28, 2026
  2. added
    type/feature
    scope/cli
    priority/p0-critical
    on Sep 28, 2026
  3. changed the title [-]feat(cli): comprehensive devops cli grafana observability dashboard suite & gitops provisioner (`devops grafana dashboards sync`)[/-] [+]feat(cli): devops-cli dashboards chart the metrics the cli sends and the grafana sidecar provisions them[/+] on Oct 1, 2026
  4. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    The split-offs from this item's refinement are filed: candidate findings by verdict #812, devops-cli logs to Loki #813, GitHub API request and throttle counters #814, LLM slot wait time #815, the response-cache counting defect #816, embedding-cache counters #817, and dropping the kube-prometheus-stack service aliases #818.

  5. added
    priority/p2-medium
    and removed
    priority/p0-critical
    on Oct 1, 2026
  6. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    Relabelled from priority/p0-critical to priority/p2-medium, as this item's refinement proposes: it is a feature, not a critical fix. It stays in v0.2.24, which it was already in when the release started.

  7. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    Closed by #831, merged into release/v0.2.24.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

  8. added a commit that references this issue on Oct 1, 2026
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

    priority/p2-mediumscope/clitype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions