Skip to content

Commit 26db1e1

Browse files
authored
[*] sort webui preset selection list and add descriptions, fixes #1050 (#1172)
Sort presets in logical order (minimal → exhaustive → cloud → special) and display descriptions to help users choose the right preset. Remove outdated presets `prometheus-async` and `unprivileged`.
1 parent 46805e2 commit 26db1e1

File tree

3 files changed

+66
-45
lines changed

3 files changed

+66
-45
lines changed

internal/metrics/metrics.yaml

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4391,24 +4391,6 @@ presets:
43914391
reco_partial_index_candidates: 79200
43924392
reco_sprocs_wo_search_path: 86400
43934393
reco_superusers: 93600
4394-
prometheus-async:
4395-
description: Tuned for the Prometheus async scrapping
4396-
metrics:
4397-
backends: 30
4398-
bgwriter: 60
4399-
checkpointer: 60
4400-
db_size: 300
4401-
db_stats: 30
4402-
locks_mode: 30
4403-
replication: 120
4404-
replication_slots: 120
4405-
settings: 300
4406-
sproc_stats: 180
4407-
stat_statements_calls: 60
4408-
table_io_stats: 300
4409-
table_stats: 300
4410-
wait_events: 60
4411-
wal: 60
44124394
rds:
44134395
description: similar to 'exhaustive' with stuff that's not accessible on AWS RDS removed
44144396
metrics:
@@ -4480,29 +4462,6 @@ presets:
44804462
wal: 60
44814463
wal_receiver: 120
44824464
wal_size: 300
4483-
unprivileged:
4484-
description: no wrappers + only pg_stat_statements extension expected (developer mode)
4485-
metrics:
4486-
archiver: 60
4487-
archiver_pending_count: 120
4488-
bgwriter: 60
4489-
checkpointer: 60
4490-
change_events: 300
4491-
db_size: 300
4492-
db_stats: 60
4493-
index_stats: 900
4494-
instance_up: 60
4495-
locks: 60
4496-
locks_mode: 60
4497-
replication: 120
4498-
replication_slots: 120
4499-
sequence_health: 3600
4500-
settings: 7200
4501-
sproc_stats: 180
4502-
stat_statements_calls: 60
4503-
table_io_stats: 600
4504-
table_stats: 300
4505-
wal: 60
45064465
debug:
45074466
description: all available metrics with 30 second intervals for debugging and development
45084467
metrics:

internal/webui/src/components/Autocomplete/Autocomplete.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { AutocompleteRenderInputParams, Autocomplete as MuiAutocomplete, TextField } from "@mui/material";
1+
import { AutocompleteRenderInputParams, Autocomplete as MuiAutocomplete, TextField, Box, Typography } from "@mui/material";
22
import { ControllerRenderProps } from "react-hook-form";
33

4+
type AutocompleteOption = {
5+
label: string;
6+
description?: string;
7+
};
8+
49
type Props = {
510
id?: string;
611
label: string;
7-
options: { label: string }[];
12+
options: AutocompleteOption[];
813
loading?: boolean;
914
error?: boolean;
1015
} & ControllerRenderProps;
@@ -26,6 +31,19 @@ export const Autocomplete = (props: Props) => {
2631
id={id}
2732
options={options}
2833
renderInput={customInput}
34+
getOptionLabel={(option) => typeof option === "string" ? option : option.label}
35+
renderOption={(props, option) => (
36+
<Box component="li" {...props}>
37+
<Box>
38+
<Typography variant="body1">{option.label}</Typography>
39+
{option.description && (
40+
<Typography variant="body2" color="text.secondary" sx={{ fontSize: '0.875rem' }}>
41+
{option.description}
42+
</Typography>
43+
)}
44+
</Box>
45+
</Box>
46+
)}
2947
onChange={(_, value) => field.onChange(value ? value.label : "")}
3048
loading={loading}
3149
componentsProps={{

internal/webui/src/containers/SourceFormDialog/components/SourceForm/components/SourceFormStepMetrics.tsx

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,52 @@ export const SourceFormStepMetrics = () => {
3535
const presets = usePresets();
3636
const metrics = useMetrics();
3737

38+
// Define the logical order for presets
39+
const sortPresets = (presetKeys: string[]) => {
40+
const order = [
41+
'minimal',
42+
'basic',
43+
'standard',
44+
'exhaustive',
45+
'full',
46+
'exhaustive_no_python',
47+
// Cloud providers (alphabetically)
48+
'aiven',
49+
'azure',
50+
'gce',
51+
'rds',
52+
// Special presets (alphabetically)
53+
'debug',
54+
'pgbouncer',
55+
'pgpool',
56+
'recommendations',
57+
];
58+
59+
return presetKeys.sort((a, b) => {
60+
const indexA = order.indexOf(a);
61+
const indexB = order.indexOf(b);
62+
63+
// If both are in the order array, sort by their position
64+
if (indexA !== -1 && indexB !== -1) {
65+
return indexA - indexB;
66+
}
67+
68+
// If only one is in the order array, it comes first
69+
if (indexA !== -1) return -1;
70+
if (indexB !== -1) return 1;
71+
72+
// If neither is in the order array, sort alphabetically
73+
return a.localeCompare(b);
74+
});
75+
};
76+
3877
const presetsOptions = useMemo(
39-
() => presets.data ? Object.keys(presets.data).sort((a, b) => a.localeCompare(b)).map((key) => ({ label: key })) : [],
78+
() => presets.data
79+
? sortPresets(Object.keys(presets.data)).map((key) => ({
80+
label: key,
81+
description: presets.data[key].Description
82+
}))
83+
: [],
4084
[presets.data],
4185
);
4286

@@ -230,7 +274,7 @@ export const SourceFormStepMetrics = () => {
230274
<Checkbox
231275
{...onlyIfMasterField}
232276
size="medium"
233-
checked={onlyIfMasterField.value}
277+
checked={onlyIfMasterField.value}
234278
/>
235279
}
236280
/>

0 commit comments

Comments
 (0)