From de3524034fe5039c535a1ebe7e825c5beedad104 Mon Sep 17 00:00:00 2001 From: "kemal.earth" <606977+kemaldotearth@users.noreply.github.com> Date: Fri, 25 Sep 2026 17:27:54 +0100 Subject: [PATCH 1/7] feat(studio): add ability to drag top section map (#50904) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem Top section map view on project overview wasn't very usable on smaller window sizes. No ability to drag and see any instances on west coast without stretching viewport or it being cut off. ## Solution Adds dragging to map area so you can bring into view locations out of the bounding box. ## Review instructions 1. Switch to map view and **drag the map** — it should pan, and the previously cut-off regions should be reachable. 2. The drag should **track the cursor 1:1**, with no rubber-band lag. (The 300ms transform transition is what caused that; it's now suppressed mid-drag.) 3. Drag hard toward each edge — the map should **stop at the frame bounds** rather than sliding off into empty background. 4. Cursor should read `grab`, and `grabbing` while dragging. ### Regressions to rule out 5. **Wheel/trackpad scroll over the map** must not zoom it, and the page behind it must still scroll normally. Trackpad pinch must not zoom either. 6. **Double-click** on the map must not zoom. 7. **Click a region marker** — still recenters, zooms to 2.0, and opens the region detail panel bottom-right. The recenter should still animate smoothly. 8. **Close** in that panel still resets to the default center and zoom. 9. **Hover a marker** at default zoom — the country/database tooltip still appears; the dashed lines between primary and replicas still render. 10. Toggle back to **flow view** — unchanged. ## Summary by CodeRabbit * **New Features** * Map view now supports dragging to pan, with cursor changes to indicate when panning is available or in progress. * **Bug Fixes** * Map zoom input is filtered based on event type, modifier keys, and mouse-button state. --- .../InfrastructureConfiguration/MapView.tsx | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/MapView.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/MapView.tsx index 3081274ab3cc3..39cf26f669752 100644 --- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/MapView.tsx +++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/MapView.tsx @@ -4,7 +4,7 @@ import { partition, uniqBy } from 'lodash' import { MoreVertical } from 'lucide-react' import Link from 'next/link' import { parseAsBoolean, useQueryState } from 'nuqs' -import { useEffect, useState } from 'react' +import { useCallback, useEffect, useState } from 'react' import { ComposableMap, Geographies, @@ -35,6 +35,9 @@ import { formatDatabaseID } from '@/data/read-replicas/replicas.utils' import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled' import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector' +const MAP_WIDTH = 800 +const MAP_HEIGHT = 600 + const MapView = () => { const { ref } = useParams() const dbSelectorState = useDatabaseSelectorStateSnapshot() @@ -43,6 +46,7 @@ const MapView = () => { ]) const [mount, setMount] = useState(false) + const [isPanning, setIsPanning] = useState(false) const [zoom, setZoom] = useState(1.5) const [center, setCenter] = useState<[number, number]>([14, 7]) const [tooltip, setTooltip] = useState<{ @@ -78,18 +82,34 @@ const MapView = () => { setTimeout(() => setMount(true), 100) }, []) + const filterZoomEvent = useCallback((event: SVGElement) => { + const { type, ctrlKey, button } = event as unknown as MouseEvent + return type !== 'wheel' && type !== 'dblclick' && !ctrlKey && !button + }, []) + const onMoveStart = useCallback(() => setIsPanning(true), []) + const onMoveEnd = useCallback(() => setIsPanning(false), []) + return ( -
- +
+ - !['MouseEvent', 'WheelEvent'].includes(name) - } + translateExtent={[ + [0, 0], + [MAP_WIDTH, MAP_HEIGHT], + ]} + filterZoomEvent={filterZoomEvent} + onMoveStart={onMoveStart} + onMoveEnd={onMoveEnd} > {({ geographies }) => From 509afd0bf0d260818d2b856f812a9d1ced05f3f7 Mon Sep 17 00:00:00 2001 From: Chris Opland Date: Fri, 25 Sep 2026 12:20:23 -0500 Subject: [PATCH 2/7] fix(o11y): support partial metric loading (#50867) --- .../DatabaseInfrastructureMetric.test.tsx | 150 ++++++++++++++++++ .../DatabaseInfrastructureMetric.tsx | 121 ++++++++++++++ .../DatabaseInfrastructureSection.tsx | 142 ++--------------- .../ComputeMetricsFooter.tsx | 25 ++- .../infra-monitoring-queries.test.ts | 50 +++++- .../analytics/infra-monitoring-queries.ts | 20 ++- .../data/analytics/infra-monitoring-query.ts | 1 + .../hooks/analytics/useComputeMetrics.ts | 34 ++-- .../analytics/useComputeMetrics.utils.ts | 27 ++++ .../analytics/useComputeMetrics.utils.test.ts | 75 +++++++++ 10 files changed, 486 insertions(+), 159 deletions(-) create mode 100644 apps/studio/components/interfaces/Observability/DatabaseInfrastructureMetric.test.tsx create mode 100644 apps/studio/components/interfaces/Observability/DatabaseInfrastructureMetric.tsx create mode 100644 apps/studio/hooks/analytics/useComputeMetrics.utils.ts create mode 100644 apps/studio/tests/hooks/analytics/useComputeMetrics.utils.test.ts diff --git a/apps/studio/components/interfaces/Observability/DatabaseInfrastructureMetric.test.tsx b/apps/studio/components/interfaces/Observability/DatabaseInfrastructureMetric.test.tsx new file mode 100644 index 0000000000000..8489965673e24 --- /dev/null +++ b/apps/studio/components/interfaces/Observability/DatabaseInfrastructureMetric.test.tsx @@ -0,0 +1,150 @@ +import { QueryClient } from '@tanstack/react-query' +import { screen, waitFor, within } from '@testing-library/react' +import { HttpResponse } from 'msw' +import { describe, expect, it } from 'vitest' + +import { DatabaseInfrastructureSection } from './DatabaseInfrastructureSection' +import type { InfraMonitoringMultiResponse } from '@/data/analytics/infra-monitoring-query' +import { databaseKeys } from '@/data/database/keys' +import { projectKeys } from '@/data/projects/keys' +import { customRender } from '@/tests/lib/custom-render' +import { addAPIMock, type APIErrorBody } from '@/tests/lib/msw' + +const values: Record = { + avg_cpu_usage: 25, + ram_usage: 60, + disk_io_consumption: 40, + disk_fs_used_system: 10, + disk_fs_used_wal: 5, + pg_database_size: 35, + disk_fs_size: 100, + pg_stat_database_num_backends: 12, +} + +function mockMetrics(failedAttribute?: string, includeErrors = true) { + const requests: string[][] = [] + addAPIMock({ + method: 'get', + path: '/platform/projects/:ref/infra-monitoring', + response: ({ request }) => { + const attributes = new URL(request.url).searchParams.get('attributes')!.split(',') + requests.push(attributes) + const succeeded = attributes.filter( + (attribute) => failedAttribute !== '*' && attribute !== failedAttribute + ) + const failed = attributes.filter((attribute) => !succeeded.includes(attribute)) + const series = Object.fromEntries( + succeeded.map((attribute) => [ + attribute, + { + totalAverage: values[attribute], + total: values[attribute], + format: '%', + yAxisLimit: 100, + }, + ]) + ) + const pointValues = Object.fromEntries( + succeeded.map((attribute) => [attribute, String(values[attribute])]) + ) + return HttpResponse.json({ + series, + data: succeeded.length + ? [{ period_start: '2026-09-24T00:00:00Z', values: pointValues }] + : [], + ...(includeErrors + ? { + errors: Object.fromEntries( + failed.map((attribute) => [attribute, { message: 'Metric is not supported' }]) + ), + } + : {}), + }) + }, + }) + return requests +} + +function renderMetrics() { + const queryClient = new QueryClient({ + defaultOptions: { queries: { retry: false, staleTime: Infinity } }, + }) + queryClient.setQueryData(projectKeys.detail('default'), { + ref: 'default', + status: 'ACTIVE_HEALTHY', + connectionString: 'postgresql://localhost/postgres', + }) + queryClient.setQueryData(databaseKeys.maxConnections('default'), { maxConnections: 100 }) + customRender( + , + { queryClient } + ) +} + +function card(label: string) { + return within(screen.getByRole('link', { name: new RegExp(label) })) +} + +describe('DatabaseInfrastructureSection batched metrics', () => { + it.each([false, true])( + 'renders all metrics from one request (errors field: %s)', + async (includeErrors) => { + const requests = mockMetrics(undefined, includeErrors) + renderMetrics() + + expect(await card('CPU').findByText('25%')).toBeInTheDocument() + expect(await card('Memory').findByText('60%')).toBeInTheDocument() + expect(await card('Disk IO').findByText('40%')).toBeInTheDocument() + expect(await card('Disk Usage').findByText('50%')).toBeInTheDocument() + expect(await card('Peak Connections').findByText('12/100')).toBeInTheDocument() + expect(requests).toHaveLength(1) + expect(requests[0].sort()).toEqual(Object.keys(values).sort()) + } + ) + + it.each([ + ['disk_io_consumption', 'Disk IO'], + ['disk_fs_used_wal', 'Disk Usage'], + ['pg_stat_database_num_backends', 'Peak Connections'], + ])('isolates a failed %s result to %s', async (attribute, label) => { + const requests = mockMetrics(attribute) + renderMetrics() + + expect(await card(label).findByText('Metric is not supported')).toBeInTheDocument() + expect(await card('CPU').findByText('25%')).toBeInTheDocument() + expect(await card('Memory').findByText('60%')).toBeInTheDocument() + expect(screen.getAllByText('Metric is not supported')).toHaveLength(1) + expect(card(label).queryByText('0%')).not.toBeInTheDocument() + expect(requests).toHaveLength(1) + }) + + it('shows every affected card error when all results fail', async () => { + const requests = mockMetrics('*') + renderMetrics() + await waitFor(() => expect(screen.getAllByText('Metric is not supported')).toHaveLength(5)) + expect(requests).toHaveLength(1) + }) + + it('does not display missing series as zero', async () => { + mockMetrics('disk_io_consumption', false) + renderMetrics() + expect(await card('Disk IO').findByText('Error loading data')).toBeInTheDocument() + expect(await card('CPU').findByText('25%')).toBeInTheDocument() + }) + + it('shows request-wide failures on every infrastructure card', async () => { + addAPIMock({ + method: 'get', + path: '/platform/projects/:ref/infra-monitoring', + response: () => + HttpResponse.json({ message: 'Project not found' }, { status: 404 }), + }) + renderMetrics() + await waitFor(() => expect(screen.getAllByText('Project not found')).toHaveLength(5)) + }) +}) diff --git a/apps/studio/components/interfaces/Observability/DatabaseInfrastructureMetric.tsx b/apps/studio/components/interfaces/Observability/DatabaseInfrastructureMetric.tsx new file mode 100644 index 0000000000000..edb59f9790e76 --- /dev/null +++ b/apps/studio/components/interfaces/Observability/DatabaseInfrastructureMetric.tsx @@ -0,0 +1,121 @@ +import type { UseQueryResult } from '@tanstack/react-query' +import Link from 'next/link' +import { + MetricCard, + MetricCardContent, + MetricCardHeader, + MetricCardLabel, + MetricCardValue, +} from 'ui-patterns/MetricCard' + +import { + parseConnectionsData, + parseInfrastructureMetrics, +} from './DatabaseInfrastructureSection.utils' +import { + type InfraMonitoringAttribute, + type InfraMonitoringError, + type InfraMonitoringMultiData, +} from '@/data/analytics/infra-monitoring-query' +import type { MaxConnectionsData, MaxConnectionsError } from '@/data/database/max-connections-query' + +const METRICS = { + connections: { + label: 'Peak Connections', + tooltip: + 'Highest concurrent database connections observed in the selected window, against the connection limit. Monitor to avoid connection exhaustion.', + attributes: ['pg_stat_database_num_backends'], + }, + disk: { + label: 'Disk Usage', + tooltip: 'Disk usage percentage of total disk space used', + attributes: ['disk_fs_used_system', 'disk_fs_used_wal', 'pg_database_size', 'disk_fs_size'], + }, + diskIo: { + label: 'Disk IO', + tooltip: 'Disk I/O consumption percentage. High values may indicate disk bottlenecks', + attributes: ['disk_io_consumption'], + }, + ram: { + label: 'Memory', + tooltip: 'RAM usage percentage. Sustained high usage may indicate memory pressure', + attributes: ['ram_usage'], + }, + cpu: { + label: 'CPU', + tooltip: 'CPU usage percentage. High values may suggest CPU-intensive queries or workloads', + attributes: ['avg_cpu_usage'], + }, +} satisfies Record< + string, + { label: string; tooltip: string; attributes: InfraMonitoringAttribute[] } +> + +export const INFRASTRUCTURE_METRIC_ATTRIBUTES = Object.values(METRICS).flatMap( + ({ attributes }) => attributes +) + +type DatabaseInfrastructureMetricProps = { + infraQuery: Pick< + UseQueryResult, + 'data' | 'error' | 'isLoading' + > + metric: keyof typeof METRICS + href: string + maxConnectionsQuery: Pick< + UseQueryResult, + 'data' | 'error' | 'isLoading' + > +} + +export const DatabaseInfrastructureMetric = ({ + metric, + href, + maxConnectionsQuery, + infraQuery, +}: DatabaseInfrastructureMetricProps) => { + const { label, tooltip, attributes } = METRICS[metric] + const isConnections = metric === 'connections' + const isLoading = infraQuery.isLoading || (isConnections && maxConnectionsQuery.isLoading) + const data = infraQuery.data + const errors = data && 'errors' in data ? data.errors : undefined + const metricError = attributes.map((attribute) => errors?.[attribute]).find(Boolean) + const hasMissingSeries = + data && 'series' in data && attributes.some((attribute) => !data.series[attribute]) + const error = + infraQuery.error ?? + metricError ?? + (isConnections ? maxConnectionsQuery.error : null) ?? + (hasMissingSeries ? { message: 'Error loading data' } : null) + const errorMessage = + error && typeof error === 'object' && 'message' in error + ? String(error.message) + : 'Error loading data' + + let value = '--' + if (data) { + if (isConnections) { + const connections = parseConnectionsData(data, maxConnectionsQuery.data) + if (connections.max > 0) value = `${connections.peak}/${connections.max}` + } else { + const metrics = parseInfrastructureMetrics(data) + if (metrics) value = `${metrics[metric].current.toFixed(0)}%` + } + } + + return ( + + + + {label} + + + {!!error && ( +
{errorMessage}
+ )} + {!error && {value}} +
+
+ + ) +} diff --git a/apps/studio/components/interfaces/Observability/DatabaseInfrastructureSection.tsx b/apps/studio/components/interfaces/Observability/DatabaseInfrastructureSection.tsx index 13c5d8eeb5467..0f8cda2c25cd5 100644 --- a/apps/studio/components/interfaces/Observability/DatabaseInfrastructureSection.tsx +++ b/apps/studio/components/interfaces/Observability/DatabaseInfrastructureSection.tsx @@ -11,9 +11,9 @@ import { } from 'ui-patterns/MetricCard' import { - parseConnectionsData, - parseInfrastructureMetrics, -} from './DatabaseInfrastructureSection.utils' + DatabaseInfrastructureMetric, + INFRASTRUCTURE_METRIC_ATTRIBUTES, +} from './DatabaseInfrastructureMetric' import { useInfraMonitoringAttributesQuery } from '@/data/analytics/infra-monitoring-query' import { useMaxConnectionsQuery } from '@/data/database/max-connections-query' import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' @@ -66,44 +66,19 @@ export const DatabaseInfrastructureSection = ({ return { startDate: start, endDate: end, infraInterval } }, [interval, refreshKey]) - const { - data: infraData, - isLoading: infraLoading, - error: infraError, - } = useInfraMonitoringAttributesQuery({ + const infraQuery = useInfraMonitoringAttributesQuery({ projectRef, - attributes: [ - 'avg_cpu_usage', - 'ram_usage', - 'disk_fs_used_system', - 'disk_fs_used_wal', - 'pg_database_size', - 'disk_fs_size', - 'disk_io_consumption', - 'pg_stat_database_num_backends', - ], + attributes: INFRASTRUCTURE_METRIC_ATTRIBUTES, startDate, endDate, interval: infraInterval, }) - const { data: maxConnectionsData } = useMaxConnectionsQuery({ + const maxConnectionsQuery = useMaxConnectionsQuery({ projectRef, connectionString: project?.connectionString, }) - const metrics = useMemo(() => parseInfrastructureMetrics(infraData), [infraData]) - - const connections = useMemo( - () => parseConnectionsData(infraData, maxConnectionsData), - [infraData, maxConnectionsData] - ) - - const errorMessage = - infraError && typeof infraError === 'object' && 'message' in infraError - ? String(infraError.message) - : 'Error loading data' - // Generate database report URL with time range parameters const getDatabaseReportUrl = () => { const now = dayjs() @@ -162,102 +137,15 @@ export const DatabaseInfrastructureSection = ({ - - - - - Peak Connections - - - - {infraError ? ( -
{errorMessage}
- ) : connections.max > 0 ? ( - - {connections.peak}/{connections.max} - - ) : ( - -- - )} -
-
- - - - - - - Disk Usage - - - - {infraError ? ( -
{errorMessage}
- ) : metrics ? ( - {metrics.disk.current.toFixed(0)}% - ) : ( - -- - )} -
-
- - - - - - - Disk IO - - - - {infraError ? ( -
{errorMessage}
- ) : metrics ? ( - {metrics.diskIo.current.toFixed(0)}% - ) : ( - -- - )} -
-
- - - - - - - Memory - - - - {infraError ? ( -
{errorMessage}
- ) : metrics ? ( - {metrics.ram.current.toFixed(0)}% - ) : ( - -- - )} -
-
- - - - - - - CPU - - - - {infraError ? ( -
{errorMessage}
- ) : metrics ? ( - {metrics.cpu.current.toFixed(0)}% - ) : ( - -- - )} -
-
- + {(['connections', 'disk', 'diskIo', 'ram', 'cpu'] as const).map((metric) => ( + + ))}
) diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/ComputeMetricsFooter.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/ComputeMetricsFooter.tsx index 4ca4b8d3b433c..2250c7d0a84df 100644 --- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/ComputeMetricsFooter.tsx +++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/ComputeMetricsFooter.tsx @@ -33,10 +33,17 @@ export const ComputeMetricsFooter = ({ showConnections = true }: { showConnectio href={observabilityUrl} className="border-t px-3 py-2 hover:bg-surface-200 transition flex items-center gap-x-3 text-xs" > - {/* Stable live region: announces loading/failure, never the polled values */} + {/* Stable live region: announces loading/unavailability, never the polled values */} {isMetricsLoading && 'Loading metrics'} {!isMetricsLoading && isMetricsError && 'Metrics unavailable'} + {!isMetricsLoading && !isMetricsError && ( + <> + {cpu === null && 'CPU unavailable. '} + {disk === null && 'Disk unavailable. '} + {memory === null && 'RAM unavailable.'} + + )} {/* h-4 matches the text-xs line height so the card doesn't shift when metrics load */} {isMetricsLoading && ( @@ -53,17 +60,17 @@ export const ComputeMetricsFooter = ({ showConnections = true }: { showConnectio {!isMetricsLoading && !isMetricsError && ( <> - CPU {cpu.toFixed(0)}% + CPU · - Disk {disk.toFixed(0)}% + Disk · - RAM {memory.toFixed(0)}% + RAM - {showConnections && connections.max > 0 && ( + {showConnections && connections !== null && connections.max > 0 && ( <> · @@ -79,3 +86,11 @@ export const ComputeMetricsFooter = ({ showConnections = true }: { showConnectio ) } + +function MetricValue({ value }: { value: number | null }) { + if (value === null) { + return Unavailable + } + + return {value.toFixed(0)}% +} diff --git a/apps/studio/data/analytics/infra-monitoring-queries.test.ts b/apps/studio/data/analytics/infra-monitoring-queries.test.ts index b8be88aa2f3b7..504bab80a7dd2 100644 --- a/apps/studio/data/analytics/infra-monitoring-queries.test.ts +++ b/apps/studio/data/analytics/infra-monitoring-queries.test.ts @@ -1,12 +1,20 @@ +import { waitFor } from '@testing-library/react' import dayjs from 'dayjs' +import { HttpResponse } from 'msw' import { describe, expect, it } from 'vitest' -import { aggregate1MinTo2Min, mapResponseToAnalyticsData } from './infra-monitoring-queries' +import { + aggregate1MinTo2Min, + mapResponseToAnalyticsData, + useInfraMonitoringQueries, +} from './infra-monitoring-queries' import type { InfraMonitoringMultiData, InfraMonitoringMultiResponse, InfraMonitoringSingleResponse, } from './infra-monitoring-query' +import { customRenderHook } from '@/tests/lib/custom-render' +import { addAPIMock } from '@/tests/lib/msw' const mockMultiResponse: InfraMonitoringMultiResponse = { data: [ @@ -500,3 +508,43 @@ describe('aggregate1MinTo2Min', () => { expect(typeof result[0].periodStartFormatted).toBe('string') }) }) + +describe('useInfraMonitoringQueries partial failures', () => { + it('reports errors only for failed attributes in a successful batch response', async () => { + addAPIMock({ + method: 'get', + path: '/platform/projects/:ref/infra-monitoring', + response: () => + HttpResponse.json({ + ...mockMultiResponse, + series: { ram_usage: mockMultiResponse.series.ram_usage }, + errors: { max_cpu_usage: { message: 'CPU unavailable' } }, + }), + }) + const { result } = customRenderHook(() => + useInfraMonitoringQueries( + ['max_cpu_usage', 'ram_usage'], + 'default', + '2024-01-02T00:00:00Z', + '2024-01-03T00:00:00Z', + '1h', + undefined, + undefined, + true + ) + ) + + await waitFor(() => expect(result.current[1].status).toBe('success')) + expect(result.current[0]).toMatchObject({ + data: undefined, + error: { message: 'CPU unavailable' }, + isError: true, + status: 'error', + }) + expect(result.current[1]).toMatchObject({ + error: null, + isError: false, + data: { total: 3 }, + }) + }) +}) diff --git a/apps/studio/data/analytics/infra-monitoring-queries.ts b/apps/studio/data/analytics/infra-monitoring-queries.ts index 6c58dc2490618..2d1ad996a1870 100644 --- a/apps/studio/data/analytics/infra-monitoring-queries.ts +++ b/apps/studio/data/analytics/infra-monitoring-queries.ts @@ -66,14 +66,18 @@ export function useInfraMonitoringQueries( return [] } - return attributes.map((attribute) => ({ - data: seriesByAttribute?.[attribute], - error: query.error, - isError: query.isError, - isFetching: query.isFetching, - isLoading: query.isLoading, - status: query.status, - })) + return attributes.map((attribute) => { + const metricError = + query.data && 'errors' in query.data ? query.data.errors?.[attribute] : undefined + return { + data: seriesByAttribute?.[attribute], + error: query.error ?? metricError ?? null, + isError: query.isError || !!metricError, + isFetching: query.isFetching, + isLoading: query.isLoading, + status: metricError ? 'error' : query.status, + } + }) } type AggregatedBucket = { diff --git a/apps/studio/data/analytics/infra-monitoring-query.ts b/apps/studio/data/analytics/infra-monitoring-query.ts index fe4b5fcdabe8a..69846bb3195de 100644 --- a/apps/studio/data/analytics/infra-monitoring-query.ts +++ b/apps/studio/data/analytics/infra-monitoring-query.ts @@ -33,6 +33,7 @@ export type InfraMonitoringMultiResponse = { values: Record }[] series: Record + errors?: Record } // TODO(raulb): Simplify to just InfraMonitoringMultiResponse once API always returns multi-attribute format. diff --git a/apps/studio/hooks/analytics/useComputeMetrics.ts b/apps/studio/hooks/analytics/useComputeMetrics.ts index 63e3a5ba6204b..6f716e128496e 100644 --- a/apps/studio/hooks/analytics/useComputeMetrics.ts +++ b/apps/studio/hooks/analytics/useComputeMetrics.ts @@ -1,6 +1,7 @@ import dayjs from 'dayjs' import { useMemo } from 'react' +import { COMPUTE_METRICS_ATTRIBUTES, getComputeMetricAvailability } from './useComputeMetrics.utils' import { parseConnectionsData, parseInfrastructureMetrics, @@ -10,10 +11,10 @@ import { useMaxConnectionsQuery } from '@/data/database/max-connections-query' import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject' export type ComputeMetrics = { - cpu: number - disk: number - memory: number - connections: { peak: number; max: number } + cpu: number | null + disk: number | null + memory: number | null + connections: { peak: number; max: number } | null isLoading: boolean isError: boolean } @@ -37,21 +38,17 @@ export function useComputeMetrics({ projectRef }: { projectRef?: string }): Comp isError, } = useInfraMonitoringAttributesQuery({ projectRef, - attributes: [ - 'avg_cpu_usage', - 'ram_usage', - 'disk_fs_used_system', - 'disk_fs_used_wal', - 'pg_database_size', - 'disk_fs_size', - 'pg_stat_database_num_backends', - ], + attributes: COMPUTE_METRICS_ATTRIBUTES, startDate, endDate, interval: '1h', }) - const { data: maxConnectionsData, isLoading: connectionsLoading } = useMaxConnectionsQuery({ + const { + data: maxConnectionsData, + isLoading: connectionsLoading, + isError: isConnectionsError, + } = useMaxConnectionsQuery({ projectRef, connectionString: project?.connectionString, }) @@ -61,12 +58,13 @@ export function useComputeMetrics({ projectRef }: { projectRef?: string }): Comp () => parseConnectionsData(infraData, maxConnectionsData), [infraData, maxConnectionsData] ) + const availability = getComputeMetricAvailability(infraData) return { - cpu: metrics?.cpu.current ?? 0, - disk: metrics?.disk.current ?? 0, - memory: metrics?.ram.current ?? 0, - connections, + cpu: availability.cpu ? (metrics?.cpu.current ?? null) : null, + disk: availability.disk ? (metrics?.disk.current ?? null) : null, + memory: availability.memory ? (metrics?.ram.current ?? null) : null, + connections: availability.connections && !isConnectionsError ? connections : null, isLoading: infraLoading || connectionsLoading, isError, } diff --git a/apps/studio/hooks/analytics/useComputeMetrics.utils.ts b/apps/studio/hooks/analytics/useComputeMetrics.utils.ts new file mode 100644 index 0000000000000..c411933cd9809 --- /dev/null +++ b/apps/studio/hooks/analytics/useComputeMetrics.utils.ts @@ -0,0 +1,27 @@ +import type { + InfraMonitoringAttribute, + InfraMonitoringResponse, +} from '@/data/analytics/infra-monitoring-query' + +const COMPUTE_METRIC_ATTRIBUTES = { + cpu: ['avg_cpu_usage'], + memory: ['ram_usage'], + disk: ['disk_fs_used_system', 'disk_fs_used_wal', 'pg_database_size', 'disk_fs_size'], + connections: ['pg_stat_database_num_backends'], +} satisfies Record + +export const COMPUTE_METRICS_ATTRIBUTES = Object.values(COMPUTE_METRIC_ATTRIBUTES).flat() + +export function getComputeMetricAvailability(data: InfraMonitoringResponse | undefined) { + const hasMetricData = (attributes: InfraMonitoringAttribute[]) => + !!data && + 'series' in data && + attributes.every((attribute) => !!data.series[attribute] && !data.errors?.[attribute]) + + return { + cpu: hasMetricData(COMPUTE_METRIC_ATTRIBUTES.cpu), + memory: hasMetricData(COMPUTE_METRIC_ATTRIBUTES.memory), + disk: hasMetricData(COMPUTE_METRIC_ATTRIBUTES.disk), + connections: hasMetricData(COMPUTE_METRIC_ATTRIBUTES.connections), + } +} diff --git a/apps/studio/tests/hooks/analytics/useComputeMetrics.utils.test.ts b/apps/studio/tests/hooks/analytics/useComputeMetrics.utils.test.ts new file mode 100644 index 0000000000000..8b224201467cd --- /dev/null +++ b/apps/studio/tests/hooks/analytics/useComputeMetrics.utils.test.ts @@ -0,0 +1,75 @@ +import { describe, expect, it } from 'vitest' + +import type { InfraMonitoringMultiResponse } from '@/data/analytics/infra-monitoring-query' +import { + COMPUTE_METRICS_ATTRIBUTES, + getComputeMetricAvailability, +} from '@/hooks/analytics/useComputeMetrics.utils' + +function createMetricsResponse(): InfraMonitoringMultiResponse { + return { + data: [], + series: Object.fromEntries( + COMPUTE_METRICS_ATTRIBUTES.map((attribute) => [ + attribute, + { yAxisLimit: 100, format: '', total: 0, totalAverage: 0 }, + ]) + ), + } +} + +const allAvailable = { cpu: true, memory: true, disk: true, connections: true } + +describe('getComputeMetricAvailability', () => { + it('keeps successful zero values available', () => { + expect(getComputeMetricAvailability(createMetricsResponse())).toEqual(allAvailable) + }) + + it.each([ + ['avg_cpu_usage', 'cpu'], + ['ram_usage', 'memory'], + ['disk_fs_used_system', 'disk'], + ['disk_fs_used_wal', 'disk'], + ['pg_database_size', 'disk'], + ['disk_fs_size', 'disk'], + ['pg_stat_database_num_backends', 'connections'], + ])( + 'only marks the affected metric unavailable when %s fails or is missing', + (attribute, metric) => { + const response = createMetricsResponse() + response.errors = { [attribute]: { message: 'Failed to load attribute' } } + expect(getComputeMetricAvailability(response)).toEqual({ ...allAvailable, [metric]: false }) + + delete response.errors + delete response.series[attribute] + expect(getComputeMetricAvailability(response)).toEqual({ ...allAvailable, [metric]: false }) + } + ) + + it('ignores errors for unrelated attributes', () => { + const response = createMetricsResponse() + response.errors = { disk_io_consumption: { message: 'Failed to load attribute' } } + expect(getComputeMetricAvailability(response)).toEqual(allAvailable) + }) + + it.each([undefined, { data: [], series: {} }])('handles absent metrics', (response) => { + expect(getComputeMetricAvailability(response)).toEqual({ + cpu: false, + memory: false, + disk: false, + connections: false, + }) + }) + + it('handles a response without multi-attribute series', () => { + expect( + getComputeMetricAvailability({ + data: [], + yAxisLimit: 100, + format: '', + total: 0, + totalAverage: 0, + }) + ).toEqual({ cpu: false, memory: false, disk: false, connections: false }) + }) +}) From 830c06d494d6692d0a37e64aa56c77dbdca3752d Mon Sep 17 00:00:00 2001 From: Sean Geoghegan Date: Sat, 26 Sep 2026 03:07:24 +0930 Subject: [PATCH 3/7] docs: clarify authorisation window when policies change (#50695) ## Solution Clarifying the authorisation window for RLS/access checks on channels in Realtime. ## Review instructions Provide a clear numbered procedure that the PR reviewer can walk through. 1. For example, `Open the live and preview links side-by-side.` 2. For example, `See the issue is fixed.` ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which references [WORD_LIST](https://github.com/supabase/supabase/blob/master/apps/docs/WORD_LIST.md) and the docs [CONTRIBUTING](https://github.com/supabase/supabase/blob/master/apps/docs/CONTRIBUTING.md) guide ## Summary by CodeRabbit * **Documentation** * Clarified that Realtime authorization policy changes may not affect already-connected clients until their JWT expires or a new JWT is provided. --- apps/docs/content/guides/realtime/authorization.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/docs/content/guides/realtime/authorization.mdx b/apps/docs/content/guides/realtime/authorization.mdx index 7b8cd831b9b89..7dc0410d29cb2 100644 --- a/apps/docs/content/guides/realtime/authorization.mdx +++ b/apps/docs/content/guides/realtime/authorization.mdx @@ -402,6 +402,8 @@ Realtime updates the access policy cache for a client based on your RLS policies - A client connects to Realtime and subscribes to a Channel - A new JWT is sent to Realtime from a client via the [`access_token` message](/docs/guides/realtime/protocol#access-token) +This means that if you revoke a user's access (for example, by removing a row an RLS policy uses to grant it) while they're still connected, they'll keep receiving messages until their JWT expires or a new one is sent. + If a new JWT is never received on the Channel, the client will be disconnected when the JWT expires. Make sure to keep the JWT expiration window short. From a21111b7e0a0f2866cf56e5938cf786322305f96 Mon Sep 17 00:00:00 2001 From: Sean Geoghegan Date: Sat, 26 Sep 2026 03:08:14 +0930 Subject: [PATCH 4/7] docs: Clarify private flag for broadcast from database (#50192) ## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Doc update ## What is the current behavior? The description of the private flag for broadcast from database functions is inconsistent and a bit confusing. ## What is the new behavior? Use the same language on both examples and clarify the default, and what true and false map to. ## Summary by CodeRabbit - **Documentation** - Clarified the meaning of boolean privacy flags in realtime SQL examples: `true` indicates Private (the default), while `false` indicates Public. --- apps/docs/content/guides/realtime/broadcast.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/docs/content/guides/realtime/broadcast.mdx b/apps/docs/content/guides/realtime/broadcast.mdx index 1ebfc278dbd04..f56f9e5617053 100644 --- a/apps/docs/content/guides/realtime/broadcast.mdx +++ b/apps/docs/content/guides/realtime/broadcast.mdx @@ -509,7 +509,7 @@ select jsonb_build_object('hello', 'world'), -- JSONB Payload 'event', -- Event name 'topic', -- Topic - false -- Public / Private flag + false -- Private flag - true: Private (default), false: Public ); ``` @@ -530,7 +530,7 @@ select '\x012345'::bytea, -- bytea payload 'event', -- Event name 'topic', -- Topic - true -- Private / Public flag (defaults to true) + true -- Private flag - true: Private (default), false: Public ); ``` From c6b92060d2d9183ff4708fee346f391ca5253fb5 Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Fri, 25 Sep 2026 13:39:51 -0400 Subject: [PATCH 5/7] docs(realtime): realtime permissions (#50735) All changes are related to Realtime permissions that I observed on support tickets recently: - Migrations can't have `ALTER TABLE realtime.messages`. That's is not allowed and breaks migrations. - Missing realtime.messages partitions are usually due to lack of connections - Errors like "must be owner of table messages" are misleading Closes REAL-1125 ## Additional context https://supabase.slack.com/archives/C01G8CC0X9D/p1789981286693829 and SU-479680 ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which references [WORD_LIST](https://github.com/supabase/supabase/blob/master/apps/docs/WORD_LIST.md) and the docs [CONTRIBUTING](https://github.com/supabase/supabase/blob/master/apps/docs/CONTRIBUTING.md) guide ## Summary by CodeRabbit * **Documentation** * Clarified Realtime authorization restrictions, supported RLS policy management, and the existing RLS configuration for `realtime.messages`. * Documented broadcast partition creation, connection requirements, and warning behavior when partitions are unavailable. * Added troubleshooting guidance for ownership errors, including migration rollback implications and supported remedies. * Added instructions for inspecting message partitions and diagnosing missing, expired, or unavailable partition configurations. --- .../content/guides/realtime/authorization.mdx | 12 ++- .../content/guides/realtime/broadcast.mdx | 2 + ...altime-must-be-owner-of-table-messages.mdx | 84 +++++++++++++++++++ ...ealtime-warn-sending-broadcast-message.mdx | 18 ++++ 4 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 apps/docs/content/troubleshooting/realtime-must-be-owner-of-table-messages.mdx diff --git a/apps/docs/content/guides/realtime/authorization.mdx b/apps/docs/content/guides/realtime/authorization.mdx index 7dc0410d29cb2..a467f43d6fa76 100644 --- a/apps/docs/content/guides/realtime/authorization.mdx +++ b/apps/docs/content/guides/realtime/authorization.mdx @@ -25,9 +25,17 @@ By creating RLS policies on the `realtime.messages` table you can control the ac -Realtime locks down the `realtime` schema to protect it against unexpected changes to guarantee the healthy operation of the Realtime service and avoid conflicts that could be caused by future migrations. Creating a table or function in `realtime` is expected to fail with `permission denied for schema realtime`, whether you run the SQL yourself or through the dashboard. Managing RLS policies on `realtime.messages` is allowed. +Realtime locks down the `realtime` schema to protect it against unexpected changes to guarantee the healthy operation of the Realtime service and avoid conflicts that could be caused by future migrations. Creating a table or function in `realtime` is expected to fail with `permission denied for schema realtime`, whether you run the SQL yourself or through the dashboard. Managing RLS policies on `realtime.messages` is allowed: [`supautils`](https://github.com/supabase/supautils) lets the `postgres` role run policy statements on that table without owning it. -Row level security (RLS) is enabled by default on table `realtime.messages`, you don't need to execute `ALTER TABLE realtime.messages ENABLE ROW LEVEL SECURITY`. +Row Level Security is already enabled on `realtime.messages`, so don't add `ALTER TABLE realtime.messages ENABLE ROW LEVEL SECURITY` to a migration. Postgres checks table ownership before it checks whether the setting would change, so the statement fails with `42501 must be owner of table messages`. That aborts the transaction, and every statement after it is skipped, including any `create policy` statements that follow. + +Remove the `ALTER TABLE` line and the rest of the migration passes. If a migration needs to check that RLS is on, read the catalog: + +```sql +select relrowsecurity from pg_class where oid = 'realtime.messages'::regclass; +``` + +If you hit that error, see [must be owner of table messages](/docs/guides/troubleshooting/realtime-must-be-owner-of-table-messages). diff --git a/apps/docs/content/guides/realtime/broadcast.mdx b/apps/docs/content/guides/realtime/broadcast.mdx index f56f9e5617053..41240dafea0bf 100644 --- a/apps/docs/content/guides/realtime/broadcast.mdx +++ b/apps/docs/content/guides/realtime/broadcast.mdx @@ -1020,6 +1020,8 @@ Broadcast Changes allows you to trigger messages from your database. To achieve It uses partitioned tables per day, which allows performant deletion of your previous messages by dropping the physical tables of this partitioned table. Tables older than 3 days are deleted. +A client connecting over WebSocket creates those daily partitions. `realtime.send` does not. With no partition for today, the insert fails and Postgres logs a `WarnSendingBroadcastMessage` warning, so connect a client before you broadcast from the database. See [Realtime: `WarnSendingBroadcastMessage`](/docs/guides/troubleshooting/realtime-warn-sending-broadcast-message) if you hit that warning. + Broadcasting from the database works like a client-side broadcast, using WebSockets to send JSON payloads. [Realtime Authorization](/docs/guides/realtime/authorization) is required and enabled by default to protect your data. Broadcast Changes provides two functions to help you send messages: diff --git a/apps/docs/content/troubleshooting/realtime-must-be-owner-of-table-messages.mdx b/apps/docs/content/troubleshooting/realtime-must-be-owner-of-table-messages.mdx new file mode 100644 index 0000000000000..4e756227e09a2 --- /dev/null +++ b/apps/docs/content/troubleshooting/realtime-must-be-owner-of-table-messages.mdx @@ -0,0 +1,84 @@ +--- +title = "Realtime: \"must be owner of table messages\" when setting up Authorization" +topics = [ "realtime" ] +keywords = [ "realtime.messages", "must be owner", "42501", "row level security", "policy", "authorization", "broadcast", "migration" ] + +[[errors]] +code = "42501" +message = "must be owner of table messages" +--- + +A migration that adds an RLS policy to `realtime.messages` fails: + +``` +ERROR: 42501: must be owner of table messages +``` + +## Cause + +`realtime.messages` is owned by an internal role, `supabase_realtime_admin`. The `postgres` role is not a member of it and is not a superuser. + +Policies still work because of [`supautils`](https://github.com/supabase/supautils), the extension that gives the `postgres` role its elevated permissions on a Supabase project. It lets `postgres` run `create policy`, `alter policy`, and `drop policy` on a fixed list of tables it does not own, and `realtime.messages` is on that list. The list covers policy statements only, so `ALTER TABLE` is still refused. + +The failing statement is usually not the `create policy`. It's an `ALTER TABLE` earlier in the same migration: + +```sql +alter table realtime.messages enable row level security; +alter table realtime.messages add column ...; +alter table realtime.messages owner to postgres; +``` + +The first one is the common case. RLS is already enabled on `realtime.messages`, and Postgres checks ownership before it checks whether the setting would change, so the statement fails on every project. + +A failed statement aborts the transaction, so Postgres skips everything after it, including the `create policy`. `supabase db push` runs each migration file in one transaction, so the file rolls back and nothing is written to `supabase_migrations.schema_migrations`. + +## Fix + +Remove the `ALTER TABLE` line. Keep the policy: + +```sql +create policy "authenticated can read messages on room-1" +on "realtime"."messages" +for select +to authenticated +using ( + (select realtime.topic()) = 'room-1' +); +``` + +Run it from the SQL editor or with `supabase db push`. Both connect as `postgres`. + +To check that RLS is on, read the catalog instead of setting it: + +```sql +select relrowsecurity from pg_class where oid = 'realtime.messages'::regclass; +``` + +## What doesn't work + +Granting the owning role fails, and support can't grant it either: + +```sql +grant supabase_realtime_admin to postgres; +-- ERROR: 42501: "supabase_realtime_admin" role memberships are reserved, only superusers can grant them +``` + +Restarting the project changes nothing. + +Wrapping the `ALTER TABLE` in a function or a `do` block changes nothing either. The ownership check still runs, and a `security definer` function owned by `postgres` is still not the table owner. + +## What postgres can do on realtime.messages + +The `Yes` rows are what `supautils` delegates, plus the privileges granted to `postgres` directly. + +| Statement | Allowed | +| ----------------------------------------------------- | ------- | +| `create policy`, `alter policy`, `drop policy` | Yes | +| `comment on policy` | Yes | +| `select`, `insert` | Yes | +| `grant select`, `grant insert` to your own roles | Yes | +| `alter table` in any form | No | +| `drop table` | No | +| Creating tables or functions in the `realtime` schema | No | + +See [Realtime Authorization](/docs/guides/realtime/authorization) for writing the policies. diff --git a/apps/docs/content/troubleshooting/realtime-warn-sending-broadcast-message.mdx b/apps/docs/content/troubleshooting/realtime-warn-sending-broadcast-message.mdx index 41dfe26153e74..59e34a447e09d 100644 --- a/apps/docs/content/troubleshooting/realtime-warn-sending-broadcast-message.mdx +++ b/apps/docs/content/troubleshooting/realtime-warn-sending-broadcast-message.mdx @@ -45,6 +45,24 @@ Calling `realtime.send` or `realtime.send_binary`, the broadcast REST endpoint, +## Check which partitions you have + +```sql +select c.relname +from pg_inherits i + join pg_class c on c.oid = i.inhrelid +where i.inhparent = 'realtime.messages'::regclass +order by c.relname; +``` + +The names are dates, so the result tells you which case you are in: + +- One covers today. The missing partition is not the cause, so go to [When it is a real problem](#when-it-is-a-real-problem). +- They all end on a past date. Your window lapsed. The newest name is three days after the last time partitions were created, because each creation covers yesterday through three days ahead. +- No rows. No client has ever connected, so no partition was ever created. + +Zero rows does not mean the Realtime migrations are missing. Those would fail this query with `42P01 relation "realtime.messages" does not exist`. If you see `42P01`, open a support ticket. + ## How to avoid it - Connect a client before broadcasting from the database. A live WebSocket connection both creates the partitions and starts the consumer that receives the message. From d5cda0c6efff58227f0aaa7dfcb5077bd57a4e4b Mon Sep 17 00:00:00 2001 From: shaziya <99940835+shaziyabandukia@users.noreply.github.com> Date: Fri, 25 Sep 2026 11:36:52 -0700 Subject: [PATCH 6/7] chore(www): update quote attribution in Gemini Enterprise blog post (#50929) ## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Content update (blog post) ## What is the current behavior? The Google Cloud quote in the "Supabase is now available in Gemini Enterprise" blog post is attributed to Rayn Veerubhotla. ## What is the new behavior? The quote is now attributed to Ritika Suri, Managing Director, AI and Data Partnerships at Google Cloud. The quote text itself is unchanged. ## Additional context Attribution updated per the latest version of the internal launch doc. ## Summary by CodeRabbit * **Documentation** * Updated the Google Cloud partnership quote attribution. --- ...026-09-09-supabase-is-now-available-in-gemini-enterprise.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/www/_blog/2026-09-09-supabase-is-now-available-in-gemini-enterprise.mdx b/apps/www/_blog/2026-09-09-supabase-is-now-available-in-gemini-enterprise.mdx index a2bbb881fb03b..02f95d9aeed58 100644 --- a/apps/www/_blog/2026-09-09-supabase-is-now-available-in-gemini-enterprise.mdx +++ b/apps/www/_blog/2026-09-09-supabase-is-now-available-in-gemini-enterprise.mdx @@ -49,7 +49,7 @@ Connections are made at the Supabase organization level, and every tool the conn > Developers and their teams increasingly work from wherever the conversation is happening. Connecting Supabase's MCP Server to Gemini Enterprise means your backend is part of that conversation, grounded in live data from your actual projects. -— **Rayn Veerubhotla**, Google Managing Director, Partner Technical Architects +— **Ritika Suri**, Managing Director, AI and Data Partnerships at Google Cloud ## Get started From db2242e223be1bad917577d786b053ecef5f1660 Mon Sep 17 00:00:00 2001 From: Chris Opland Date: Fri, 25 Sep 2026 14:23:46 -0500 Subject: [PATCH 7/7] fix(o11y): add connections to footer (#50928) --- .../ComputeMetricsFooter.tsx | 28 +++++++++++++------ .../HaInstanceNode.tsx | 4 +-- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/ComputeMetricsFooter.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/ComputeMetricsFooter.tsx index 2250c7d0a84df..b033530352a35 100644 --- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/ComputeMetricsFooter.tsx +++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/ComputeMetricsFooter.tsx @@ -10,7 +10,11 @@ import { useComputeMetrics } from '@/hooks/analytics/useComputeMetrics' * to the database report. Metrics are project-scoped, which reports the * primary on both standard and High Availability projects. */ -export const ComputeMetricsFooter = ({ showConnections = true }: { showConnections?: boolean }) => { +export const ComputeMetricsFooter = ({ + isConnectionsAvailable = true, +}: { + isConnectionsAvailable?: boolean +}) => { const { ref } = useParams() const { @@ -25,6 +29,7 @@ export const ComputeMetricsFooter = ({ showConnections = true }: { showConnectio }) const observabilityUrl = `/project/${ref}/observability/database` + const hasConnectionMetrics = isConnectionsAvailable && connections !== null && connections.max > 0 return ( @@ -41,7 +46,8 @@ export const ComputeMetricsFooter = ({ showConnections = true }: { showConnectio <> {cpu === null && 'CPU unavailable. '} {disk === null && 'Disk unavailable. '} - {memory === null && 'RAM unavailable.'} + {memory === null && 'RAM unavailable. '} + {!hasConnectionMetrics && 'Connection metrics unavailable.'} )} @@ -70,14 +76,18 @@ export const ComputeMetricsFooter = ({ showConnections = true }: { showConnectio RAM - {showConnections && connections !== null && connections.max > 0 && ( - <> - · - + · + + {hasConnectionMetrics ? ( + <> {connections.peak}/{connections.max} conns - - - )} + + ) : ( + <> + Conns Unavailable + + )} + )} diff --git a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceNode.tsx b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceNode.tsx index f564131ad150f..8ce3f52c735a0 100644 --- a/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceNode.tsx +++ b/apps/studio/components/interfaces/Settings/Infrastructure/InfrastructureConfiguration/HaInstanceNode.tsx @@ -115,8 +115,8 @@ export const HaPrimaryNode = ({ data }: NodeProps>) => { )} {/* Whether connection metrics are meaningful through the multigateway - is unconfirmed, so they're left off for HA projects. */} - + is unconfirmed, so they're marked unavailable for HA projects. */} +