Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(studio): add Disk IO Burst Balance chart to DB Report (#45516)

Jordi Enric420d4d0b5ac3
diff --git a/apps/studio/components/ui/Charts/ChartHeader.tsx b/apps/studio/components/ui/Charts/ChartHeader.tsx
index 6a77a2a8375..3b807513217 100644
--- a/apps/studio/components/ui/Charts/ChartHeader.tsx
+++ b/apps/studio/components/ui/Charts/ChartHeader.tsx
@@ -8,8 +8,7 @@ import {
} from 'lucide-react'
import Link from 'next/link'
import { useEffect, useState } from 'react'
-import { Badge, cn } from 'ui'
-import { InfoTooltip } from 'ui-patterns/info-tooltip'
+import { Badge, cn, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import { formatPercentage, numberFormatter } from './Charts.utils'
import { useChartHoverState } from './useChartHoverState'
@@ -187,9 +186,30 @@ export const ChartHeader = ({
<h3 className={'text-foreground-lighter ' + (minimalHeader ? 'text-xs' : 'text-sm')}>
{title}
</h3>
- {titleTooltip && <InfoTooltip>{titleTooltip}</InfoTooltip>}
+ {titleTooltip && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <InfoIcon className="w-4 h-4 text-foreground-lighter" />
+ </TooltipTrigger>
+ <TooltipContent side="top" className="max-w-xs">
+ {titleTooltip}
+ {docsUrl && (
+ <>
+ {' '}
+ <Link
+ href={docsUrl}
+ target="_blank"
+ className="underline text-foreground hover:text-foreground-light"
+ >
+ Read docs
+ </Link>
+ </>
+ )}
+ </TooltipContent>
+ </Tooltip>
+ )}
</div>
- {docsUrl && (
+ {!titleTooltip && docsUrl && (
<ButtonTooltip
type="text"
className="px-1"
diff --git a/apps/studio/data/reports/database-charts.ts b/apps/studio/data/reports/database-charts.ts
index 5f5c0e5ad9e..61b380dbc8c 100644
--- a/apps/studio/data/reports/database-charts.ts
+++ b/apps/studio/data/reports/database-charts.ts
@@ -1,4 +1,4 @@
-import { COMPUTE_MAX_IOPS } from 'shared-data'
+import { COMPUTE_DISK, COMPUTE_MAX_IOPS } from 'shared-data'
import { mapComputeSizeNameToAddonVariantId } from '@/components/interfaces/DiskManagement/DiskManagement.utils'
import { compactNumberFormatter } from '@/components/ui/Charts/Charts.utils'
@@ -9,28 +9,48 @@ import { Project } from '@/data/projects/project-detail-query'
import { DOCS_URL } from '@/lib/constants'
import { formatBytes } from '@/lib/helpers'
+// Compute variants below 4XL run on EBS instances that draw on a burst
+// credit pool for disk IO, so the burst balance chart only makes sense for
+// these. Larger instances have dedicated IOPS and don't expose this metric.
+const BURSTABLE_IO_VARIANTS = new Set([
+ 'ci_nano',
+ 'ci_micro',
+ 'ci_small',
+ 'ci_medium',
+ 'ci_large',
+ 'ci_xlarge',
+ 'ci_2xlarge',
+])
+
export const getReportAttributesV2: (
entitledFeatures: string[],
project: Project,
diskConfig?: DiskAttributesData,
maxConnections?: MaxConnectionsData,
pgBouncerMaxConnections?: number,
- isSpendCapEnabled?: boolean
+ isSpendCapEnabled?: boolean,
+ showDiskIOBurstBalanceChart?: boolean
) => ReportAttributes[] = (
entitledFeatures,
project,
diskConfig,
maxConnections,
pgBouncerMaxConnections,
- isSpendCapEnabled
+ isSpendCapEnabled,
+ showDiskIOBurstBalanceChart
) => {
+ const computeVariantId = mapComputeSizeNameToAddonVariantId(project?.infra_compute_size)
const provisionedDiskIops = diskConfig?.attributes?.iops
- const computeIopsLimit =
- COMPUTE_MAX_IOPS[mapComputeSizeNameToAddonVariantId(project?.infra_compute_size)]
+ const computeIopsLimit = COMPUTE_MAX_IOPS[computeVariantId]
const effectiveMaxIops =
typeof provisionedDiskIops === 'number' && typeof computeIopsLimit === 'number'
? Math.min(provisionedDiskIops, computeIopsLimit)
: provisionedDiskIops
+ const hasBurstableIO = BURSTABLE_IO_VARIANTS.has(computeVariantId)
+ const showBurstBalanceChart = !!showDiskIOBurstBalanceChart && hasBurstableIO
+ const baselineThroughputMBps = COMPUTE_DISK[computeVariantId]?.baselineThroughputMBps
+ const baselineThroughputLabel =
+ typeof baselineThroughputMBps === 'number' ? `${baselineThroughputMBps} MB/s` : 'its baseline'
return [
{
@@ -312,6 +332,37 @@ export const getReportAttributesV2: (
},
],
},
+ {
+ id: 'disk-io-burst-balance',
+ label: 'Disk IO Burst Balance',
+ titleTooltip: `The burst credit pool that smaller compute instances draw on to sustain IO above their baseline. When the balance hits 0%, sustained throughput returns to its baseline of ${baselineThroughputLabel} until it refills.`,
+ docsUrl: `${DOCS_URL}/guides/platform/compute-add-ons#disk-throughput-and-iops`,
+ syncId: 'database-reports',
+ hide: !showBurstBalanceChart,
+ format: '%',
+ valuePrecision: 0,
+ showTooltip: true,
+ showLegend: false,
+ showMaxValue: false,
+ showGrid: true,
+ YAxisProps: {
+ width: 55,
+ domain: [0, 100] as [number, number],
+ allowDataOverflow: true,
+ tickFormatter: (v: number) => `${Math.round(v)}%`,
+ },
+ hideChartType: false,
+ defaultChartStyle: 'bar',
+ attributes: [
+ {
+ attribute: 'disk_io_budget',
+ provider: 'infra-monitoring',
+ label: 'Burst credits remaining',
+ format: '%',
+ tooltip: `Percentage of EBS burst credits remaining. Drops only matter while the instance is bursting above its baseline IO. At 0%, sustained throughput returns to its baseline of ${baselineThroughputLabel} until it refills.`,
+ },
+ ],
+ },
{
// Client Connections metric for free tier
id: 'client-connections-basic',
diff --git a/apps/studio/pages/project/[ref]/observability/database.tsx b/apps/studio/pages/project/[ref]/observability/database.tsx
index 842fa336c06..7c8fc2c62b9 100644
--- a/apps/studio/pages/project/[ref]/observability/database.tsx
+++ b/apps/studio/pages/project/[ref]/observability/database.tsx
@@ -1,6 +1,6 @@
import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useQueryClient } from '@tanstack/react-query'
-import { useParams } from 'common'
+import { useFlag, useParams } from 'common'
import dayjs from 'dayjs'
import { ArrowRight, ExternalLink, RefreshCw } from 'lucide-react'
import Link from 'next/link'
@@ -132,13 +132,16 @@ const DatabaseUsage = () => {
!org?.usage_billing_enabled &&
project?.cloud_provider !== 'FLY'
+ const showDiskIOBurstBalanceChart = useFlag('showDiskIOBurstBalanceChart')
+
const REPORT_ATTRIBUTES = getReportAttributesV2(
entitledFeatures,
project!,
diskConfig,
maxConnections,
defaultMaxClientConn,
- isSpendCapEnabled
+ isSpendCapEnabled,
+ showDiskIOBurstBalanceChart
)
const { isPending: isUpdatingDiskSize } = useProjectDiskResizeMutation({