log-constants.ts331 lines · main
1type LogTable =
2 | 'edge_logs'
3 | 'postgres_logs'
4 | 'function_logs'
5 | 'function_edge_logs'
6 | 'auth_logs'
7 | 'auth_audit_logs'
8 | 'realtime_logs'
9 | 'storage_logs'
10 | 'postgrest_logs'
11 | 'supavisor_logs'
12 | 'pgbouncer_logs'
13 | 'pg_cron_logs'
14 | 'pg_upgrade_logs'
15
16type LogSchema = {
17 name: string
18 reference: LogTable
19 fields: {
20 path: string
21 type: string
22 }[]
23}
24
25const schemas: LogSchema[] = [
26 {
27 name: 'API Gateway',
28 reference: 'edge_logs',
29 fields: [
30 { path: 'id', type: 'string' },
31 { path: 'timestamp', type: 'datetime' },
32 { path: 'event_message', type: 'string' },
33 { path: 'identifier', type: 'string' },
34 { path: 'metadata.load_balancer_redirect_identifier', type: 'string' },
35 { path: 'metadata.request.cf.asOrganization', type: 'string' },
36 { path: 'metadata.request.cf.asn', type: 'number' },
37 { path: 'metadata.request.cf.botManagement.corporateProxy', type: 'boolean' },
38 { path: 'metadata.request.cf.botManagement.detectionIds', type: 'number[]' },
39 { path: 'metadata.request.cf.botManagement.ja3Hash', type: 'string' },
40 { path: 'metadata.request.cf.botManagement.score', type: 'number' },
41 { path: 'metadata.request.cf.botManagement.staticResource', type: 'boolean' },
42 { path: 'metadata.request.cf.botManagement.verifiedBot', type: 'boolean' },
43 { path: 'metadata.request.cf.city', type: 'string' },
44 { path: 'metadata.request.cf.clientTcpRtt', type: 'number' },
45 { path: 'metadata.request.cf.clientTrustScore', type: 'number' },
46 { path: 'metadata.request.cf.colo', type: 'string' },
47 { path: 'metadata.request.cf.continent', type: 'string' },
48 { path: 'metadata.request.cf.country', type: 'string' },
49 { path: 'metadata.request.cf.edgeRequestKeepAliveStatus', type: 'number' },
50 { path: 'metadata.request.cf.httpProtocol', type: 'string' },
51 { path: 'metadata.request.cf.latitude', type: 'string' },
52 { path: 'metadata.request.cf.longitude', type: 'string' },
53 { path: 'metadata.request.cf.metroCode', type: 'string' },
54 { path: 'metadata.request.cf.postalCode', type: 'string' },
55 { path: 'metadata.request.cf.region', type: 'string' },
56 { path: 'metadata.request.cf.timezone', type: 'string' },
57 { path: 'metadata.request.cf.tlsCipher', type: 'string' },
58 { path: 'metadata.request.cf.tlsClientAuth.certPresented', type: 'string' },
59 { path: 'metadata.request.cf.tlsClientAuth.certRevoked', type: 'string' },
60 { path: 'metadata.request.cf.tlsClientAuth.certVerified', type: 'string' },
61 { path: 'metadata.request.cf.tlsExportedAuthenticator.clientFinished', type: 'string' },
62 { path: 'metadata.request.cf.tlsExportedAuthenticator.clientHandshake', type: 'string' },
63 { path: 'metadata.request.cf.tlsExportedAuthenticator.serverFinished', type: 'string' },
64 { path: 'metadata.request.cf.tlsExportedAuthenticator.serverHandshake', type: 'string' },
65 { path: 'metadata.request.cf.tlsVersion', type: 'string' },
66 { path: 'metadata.request.headers.cf_connecting_ip', type: 'string' },
67 { path: 'metadata.request.headers.cf_ipcountry', type: 'string' },
68 { path: 'metadata.request.headers.cf_ray', type: 'string' },
69 { path: 'metadata.request.headers.host', type: 'string' },
70 { path: 'metadata.request.headers.referer', type: 'string' },
71 { path: 'metadata.request.headers.x_client_info', type: 'string' },
72 { path: 'metadata.request.headers.x_forwarded_proto', type: 'string' },
73 { path: 'metadata.request.headers.x_real_ip', type: 'string' },
74 { path: 'metadata.request.host', type: 'string' },
75 { path: 'metadata.request.method', type: 'string' },
76 { path: 'metadata.request.path', type: 'string' },
77 { path: 'metadata.request.protocol', type: 'string' },
78 { path: 'metadata.request.search', type: 'string' },
79 { path: 'metadata.request.url', type: 'string' },
80 { path: 'metadata.response.headers.cf_cache_status', type: 'string' },
81 { path: 'metadata.response.headers.cf_ray', type: 'string' },
82 { path: 'metadata.response.headers.content_location', type: 'string' },
83 { path: 'metadata.response.headers.content_range', type: 'string' },
84 { path: 'metadata.response.headers.content_type', type: 'string' },
85 { path: 'metadata.response.headers.date', type: 'string' },
86 { path: 'metadata.response.headers.sb_gateway_version', type: 'string' },
87 { path: 'metadata.response.headers.transfer_encoding', type: 'string' },
88 { path: 'metadata.response.headers.x_kong_proxy_latency', type: 'string' },
89 { path: 'metadata.response.origin_time', type: 'number' },
90 { path: 'metadata.response.status_code', type: 'number' },
91 ],
92 },
93 {
94 name: 'Auth',
95 reference: 'auth_logs',
96 fields: [
97 { path: 'event_message', type: 'string' },
98 { path: 'id', type: 'string' },
99 { path: 'timestamp', type: 'datetime' },
100 { path: 'metadata.auth_event.action', type: 'string' },
101 { path: 'metadata.auth_event.actor_id', type: 'string' },
102 { path: 'metadata.auth_event.actor_via_sso', type: 'boolean' },
103 { path: 'metadata.auth_event.actor_username', type: 'string' },
104 { path: 'metadata.auth_event.log_type', type: 'string' },
105 { path: 'metadata.auth_event.traits.provider', type: 'string' },
106 { path: 'metadata.auth_event.traits.user_email', type: 'string' },
107 { path: 'metadata.auth_event.traits.user_id', type: 'string' },
108 { path: 'metadata.auth_event.traits.user_phone', type: 'string' },
109 { path: 'metadata.component', type: 'string' },
110 { path: 'metadata.duration', type: 'number' },
111 { path: 'metadata.host', type: 'string' },
112 { path: 'metadata.level', type: 'string' },
113 { path: 'metadata.method', type: 'string' },
114 { path: 'metadata.msg', type: 'string' },
115 { path: 'metadata.path', type: 'string' },
116 { path: 'metadata.referer', type: 'string' },
117 { path: 'metadata.remote_addr', type: 'string' },
118 { path: 'metadata.status', type: 'number' },
119 { path: 'metadata.timestamp', type: 'string' },
120 ],
121 },
122 {
123 name: 'Auth Audit Logs',
124 reference: 'auth_audit_logs',
125 fields: [
126 { path: 'event_message', type: 'string' },
127 { path: 'id', type: 'string' },
128 { path: 'identifier', type: 'string' },
129 { path: 'timestamp', type: 'datetime' },
130 { path: 'metadata.auth_audit_event.action', type: 'string' },
131 { path: 'metadata.auth_audit_event.actor_id', type: 'string' },
132 { path: 'metadata.auth_audit_event.actor_name', type: 'string' },
133 { path: 'metadata.auth_audit_event.actor_username', type: 'string' },
134 { path: 'metadata.auth_audit_event.actor_via_sso', type: 'boolean' },
135 { path: 'metadata.auth_audit_event.audit_log_id', type: 'string' },
136 { path: 'metadata.auth_audit_event.created_at', type: 'string' },
137 { path: 'metadata.auth_audit_event.log_type', type: 'string' },
138 { path: 'metadata.auth_audit_event.request_id', type: 'string' },
139 { path: 'metadata.auth_audit_event.user_agent', type: 'string' },
140 { path: 'metadata.host', type: 'string' },
141 { path: 'metadata.level', type: 'string' },
142 { path: 'metadata.msg', type: 'string' },
143 ],
144 },
145 {
146 name: 'Storage',
147 reference: 'storage_logs',
148 fields: [
149 { path: 'event_message', type: 'string' },
150 { path: 'id', type: 'string' },
151 { path: 'timestamp', type: 'datetime' },
152 { path: 'metadata.context.host', type: 'string' },
153 { path: 'metadata.context.pid', type: 'number' },
154 { path: 'metadata.level', type: 'string' },
155 { path: 'metadata.project', type: 'string' },
156 { path: 'metadata.req.headers.accept', type: 'string' },
157 { path: 'metadata.req.headers.cf_connecting_ip', type: 'string' },
158 { path: 'metadata.req.headers.cf_ray', type: 'string' },
159 { path: 'metadata.req.headers.content_length', type: 'string' },
160 { path: 'metadata.req.headers.content_type', type: 'string' },
161 { path: 'metadata.req.headers.host', type: 'string' },
162 { path: 'metadata.req.headers.referer', type: 'string' },
163 { path: 'metadata.req.headers.user_agent', type: 'string' },
164 { path: 'metadata.req.headers.x_client_info', type: 'string' },
165 { path: 'metadata.req.headers.x_forwarded_proto', type: 'string' },
166 { path: 'metadata.req.hostname', type: 'string' },
167 { path: 'metadata.req.method', type: 'string' },
168 { path: 'metadata.req.remoteAddress', type: 'string' },
169 { path: 'metadata.req.remotePort', type: 'number' },
170 { path: 'metadata.req.url', type: 'string' },
171 { path: 'metadata.reqId', type: 'string' },
172 { path: 'metadata.res.statusCode', type: 'number' },
173 { path: 'metadata.res.headers.content_length', type: 'number' },
174 { path: 'metadata.res.headers.content_type', type: 'string' },
175 { path: 'metadata.responseTime', type: 'number' },
176 { path: 'metadata.tenantId', type: 'string' },
177 { path: 'metadata.rawError', type: 'string' },
178 ],
179 },
180 {
181 name: 'Function Edge',
182 reference: 'function_edge_logs',
183 fields: [
184 { path: 'event_message', type: 'string' },
185 { path: 'id', type: 'string' },
186 { path: 'timestamp', type: 'datetime' },
187 { path: 'metadata.deployment_id', type: 'string' },
188 { path: 'metadata.execution_time_ms', type: 'number' },
189 { path: 'metadata.function_id', type: 'string' },
190 { path: 'metadata.project_ref', type: 'string' },
191 { path: 'metadata.request.headers.accept', type: 'string' },
192 { path: 'metadata.request.headers.content_length', type: 'string' },
193 { path: 'metadata.request.headers.host', type: 'string' },
194 { path: 'metadata.request.headers.user_agent', type: 'string' },
195 { path: 'metadata.request.host', type: 'string' },
196 { path: 'metadata.request.method', type: 'string' },
197 { path: 'metadata.request.pathname', type: 'string' },
198 { path: 'metadata.request.protocol', type: 'string' },
199 { path: 'metadata.request.url', type: 'string' },
200 { path: 'metadata.response.headers.content_length', type: 'string' },
201 { path: 'metadata.response.headers.content_type', type: 'string' },
202 { path: 'metadata.response.headers.date', type: 'string' },
203 { path: 'metadata.response.headers.server', type: 'string' },
204 { path: 'metadata.response.headers.vary', type: 'string' },
205 { path: 'metadata.response.status_code', type: 'number' },
206 { path: 'metadata.version', type: 'string' },
207 ],
208 },
209 {
210 name: 'Function Runtime',
211 reference: 'function_logs',
212 fields: [
213 { path: 'event_message', type: 'string' },
214 { path: 'id', type: 'string' },
215 { path: 'timestamp', type: 'datetime' },
216 { path: 'metadata.deployment_id', type: 'string' },
217 { path: 'metadata.event_type', type: 'string' },
218 { path: 'metadata.execution_id', type: 'string' },
219 { path: 'metadata.function_id', type: 'string' },
220 { path: 'metadata.level', type: 'string' },
221 { path: 'metadata.project_ref', type: 'string' },
222 { path: 'metadata.region', type: 'string' },
223 { path: 'metadata.timestamp', type: 'string' },
224 { path: 'metadata.version', type: 'string' },
225 ],
226 },
227 {
228 name: 'Postgres',
229 reference: 'postgres_logs',
230 fields: [
231 { path: 'event_message', type: 'string' },
232 { path: 'id', type: 'string' },
233 { path: 'timestamp', type: 'datetime' },
234 { path: 'identifier', type: 'string' },
235 { path: 'metadata.host', type: 'string' },
236 { path: 'metadata.parsed.backend_type', type: 'string' },
237 { path: 'metadata.parsed.command_tag', type: 'string' },
238 { path: 'metadata.parsed.connection_from', type: 'string' },
239 { path: 'metadata.parsed.database_name', type: 'string' },
240 { path: 'metadata.parsed.error_severity', type: 'string' },
241 { path: 'metadata.parsed.process_id', type: 'number' },
242 { path: 'metadata.parsed.query_id', type: 'number' },
243 { path: 'metadata.parsed.session_id', type: 'string' },
244 { path: 'metadata.parsed.session_line_num', type: 'number' },
245 { path: 'metadata.parsed.session_start_time', type: 'string' },
246 { path: 'metadata.parsed.sql_state_code', type: 'string' },
247 { path: 'metadata.parsed.timestamp', type: 'string' },
248 { path: 'metadata.parsed.transaction_id', type: 'number' },
249 { path: 'metadata.parsed.user_name', type: 'string' },
250 { path: 'metadata.parsed.virtual_transaction_id', type: 'string' },
251 ],
252 },
253 {
254 name: 'Realtime',
255 reference: 'realtime_logs',
256 fields: [
257 { path: 'event_message', type: 'string' },
258 { path: 'id', type: 'string' },
259 { path: 'timestamp', type: 'datetime' },
260 { path: 'metadata.level', type: 'string' },
261 { path: 'metadata.measurements.connected', type: 'number' },
262 { path: 'metadata.measurements.connected_cluster', type: 'number' },
263 { path: 'metadata.measurements.limit', type: 'number' },
264 { path: 'metadata.measurements.sum', type: 'number' },
265 { path: 'metadata.external_id', type: 'string' },
266 ],
267 },
268 {
269 name: 'PostgREST',
270 reference: 'postgrest_logs',
271 fields: [
272 { path: 'event_message', type: 'string' },
273 { path: 'id', type: 'string' },
274 { path: 'identifier', type: 'string' },
275 { path: 'timestamp', type: 'datetime' },
276 { path: 'metadata.host', type: 'string' },
277 ],
278 },
279 {
280 name: 'Supavisor (Shared Pooler)',
281 reference: 'supavisor_logs',
282 fields: [
283 { path: 'event_message', type: 'string' },
284 { path: 'id', type: 'string' },
285 { path: 'timestamp', type: 'datetime' },
286 { path: 'metadata.context.application', type: 'string' },
287 { path: 'metadata.context.domain', type: 'string[]' },
288 { path: 'metadata.context.file', type: 'string' },
289 { path: 'metadata.context.function', type: 'string' },
290 { path: 'metadata.context.gl', type: 'string' },
291 { path: 'metadata.context.line', type: 'number' },
292 { path: 'metadata.context.mfa', type: 'string[]' },
293 { path: 'metadata.context.module', type: 'string' },
294 { path: 'metadata.context.pid', type: 'string' },
295 { path: 'metadata.context.time', type: 'number' },
296 { path: 'metadata.context.vm.node', type: 'string' },
297 { path: 'metadata.db_name', type: 'string' },
298 { path: 'metadata.instance_id', type: 'string' },
299 { path: 'metadata.level', type: 'string' },
300 { path: 'metadata.project', type: 'string' },
301 { path: 'metadata.region', type: 'string' },
302 { path: 'metadata.type', type: 'string' },
303 { path: 'metadata.user', type: 'string' },
304 ],
305 },
306 {
307 name: 'PgBouncer (Dedicated Pooler)',
308 reference: 'pgbouncer_logs',
309 fields: [
310 { path: 'id', type: 'string' },
311 { path: 'event_message', type: 'string' },
312 { path: 'file', type: 'string' },
313 { path: 'timestamp', type: 'datetime' },
314 { path: 'metadata.host', type: 'string' },
315 { path: 'project', type: 'string' },
316 ],
317 },
318 {
319 name: 'Database Version Upgrade',
320 reference: 'pg_upgrade_logs',
321 fields: [
322 { path: 'event_message', type: 'string' },
323 { path: 'id', type: 'string' },
324 { path: 'timestamp', type: 'datetime' },
325 ],
326 },
327]
328
329export default {
330 schemas,
331}