[PR #351] [MERGED] fix(observability): correct Claude Code dashboard queries against live telemetry #96

Closed
opened 2026-06-08 08:29:55 +00:00 by ryangr0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/webgrip/homelab-cluster/pull/351
Author: @Ryangr0
Created: 6/7/2026
Status: Merged
Merged: 6/7/2026
Merged by: @Ryangr0

Base: mainHead: fix/claude-code-dashboard-queries


📝 Commits (1)

  • 90750e9 fix(observability): correct Claude Code dashboard queries against live telemetry

📊 Changes

4 files changed (+19 additions, -19 deletions)

View changed files

📝 kubernetes/apps/observability/grafana/app/dashboards/claude-code-activity-tools.yaml (+8 -8)
📝 kubernetes/apps/observability/grafana/app/dashboards/claude-code-command-center.yaml (+5 -5)
📝 kubernetes/apps/observability/grafana/app/dashboards/claude-code-cost-tokens.yaml (+4 -4)
📝 kubernetes/apps/observability/grafana/app/dashboards/claude-code-events-traces.yaml (+2 -2)

📄 Description

Follow-up to #350. Now that Claude Code telemetry is actually flowing (service.name=claude-code), I verified every query class against live data and fixed two issues the documented schema didn't surface.

Fixes

  • active_time metric name — it is claude_code_active_time_seconds_total (not the guessed _active_time_total_seconds_total); dropped the dead fallback. Affects 4 panels across all dashboards. (cost_usage_USD_total / token_usage_tokens_total / session_count_total were already exact.)
  • Loki events nest fields under attributes.* — a bare | json explodes every attribute into a stream label, which silently broke quantile_over_time/unwrap (returned per-line raw values instead of an aggregate). Switched all aggregation queries to explicit extraction, e.g. | json duration_ms="attributes.duration_ms" | unwrap duration_ms. Logs panels keep bare | json (display only).
  • Nested JSON strings — MCP tool name, Bash full_command, and edited file_path live inside attributes.tool_parameters / attributes.tool_input; extracted via line_format "{{.x}}" | json field="field" re-parse.

Verified live (via Grafana MCP)

  • "Top files edited" returns the actual dashboard files with edit counts.
  • "Tool success ratio" returns Edit/mcp_tool/Bash all succeeding.
  • quantile_over_time on attributes_duration_ms returns a single clean p90.

Notes

  • active_time / lines_of_code / commit / pull_request / code_edit_tool.decision populate as those events occur (none yet in the initial SDK session — not a query bug).
  • Some MCP server names render as custom (Claude Code redacts user-configured MCP server names by default).

Validation: inline dashboard JSON parses, unique panel IDs, $$-escaped macros intact; kustomize build kubernetes/apps/observability/grafana/app is clean (35 dashboards / 10 folders).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/webgrip/homelab-cluster/pull/351 **Author:** [@Ryangr0](https://github.com/Ryangr0) **Created:** 6/7/2026 **Status:** ✅ Merged **Merged:** 6/7/2026 **Merged by:** [@Ryangr0](https://github.com/Ryangr0) **Base:** `main` ← **Head:** `fix/claude-code-dashboard-queries` --- ### 📝 Commits (1) - [`90750e9`](https://github.com/webgrip/homelab-cluster/commit/90750e907ca3c8b366a35e42125efd76d26f35f0) fix(observability): correct Claude Code dashboard queries against live telemetry ### 📊 Changes **4 files changed** (+19 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `kubernetes/apps/observability/grafana/app/dashboards/claude-code-activity-tools.yaml` (+8 -8) 📝 `kubernetes/apps/observability/grafana/app/dashboards/claude-code-command-center.yaml` (+5 -5) 📝 `kubernetes/apps/observability/grafana/app/dashboards/claude-code-cost-tokens.yaml` (+4 -4) 📝 `kubernetes/apps/observability/grafana/app/dashboards/claude-code-events-traces.yaml` (+2 -2) </details> ### 📄 Description Follow-up to #350. Now that Claude Code telemetry is actually flowing (`service.name=claude-code`), I verified every query class against live data and fixed two issues the documented schema didn't surface. ## Fixes - **`active_time` metric name** — it is `claude_code_active_time_seconds_total` (not the guessed `_active_time_total_seconds_total`); dropped the dead fallback. Affects 4 panels across all dashboards. (`cost_usage_USD_total` / `token_usage_tokens_total` / `session_count_total` were already exact.) - **Loki events nest fields under `attributes.*`** — a bare `| json` explodes every attribute into a stream label, which silently broke `quantile_over_time`/`unwrap` (returned per-line raw values instead of an aggregate). Switched all aggregation queries to explicit extraction, e.g. `| json duration_ms="attributes.duration_ms" | unwrap duration_ms`. Logs panels keep bare `| json` (display only). - **Nested JSON strings** — MCP tool name, Bash `full_command`, and edited `file_path` live inside `attributes.tool_parameters` / `attributes.tool_input`; extracted via `line_format "{{.x}}" | json field="field"` re-parse. ## Verified live (via Grafana MCP) - "Top files edited" returns the actual dashboard files with edit counts. - "Tool success ratio" returns Edit/mcp_tool/Bash all succeeding. - `quantile_over_time` on `attributes_duration_ms` returns a single clean p90. ## Notes - `active_time` / `lines_of_code` / `commit` / `pull_request` / `code_edit_tool.decision` populate as those events occur (none yet in the initial SDK session — not a query bug). - Some MCP server names render as `custom` (Claude Code redacts user-configured MCP server names by default). Validation: inline dashboard JSON parses, unique panel IDs, `$$`-escaped macros intact; `kustomize build kubernetes/apps/observability/grafana/app` is clean (35 dashboards / 10 folders). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
ryangr0 2026-06-08 08:29:55 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
webgrip/homelab-cluster#96
No description provided.