:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(metrics): batch catalog values and restore sparklines (#100186)
Frank Hamand85e86b7f36a8
diff --git a/docs/internal/metrics-catalog.md b/docs/internal/metrics-catalog.mdnew file mode 100644index 000000000000..e666abe8d7ff--- /dev/null+++ b/docs/internal/metrics-catalog.md@@ -0,0 +1,26 @@+# Metric catalog++The catalog first requests metric names and types from `metrics/names/`.+It does not read metric values until a card is near the visible area.++Visible cards enter a shared queue.+After 50 ms, the queue sends up to 20 exact names to `metrics/values/` in one request.+Only one batch runs at a time.+The request uses POST with a JSON `names` array and keeps the current service filter.+The server ignores `value` and `limit` when `names` is present.+It returns up to 24 recent sparkline points per metric.++The catalog matches responses by metric name, not response order.+A service change clears queued cards and makes old responses invalid, including errors.+Failed cards keep the Retry button.+Query budget failures return an error instead of partial results.+The catalog shows the empty state only after a successful request returns no usable points.++Each sparkline needs an explicit width and height.+The card gives the shared `Sparkline` component `w-full h-full` inside a fixed-height container.++## Tests++The component tests check the POST batch after the queue delay.+The Storybook tests use an explicit container width and wait for a visible chart.+They do not wait for every loading placeholder to disappear: offscreen cards stay unloaded until they enter view.diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex bd23f9e0e9ef..d36b6b6047a6 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5164,6 +5164,14 @@ snapshots:hash: v1.k794b7964.ee00c0f572067d18b53141dce72c182c640f399bd746abce9b2098503dbb62aa.Bkt1qCLQus_6z8XlmJ6Ax5cQjvOkEdyrQDtZKyV_KJYmetrics-group-by--default--light:hash: v1.k794b7964.e5d6a1978e274f76e13a0476f07c2956302b2b84bc318e38c55c72bd2839d8e9.sZnt-HOnAKGE8421CprrJcFq9wQut5SU7DSEi_6Kqiw+ metrics-metricscatalog--default--dark:+ hash: v1.k794b7964.03eb5c94a0b676523fab94c0f45cfb5c89acf5b211f8a273a56defdc04bb274e.yxgu8CrbnCWMkqbLOmjKAsTsP6eZXMesGP_SMos45Lo+ metrics-metricscatalog--default--light:+ hash: v1.k794b7964.8a2362832fc615534a844c97d5e3d7d812dd7071bfb09bcb907e99fd99e37da1.aX4HUfYWaWvRqq4F_dBc3vN4r6p4mw4VZvlGgxov4Ys+ metrics-metricscatalog--narrow--dark:+ hash: v1.k794b7964.bf1f6c610a35043d4c59f8c9da55528374c583d16614dcb2e0aa7a3849ea5757.lUlOAQc8Gubzqf640TCsDgrYGE8AyNyA4x9hAqJycAk+ metrics-metricscatalog--narrow--light:+ hash: v1.k794b7964.cea7d6fed3b34d961bfb7c08500061c0f7e3a11457eedec11738f156c1505ce4.LlZKIPi7EOv8jYnruCnJtJOLFDEUyQ420m-ZIvzN0O4posthog-3000-keyboard-shortcut--default--dark:hash: v1.k794b7964.a5fc5a426df52137d3fb6377a06c7b39c36b041280de154cf2b95cbe46932b8d.f2HHu2jv6bztshqmrVtHpiuuv3PJZNskIh7SbZRgIpkposthog-3000-keyboard-shortcut--default--light:diff --git a/products/metrics/backend/facade/api.py b/products/metrics/backend/facade/api.pyindex d415e3286615..01ab5706cf0e 100644--- a/products/metrics/backend/facade/api.py+++ b/products/metrics/backend/facade/api.py@@ -223,6 +223,7 @@ def list_metric_names(search: str = "",limit: int = 100,services: Sequence[str] = (),+ names: Sequence[str] = (),) -> list[dict[str, Any]]:"""List distinct metric names for the team's picker.@@ -234,6 +235,8 @@ def list_metric_names(The unsearched list is cached per team and service scope for a minute;searches are not."""+ if names:+ return MetricNamesQueryRunner(team=team, services=services, names=names, limit=len(names)).run()return cached_metric_names(team=team, search=search, limit=limit, services=services)diff --git a/products/metrics/backend/facade/contracts.py b/products/metrics/backend/facade/contracts.pyindex 2dc59bdac0ab..e773f15763ef 100644--- a/products/metrics/backend/facade/contracts.py+++ b/products/metrics/backend/facade/contracts.py@@ -27,6 +27,7 @@ from .enums import AttributeScope, FilterOp, MetricAggregation, MetricType# Each clause runs its own ClickHouse query on the shared logs cluster, so# the clause count per request is hard-capped.MAX_CLAUSES_PER_QUERY = 10+MAX_SPARKLINE_BATCH_SIZE = 20# Private-alpha gate. Every read surface (viewset, query runner, MCP tools)# must check the same flag, or one of them becomes a bypass.diff --git a/products/metrics/backend/metric_names_query_runner.py b/products/metrics/backend/metric_names_query_runner.pyindex 1b44399e3ea2..529aba91e81d 100644--- a/products/metrics/backend/metric_names_query_runner.py+++ b/products/metrics/backend/metric_names_query_runner.py@@ -35,6 +35,7 @@ from posthog.hogql.query import execute_hogql_queryfrom posthog.clickhouse.client.connection import Workloadfrom posthog.models import Team+from products.metrics.backend.facade.contracts import MAX_SPARKLINE_BATCH_SIZEfrom products.metrics.backend.search import ilike_pattern# Autocomplete tolerates partial results, so reads break at the budget instead@@ -43,6 +44,10 @@ _QUERY_SETTINGS = HogQLGlobalSettings(max_bytes_to_read=HOGQL_MAX_BYTES_TO_READ_FOR_METRICS_USER_QUERIES,read_overflow_mode="break",)+_SPARKLINE_QUERY_SETTINGS = HogQLGlobalSettings(+ max_bytes_to_read=HOGQL_MAX_BYTES_TO_READ_FOR_METRICS_USER_QUERIES,+ read_overflow_mode="throw",+)# Both `metric_series` and `metrics` expire at the same `original_expiry_timestamp`,# which ingest sets to the team's retention (90 days by default).@@ -82,6 +87,7 @@ class MetricNamesQueryRunner:lookback: dt.timedelta = dt.timedelta(days=7),services: Sequence[str] = (),include_sparklines: bool = True,+ names: Sequence[str] = (),) -> None:if limit <= 0 or limit > 1000:raise ValueError("limit must be in [1, 1000]")@@ -89,6 +95,8 @@ class MetricNamesQueryRunner:raise ValueError("lookback must be positive")if len(services) > MAX_PICKER_SERVICES:raise ValueError(f"at most {MAX_PICKER_SERVICES} services may be selected")+ if len(names) > MAX_SPARKLINE_BATCH_SIZE:+ raise ValueError(f"at most {MAX_SPARKLINE_BATCH_SIZE} metric names may be selected")self.team = teamself.search = search.strip()@@ -103,6 +111,7 @@ class MetricNamesQueryRunner:# expensive part of a name lookup. Callers that only need the type# (anomaly defaults) skip it.self.include_sparklines = include_sparklines+ self.names = tuple(sorted(set(names)))def _build_query(self) -> ast.SelectQuery:# The alias is `last_seen_at`, not `last_seen`: HogQL registers select@@ -159,6 +168,17 @@ class MetricNamesQueryRunner:# Both variants above filter on the lookback, so there is always a WHERE to# extend; the assert is what tells the type checker so.assert query.where is not None+ if self.names:+ query.where = ast.And(+ exprs=[+ query.where,+ ast.CompareOperation(+ op=ast.CompareOperationOp.In,+ left=ast.Field(chain=["metric_name"]),+ right=ast.Tuple(exprs=[ast.Constant(value=name) for name in self.names]),+ ),+ ]+ )# Appended to the parsed tree rather than written into both SQL variants# above, so the scoped and unscoped pickers stay one query definition.@@ -184,7 +204,7 @@ class MetricNamesQueryRunner:query=self._build_query(),team=self.team,workload=Workload.LOGS, # metrics share the logs ClickHouse workload pool for now- settings=_QUERY_SETTINGS,+ settings=_SPARKLINE_QUERY_SETTINGS if self.names else _QUERY_SETTINGS,)names = [row[0] for row in response.results]@@ -257,7 +277,7 @@ class MetricNamesQueryRunner:query=query,team=self.team,workload=Workload.LOGS,- settings=_QUERY_SETTINGS,+ settings=_SPARKLINE_QUERY_SETTINGS,)sparklines: dict[str, list[float]] = {}diff --git a/products/metrics/backend/presentation/api.py b/products/metrics/backend/presentation/api.pyindex 65d272f453ae..e03eb03ff70b 100644--- a/products/metrics/backend/presentation/api.py+++ b/products/metrics/backend/presentation/api.py@@ -41,6 +41,7 @@ from products.metrics.backend.facade.api import ()from products.metrics.backend.facade.contracts import (MAX_CLAUSES_PER_QUERY,+ MAX_SPARKLINE_BATCH_SIZE,METRICS_ERROR_OVERLAYS_FEATURE_FLAG,METRICS_FEATURE_FLAG,METRICS_FUNDAMENTALS_FEATURE_FLAG,@@ -464,6 +465,16 @@ class _MetricValuesParamsSerializer(serializers.Serializer):return [service.strip() for service in value.split(",")]+class _MetricCatalogValuesParamsSerializer(_MetricValuesParamsSerializer):+ names = serializers.ListField(+ child=serializers.CharField(max_length=255, trim_whitespace=False),+ allow_empty=False,+ min_length=1,+ max_length=MAX_SPARKLINE_BATCH_SIZE,+ help_text="Exact metric names to load as a batch. Overrides value and limit.",+ )++class _MetricNameSerializer(serializers.Serializer):name = serializers.CharField(help_text="Metric name as it appears in the team's data.")metric_type = serializers.CharField(@@ -903,12 +914,18 @@ class MetricsViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):return Response(asdict(overview), status=status.HTTP_200_OK)@extend_schema(+ methods=["GET"],parameters=[_MetricValuesParamsSerializer],responses={200: _MetricNamesResponseSerializer},)+ @extend_schema(+ methods=["POST"],+ request=_MetricCatalogValuesParamsSerializer,+ responses={200: _MetricNamesResponseSerializer},+ )@action(detail=False,- methods=["GET"],+ methods=["GET", "POST"],required_scopes=["metrics:read"],throttle_classes=[ClickHouseBurstRateThrottle, ClickHouseSustainedRateThrottle],)@@ -916,7 +933,11 @@ class MetricsViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):"""Distinct metric names for the team. Backs the catalog UI."""tag_queries(product=Product.METRICS, feature=Feature.QUERY)- params = _MetricValuesParamsSerializer(data=request.query_params)+ params = (+ _MetricCatalogValuesParamsSerializer(data=request.data)+ if request.method == "POST"+ else _MetricValuesParamsSerializer(data=request.query_params)+ )params.is_valid(raise_exception=True)try:@@ -925,6 +946,7 @@ class MetricsViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):search=params.validated_data["value"],limit=params.validated_data["limit"],services=params.validated_data["service"],+ names=params.validated_data.get("names", []),)except ValueError as exc:raise ParseError(str(exc))diff --git a/products/metrics/backend/tests/test_metric_names_query_runner.py b/products/metrics/backend/tests/test_metric_names_query_runner.pyindex b72ebb20cff5..c7ce705f3b8c 100644--- a/products/metrics/backend/tests/test_metric_names_query_runner.py+++ b/products/metrics/backend/tests/test_metric_names_query_runner.py@@ -10,6 +10,7 @@ from parameterized import parameterizedfrom rest_framework import statusfrom products.metrics.backend.facade.api import list_metric_picker_names+from products.metrics.backend.facade.contracts import MAX_SPARKLINE_BATCH_SIZEfrom products.metrics.backend.metric_names_query_runner import (MAX_PICKER_SERVICES,MetricNamesQueryRunner,@@ -239,9 +240,10 @@ class TestMetricsValuesAPI(ClickhouseTestMixin, APIBaseTest):truncate_metrics_tables()cache.clear()- def test_values_requires_authentication(self):+ @parameterized.expand([("get",), ("post",)])+ def test_values_requires_authentication(self, method):self.client.logout()- response = self.client.get(f"/api/projects/{self.team.id}/metrics/values")+ response = getattr(self.client, method)(f"/api/projects/{self.team.id}/metrics/values")self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)def test_values_returns_empty_for_no_data(self):@@ -279,6 +281,47 @@ class TestMetricsValuesAPI(ClickhouseTestMixin, APIBaseTest):names = [row["name"] for row in response.json()["results"]]self.assertEqual(names, ["http.duration"])+ def test_values_batch_matches_exact_names_and_service(self):+ anchor = timezone.now().replace(microsecond=0) - dt.timedelta(minutes=5)+ for metric_name, service in [+ ("queue.depth", "web"),+ ("queue.depth.extra", "web"),+ ("http.duration", "web"),+ ("worker.count", "worker"),+ ]:+ seed_metric(+ team_id=self.team.id,+ metric_name=metric_name,+ points=[(anchor - dt.timedelta(minutes=20), 1.0), (anchor, 2.0)],+ service_name=service,+ )+ response = self.client.post(+ f"/api/projects/{self.team.id}/metrics/values/",+ {+ "names": ["queue.depth", "http.duration", "worker.count", "missing.metric"],+ "service": "web",+ "limit": 1,+ },+ format="json",+ )+ self.assertEqual(response.status_code, status.HTTP_200_OK)+ rows = response.json()["results"]+ self.assertEqual({row["name"] for row in rows}, {"queue.depth", "http.duration"})+ for row in rows:+ self.assertEqual(row["sparkline"], [1.0, 2.0])++ @parameterized.expand(+ [+ ("empty", []),+ ("too many", [f"metric.{index}" for index in range(MAX_SPARKLINE_BATCH_SIZE + 1)]),+ ("blank", [""]),+ ("too long", ["a" * 256]),+ ]+ )+ def test_values_rejects_invalid_names(self, _name, names):+ response = self.client.post(f"/api/projects/{self.team.id}/metrics/values/", {"names": names}, format="json")+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)+@parameterized.expand([# Omitting the param and sending it empty mean different things, and thediff --git a/products/metrics/frontend/components/MetricsCatalog.stories.tsx b/products/metrics/frontend/components/MetricsCatalog.stories.tsxnew file mode 100644index 000000000000..a3208778b0d0--- /dev/null+++ b/products/metrics/frontend/components/MetricsCatalog.stories.tsx@@ -0,0 +1,77 @@+import type { Meta, StoryObj } from '@storybook/react'++import { mswDecorator } from '~/mocks/browser'+import { AccessControlLevel, AccessControlResourceType } from '~/types'++import type { _MetricCatalogValuesParamsApi } from '../generated/api.schemas'+import { MetricsCatalog } from './MetricsCatalog'++const items = Array.from({ length: 40 }, (_, index) => ({+ name: `example.queue.${index}`,+ metric_type: 'gauge',+}))++const meta: Meta<typeof MetricsCatalog> = {+ title: 'Metrics/MetricsCatalog',+ component: MetricsCatalog,+ beforeEach: () => {+ const context = window.POSTHOG_APP_CONTEXT!+ const previous = context.resource_access_control+ context.resource_access_control = {+ ...previous,+ [AccessControlResourceType.Metrics]: AccessControlLevel.Viewer,+ }+ return () => {+ context.resource_access_control = previous+ }+ },+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:team_id/metrics/names/': { results: items },+ },+ post: {+ '/api/projects/:team_id/metrics/values/': async ({ request }) => {+ const { names } = (await request.json()) as _MetricCatalogValuesParamsApi+ return [+ 200,+ {+ results: names.map((name) => ({+ name,+ metric_type: 'gauge',+ sparkline: [4, 6, 3, 7, 9, 5, 8, 4, 7, 10, 6, 9, 8, 5, 7, 11, 6, 8, 10, 7, 9, 6, 8, 12],+ })),+ },+ ]+ },+ },+ }),+ ],+ parameters: {+ testOptions: {+ snapshotBrowsers: ['chromium'],+ waitForLoadersToDisappear: false,+ waitForSelector: 'canvas[aria-label]',+ },+ },+ render: () => (+ <div className="h-[600px] w-[1200px] max-w-full overflow-auto">+ <MetricsCatalog />+ </div>+ ),+}++export default meta+type Story = StoryObj<typeof meta>++export const Default: Story = {}++export const Narrow: Story = {+ decorators: [+ (Story) => (+ <div className="w-[520px]">+ <Story />+ </div>+ ),+ ],+}diff --git a/products/metrics/frontend/components/MetricsCatalog.test.tsx b/products/metrics/frontend/components/MetricsCatalog.test.tsxindex 108ec099d472..acebe534bbd5 100644--- a/products/metrics/frontend/components/MetricsCatalog.test.tsx+++ b/products/metrics/frontend/components/MetricsCatalog.test.tsx@@ -1,18 +1,18 @@import '@testing-library/jest-dom'-import { act, cleanup, render, screen } from '@testing-library/react'+import { act, cleanup, render, screen, waitFor } from '@testing-library/react'import { Provider } from 'kea'import { initKeaTests } from '~/test/init'import { AccessControlLevel, AccessControlResourceType, AppContext } from '~/types'-import { metricsNamesRetrieve, metricsValuesRetrieve } from '../generated/api'+import { metricsNamesRetrieve, metricsValuesCreate } from '../generated/api'import { MetricsCatalog } from './MetricsCatalog'jest.mock('../generated/api', () => ({...jest.requireActual('../generated/api'),metricsNamesRetrieve: jest.fn(),- metricsValuesRetrieve: jest.fn(),+ metricsValuesCreate: jest.fn(),metricsQueryCreate: jest.fn(),}))@@ -52,9 +52,6 @@ const scrollIntoView = (testId: string): void => {}}-// The catalog only lists names, so each card asks for its own sparkline. That-// request must wait until the card is near the viewport, or the lazy load is-// no cheaper than the one query over every metric it replaced.describe('MetricsCatalog', () => {beforeEach(() => {window.POSTHOG_APP_CONTEXT = {@@ -68,8 +65,8 @@ describe('MetricsCatalog', () => {FakeIntersectionObserver.observers = []window.IntersectionObserver = FakeIntersectionObserver as unknown as typeof IntersectionObserverjest.mocked(metricsNamesRetrieve).mockResolvedValue({ results: CATALOG_ITEMS } as any)- jest.mocked(metricsValuesRetrieve).mockReset()- jest.mocked(metricsValuesRetrieve).mockResolvedValue({ results: [] } as any)+ jest.mocked(metricsValuesCreate).mockReset()+ jest.mocked(metricsValuesCreate).mockResolvedValue({ results: [] } as any)})afterEach(() => cleanup())@@ -81,16 +78,32 @@ describe('MetricsCatalog', () => {</Provider>)expect(await screen.findByText('queue.depth')).toBeInTheDocument()- expect(jest.mocked(metricsValuesRetrieve)).not.toHaveBeenCalled()+ expect(metricsValuesCreate).not.toHaveBeenCalled()await act(async () => {scrollIntoView('metrics-catalog-card-queue.depth')})- expect(jest.mocked(metricsValuesRetrieve)).toHaveBeenCalledTimes(1)- expect(jest.mocked(metricsValuesRetrieve)).toHaveBeenCalledWith(- expect.any(String),- expect.objectContaining({ value: 'queue.depth', limit: 1 })+ await waitFor(() => expect(metricsValuesCreate).toHaveBeenCalledTimes(1))+ expect(metricsValuesCreate).toHaveBeenCalledWith(expect.any(String), { names: ['queue.depth'] })+ })++ it('batches cards that enter view together', async () => {+ render(+ <Provider>+ <MetricsCatalog />+ </Provider>)+ expect(await screen.findByText('queue.depth')).toBeInTheDocument()++ await act(async () => {+ scrollIntoView('metrics-catalog-card-http.server.duration')+ scrollIntoView('metrics-catalog-card-queue.depth')+ })++ await waitFor(() => expect(metricsValuesCreate).toHaveBeenCalledTimes(1))+ expect(metricsValuesCreate).toHaveBeenCalledWith(expect.any(String), {+ names: ['http.server.duration', 'queue.depth'],+ })})})diff --git a/products/metrics/frontend/components/MetricsCatalog.tsx b/products/metrics/frontend/components/MetricsCatalog.tsxindex 327460a4e7d0..f8682ff54f70 100644--- a/products/metrics/frontend/components/MetricsCatalog.tsx+++ b/products/metrics/frontend/components/MetricsCatalog.tsx@@ -35,7 +35,8 @@ const typeTagLabel = (metricType: string): string =>const CatalogCard = ({ item }: { item: MetricCatalogItem }): JSX.Element => {const { openMetric, loadSparkline, retrySparkline } = useActions(metricsCatalogLogic)- const { catalogItemDetails, catalogItemDetailsFailed, catalogItemDetailsLoading } = useValues(metricsCatalogLogic)+ const { catalogItemDetails, catalogItemDetailsFailed, catalogItemDetailsLoading, catalogItemsLoading } =+ useValues(metricsCatalogLogic)const cardRef = useRef<HTMLButtonElement>(null)const detail = catalogItemDetails[item.name]const failed = catalogItemDetailsFailed[item.name]@@ -43,7 +44,7 @@ const CatalogCard = ({ item }: { item: MetricCatalogItem }): JSX.Element => {useEffect(() => {const card = cardRef.current- if (!card || detail || failed || loading) {+ if (!card || detail || failed || loading || catalogItemsLoading) {return}// Browsers without IntersectionObserver still show a useful catalog;@@ -65,7 +66,7 @@ const CatalogCard = ({ item }: { item: MetricCatalogItem }): JSX.Element => {)observer.observe(card)return () => observer.disconnect()- }, [detail, item, loadSparkline, loading])+ }, [catalogItemsLoading, detail, failed, item, loadSparkline, loading])return (<div className="flex flex-col border rounded hover:border-accent-primary focus-within:border-accent-primary transition-colors bg-bg-3000">@@ -86,8 +87,8 @@ const CatalogCard = ({ item }: { item: MetricCatalogItem }): JSX.Element => {</div><div className="h-10 w-full">{detail?.sparkline && detail.sparkline.length > 1 ? (- <Sparkline data={detail.sparkline} type="line" />- ) : loading ? (+ <Sparkline data={detail.sparkline} type="line" className="w-full h-full" />+ ) : loading || (!detail && !failed) ? (<LemonSkeleton className="h-full" />) : failed ? (<div className="h-full flex items-center text-xs text-muted">Could not load recent data</div>@@ -122,7 +123,7 @@ export const MetricsCatalog = (): JSX.Element => {const { setSearch } = useActions(logic)return (- <div className="flex flex-col gap-3 overflow-y-auto">+ <div className="@container flex flex-col gap-3 overflow-y-auto"><div className="flex items-center justify-between gap-2 flex-wrap"><p className="text-secondary mb-0">Every metric you are collecting, as a card. Click one to open its chart.@@ -138,7 +139,7 @@ export const MetricsCatalog = (): JSX.Element => {/></div>{catalogItemsLoading && visibleItems.length === 0 ? (- <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3">+ <div className="grid grid-cols-1 @xl:grid-cols-2 @4xl:grid-cols-3 @6xl:grid-cols-4 gap-3">{Array.from({ length: 8 }).map((_, i) => (<LemonSkeleton key={i} className="h-32" />))}@@ -148,7 +149,7 @@ export const MetricsCatalog = (): JSX.Element => {{search ? `No metrics match "${search}".` : 'No metrics reported in the current scope yet.'}</div>) : (- <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3">+ <div className="grid grid-cols-1 @xl:grid-cols-2 @4xl:grid-cols-3 @6xl:grid-cols-4 gap-3">{visibleItems.map((item) => (<CatalogCard key={item.name} item={item} />))}diff --git a/products/metrics/frontend/components/metricsCatalogLogic.test.ts b/products/metrics/frontend/components/metricsCatalogLogic.test.tsindex 16fa7dbd3218..27ca9b60e258 100644--- a/products/metrics/frontend/components/metricsCatalogLogic.test.ts+++ b/products/metrics/frontend/components/metricsCatalogLogic.test.ts@@ -3,16 +3,16 @@ import { expectLogic } from 'kea-test-utils'import { initKeaTests } from '~/test/init'import { AccessControlLevel, AccessControlResourceType, AppContext } from '~/types'-import { metricsNamesRetrieve, metricsValuesRetrieve } from '../generated/api'+import { metricsNamesRetrieve, metricsValuesCreate } from '../generated/api'import { metricsSceneLogic } from '../metricsSceneLogic'import { metricNamePickerLogic } from './metricNamePickerLogic'-import { metricsCatalogLogic } from './metricsCatalogLogic'+import { SPARKLINE_BATCH_SIZE, metricsCatalogLogic } from './metricsCatalogLogic'import { metricsViewerLogic } from './metricsViewerLogic'jest.mock('../generated/api', () => ({...jest.requireActual('../generated/api'),metricsNamesRetrieve: jest.fn(),- metricsValuesRetrieve: jest.fn(),+ metricsValuesCreate: jest.fn(),metricsQueryCreate: jest.fn(),}))@@ -47,8 +47,9 @@ describe('metricsCatalogLogic', () => {},} as AppContextinitKeaTests()- jest.mocked(metricsValuesRetrieve).mockReset()- jest.mocked(metricsValuesRetrieve).mockResolvedValue({ results: [SPARKLINE_ITEM] } as any)+ jest.mocked(metricsValuesCreate).mockReset()+ jest.mocked(metricsValuesCreate).mockResolvedValue({ results: [SPARKLINE_ITEM] } as any)+ jest.mocked(metricsNamesRetrieve).mockReset()jest.mocked(metricsNamesRetrieve).mockResolvedValue({ results: CATALOG_ITEMS } as any)})@@ -63,91 +64,111 @@ describe('metricsCatalogLogic', () => {await expectLogic(logic).toDispatchActions(['loadCatalogSuccess']).toMatchValues({catalogItems: CATALOG_ITEMS,})+ expect(metricsValuesCreate).not.toHaveBeenCalled()})- it('loads a card sparkline only when that card enters view', async () => {+ it('batches visible cards and maps each result by name', async () => {+ const queueDetail = { ...CATALOG_ITEMS[1], sparkline: [3, 2, 1] }+ jest.mocked(metricsValuesCreate).mockResolvedValueOnce({ results: [queueDetail, SPARKLINE_ITEM] } as any)logic = metricsCatalogLogic()logic.mount()await expectLogic(logic).toDispatchActions(['loadCatalogSuccess'])await expectLogic(logic, () => {logic.actions.loadSparkline(CATALOG_ITEMS[0])+ logic.actions.loadSparkline(CATALOG_ITEMS[1])+ logic.actions.loadSparkline(CATALOG_ITEMS[0])}).toDispatchActions(['loadSparklineSuccess'])- expect(jest.mocked(metricsValuesRetrieve)).toHaveBeenCalledWith(- expect.any(String),- expect.objectContaining({ value: 'http.server.duration', limit: 1 })- )+ expect(jest.mocked(metricsValuesCreate)).toHaveBeenCalledWith(expect.any(String), {+ names: ['http.server.duration', 'queue.depth'],+ })+ expect(metricsValuesCreate).toHaveBeenCalledTimes(1)expect(logic.values.catalogItemDetails['http.server.duration']).toEqual(SPARKLINE_ITEM)+ expect(logic.values.catalogItemDetails['queue.depth']).toEqual(queueDetail)+ expect(logic.values.catalogItemDetailsLoading).toEqual({ 'http.server.duration': false, 'queue.depth': false })})- it('retries a sparkline after a transient failure', async () => {- jest.mocked(metricsValuesRetrieve)- .mockRejectedValueOnce(new Error('temporary error'))- .mockResolvedValueOnce({ results: [SPARKLINE_ITEM] } as any)+ it('bounds batches and queues cards that enter view during a request', async () => {+ const items = Array.from({ length: SPARKLINE_BATCH_SIZE + 2 }, (_, index) => ({+ name: `metric.${index}`,+ metric_type: 'gauge',+ }))+ let completeBatch!: (response: any) => void+ jest.mocked(metricsValuesCreate).mockImplementationOnce(+ () => new Promise((resolve) => (completeBatch = resolve))+ )logic = metricsCatalogLogic()logic.mount()await expectLogic(logic).toDispatchActions(['loadCatalogSuccess'])await expectLogic(logic, () => {- logic.actions.loadSparkline(CATALOG_ITEMS[0])- }).toDispatchActions(['loadSparklineFailure'])- expect(logic.values.catalogItemDetailsFailed['http.server.duration']).toBe(true)+ items.slice(0, -1).forEach(logic.actions.loadSparkline)+ }).toDispatchActions(['dequeueSparklines'])+ logic.actions.loadSparkline(items[items.length - 1])+ expect(metricsValuesCreate).toHaveBeenCalledTimes(1)+ expect(jest.mocked(metricsValuesCreate).mock.calls[0][1]?.names).toHaveLength(SPARKLINE_BATCH_SIZE)- await expectLogic(logic, () => {- logic.actions.retrySparkline(CATALOG_ITEMS[0])- }).toDispatchActions(['loadSparklineSuccess'])+ await expectLogic(logic, () => completeBatch({ results: [] })).toFinishAllListeners()- expect(logic.values.catalogItemDetailsFailed['http.server.duration']).toBe(false)- expect(jest.mocked(metricsValuesRetrieve)).toHaveBeenCalledTimes(2)+ expect(metricsValuesCreate).toHaveBeenCalledTimes(2)+ expect(jest.mocked(metricsValuesCreate).mock.calls[1][1]?.names).toEqual(+ items.slice(SPARKLINE_BATCH_SIZE).map((item) => item.name)+ )+ expect(Object.keys(logic.values.catalogItemDetails)).toHaveLength(items.length)+ expect(Object.values(logic.values.catalogItemDetailsLoading)).not.toContain(true)})- it('keeps every in-flight card when more cards scroll into view', async () => {- // Several cards cross the viewport at once. Each one is its own request,- // so a later card must not cancel or fail an earlier one still in flight.- jest.mocked(metricsValuesRetrieve).mockImplementation(- (_teamId: any, params: any) =>- new Promise((resolve) =>- setTimeout(() => resolve({ results: [{ ...SPARKLINE_ITEM, name: params.value }] } as any), 0)- ) as any+ it.each(['success', 'failure'])('discards an old scope batch %s', async (outcome) => {+ let finishBatch!: () => void+ jest.mocked(metricsValuesCreate).mockImplementationOnce(+ () =>+ new Promise((resolve, reject) => {+ finishBatch = () =>+ outcome === 'success'+ ? resolve({ results: [SPARKLINE_ITEM] } as any)+ : reject(new Error('old scope'))+ }))logic = metricsCatalogLogic()logic.mount()await expectLogic(logic).toDispatchActions(['loadCatalogSuccess'])+ await expectLogic(logic, () => logic.actions.loadSparkline(CATALOG_ITEMS[0])).toDispatchActions([+ 'dequeueSparklines',+ ])+ await expectLogic(logic, () => logic.actions.setServices(['worker'])).toDispatchActions(['loadCatalogSuccess'])+ await expectLogic(logic, finishBatch).toFinishAllListeners()- await expectLogic(logic, () => {- logic.actions.loadSparkline(CATALOG_ITEMS[0])- logic.actions.loadSparkline(CATALOG_ITEMS[1])- }).toFinishAllListeners()-+ expect(logic.values.catalogItemDetails).toEqual({})expect(logic.values.catalogItemDetailsFailed).toEqual({})- expect(Object.keys(logic.values.catalogItemDetails).sort()).toEqual([- CATALOG_ITEMS[0].name,- CATALOG_ITEMS[1].name,+ await expectLogic(logic, () => logic.actions.loadSparkline(CATALOG_ITEMS[0])).toDispatchActions([+ 'loadSparklineSuccess',])+ expect(metricsValuesCreate).toHaveBeenLastCalledWith(expect.any(String), {+ names: [CATALOG_ITEMS[0].name],+ service: 'worker',+ })})- it('a rejection from the old service scope does not fail the same card in the new scope', async () => {- // A card in scope A fails after the person has entered scope B. The name- // can exist in both, and the new card must still get to ask for itself.- let rejectFirst: (error: Error) => void = () => {}- jest.mocked(metricsValuesRetrieve).mockImplementationOnce(- () => new Promise((_resolve, reject) => (rejectFirst = reject)) as any- )- metricNamePickerLogic.mount()+ it('retries a sparkline after a transient failure', async () => {+ jest.mocked(metricsValuesCreate)+ .mockRejectedValueOnce(new Error('temporary error'))+ .mockResolvedValueOnce({ results: [SPARKLINE_ITEM] } as any)logic = metricsCatalogLogic()logic.mount()await expectLogic(logic).toDispatchActions(['loadCatalogSuccess'])- logic.actions.loadSparkline(CATALOG_ITEMS[0])- metricNamePickerLogic.actions.setServices(['api'])- await expectLogic(logic).toDispatchActions(['loadCatalogSuccess'])+ await expectLogic(logic, () => {+ logic.actions.loadSparkline(CATALOG_ITEMS[0])+ }).toDispatchActions(['loadSparklineFailure'])+ expect(logic.values.catalogItemDetailsFailed['http.server.duration']).toBe(true)- rejectFirst(new Error('boom'))- await expectLogic(logic).toFinishAllListeners()+ await expectLogic(logic, () => {+ logic.actions.retrySparkline(CATALOG_ITEMS[0])+ }).toDispatchActions(['loadSparklineSuccess'])- expect(logic.values.catalogItemDetailsFailed).toEqual({})- expect(logic.values.catalogItemDetailsLoading[CATALOG_ITEMS[0].name]).toBeUndefined()+ expect(logic.values.catalogItemDetailsFailed['http.server.duration']).toBe(false)+ expect(jest.mocked(metricsValuesCreate)).toHaveBeenCalledTimes(2)})it('narrows the visible cards by a search substring', async () => {diff --git a/products/metrics/frontend/components/metricsCatalogLogic.tsx b/products/metrics/frontend/components/metricsCatalogLogic.tsxindex 544d7f750099..e1480ac1bc72 100644--- a/products/metrics/frontend/components/metricsCatalogLogic.tsx+++ b/products/metrics/frontend/components/metricsCatalogLogic.tsx@@ -3,7 +3,7 @@ import { loaders } from 'kea-loaders'import { teamLogic } from 'scenes/teamLogic'-import { metricsNamesRetrieve, metricsValuesRetrieve } from '../generated/api'+import { metricsNamesRetrieve, metricsValuesCreate } from '../generated/api'import type { _MetricNameApi, _MetricPickerNameApi } from '../generated/api.schemas'import { canViewMetrics } from '../metricsAccess'import { metricsSceneLogic } from '../metricsSceneLogic'@@ -13,15 +13,19 @@ import { metricsViewerLogic, toKnownMetricType } from './metricsViewerLogic'/** One catalog card: a metric name plus what makes it scannable before opening it. */export type MetricCatalogItem = _MetricPickerNameApi+export const SPARKLINE_BATCH_SIZE = 20+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface metricsCatalogLogicValues {pickerServices: string[] // metricNamePickerLogiccurrentTeamId: number | null // teamLogic+ catalogGeneration: numbercatalogItemDetails: Record<string, _MetricNameApi>catalogItemDetailsFailed: Record<string, boolean>catalogItemDetailsLoading: Record<string, boolean>catalogItems: MetricCatalogItem[]catalogItemsLoading: boolean+ pendingSparklines: Record<string, MetricCatalogItem>search: stringvisibleItems: MetricCatalogItem[]}@@ -40,7 +44,10 @@ export interface metricsCatalogLogicActions {setSelectedMetricType: (metricType: null | import('../generated/api.schemas').OtelMetricTypeEnumApi) => {metricType: null | import('../generated/api.schemas').OtelMetricTypeEnumApi} // metricsViewerLogic- loadCatalog: () => any+ dequeueSparklines: (names: string[]) => {+ names: string[]+ }+ loadCatalog: (_: void) => voidloadCatalogFailure: (error: string,errorObject?: any@@ -50,14 +57,15 @@ export interface metricsCatalogLogicActions {}loadCatalogSuccess: (catalogItems: _MetricPickerNameApi[],- payload?: any+ payload?: void) => {catalogItems: _MetricPickerNameApi[]- payload?: any+ payload?: void}loadSparkline: (item: MetricCatalogItem) => {item: _MetricPickerNameApi}+ loadSparklineBatch: () => {}loadSparklineFailure: (name: string) => {name: string}@@ -71,15 +79,15 @@ export interface metricsCatalogLogicActions {openMetric: (item: MetricCatalogItem) => {item: _MetricPickerNameApi}+ queueSparkline: (item: MetricCatalogItem) => {+ item: _MetricPickerNameApi+ }retrySparkline: (item: MetricCatalogItem) => {item: _MetricPickerNameApi}setSearch: (search: string) => {search: string}- setSparklineLoading: (name: string) => {- name: string- }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -112,7 +120,9 @@ export const metricsCatalogLogic = kea<metricsCatalogLogicType>([actions({setSearch: (search: string) => ({ search }),loadSparkline: (item: MetricCatalogItem) => ({ item }),- setSparklineLoading: (name: string) => ({ name }),+ queueSparkline: (item: MetricCatalogItem) => ({ item }),+ loadSparklineBatch: () => ({}),+ dequeueSparklines: (names: string[]) => ({ names }),loadSparklineSuccess: (name: string, item: _MetricNameApi) => ({ name, item }),loadSparklineFailure: (name: string) => ({ name }),retrySparkline: (item: MetricCatalogItem) => ({ item }),@@ -121,6 +131,16 @@ export const metricsCatalogLogic = kea<metricsCatalogLogicType>([}),reducers({search: ['' as string, { setSearch: (_, { search }) => search }],+ catalogGeneration: [0, { loadCatalog: (state) => state + 1 }],+ pendingSparklines: [+ {} as Record<string, MetricCatalogItem>,+ {+ loadCatalog: () => ({}),+ queueSparkline: (state, { item }) => ({ ...state, [item.name]: item }),+ dequeueSparklines: (state, { names }) =>+ Object.fromEntries(Object.entries(state).filter(([name]) => !names.includes(name))),+ },+ ],// Details depend on the service scope. Drop the old scope as soon as a// replacement name list starts loading, so a late card can never show a// sparkline from the service the person just left.@@ -143,7 +163,7 @@ export const metricsCatalogLogic = kea<metricsCatalogLogicType>([{} as Record<string, boolean>,{loadCatalog: () => ({}),- setSparklineLoading: (state, { name }) => ({ ...state, [name]: true }),+ queueSparkline: (state, { item }) => ({ ...state, [item.name]: true }),loadSparklineSuccess: (state, { name }) => ({ ...state, [name]: false }),loadSparklineFailure: (state, { name }) => ({ ...state, [name]: false }),},@@ -153,7 +173,7 @@ export const metricsCatalogLogic = kea<metricsCatalogLogicType>([catalogItems: [[] as MetricCatalogItem[],{- loadCatalog: async (): Promise<MetricCatalogItem[]> => {+ loadCatalog: async (_: void, breakpoint): Promise<MetricCatalogItem[]> => {if (!canViewMetrics()) {return []}@@ -166,6 +186,7 @@ export const metricsCatalogLogic = kea<metricsCatalogLogicType>([limit: 500,...(values.pickerServices.length ? { service: values.pickerServices.join(',') } : {}),})+ breakpoint()return response.results},},@@ -183,48 +204,70 @@ export const metricsCatalogLogic = kea<metricsCatalogLogicType>([},],}),- listeners(({ actions, values }) => ({+ listeners(({ actions, values, cache }) => ({// Re-scope: entering a service from the overview or a viewer filter change// re-reads the cards for that scope.setServices: () => {actions.loadCatalog()},- // No kea breakpoint here: its counter is per action type, not per card, so- // the next card scrolling into view would abort every request still in- // flight and leave those cards on an error they never actually hit.- loadSparkline: async ({ item }) => {+ loadSparkline: ({ item }) => {// An IntersectionObserver can notify more than once while a card is// near the viewport. Keep one request per name and retry only after a// failed request or after the catalog scope changes.- if (values.catalogItemDetails[item.name] || values.catalogItemDetailsLoading[item.name]) {+ if (+ values.catalogItemsLoading ||+ values.catalogItemDetails[item.name] ||+ values.catalogItemDetailsLoading[item.name] ||+ values.catalogItemDetailsFailed[item.name]+ ) {+ return+ }+ actions.queueSparkline(item)+ if (!cache.loadingBatch) {+ actions.loadSparklineBatch()+ }+ },+ loadSparklineBatch: async (_, breakpoint) => {+ if (cache.loadingBatch) {return}- const teamId = values.currentTeamId- const services = values.pickerServices- // The service scope can change while the query runs. The name list was- // reset for that new scope, so neither a late result nor a late- // rejection may land on a card that now belongs to another scope.- const stillInScope = (): boolean =>- teamId === values.currentTeamId && services.join('\u0000') === values.pickerServices.join('\u0000')- actions.setSparklineLoading(item.name)+ cache.loadingBatch = truetry {- const response = await metricsValuesRetrieve(String(teamId), {- value: item.name,- limit: 1,- ...(services.length ? { service: services.join(',') } : {}),- })- if (!stillInScope()) {- return- }- // A name can disappear between the first request and this lazy- // lookup. Treat that the same as a metric with no recent points,- // which stops an observer retry loop for a stale card.- actions.loadSparklineSuccess(item.name, response.results[0] ?? { ...item, sparkline: [] })- } catch {- if (!stillInScope()) {- return+ await breakpoint(50)+ while (Object.keys(values.pendingSparklines).length > 0) {+ const items = Object.values(values.pendingSparklines).slice(0, SPARKLINE_BATCH_SIZE)+ const names = items.map((item) => item.name)+ const generation = values.catalogGeneration+ const teamId = values.currentTeamId+ actions.dequeueSparklines(names)+ let results: _MetricNameApi[] | undefined+ try {+ const response = await metricsValuesCreate(String(teamId), {+ names,+ ...(values.pickerServices.length ? { service: values.pickerServices.join(',') } : {}),+ })+ results = response.results+ } catch {+ results = undefined+ }+ breakpoint()+ if (generation !== values.catalogGeneration || teamId !== values.currentTeamId) {+ continue+ }+ const details = new Map(results?.map((item) => [item.name, item]))+ for (const item of items) {+ if (results) {+ actions.loadSparklineSuccess(+ item.name,+ details.get(item.name) ?? { ...item, sparkline: [] }+ )+ } else {+ actions.loadSparklineFailure(item.name)+ }+ }}- actions.loadSparklineFailure(item.name)+ } finally {+ cache.loadingBatch = false}},retrySparkline: ({ item }) => {diff --git a/products/metrics/frontend/generated/api.schemas.ts b/products/metrics/frontend/generated/api.schemas.tsindex 644dfb3c95a4..bea8f808894a 100644--- a/products/metrics/frontend/generated/api.schemas.ts+++ b/products/metrics/frontend/generated/api.schemas.ts@@ -810,6 +810,32 @@ export interface _MetricNamesResponseApi {results: _MetricNameApi[]}+export interface _MetricCatalogValuesParamsApi {+ /**+ * Substring filter (case-insensitive) applied to metric names.+ * @maxLength 255+ */+ value?: string+ /**+ * Max number of names to return. Defaults to 100; maximum 1000.+ * @minimum 1+ * @maximum 1000+ */+ limit?: number+ /**+ * Comma-separated services to narrow the list to, e.g. `service=web,worker`. Omit for every service. Send it empty to select only series whose sender did not set `service.name`. A service name containing a comma cannot be selected.+ * @maxLength 1024+ */+ service?: string+ /**+ * Exact metric names to load as a batch. Overrides value and limit.+ * @minItems 1+ * @maxItems 20+ * @items.maxLength 255+ */+ names: string[]+}+export type MetricsAttributeValuesRetrieveParams = {/*** Lower bound (inclusive) of the window values are suggested from. ISO 8601. Defaults to 7 days ago.diff --git a/products/metrics/frontend/generated/api.ts b/products/metrics/frontend/generated/api.tsindex fde7ebc42760..411333ea8d95 100644--- a/products/metrics/frontend/generated/api.ts+++ b/products/metrics/frontend/generated/api.ts@@ -21,6 +21,7 @@ import type {_MetricAnomalyRequestApi,_MetricAttributeKeysResponseApi,_MetricAttributeValuesResponseApi,+ _MetricCatalogValuesParamsApi,_MetricErrorSpikesResponseApi,_MetricExplainRequestApi,_MetricExplainResponseApi,@@ -344,3 +345,23 @@ export const metricsValuesRetrieve = async (method: 'GET',})}++export const getMetricsValuesCreateUrl = (projectId: string) => {+ return `/api/projects/${projectId}/metrics/values/`+}++/**+ * Distinct metric names for the team. Backs the catalog UI.+ */+export const metricsValuesCreate = async (+ projectId: string,+ _metricCatalogValuesParamsApi: _MetricCatalogValuesParamsApi,+ options?: RequestInit+): Promise<_MetricNamesResponseApi> => {+ return apiMutator<_MetricNamesResponseApi>(getMetricsValuesCreateUrl(projectId), {+ ...options,+ method: 'POST',+ headers: { 'Content-Type': 'application/json', ...options?.headers },+ body: JSON.stringify(_metricCatalogValuesParamsApi),+ })+}diff --git a/products/metrics/frontend/generated/api.zod.ts b/products/metrics/frontend/generated/api.zod.tsindex 570d1f5e949a..0fe892683a90 100644--- a/products/metrics/frontend/generated/api.zod.ts+++ b/products/metrics/frontend/generated/api.zod.ts@@ -582,3 +582,44 @@ export const MetricsSamplesCreateBody = /* @__PURE__ */ zod.object({}).describe('The raw-emissions query to execute.'),})++/**+ * Distinct metric names for the team. Backs the catalog UI.+ */+export const metricsValuesCreateBodyValueDefault = ``+export const metricsValuesCreateBodyValueMax = 255++export const metricsValuesCreateBodyLimitDefault = 100+export const metricsValuesCreateBodyLimitMax = 1000++export const metricsValuesCreateBodyServiceMax = 1024++export const metricsValuesCreateBodyNamesItemMax = 255++export const metricsValuesCreateBodyNamesMax = 20++export const MetricsValuesCreateBody = /* @__PURE__ */ zod.object({+ value: zod+ .string()+ .max(metricsValuesCreateBodyValueMax)+ .default(metricsValuesCreateBodyValueDefault)+ .describe('Substring filter (case-insensitive) applied to metric names.'),+ limit: zod+ .number()+ .min(1)+ .max(metricsValuesCreateBodyLimitMax)+ .default(metricsValuesCreateBodyLimitDefault)+ .describe('Max number of names to return. Defaults to 100; maximum 1000.'),+ service: zod+ .string()+ .max(metricsValuesCreateBodyServiceMax)+ .optional()+ .describe(+ 'Comma-separated services to narrow the list to, e.g. `service=web,worker`. Omit for every service. Send it empty to select only series whose sender did not set `service.name`. A service name containing a comma cannot be selected.'+ ),+ names: zod+ .array(zod.string().max(metricsValuesCreateBodyNamesItemMax))+ .min(1)+ .max(metricsValuesCreateBodyNamesMax)+ .describe('Exact metric names to load as a batch. Overrides value and limit.'),+})diff --git a/products/metrics/mcp/tools.yaml b/products/metrics/mcp/tools.yamlindex 83c8b9dd2388..644d59e29e96 100644--- a/products/metrics/mcp/tools.yaml+++ b/products/metrics/mcp/tools.yaml@@ -62,6 +62,9 @@ tools:metrics-samples-create:operation: metrics_samples_createenabled: false+ metrics-values-create:+ operation: metrics_values_create+ enabled: falsequery-metrics:operation: metrics_query_createenabled: truediff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex f6e566c7d57a..b2559d25348c 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -92938,6 +92938,32 @@ export namespace Schemas {agrees: boolean | null;}+ export interface _MetricCatalogValuesParams {+ /**+ * Substring filter (case-insensitive) applied to metric names.+ * @maxLength 255+ */+ value?: string;+ /**+ * Max number of names to return. Defaults to 100; maximum 1000.+ * @minimum 1+ * @maximum 1000+ */+ limit?: number;+ /**+ * Comma-separated services to narrow the list to, e.g. `service=web,worker`. Omit for every service. Send it empty to select only series whose sender did not set `service.name`. A service name containing a comma cannot be selected.+ * @maxLength 1024+ */+ service?: string;+ /**+ * Exact metric names to load as a batch. Overrides value and limit.+ * @minItems 1+ * @maxItems 20+ * @items.maxLength 255+ */+ names: string[];+ }+export interface _MetricGroupBy {/*** Attribute name to split series by (e.g. 'k8s.pod.name', 'env').