The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
add pgbouncer connections to database report (#33895)
Jordi Enric31c6887f6687
diff --git a/apps/studio/pages/project/[ref]/reports/database.tsx b/apps/studio/pages/project/[ref]/reports/database.tsxindex e73c95ce2ee..06843be2514 100644--- a/apps/studio/pages/project/[ref]/reports/database.tsx+++ b/apps/studio/pages/project/[ref]/reports/database.tsx@@ -32,6 +32,8 @@ import type { NextPageWithLayout } from 'types'import DefaultLayout from 'components/layouts/DefaultLayout'import { useSendEventMutation } from 'data/telemetry/send-event-mutation'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'+import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query'+import { Admonition } from 'ui-patterns'const DatabaseReport: NextPageWithLayout = () => {return (@@ -49,15 +51,6 @@ DatabaseReport.getLayout = (page) => (export default DatabaseReport-const REPORT_ATTRIBUTES = [- { id: 'ram_usage', label: 'Memory usage' },- { id: 'avg_cpu_usage', label: 'Average CPU usage' },- { id: 'max_cpu_usage', label: 'Max CPU usage' },- { id: 'disk_io_consumption', label: 'Disk IO consumed' },- { id: 'pg_stat_database_num_backends', label: 'Number of database connections' },- { id: 'supavisor_connections_active', label: 'Number of supavisor connections' },-]-const DatabaseUsage = () => {const { db, chart, ref } = useParams()const { project } = useProjectContext()@@ -86,6 +79,33 @@ const DatabaseUsage = () => {},})+ const { data: pgBouncerConfig } = usePgbouncerConfigQuery({+ projectRef: ref ?? 'default',+ })+ const isPgBouncerEnabled = pgBouncerConfig?.pgbouncer_enabled++ const REPORT_ATTRIBUTES = [+ { id: 'ram_usage', label: 'Memory usage', hide: false },+ { id: 'avg_cpu_usage', label: 'Average CPU usage', hide: false },+ { id: 'max_cpu_usage', label: 'Max CPU usage', hide: false },+ { id: 'disk_io_consumption', label: 'Disk IO consumed', hide: false },+ {+ id: 'pg_stat_database_num_backends',+ label: 'Pooler to database connections',+ hide: false,+ },+ {+ id: 'supavisor_connections_active',+ label: 'Client to Supavisor connections',+ hide: false,+ },+ {+ id: 'pgbouncer_pools_client_active_connections',+ label: 'Client to dedicated pooler connections',+ hide: !isPgBouncerEnabled,+ },+ ] as const+const { isLoading: isUpdatingDiskSize } = useProjectDiskResizeMutation({onSuccess: (_, variables) => {toast.success(`Successfully updated disk size to ${variables.volumeSize} GB`)@@ -104,7 +124,7 @@ const DatabaseUsage = () => {REPORT_ATTRIBUTES.forEach((attr) => {queryClient.invalidateQueries(analyticsKeys.infraMonitoring(ref, {- attribute: attr.id,+ attribute: attr?.id,startDate: period_start.date,endDate: period_start.end,interval,@@ -230,16 +250,27 @@ const DatabaseUsage = () => {</div><div className="space-y-6">{dateRange &&- REPORT_ATTRIBUTES.map((attr) => (- <ChartHandler- key={attr.id}- provider="infra-monitoring"- attribute={attr.id}- label={attr.label}- interval={dateRange.interval}- startDate={dateRange?.period_start?.date}- endDate={dateRange?.period_end?.date}- />+ REPORT_ATTRIBUTES.filter((attr) => !attr.hide).map((attr) => (+ <>+ <ChartHandler+ key={attr.id}+ provider="infra-monitoring"+ attribute={attr.id}+ label={attr.label}+ interval={dateRange.interval}+ startDate={dateRange?.period_start?.date}+ endDate={dateRange?.period_end?.date}+ />+ {attr.id === 'pgbouncer_pools_client_active_connections' && (+ <Admonition type="note" title="Dedicated Pooler is enabled" className="p-2">+ <p>+ Your project is currently using the Dedicated Pooler instead of Supavisor.+ You can update this in{' '}+ <Link href={`/project/${ref}/settings/database`}>Database settings</Link>.+ </p>+ </Admonition>+ )}+ </>))}</div></Panel.Content>