log-constants.ts 15 KB

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