Skip to content

Commit 7f659ef

Browse files
authored
Merge pull request supabase#7313 from Hallidayo/explorer-logs-sql-queries
timestamp casting as time and formatting changes
2 parents 6ef90f0 + c86bc0f commit 7f659ef

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

studio/components/interfaces/Settings/Logs/Logs.constants.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,25 @@ export const TEMPLATES: LogTemplate[] = [
2121
description: 'Count of commits made by users on the database',
2222
mode: 'custom',
2323
searchString: `select
24-
p.user_name, count(*) as count
24+
p.user_name,
25+
count(*) as count
2526
from postgres_logs
2627
left join unnest(metadata) as m on true
2728
left join unnest(m.parsed) as p on true
2829
where
2930
regexp_contains(event_message, 'COMMIT')
3031
group by
3132
p.user_name
32-
`,
33+
`,
3334
for: ['database'],
3435
},
3536
{
3637
label: 'Metadata IP',
3738
description: 'List all IP addresses that used the Supabase API',
3839
mode: 'custom',
39-
searchString: `select timestamp, h.x_real_ip
40+
searchString: `select
41+
cast(timestamp as datetime) as timestamp,
42+
h.x_real_ip
4043
from edge_logs
4144
left join unnest(metadata) as m on true
4245
left join unnest(m.request) as r on true
@@ -50,7 +53,8 @@ where h.x_real_ip is not null
5053
description: 'List all ISO 3166-1 alpha-2 country codes that used the Supabase API',
5154
mode: 'custom',
5255
searchString: `select
53-
cf.country, count(*) as count
56+
cf.country,
57+
count(*) as count
5458
from edge_logs
5559
left join unnest(metadata) as m on true
5660
left join unnest(m.request) as r on true
@@ -67,7 +71,7 @@ order by
6771
mode: 'custom',
6872
description: 'List all Supabase API requests that are slow',
6973
searchString: `select
70-
timestamp,
74+
cast(timestamp as datetime) as timestamp,
7175
event_message,
7276
r.origin_time
7377
from edge_logs
@@ -85,8 +89,8 @@ limit 100
8589
label: '500 Request Codes',
8690
description: 'List all Supabase API requests that responded witha 5XX status code',
8791
mode: 'custom',
88-
searchString: `SELECT
89-
timestamp,
92+
searchString: `select
93+
cast(timestamp as datetime) as timestamp,
9094
event_message,
9195
r.status_code
9296
from edge_logs
@@ -104,7 +108,7 @@ limit 100
104108
label: 'Top Paths',
105109
description: 'List the most requested Supabase API paths',
106110
mode: 'custom',
107-
searchString: `SELECT
111+
searchString: `select
108112
r.path as path,
109113
r.search as params,
110114
count(timestamp) as c
@@ -124,8 +128,8 @@ limit 100
124128
label: 'REST Requests',
125129
description: 'List all PostgREST requests',
126130
mode: 'custom',
127-
searchString: `SELECT
128-
timestamp,
131+
searchString: `select
132+
cast(timestamp as datetime) as timestamp,
129133
event_message
130134
from edge_logs
131135
cross join unnest(metadata) as m
@@ -142,14 +146,13 @@ limit 100
142146
label: 'Errors',
143147
description: 'List all Postgres error messages with ERROR, FATAL, or PANIC severity',
144148
mode: 'custom',
145-
searchString: `SELECT
146-
t.timestamp,
149+
searchString: `select
150+
cast(t.timestamp as datetime) as timestamp,
147151
p.error_severity,
148152
event_message
149-
from
150-
postgres_logs as t
151-
cross join unnest(metadata) as m
152-
cross join unnest(m.parsed) as p
153+
from postgres_logs as t
154+
cross join unnest(metadata) as m
155+
cross join unnest(m.parsed) as p
153156
where
154157
p.error_severity in ('ERROR', 'FATAL', 'PANIC')
155158
order by
@@ -165,10 +168,9 @@ limit 100
165168
count(t.timestamp) as count,
166169
p.user_name,
167170
p.error_severity
168-
from
169-
postgres_logs as t
170-
cross join unnest(metadata) as m
171-
cross join unnest(m.parsed) as p
171+
from postgres_logs as t
172+
cross join unnest(metadata) as m
173+
cross join unnest(m.parsed) as p
172174
where
173175
p.error_severity in ('ERROR', 'FATAL', 'PANIC')
174176
group by

0 commit comments

Comments
 (0)