feat(metrics): expose query-metrics and metric-names-list MCP tools#63130
feat(metrics): expose query-metrics and metric-names-list MCP tools#63130DanielVisca wants to merge 3 commits into
Conversation
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
products/metrics/mcp/prompts/metric-names-list.md:7-9
Missing aggregation guidance for two listed types
The prompt enumerates five OTel types — `gauge`, `sum`, `histogram`, `summary`, `exponential_histogram` — but the aggregation bullet-list at the end only covers three of them. An LLM that encounters a `summary` or `exponential_histogram` metric has no guidance from this prompt and may silently guess the wrong aggregation. The same gap exists in `query-metrics.md` under "Pick the aggregation by metric type". Adding a bullet for each missing type (e.g. `summary`: use `avg` or `p95`; `exponential_histogram`: use `histogram_quantile`) would make the instructions complete.
Reviews (1): Last reviewed commit: "feat(metrics): expose query-metrics and ..." | Re-trigger Greptile |
| - `sum` (counters, usually `_total`-suffixed): use `rate` or `increase` | ||
| - `gauge`: use `avg`, `p95`, or `sum` | ||
| - `histogram`: use `histogram_quantile` with a `quantile` |
There was a problem hiding this comment.
Missing aggregation guidance for two listed types
The prompt enumerates five OTel types — gauge, sum, histogram, summary, exponential_histogram — but the aggregation bullet-list at the end only covers three of them. An LLM that encounters a summary or exponential_histogram metric has no guidance from this prompt and may silently guess the wrong aggregation. The same gap exists in query-metrics.md under "Pick the aggregation by metric type". Adding a bullet for each missing type (e.g. summary: use avg or p95; exponential_histogram: use histogram_quantile) would make the instructions complete.
Prompt To Fix With AI
This is a comment left during a code review.
Path: products/metrics/mcp/prompts/metric-names-list.md
Line: 7-9
Comment:
Missing aggregation guidance for two listed types
The prompt enumerates five OTel types — `gauge`, `sum`, `histogram`, `summary`, `exponential_histogram` — but the aggregation bullet-list at the end only covers three of them. An LLM that encounters a `summary` or `exponential_histogram` metric has no guidance from this prompt and may silently guess the wrong aggregation. The same gap exists in `query-metrics.md` under "Pick the aggregation by metric type". Adding a bullet for each missing type (e.g. `summary`: use `avg` or `p95`; `exponential_histogram`: use `histogram_quantile`) would make the instructions complete.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
MCP UI Apps size report
|
|
Size Change: 0 B Total Size: 72.4 MB ℹ️ View Unchanged
|
113a13f to
98f6b8e
Compare
5bcd791 to
6c1fa46
Compare
fb9d3f3 to
56996b6
Compare
There was a problem hiding this comment.
Purely additive, read-only MCP tool registration gated by a feature flag. No production logic, data models, or API contracts are changed. Security annotations are correct, API paths are properly escaped, and CI prerequisites passed. The bot comment about missing aggregation guidance for two rare OTel types in an LLM prompt is a documentation quality note on an older commit, not a showstopper.
🕸️ Eager graphHow much code each root forces the browser to download and decode through static imports — the regression class total bundle size can't see.
✅ Largest files eagerly reachable from
|
| Size | File |
|---|---|
| 878.2 KiB | src/styles/global.scss |
| 609.0 KiB | public/hedgehog/burning-money-hog.png |
| 541.9 KiB | public/hedgehog/waving-hog.png |
| 448.2 KiB | public/hedgehog/stop-sign-hog.png |
| 362.0 KiB | public/hedgehog/phone-pair-hogs.png |
| 354.8 KiB | ../node_modules/.pnpm/@posthog+icons@0.36.6_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js |
| 335.6 KiB | public/hedgehog/desk-hog.png |
| 323.2 KiB | public/hedgehog/3-bears-hogs.png |
| 297.4 KiB | src/taxonomy/core-filter-definitions-by-group.json |
| 285.8 KiB | src/lib/api.ts |
Largest files eagerly reachable from src/scenes/AuthenticatedShell.tsx
| Size | File |
|---|---|
| 878.2 KiB | src/styles/global.scss |
| 760.0 KiB | src/queries/validators.js |
| 609.0 KiB | public/hedgehog/burning-money-hog.png |
| 541.9 KiB | public/hedgehog/waving-hog.png |
| 448.2 KiB | public/hedgehog/stop-sign-hog.png |
| 398.7 KiB | ../node_modules/.pnpm/chart.js@4.5.1/node_modules/chart.js/dist/chart.js |
| 362.0 KiB | public/hedgehog/phone-pair-hogs.png |
| 354.8 KiB | ../node_modules/.pnpm/@posthog+icons@0.36.6_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js |
| 335.6 KiB | public/hedgehog/desk-hog.png |
| 323.2 KiB | public/hedgehog/3-bears-hogs.png |
Posted automatically by check-eager-graph · sizes are input-source bytes from the esbuild metafile · part of #32479
6c1fa46 to
0838f8d
Compare
56996b6 to
25d58a1
Compare
New commits pushed (delta classified non_linear_history) — stamphog approval dismissed; re-review running automatically.
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
|
Retaining stamphog approval — delta since last review classified as |
Two read-only tools over the existing endpoints, gated on the metrics feature flag and metrics:read scope. The query-metrics prompt encodes the workflow (discover names first, pick aggregation by metric type, counter-aware rate/increase, filters/groupBy/formula) plus the anomaly-investigation playbook (onset, dimension drill-down, cross-signal correlation into logs and traces). Supersedes the earlier standalone tools PR that targeted the legacy flat-points response shape. How to validate manually: - hogli build:openapi regenerates services/mcp/src/tools/generated/metrics.ts - with the stack and local pipe running, an MCP session against localhost:8787/mcp (personal API key with metrics:read) lists both tools and query-metrics returns the lag series Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
9ad6641 to
a4aecc5
Compare
New commits pushed (delta classified non_linear_history) — stamphog approval dismissed; re-review running automatically.
e0f673f to
a4aecc5
Compare
|
🎭 Playwright report · View test results →
These issues are not necessarily caused by your changes. |

Problem
The headline goal of the metrics effort is MCP-first incident investigation — agents need to discover and query metrics. An earlier tools PR (#60379) targeted the legacy flat-points response shape; this supersedes it on the
[MetricSeries]shape.Changes
products/metrics/mcp/tools.yamlexposing two read-only tools (scopemetrics:read, gated on themetricsfeature flag):metric-names-list→GET /metrics/values— discovery with substring search; the prompt tells agents the metric type → aggregation mapping.query-metrics→POST /metrics/query— the full query surface (filters, group-by, rate, quantiles, formulas). The prompt file encodes the workflow: discover names first, pick aggregation by OTel type, neversuma cumulative counter, plus the anomaly-investigation outline.Generated handlers/schemas regenerated (
services/mcp/src/tools/generated/metrics.ts).How did you test this code?
I'm an agent. Verified through the actual MCP protocol against the local dev server (
localhost:8787/mcp?mode=tools&features=metrics):tools/listshows both tools;query-metricsreturned the live ingestion-lag series;metric-names-listreturned names+types for a substring. Local-dev note for repeating this: the flag gate fails closed locally —services/mcp/.envneedsFEATURE_FLAG_OVERRIDES={"metrics": true}andNODE_ENV=development.🤖 Agent context
Autonomy: Human-driven (agent-assisted) — directed by @DanielVisca
Tool names follow the existing
query-logsprecedent; descriptions live inmcp/prompts/*.mdfiles (the playbook-encoding mechanism the logs product established). Recommend closing #60379 in favor of this.