metrics.tsx407 lines · main
1import { Auth, Realtime, Storage } from 'icons'
2import { ActivityIcon, DatabaseIcon, HeartIcon, ServerIcon } from 'lucide-react'
3import { ReactNode } from 'react'
4
5export type Metric = {
6 key: string
7 label: string
8 provider?: string
9 category?: MetricCategory
10 id?: string
11}
12
13type MetricCategory = {
14 label: string
15 icon: (className?: string) => ReactNode
16 key: string
17}
18
19export const METRIC_CATEGORIES = {
20 API: {
21 label: 'All API usage',
22 icon: (className?: string) => <ActivityIcon size={16} className={className} />,
23 key: 'api',
24 },
25 API_DATABASE: {
26 label: 'Database API',
27 icon: (className?: string) => <DatabaseIcon size={16} className={className} />,
28 key: 'api_database',
29 },
30 API_AUTH: {
31 label: 'Authentication',
32 icon: (className?: string) => <Auth size={16} className={className} />,
33 key: 'api_auth',
34 },
35 API_STORAGE: {
36 label: 'Storage',
37 icon: (className?: string) => <Storage size={16} className={className} />,
38 key: 'api_storage',
39 },
40 API_REALTIME: {
41 label: 'Realtime',
42 icon: (className?: string) => <Realtime size={16} className={className} />,
43 key: 'api_realtime',
44 },
45 INSTANCE: {
46 label: 'Instance health',
47 icon: (className?: string) => <HeartIcon size={16} className={className} />,
48 key: 'instance',
49 },
50 SUPAVISOR: {
51 label: 'Supavisor',
52 icon: (className?: string) => <ServerIcon size={16} className={className} />,
53 key: 'supavisor',
54 },
55}
56
57// [Joshen] Eventually we can remove some charts here from DEPRECATED_REPORTS from Reports.constants.ts
58export const METRICS: Metric[] = [
59 {
60 key: 'avg_cpu_usage',
61 label: 'Average CPU % Usage',
62 provider: 'infra-monitoring',
63 category: METRIC_CATEGORIES.INSTANCE,
64 },
65 {
66 key: 'max_cpu_usage',
67 label: 'Max CPU % Usage',
68 provider: 'infra-monitoring',
69 category: METRIC_CATEGORIES.INSTANCE,
70 },
71 {
72 key: 'disk_io_consumption',
73 label: 'Disk IO % Consumed',
74 provider: 'infra-monitoring',
75 category: METRIC_CATEGORIES.INSTANCE,
76 },
77 {
78 key: 'disk_io_budget',
79 label: 'Disk IO % Remaining',
80 provider: 'infra-monitoring',
81 category: METRIC_CATEGORIES.INSTANCE,
82 },
83 {
84 key: 'ram_usage',
85 label: 'Memory % Usage',
86 provider: 'infra-monitoring',
87 category: METRIC_CATEGORIES.INSTANCE,
88 },
89 {
90 key: 'total_realtime_egress',
91 label: 'Realtime Connection Egress',
92 provider: 'daily-stats',
93 category: METRIC_CATEGORIES.API,
94 },
95 {
96 key: 'total_realtime_requests',
97 label: 'Realtime Connection Requests',
98 provider: 'daily-stats',
99 category: METRIC_CATEGORIES.API_REALTIME,
100 },
101 {
102 key: 'total_realtime_ingress',
103 label: 'Realtime Connection Ingress',
104 provider: 'daily-stats',
105 category: METRIC_CATEGORIES.API_REALTIME,
106 },
107
108 /**
109 * API
110 */
111 {
112 key: 'total_rest_ingress',
113 label: 'API Ingress',
114 provider: 'daily-stats',
115 category: METRIC_CATEGORIES.API_DATABASE,
116 },
117 {
118 key: 'total_rest_egress',
119 label: 'API Egress',
120 provider: 'daily-stats',
121 category: METRIC_CATEGORIES.API_DATABASE,
122 },
123 {
124 key: 'total_rest_requests',
125 label: 'API Requests',
126 provider: 'daily-stats',
127 category: METRIC_CATEGORIES.API_DATABASE,
128 },
129 {
130 key: 'total_rest_get_requests',
131 label: 'API GET Requests',
132 provider: 'daily-stats',
133 category: METRIC_CATEGORIES.API_DATABASE,
134 },
135 {
136 key: 'total_rest_post_requests',
137 label: 'API POST Requests',
138 provider: 'daily-stats',
139 category: METRIC_CATEGORIES.API_DATABASE,
140 },
141 {
142 key: 'total_rest_patch_requests',
143 label: 'API PATCH Requests',
144 provider: 'daily-stats',
145 category: METRIC_CATEGORIES.API_DATABASE,
146 },
147 {
148 key: 'total_rest_delete_requests',
149 label: 'API DELETE Requests',
150 provider: 'daily-stats',
151 category: METRIC_CATEGORIES.API_DATABASE,
152 },
153 {
154 key: 'total_rest_options_requests',
155 label: 'API OPTIONS Requests',
156 provider: 'daily-stats',
157 category: METRIC_CATEGORIES.API_DATABASE,
158 },
159
160 /**
161 * Auth
162 */
163
164 {
165 key: 'total_auth_billing_period_mau',
166 label: 'Auth Monthly Active User',
167 provider: 'daily-stats',
168 category: METRIC_CATEGORIES.API_AUTH,
169 },
170 {
171 key: 'total_auth_billing_period_sso_mau',
172 label: 'Auth Monthly Active SSO User',
173 provider: 'daily-stats',
174 category: METRIC_CATEGORIES.API_AUTH,
175 },
176 {
177 key: 'total_auth_ingress',
178 label: 'Auth Ingress',
179 provider: 'daily-stats',
180 category: METRIC_CATEGORIES.API_AUTH,
181 },
182 {
183 key: 'total_auth_egress',
184 label: 'Auth Egress',
185 provider: 'daily-stats',
186 category: METRIC_CATEGORIES.API_AUTH,
187 },
188 {
189 key: 'total_auth_requests',
190 label: 'Auth Requests',
191 provider: 'daily-stats',
192 category: METRIC_CATEGORIES.API_AUTH,
193 },
194 {
195 key: 'total_auth_get_requests',
196 label: 'Auth GET Requests',
197 provider: 'daily-stats',
198 category: METRIC_CATEGORIES.API_AUTH,
199 },
200 {
201 key: 'total_auth_post_requests',
202 label: 'Auth POST Requests',
203 provider: 'daily-stats',
204 category: METRIC_CATEGORIES.API_AUTH,
205 },
206 {
207 key: 'total_auth_patch_requests',
208 label: 'Auth PATCH Requests',
209 provider: 'daily-stats',
210 category: METRIC_CATEGORIES.API_AUTH,
211 },
212 {
213 key: 'total_auth_options_requests',
214 label: 'Auth OPTIONS Requests',
215 provider: 'daily-stats',
216 category: METRIC_CATEGORIES.API_AUTH,
217 },
218
219 /**
220 * Storage
221 */
222 {
223 key: 'total_storage_ingress',
224 label: 'Storage Ingress',
225 provider: 'daily-stats',
226 category: METRIC_CATEGORIES.API_STORAGE,
227 },
228 {
229 key: 'total_storage_egress',
230 label: 'Storage Egress',
231 provider: 'daily-stats',
232 category: METRIC_CATEGORIES.API_STORAGE,
233 },
234 {
235 key: 'total_storage_image_render_count',
236 label: 'Storage Image Transformations',
237 provider: 'daily-stats',
238 category: METRIC_CATEGORIES.API_STORAGE,
239 },
240 {
241 key: 'total_storage_requests',
242 label: 'Storage Requests',
243 provider: 'daily-stats',
244 category: METRIC_CATEGORIES.API_STORAGE,
245 },
246 {
247 key: 'total_storage_get_requests',
248 label: 'Storage GET Requests',
249 provider: 'daily-stats',
250 category: METRIC_CATEGORIES.API_STORAGE,
251 },
252 {
253 key: 'total_storage_post_requests',
254 label: 'Storage POST Requests',
255 provider: 'daily-stats',
256 category: METRIC_CATEGORIES.API_STORAGE,
257 },
258 {
259 key: 'total_storage_delete_requests',
260 label: 'Storage DELETE Requests',
261 provider: 'daily-stats',
262 category: METRIC_CATEGORIES.API_STORAGE,
263 },
264 {
265 key: 'total_storage_options_requests',
266 label: 'Storage OPTIONS Requests',
267 provider: 'daily-stats',
268 category: METRIC_CATEGORIES.API_STORAGE,
269 },
270 {
271 key: 'total_auth_delete_requests',
272 label: 'Auth DELETE Requests',
273 provider: 'daily-stats',
274 category: METRIC_CATEGORIES.API_AUTH,
275 },
276
277 {
278 key: 'total_egress',
279 label: 'All Egress',
280 provider: 'daily-stats',
281 category: METRIC_CATEGORIES.API,
282 },
283
284 {
285 key: 'total_get_requests',
286 label: 'All GET Requests',
287 provider: 'daily-stats',
288 category: METRIC_CATEGORIES.API,
289 },
290
291 {
292 key: 'total_cached_egress',
293 label: 'All Cached Egress',
294 provider: 'daily-stats',
295 category: METRIC_CATEGORIES.API_STORAGE,
296 },
297
298 {
299 key: 'total_storage_patch_requests',
300 label: 'Storage PATCH Requests',
301 provider: 'daily-stats',
302 category: METRIC_CATEGORIES.API_STORAGE,
303 },
304 {
305 key: 'total_requests',
306 label: 'All Requests',
307 provider: 'daily-stats',
308 category: METRIC_CATEGORIES.API,
309 },
310 {
311 key: 'total_patch_requests',
312 label: 'All PATCH Requests',
313 provider: 'daily-stats',
314 category: METRIC_CATEGORIES.API,
315 },
316 {
317 key: 'total_post_requests',
318 label: 'All POST Requests',
319 provider: 'daily-stats',
320 category: METRIC_CATEGORIES.API,
321 },
322
323 {
324 key: 'total_ingress',
325 label: 'All Ingress',
326 provider: 'daily-stats',
327 category: METRIC_CATEGORIES.API,
328 },
329 {
330 key: 'total_delete_requests',
331 label: 'All DELETE Requests',
332 provider: 'daily-stats',
333 category: METRIC_CATEGORIES.API,
334 },
335 {
336 key: 'total_options_requests',
337 label: 'All OPTIONS Requests',
338 provider: 'daily-stats',
339 category: METRIC_CATEGORIES.API,
340 },
341
342 /** Supavisor */
343 {
344 key: 'total_supavisor_egress_bytes',
345 label: 'Shared Pooler Egress',
346 provider: 'daily-stats',
347 category: METRIC_CATEGORIES.SUPAVISOR,
348 },
349]
350
351export const TIME_PERIODS_BILLING = [
352 {
353 key: 'currentBillingCycle',
354 label: 'Current billing cycle',
355 interval: '1d',
356 },
357 {
358 key: 'previousBillingCycle',
359 label: 'Previous billing cycle',
360 interval: '1d',
361 },
362]
363
364export const TIME_PERIODS_REPORTS = [
365 {
366 key: '7d',
367 label: 'Last 7 days',
368 interval: '1d',
369 },
370 {
371 key: '30d',
372 label: 'Last 30 days',
373 interval: '1d',
374 },
375 {
376 key: 'startMonth',
377 label: 'This month',
378 interval: '1d',
379 },
380]
381
382export const TIME_PERIODS_INFRA = [
383 {
384 key: '10m',
385 label: 'Last 10 minutes',
386 },
387 {
388 key: '30m',
389 label: 'Last 30 minutes',
390 },
391 {
392 key: '1h',
393 label: 'Last hour',
394 },
395 {
396 key: '3h',
397 label: 'Last 3 hours',
398 },
399 {
400 key: '1d',
401 label: 'Last 24 hours',
402 },
403 {
404 key: '7d',
405 label: 'Last 7 days',
406 },
407]