ResourceExhaustionWarningBanner.constants.ts 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import { DOCS_URL } from '@/lib/constants'
  2. interface ResourceWarningMessage {
  3. // should match pathnames, ex: ('/', 'project/[ref]/auth', 'project/[ref]/database', '/project/[ref]/settings/api')
  4. restrictToRoutes?: string[]
  5. bannerContent: {
  6. warning: { title: string; description: string }
  7. critical: { title?: string; description?: string }
  8. }
  9. cardContent: {
  10. warning: { title: string; description: string }
  11. critical: { title?: string; description?: string }
  12. }
  13. docsUrl?: string
  14. // In-app destination for inspecting the metric (e.g. observability charts).
  15. // [ref] is replaced with the current project ref at render time.
  16. metricsHref?: string
  17. buttonText?: string
  18. aiPrompt?: string
  19. metric: string | null
  20. }
  21. type ResourceWarningMessages = Record<string, ResourceWarningMessage>
  22. export const RESOURCE_WARNING_MESSAGES: ResourceWarningMessages = {
  23. is_readonly_mode_enabled: {
  24. bannerContent: {
  25. warning: {
  26. title:
  27. 'Your project is currently in read-only mode and is no longer accepting write requests',
  28. description:
  29. 'You will need to manually override read-only mode and reduce the disk size to below 95%',
  30. },
  31. critical: {
  32. title:
  33. 'Your project is currently in read-only mode and is no longer accepting write requests',
  34. description:
  35. 'You will need to manually override read-only mode and reduce the disk size to below 95%',
  36. },
  37. },
  38. cardContent: {
  39. warning: {
  40. title: 'Project is in read-only mode',
  41. description: 'Database is no longer accepting write requests.',
  42. },
  43. critical: {
  44. title: 'Project is in read-only mode',
  45. description: 'Database is no longer accepting write requests.',
  46. },
  47. },
  48. docsUrl: `${DOCS_URL}/guides/platform/database-size#disabling-read-only-mode`,
  49. buttonText: 'Manage disk',
  50. metric: 'read_only',
  51. },
  52. disk_io_exhaustion: {
  53. bannerContent: {
  54. warning: {
  55. title: 'Your project is about to deplete its Disk IO Budget',
  56. description:
  57. 'Once exhausted, disk throughput will return to its baseline of {baseline} until the budget resets. Upgrade your compute or use the AI Assistant to identify and optimize disk-intensive queries.',
  58. },
  59. critical: {
  60. title:
  61. 'Your project has depleted its Disk IO Budget. Disk throughput is at its baseline of {baseline}',
  62. description:
  63. 'Throughput will stay at baseline until the budget resets. Upgrade your compute to sustain higher throughput, or use the AI Assistant to identify and optimize disk-intensive queries.',
  64. },
  65. },
  66. cardContent: {
  67. warning: {
  68. title: 'Project is depleting its Disk IO Budget',
  69. description: 'It may become unresponsive if fully exhausted',
  70. },
  71. critical: {
  72. title: 'Project has depleted its Disk IO Budget',
  73. description: 'It may become unresponsive',
  74. },
  75. },
  76. docsUrl: `${DOCS_URL}/guides/troubleshooting/exhaust-disk-io`,
  77. metricsHref: '/project/[ref]/observability/database',
  78. buttonText: 'Upgrade compute',
  79. aiPrompt:
  80. 'My database is running out of Disk IO budget. Can you query pg_stat_statements to find the top queries by shared blocks read and written, identify which are causing the most disk I/O, and suggest specific optimizations to reduce disk usage?',
  81. metric: 'disk_io',
  82. },
  83. disk_space_exhaustion: {
  84. bannerContent: {
  85. warning: {
  86. title:
  87. 'Your project is about to exhaust its available disk space, and may become unresponsive once fully exhausted',
  88. description:
  89. 'You can opt to increase your disk size up to 200GB on the Database Settings page.',
  90. },
  91. critical: {
  92. title: 'Your project has exhausted its available disk space, and may become unresponsive',
  93. description:
  94. 'You can opt to increase your disk size up to 200GB on the Database Settings page.',
  95. },
  96. },
  97. cardContent: {
  98. warning: {
  99. title: 'Project is exhausting its available disk space',
  100. description: 'It may become unresponsive if fully exhausted',
  101. },
  102. critical: {
  103. title: 'Project has exhausted its available disk space',
  104. description: 'It may become unresponsive',
  105. },
  106. },
  107. docsUrl: `${DOCS_URL}/guides/platform/database-size#disk-management`,
  108. buttonText: undefined,
  109. metric: 'disk_space',
  110. },
  111. cpu_exhaustion: {
  112. bannerContent: {
  113. warning: {
  114. title: 'Your project is currently facing high CPU usage, and its performance is affected',
  115. description:
  116. 'Upgrade your compute or use the AI Assistant to identify and optimize CPU-intensive queries.',
  117. },
  118. critical: {
  119. title: "Your project's CPU usage is at 100% and its performance is affected",
  120. description:
  121. 'Upgrade your compute or use the AI Assistant to identify and optimize CPU-intensive queries.',
  122. },
  123. },
  124. cardContent: {
  125. warning: {
  126. title: 'Project has high CPU usage',
  127. description: `Performance is affected`,
  128. },
  129. critical: {
  130. title: 'Project CPU usage is at 100%',
  131. description: `Performance is affected`,
  132. },
  133. },
  134. docsUrl: `${DOCS_URL}/guides/troubleshooting/high-cpu-usage`,
  135. buttonText: 'Upgrade compute',
  136. aiPrompt:
  137. 'My database is experiencing high CPU usage. Can you query pg_stat_statements to find the top queries by total execution time and mean execution time, identify which are most CPU-intensive, and suggest specific optimizations such as missing indexes or query rewrites to reduce CPU load?',
  138. metric: 'cpu',
  139. },
  140. memory_and_swap_exhaustion: {
  141. bannerContent: {
  142. warning: {
  143. title:
  144. 'Your project is currently facing high memory usage, and its performance is affected',
  145. description:
  146. 'Upgrade your compute or use the AI Assistant to identify and optimize memory-intensive queries.',
  147. },
  148. critical: {
  149. title: "Your project's memory usage is at 100%, and its performance is affected",
  150. description:
  151. 'Upgrade your compute or use the AI Assistant to identify and optimize memory-intensive queries.',
  152. },
  153. },
  154. cardContent: {
  155. warning: {
  156. title: 'Project has high memory usage',
  157. description: `Performance is affected`,
  158. },
  159. critical: {
  160. title: 'Project memory usage is at 100%',
  161. description: `Performance is affected`,
  162. },
  163. },
  164. docsUrl: `${DOCS_URL}/guides/troubleshooting/exhaust-ram`,
  165. buttonText: 'Upgrade compute',
  166. aiPrompt:
  167. 'My database is experiencing high memory and swap usage. Can you query pg_stat_statements to find the top queries by shared buffer hits and rows returned, identify which queries are putting the most pressure on memory, and suggest optimizations to reduce memory consumption?',
  168. metric: 'ram',
  169. },
  170. auth_rate_limit_exhaustion: {
  171. // [Joel] There is no critical warning as there is no notion of critical rate limits for auth at the moment
  172. bannerContent: {
  173. warning: {
  174. title:
  175. 'Your project has exceeded email rate limits in the past 24 hours and may not reliably send auth related emails to users',
  176. description:
  177. 'Set up a custom SMTP and adjust rate limits where necessary to ensure that emails are sent out reliably.',
  178. },
  179. critical: {
  180. title: undefined,
  181. description: undefined,
  182. },
  183. },
  184. cardContent: {
  185. warning: {
  186. title: 'Your project has exceeded email rate limits',
  187. description: `You will need to set up a custom SMTP provider and adjust rate limits where necessary`,
  188. },
  189. critical: {
  190. title: undefined,
  191. description: undefined,
  192. },
  193. },
  194. docsUrl: `${DOCS_URL}/guides/platform/going-into-prod#auth-rate-limits`,
  195. buttonText: 'Enable custom SMTP',
  196. metric: 'auth_email_rate_limit',
  197. },
  198. multiple_resource_warnings: {
  199. bannerContent: {
  200. warning: {
  201. title:
  202. 'Your project is currently exhausting multiple resources, and its performance is affected',
  203. description:
  204. 'Upgrade your compute or use the AI Assistant to identify and optimize the most expensive queries.',
  205. },
  206. critical: {
  207. title: 'Your project has exhausted multiple resources, and its performance is affected',
  208. description:
  209. 'Upgrade your compute or use the AI Assistant to identify and optimize the most expensive queries.',
  210. },
  211. },
  212. cardContent: {
  213. warning: {
  214. title: 'Project is exhausting multiple resources',
  215. description: `Performance is affected.`,
  216. },
  217. critical: {
  218. title: 'Project has exhausted multiple resources',
  219. description: `Performance is affected.`,
  220. },
  221. },
  222. docsUrl: undefined,
  223. buttonText: 'Check usage',
  224. aiPrompt:
  225. 'My database is exhausting multiple resources (CPU, memory, and/or disk IO). Can you query pg_stat_statements to identify the most expensive queries overall, and suggest which optimizations would have the biggest impact on reducing resource consumption?',
  226. metric: null,
  227. },
  228. }