mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 00:19:08 +00:00
## Problem Infrastructure and Observability label consumed disk IO burst credits as “Disk IO,” so a value of 1% appears inconsistent with a remaining balance of 99% in AWS or Grafana. Both surfaces request `disk_io_consumption`, which is the inverse of `disk_io_budget`. ## Fix Show `disk_io_budget` as “Disk IO balance” and explain that it represents the lower of the remaining throughput and IOPS burst balances. Infrastructure shows the lowest sampled balance over seven days; Observability shows the selected-window average. Keep Infrastructure's overall Compute score based on consumed credits, so a full balance stays healthy and a low balance still warns. Missing balance remains unavailable. Update the compute and disk guide and disk IO troubleshooting page to explain the remaining balance, its direction, and the different aggregation windows. ## How to test - Open Infrastructure settings for a project with burstable IO. Verify the balance headline and chart show remaining credits, with 100% full and 0% exhausted. - Open Observability and verify “Disk IO balance” shows the average remaining balance for the selected window. - Hover the labels to check the explanation and aggregation window. - Verify a high balance does not inflate Compute usage, a low balance raises the warning, and missing balance does not appear as 0% or 100%. - Focused unit and MSW component tests: 79 passed, including shuffled runs with retries disabled; regression mutations caught wrong metric selection, reversed pressure, and maximum-versus-minimum selection. ## Validation Studio typecheck, changed-file ESLint, and Prettier pass locally. Verified both surfaces on the deployed preview, including Observability refresh and the balance tooltip. Documentation formatting and review pass. The local markdown build is blocked by missing generated federated content and its GitHub credentials; docs CI validates the deployed build. ## Screenshots Same project on `supabase.green` (before) and the PR preview (after), captured October 20. Infrastructure uses the same seven-day window; Observability uses Last 24 hours. ### Infrastructure | Before | After | | --- | --- | |  |  | ### Observability | Before | After | | --- | --- | |  |  | Observability balance explanation:  Fixes FDBKPRI-2885
124 lines
4.1 KiB
TypeScript
124 lines
4.1 KiB
TypeScript
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 balance',
|
|
tooltip:
|
|
'Average remaining disk IO burst balance in the selected window, using the lower of throughput and IOPS balances; 100% is full and 0% is exhausted.',
|
|
attributes: ['disk_io_budget'],
|
|
},
|
|
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<InfraMonitoringMultiData, InfraMonitoringError>,
|
|
'data' | 'error' | 'isLoading'
|
|
>
|
|
metric: keyof typeof METRICS
|
|
href: string
|
|
maxConnectionsQuery: Pick<
|
|
UseQueryResult<MaxConnectionsData, MaxConnectionsError>,
|
|
'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)
|
|
const current = metrics?.[metric].current
|
|
if (current !== undefined) value = `${current.toFixed(0)}%`
|
|
}
|
|
}
|
|
|
|
return (
|
|
<Link href={href} className="block group">
|
|
<MetricCard isLoading={isLoading}>
|
|
<MetricCardHeader linkTooltip="Go to database report">
|
|
<MetricCardLabel tooltip={tooltip}>{label}</MetricCardLabel>
|
|
</MetricCardHeader>
|
|
<MetricCardContent>
|
|
{!!error && (
|
|
<div className="text-xs text-destructive wrap-break-word">{errorMessage}</div>
|
|
)}
|
|
{!error && <MetricCardValue>{value}</MetricCardValue>}
|
|
</MetricCardContent>
|
|
</MetricCard>
|
|
</Link>
|
|
)
|
|
}
|