Skip to content

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

Add more log query templates

TzeYiing14e32afccc5c
diff --git a/studio/components/interfaces/Settings/Logs/Logs.constants.ts b/studio/components/interfaces/Settings/Logs/Logs.constants.ts
index bf641972f53..6ec4fa05f0b 100644
--- a/studio/components/interfaces/Settings/Logs/Logs.constants.ts
+++ b/studio/components/interfaces/Settings/Logs/Logs.constants.ts
@@ -56,6 +56,119 @@ ORDER BY
`,
for: ['api'],
},
+ {
+ label: 'Slow Response Time',
+ mode: 'custom',
+ searchString: `select
+ timestamp,
+ event_message,
+ r.origin_time
+FROM edge_logs
+ CROSS JOIN unnest(metadata) as m
+ CROSS JOIN unnest(m.response) as r
+WHERE
+ r.origin_time > 1000
+ORDER BY
+ timestamp DESC
+LIMIT 100
+`,
+ for: ['api'],
+ },
+ {
+ label: '500 Request Codes',
+ mode: 'custom',
+ searchString: `SELECT
+ timestamp,
+ event_message,
+ r.status_code
+FROM edge_logs
+ cross join unnest(metadata) as m
+ cross join unnest(m.response) as r
+WHERE
+ r.status_code >= 500
+ORDER BY
+ timestamp desc
+LIMIT 100
+`,
+ for: ['api'],
+ },
+ {
+ label: 'Top Paths',
+ mode: 'custom',
+ searchString: `SELECT
+ r.path as path,
+ r.search as params,
+ count(timestamp) as c
+FROM edge_logs
+ cross join unnest(metadata) as m
+ cross join unnest(m.request) as r
+GROUP BY
+ path,
+ params
+ORDER BY
+ c desc
+LIMIT 100
+`,
+ for: ['api'],
+ },
+ {
+ label: 'REST Requests',
+ mode: 'custom',
+ searchString: `SELECT
+ timestamp,
+ event_message
+FROM edge_logs
+ cross join unnest(metadata) as m
+ cross join unnest(m.request) as r
+WHERE
+ path like '%rest/v1%'
+ORDER BY
+ timestamp desc
+LIMIT 100
+`,
+ for: ['api'],
+ },
+ {
+ label: 'Errors',
+ mode: 'custom',
+ searchString: `SELECT
+ t.timestamp,
+ p.error_severity,
+ event_message
+FROM
+ postgres_logs as t
+ cross join unnest(metadata) as m
+ cross join unnest(m.parsed) as p
+WHERE
+ p.error_severity in ('ERROR', 'FATAL', 'PANIC')
+ORDER BY
+ timestamp desc
+LIMIT 100
+`,
+ for: ['database'],
+ },
+ {
+ label: 'Error Count by User',
+ mode: 'custom',
+ searchString: `SELECT
+ count(t.timestamp) as count,
+ p.user_name,
+ p.error_severity
+FROM
+ postgres_logs as t
+ cross join unnest(metadata) as m
+ cross join unnest(m.parsed) as p
+WHERE
+ p.error_severity in ('ERROR', 'FATAL', 'PANIC')
+GROUP BY
+ p.user_name,
+ p.error_severity
+ORDER BY
+ count desc
+LIMIT 100
+`,
+ for: ['database'],
+ },
]
export const LOG_TYPE_LABEL_MAPPING: { [k: string]: string } = {