The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Include `postgrest_logs` as source for Postgrest logs (#47225)
Joshen Lim086232b20796
diff --git a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.constants.tsx b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.constants.tsxindex 8abac9cca6d..99307558bc8 100644--- a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.constants.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.constants.tsx@@ -16,16 +16,19 @@ import {export const REGIONS = ['ams', 'fra', 'gru', 'hkg', 'iad', 'syd'] as constexport const METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'] as const-export const LOG_TYPES = [- 'postgres',- 'postgrest',- 'auth',- 'storage',- 'edge function',- 'realtime',- 'supavisor',- 'pgbouncer',-] as const+export const LOG_TYPES_LABELS = {+ postgres: 'Postgres',+ postgrest: 'PostgREST',+ auth: 'Auth',+ storage: 'Storage',+ 'edge function': 'Edge Function',+ realtime: 'Realtime',+ supavisor: 'Supavisor',+ pgbouncer: 'PgBouncer',+}++type LogType = keyof typeof LOG_TYPES_LABELS+export const LOG_TYPES = Object.keys(LOG_TYPES_LABELS) as [LogType, ...LogType[]]export const DEFAULT_LOG_TYPES = ['postgres', 'postgrest'] as constconst parseAsSort = createParser({diff --git a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.fields.tsx b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.fields.tsxindex ef131636e14..90975d700a4 100644--- a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.fields.tsx+++ b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.fields.tsx@@ -1,6 +1,6 @@import { cn } from 'ui'-import { LOG_TYPES, METHODS, STATUS_CODE_LABELS } from './UnifiedLogs.constants'+import { LOG_TYPES_LABELS, METHODS, STATUS_CODE_LABELS } from './UnifiedLogs.constants'import { ColumnSchema } from './UnifiedLogs.schema'import { getLevelLabel } from './UnifiedLogs.utils'import { LEVELS } from '@/components/ui/DataTable/DataTable.constants'@@ -22,12 +22,12 @@ export const filterFields = [value: 'log_type',type: 'checkbox',defaultOpen: true,- options: LOG_TYPES.map((type) => ({ label: type, value: type })),+ options: Object.entries(LOG_TYPES_LABELS).map(([value, label]) => ({ label, value })),component: (props: Option) => {return (<div className="flex w-full items-center justify-between gap-2">- <span className="capitalize text-foreground/70 group-hover:text-accent-foreground text-xs">- {props.label.replace('_', ' ')}+ <span className="text-foreground/70 group-hover:text-accent-foreground text-xs">+ {props.label}</span></div>)diff --git a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.test.ts b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.test.tsindex ba73e93c0b4..734961e7a09 100644--- a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.test.ts+++ b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.test.ts@@ -19,19 +19,20 @@ describe('UnifiedLogs.queries (OTEL flat)', () => {describe('getUnifiedLogsQuery', () => {it('defaults to postgres + postgrest log types when none specified', () => {const sql = getUnifiedLogsQuery(baseSearch)- expect(sql).toContain(`source = 'postgres_logs'`)- // postgrest = edge_logs filtered by /rest/ path- expect(sql).toContain(- `source = 'edge_logs' AND log_attributes['request.path'] LIKE '%/rest/%'`- )+ const where = sql.split(/\bWHERE\b/)[1] ?? ''+ expect(where).toContain(`source = 'postgres_logs'`)+ // postgrest = postgrest_logs OR edge_logs with /rest/ path+ expect(where).toContain(`source = 'postgrest_logs'`)+ expect(where).toContain(`log_attributes['request.path'] LIKE '%/rest/%'`)})- it('routes the `edge` log type to edge_logs without /rest/ or /storage/ paths', () => {- const sql = getUnifiedLogsQuery(withFilters('log_type:eq:edge'))- expect(sql).toContain(`NOT LIKE '%/rest/%'`)- expect(sql).toContain(`NOT LIKE '%/storage/%'`)+ it('routes the `postgrest` log type to postgrest_logs or edge_logs /rest/', () => {+ const sql = getUnifiedLogsQuery(withFilters('log_type:eq:postgrest'))const where = sql.split(/\bWHERE\b/)[1] ?? ''- expect(where).not.toContain(`source = 'postgres_logs'`)+ expect(where).toContain(`source = 'postgrest_logs'`)+ expect(where).toContain(+ `source = 'edge_logs' AND log_attributes['request.path'] LIKE '%/rest/%'`+ )})it('routes the `storage` log type to edge_logs filtered by /storage/', () => {@@ -144,7 +145,7 @@ describe('UnifiedLogs.queries (OTEL flat)', () => {expect(sql).toContain('arrayJoin([')expect(sql).toContain('multiIf(')expect(sql).toContain(`facet = 'total', 'all'`)- for (const lt of ['edge', 'postgrest', 'storage', 'postgres', 'edge function', 'auth']) {+ for (const lt of ['postgrest', 'storage', 'postgres', 'edge function', 'auth']) {expect(sql).toContain(`'${lt}'`)}for (const lvl of ['success', 'warning', 'error']) {@@ -157,7 +158,7 @@ describe('UnifiedLogs.queries (OTEL flat)', () => {})it('honours an active log_type filter in the total count scan', () => {- const sql = getLogsCountQuery(withFilters('log_type:eq:edge'))+ const sql = getLogsCountQuery(withFilters('log_type:eq:storage'))// Assert on the WHERE only: value expressions mention other sources inline.const totalWhere = whereOfBranchContaining(sql, `'all'`)expect(totalWhere).toContain(`source = 'edge_logs'`)@@ -165,9 +166,9 @@ describe('UnifiedLogs.queries (OTEL flat)', () => {})it('gives the log_type facet its own scan that excludes the log_type filter', () => {- const sql = getLogsCountQuery(withFilters('log_type:eq:edge'))+ const sql = getLogsCountQuery(withFilters('log_type:eq:postgrest'))const logTypeWhere = whereOfBranchContaining(sql, `'log_type'`)- expect(logTypeWhere).not.toContain(`NOT LIKE '%/rest/%'`)+ expect(logTypeWhere).not.toContain(`LIKE '%/rest/%'`)})})diff --git a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.ts b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.tsindex 30121d41b21..933cb626afa 100644--- a/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.ts+++ b/apps/studio/components/interfaces/UnifiedLogs/UnifiedLogs.queries.ts@@ -55,8 +55,7 @@ const HTTP_STATUS_EXPR: SafeLogSqlFragment = safeSql`if(source = 'auth_logs', lo* logs; the UI surfaces gateway HTTP traffic for those buckets.*/const LOG_TYPE_CONDITION: Record<string, SafeLogSqlFragment> = {- edge: safeSql`source = 'edge_logs' AND ${ATTR.path} NOT LIKE '%/rest/%' AND ${ATTR.path} NOT LIKE '%/storage/%'`,- postgrest: safeSql`source = 'edge_logs' AND ${ATTR.path} LIKE '%/rest/%'`,+ postgrest: safeSql`source = 'postgrest_logs' OR (source = 'edge_logs' AND ${ATTR.path} LIKE '%/rest/%')`,storage: safeSql`source = 'edge_logs' AND ${ATTR.path} LIKE '%/storage/%'`,postgres: safeSql`source = 'postgres_logs'`,'edge function': safeSql`source = 'function_edge_logs'`,@@ -67,7 +66,9 @@ const LOG_TYPE_CONDITION: Record<string, SafeLogSqlFragment> = {}// Derived `log_type` column for SELECT / GROUP BY / countIf use.+// WHEN source = 'edge_logs' AND ${ATTR.path} LIKE '%/rest/%' THEN 'postgrest'const LOG_TYPE_EXPR: SafeLogSqlFragment = safeSql`CASE+ WHEN source = 'postgrest_logs' THEN 'postgrest'WHEN source = 'edge_logs' AND ${ATTR.path} LIKE '%/rest/%' THEN 'postgrest'WHEN source = 'edge_logs' AND ${ATTR.path} LIKE '%/storage/%' THEN 'storage'WHEN source = 'edge_logs' THEN 'edge'diff --git a/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterCheckbox.tsx b/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterCheckbox.tsxindex 4905fae0397..0d5148b464b 100644--- a/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterCheckbox.tsx+++ b/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterCheckbox.tsx@@ -56,8 +56,7 @@ export function DataTableFilterCheckbox<TData>({onChange={(e) => setInputValue(e.target.value)}/>) : null}- {/* FIXME: due to the added max-h and overflow-y-auto, the hover state and border is laying on top of the scroll bar */}- <div className="max-h-[200px] overflow-y-auto rounded-sm border border-border empty:border-none">+ <div className="max-h-[215px] overflow-y-auto rounded-sm border border-border empty:border-none">{filterOptions.length === 0 && inputValue !== '' ? (<div className="flex items-center justify-center px-2 py-4 text-center"><div className="space-y-0.5">diff --git a/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterCheckboxAsync.tsx b/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterCheckboxAsync.tsxindex 676abf9b672..57b1f166306 100644--- a/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterCheckboxAsync.tsx+++ b/apps/studio/components/ui/DataTable/DataTableFilters/DataTableFilterCheckboxAsync.tsx@@ -66,7 +66,7 @@ export function DataTableFilterCheckboxAsync<TData>({onChange={(e) => setInputValue(e.target.value)}/>- <div className="max-h-[200px] overflow-y-auto rounded-sm border border-border empty:border-none">+ <div className="max-h-[215px] overflow-y-auto rounded-sm border border-border empty:border-none">{filterOptions.length === 0 ? (<div className="flex items-center justify-center px-2 py-3 text-center"><div className="space-y-0.5">