Skip to content

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

feat(studio): streamline status health visual (#46274)

kemal.earthed921f36f735
diff --git a/apps/docs/app/guides/troubleshooting/page.tsx b/apps/docs/app/guides/troubleshooting/page.tsx
index d00356c6e27..19e92851bb5 100644
--- a/apps/docs/app/guides/troubleshooting/page.tsx
+++ b/apps/docs/app/guides/troubleshooting/page.tsx
@@ -1,5 +1,3 @@
-import { type Metadata } from 'next'
-
import { TroubleshootingPreview } from '~/features/docs/Troubleshooting.ui'
import {
TroubleshootingFilter,
@@ -16,6 +14,7 @@ import { TROUBLESHOOTING_CONTAINER_ID } from '~/features/docs/Troubleshooting.ut
import { SidebarSkeleton } from '~/layouts/MainSkeleton'
import { PROD_URL } from '~/lib/constants'
import { getCustomContent } from '~/lib/custom-content/getCustomContent'
+import { type Metadata } from 'next'
const { metadataTitle } = getCustomContent(['metadata:title'])
diff --git a/apps/studio/components/interfaces/Observability/ObservabilityOverview.tsx b/apps/studio/components/interfaces/Observability/ObservabilityOverview.tsx
index b358ec29eba..bec0b4818cb 100644
--- a/apps/studio/components/interfaces/Observability/ObservabilityOverview.tsx
+++ b/apps/studio/components/interfaces/Observability/ObservabilityOverview.tsx
@@ -67,6 +67,14 @@ export const ObservabilityOverview = () => {
const serviceBase = useMemo(
() => [
+ {
+ key: 'data_api' as const,
+ name: 'API Gateway',
+ reportUrl: undefined,
+ logsUrl: `/project/${projectRef}/logs/edge-logs`,
+ enabled: isDataApiEnabled,
+ hasReport: false,
+ },
{
key: 'db' as const,
name: 'Database',
@@ -76,12 +84,12 @@ export const ObservabilityOverview = () => {
hasReport: true,
},
{
- key: 'data_api' as const,
- name: 'API Gateway',
- reportUrl: undefined,
- logsUrl: `/project/${projectRef}/logs/edge-logs`,
- enabled: isDataApiEnabled,
- hasReport: false,
+ key: 'postgrest' as const,
+ name: 'PostgREST',
+ reportUrl: `/project/${projectRef}/observability/postgrest`,
+ logsUrl: `/project/${projectRef}/logs/postgrest-logs`,
+ enabled: true,
+ hasReport: true,
},
{
key: 'auth' as const,
@@ -99,14 +107,6 @@ export const ObservabilityOverview = () => {
enabled: true,
hasReport: true,
},
- {
- key: 'realtime' as const,
- name: 'Realtime',
- reportUrl: `/project/${projectRef}/observability/realtime`,
- logsUrl: `/project/${projectRef}/logs/realtime-logs`,
- enabled: true,
- hasReport: true,
- },
{
key: 'storage' as const,
name: 'Storage',
@@ -116,10 +116,10 @@ export const ObservabilityOverview = () => {
hasReport: true,
},
{
- key: 'postgrest' as const,
- name: 'PostgREST',
- reportUrl: `/project/${projectRef}/observability/postgrest`,
- logsUrl: `/project/${projectRef}/logs/postgrest-logs`,
+ key: 'realtime' as const,
+ name: 'Realtime',
+ reportUrl: `/project/${projectRef}/observability/realtime`,
+ logsUrl: `/project/${projectRef}/logs/realtime-logs`,
enabled: true,
hasReport: true,
},
diff --git a/apps/studio/components/interfaces/Observability/ObservabilityOverviewFooter.tsx b/apps/studio/components/interfaces/Observability/ObservabilityOverviewFooter.tsx
index af9586e5144..6980c19c40f 100644
--- a/apps/studio/components/interfaces/Observability/ObservabilityOverviewFooter.tsx
+++ b/apps/studio/components/interfaces/Observability/ObservabilityOverviewFooter.tsx
@@ -2,7 +2,7 @@ import Link from 'next/link'
export const ObservabilityOverviewFooter = () => {
return (
- <div className="py-12 flex items-center justify-center">
+ <div className="pt-4 pb-12 flex items-center justify-center">
<p className="text-sm text-foreground-light">
<Link
href="https://supabase.com/docs/guides/troubleshooting"
diff --git a/apps/studio/components/interfaces/Observability/ServiceHealthTable.tsx b/apps/studio/components/interfaces/Observability/ServiceHealthTable.tsx
index cda4729c2b8..1ca65d3023d 100644
--- a/apps/studio/components/interfaces/Observability/ServiceHealthTable.tsx
+++ b/apps/studio/components/interfaces/Observability/ServiceHealthTable.tsx
@@ -1,11 +1,20 @@
import { ChevronRight, HelpCircle } from 'lucide-react'
import Link from 'next/link'
-import { Card, CardContent, Loading, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
+import {
+ Button,
+ Card,
+ CardContent,
+ cn,
+ Skeleton,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from 'ui'
+import { ChartEmptyState, ChartLoadingState } from 'ui-patterns/Chart'
import { LogsBarChart } from 'ui-patterns/LogsBarChart'
-import { ButtonTooltip } from '../../ui/ButtonTooltip'
import type { LogsBarChartDatum } from '../ProjectHome/ProjectUsage.metrics'
-import type { ServiceKey } from './ObservabilityOverview.utils'
+import { getHealthStatus, type ServiceKey } from './ObservabilityOverview.utils'
type ServiceConfig = {
key: ServiceKey
@@ -31,6 +40,13 @@ export type ServiceHealthTableProps = {
datetimeFormat: string
}
+const colorClassMap: Record<string, string> = {
+ muted: 'bg-gray-500',
+ destructive: 'bg-destructive',
+ warning: 'bg-warning',
+ brand: 'bg-brand',
+}
+
const SERVICE_DESCRIPTIONS: Record<ServiceKey, string> = {
db: 'PostgreSQL database health and performance',
auth: 'Authentication and user management',
@@ -41,102 +57,126 @@ const SERVICE_DESCRIPTIONS: Record<ServiceKey, string> = {
postgrest: 'Auto-generated REST API for your database',
}
-type ServiceRowProps = {
+const formatPercent = (value: number) =>
+ value >= 1 ? `${value.toFixed(1)}%` : `${value.toFixed(2)}%`
+
+const getSubtitle = (data: ServiceData) => {
+ if (data.total === 0) return ''
+
+ const errorRate = data.errorRate
+ const warningRate = data.total > 0 ? (data.warningCount / data.total) * 100 : 0
+
+ if (errorRate > 0) return `${formatPercent(errorRate)} errors`
+ if (warningRate > 0) return `${formatPercent(warningRate)} warnings`
+ return `${data.total.toLocaleString()} requests`
+}
+
+type ServiceCellProps = {
service: ServiceConfig
data: ServiceData
onBarClick: (datum: LogsBarChartDatum) => void
datetimeFormat: string
+ className?: string
}
-const ServiceRow = ({ service, data, onBarClick, datetimeFormat }: ServiceRowProps) => {
- const errorRate = data.total > 0 ? data.errorRate : 0
- const warningRate = data.total > 0 ? (data.warningCount / data.total) * 100 : 0
-
+const ServiceCell = ({
+ service,
+ data,
+ onBarClick,
+ datetimeFormat,
+ className,
+}: ServiceCellProps) => {
const reportUrl = service.reportUrl || service.logsUrl
+ const { color } = getHealthStatus(data.errorRate, data.total)
+ const description = SERVICE_DESCRIPTIONS[service.key] || service.description
return (
- <Link
- href={reportUrl}
- className="block group py-4 px-card border-b border-default last:border-b-0 hover:bg-surface-200 transition-colors cursor-pointer"
+ <div
+ className={cn(
+ 'group relative px-card pt-2 pb-4 hover:bg-surface-200 transition-colors',
+ className
+ )}
>
- <div className="flex items-center justify-between mb-3">
- <div className="flex items-center gap-2">
- <span className="text-foreground font-medium">{service.name}</span>
+ <div className="flex items-center justify-between mb-3 gap-2">
+ <div className="flex items-center gap-1.5 min-w-0">
+ <div
+ className={cn(
+ 'w-1.5 h-1.5 rounded-full shrink-0',
+ colorClassMap[color] || 'bg-gray-500'
+ )}
+ />
+ <h3 className="text-foreground-light font-mono uppercase text-xs truncate m-0">
+ <Link
+ href={reportUrl}
+ className="after:absolute after:inset-0 after:content-[''] focus-visible:outline-none focus-visible:after:ring-2 focus-visible:after:ring-foreground-light focus-visible:after:ring-offset-2 focus-visible:after:rounded-sm"
+ >
+ {service.name}
+ </Link>
+ </h3>
+ {description && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <button
+ type="button"
+ className="relative z-10 text-foreground-lighter hover:text-foreground-light transition-colors shrink-0"
+ aria-label={`About ${service.name}`}
+ >
+ <HelpCircle size={12} />
+ </button>
+ </TooltipTrigger>
+ <TooltipContent side="top" className="max-w-xs">
+ <p>{description}</p>
+ </TooltipContent>
+ </Tooltip>
+ )}
+ </div>
+ <div className="flex items-center gap-1.5">
+ {data.isLoading ? (
+ <Skeleton className="h-3 w-20 mt-0.5" />
+ ) : (
+ <span
+ className={cn(
+ 'text-xs truncate',
+ data.total === 0 ? 'text-foreground-lighter' : 'text-foreground'
+ )}
+ >
+ {getSubtitle(data)}
+ </span>
+ )}
<Tooltip>
<TooltipTrigger asChild>
- <button
- onClick={(e) => e.preventDefault()}
- className="text-foreground-lighter hover:text-foreground-light transition-colors"
+ <Button
+ type="text"
+ size="tiny"
+ className="relative z-10 px-1 text-foreground-lighter group-hover:text-foreground transition-colors shrink-0"
+ aria-label={`Go to ${service.name} report`}
+ asChild
>
- <HelpCircle size={14} />
- </button>
+ <Link href={reportUrl}>
+ <ChevronRight size={14} strokeWidth={1.5} />
+ </Link>
+ </Button>
</TooltipTrigger>
- <TooltipContent side="right" className="max-w-xs">
- <p>{SERVICE_DESCRIPTIONS[service.key as ServiceKey] || service.description}</p>
- </TooltipContent>
+ <TooltipContent side="top">Go to {service.name} report</TooltipContent>
</Tooltip>
</div>
- <div className="flex items-center gap-2">
- <ButtonTooltip
- type="text"
- size="tiny"
- className="p-1.5"
- tooltip={{ content: { text: `Go to ${service.name} report` } }}
- >
- <ChevronRight
- size={14}
- className="text-foreground-lighter group-hover:text-foreground"
- />
- </ButtonTooltip>
- </div>
</div>
- <div className="h-16" onClick={(e) => e.preventDefault()}>
- <Loading active={data.isLoading}>
- {data.isLoading ? (
- <div />
- ) : (
- <LogsBarChart
- data={data.total === 0 ? [] : data.eventChartData}
- DateTimeFormat={datetimeFormat}
- onBarClick={onBarClick}
- EmptyState={
- <div className="flex items-center justify-center h-full text-xs text-foreground-lighter">
- No data
- </div>
- }
- />
- )}
- </Loading>
+ <div className="relative z-10 h-16">
+ {data.isLoading ? (
+ <ChartLoadingState className="h-full" />
+ ) : (
+ <LogsBarChart
+ isFullHeight
+ hideDateRange
+ data={data.eventChartData}
+ DateTimeFormat={datetimeFormat}
+ onBarClick={onBarClick}
+ EmptyState={<ChartEmptyState className="h-full" description="No traffic" />}
+ />
+ )}
</div>
-
- <div className="flex items-center justify-center mt-2 text-xs text-foreground-lighter gap-4 font-mono tabular-nums tracking-tight">
- {data.total > 0 ? (
- <>
- {errorRate > 0 && (
- <span className="flex items-center gap-1.5">
- <div className="w-1.5 h-1.5 rounded-full bg-destructive" />
- {errorRate.toFixed(2)}% errors
- </span>
- )}
- {warningRate > 0 && (
- <span className="flex items-center gap-1.5">
- <div className="w-1.5 h-1.5 rounded-full bg-warning" />
- {warningRate.toFixed(2)}% warnings
- </span>
- )}
- {errorRate === 0 && warningRate === 0 && (
- <span className="flex items-center gap-1.5">
- <div className="w-1.5 h-1.5 rounded-full bg-brand" />
- 0% errors
- </span>
- )}
- </>
- ) : !data.isLoading ? (
- <span>No requests in this period</span>
- ) : null}
- </div>
- </Link>
+ </div>
)
}
@@ -149,22 +189,35 @@ export const ServiceHealthTable = ({
return (
<div>
<h2 className="heading-section mb-4">Service Health</h2>
- <Card>
+ <Card className="overflow-auto">
<CardContent className="p-0">
- {services.map((service) => {
- const data = serviceData[service.key]
- if (!data) return null
-
- return (
- <ServiceRow
- key={service.key}
- service={service}
- data={data}
- onBarClick={onBarClick(service.logsUrl)}
- datetimeFormat={datetimeFormat}
- />
- )
- })}
+ <div className="grid grid-cols-1 md:grid-cols-2">
+ {services.map((service, index) => {
+ const data = serviceData[service.key]
+ if (!data) return null
+
+ const isFirst = index === 0
+ const isLeftColumn = !isFirst && (index - 1) % 2 === 0
+ const isLastService = index === services.length - 1
+
+ return (
+ <ServiceCell
+ key={service.key}
+ service={service}
+ data={data}
+ onBarClick={onBarClick(service.logsUrl)}
+ datetimeFormat={datetimeFormat}
+ className={cn(
+ 'border-default border-b',
+ isFirst && 'md:col-span-2',
+ isLastService && 'md:border-b-0',
+ isLeftColumn && 'md:border-r'
+ )}
+ />
+ )
+ })}
+ <div className="bg-background/20" aria-hidden="true" />
+ </div>
</CardContent>
</Card>
</div>
diff --git a/packages/ui-patterns/src/Chart/index.tsx b/packages/ui-patterns/src/Chart/index.tsx
index 8f8034d37fc..ca9773a529a 100644
--- a/packages/ui-patterns/src/Chart/index.tsx
+++ b/packages/ui-patterns/src/Chart/index.tsx
@@ -350,8 +350,8 @@ ChartContent.displayName = 'ChartContent'
interface ChartEmptyStateProps extends React.HTMLAttributes<HTMLDivElement> {
className?: string
icon?: React.ReactNode
- title: string
- description: string
+ title?: string
+ description?: string
}
const ChartEmptyState = React.forwardRef<HTMLDivElement, ChartEmptyStateProps>(
@@ -370,8 +370,8 @@ const ChartEmptyState = React.forwardRef<HTMLDivElement, ChartEmptyStateProps>(
{icon}
</div>
)}
- <h3 className="text-sm font-medium text-foreground-light">{title}</h3>
- <p className="text-sm text-foreground-lighter">{description}</p>
+ {title && <h3 className="text-sm font-medium text-foreground-light">{title}</h3>}
+ {description && <p className="text-sm text-foreground-lighter">{description}</p>}
</div>
)
}
diff --git a/packages/ui-patterns/src/LogsBarChart/index.tsx b/packages/ui-patterns/src/LogsBarChart/index.tsx
index ec737eca928..6bd8f23612f 100644
--- a/packages/ui-patterns/src/LogsBarChart/index.tsx
+++ b/packages/ui-patterns/src/LogsBarChart/index.tsx
@@ -32,6 +32,7 @@ export const LogsBarChart = ({
isFullHeight = false,
chartConfig,
hideZeroValues = false,
+ hideDateRange = false,
}: {
data: LogsBarChartDatum[]
onBarClick?: (datum: LogsBarChartDatum, tooltipData?: CategoricalChartState) => void
@@ -40,6 +41,7 @@ export const LogsBarChart = ({
isFullHeight?: boolean
chartConfig?: ChartConfig
hideZeroValues?: boolean
+ hideDateRange?: boolean
}) => {
const [focusDataIndex, setFocusDataIndex] = useState<number | null>(null)
@@ -68,7 +70,10 @@ export const LogsBarChart = ({
data-testid="logs-bar-chart"
className={cn('flex flex-col gap-y-3', isFullHeight ? 'h-full' : 'h-24')}
>
- <ChartContainer className="h-full" config={chartConfig ?? defaultChartConfig}>
+ <ChartContainer
+ className={cn('h-full', isFullHeight && 'aspect-auto')}
+ config={chartConfig ?? defaultChartConfig}
+ >
<RechartBarChart
data={data}
onMouseMove={(e: any) => {
@@ -92,6 +97,7 @@ export const LogsBarChart = ({
dataKey="timestamp"
interval={data.length - 2}
tick={false}
+ height={hideDateRange ? 1 : undefined}
axisLine={{ stroke: CHART_COLORS.AXIS }}
tickLine={{ stroke: CHART_COLORS.AXIS }}
/>
@@ -171,7 +177,7 @@ export const LogsBarChart = ({
</Bar>
</RechartBarChart>
</ChartContainer>
- {data && (
+ {data && !hideDateRange && (
<div className="text-foreground-lighter -mt-10 flex items-center justify-between text-[10px] font-mono">
<span>{startDate}</span>
<span>{endDate}</span>