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