File tree Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,17 @@ grant pg_monitor to postgres_ai_mon;
19
19
grant select on pg_stat_statements to postgres_ai_mon;
20
20
grant select on pg_stat_database to postgres_ai_mon;
21
21
grant select on pg_stat_user_tables to postgres_ai_mon;
22
+
23
+ -- Create a public view for pg_statistic access for bloat metrics
24
+ CREATE VIEW public .pg_statistic AS
25
+ SELECT pg_statistic .stawidth ,
26
+ pg_statistic .stanullfrac ,
27
+ pg_statistic .starelid ,
28
+ pg_statistic .staattnum
29
+ FROM pg_statistic;
30
+
31
+ GRANT SELECT ON public .pg_statistic TO pg_monitor;
32
+ ALTER USER postgres_ai_mon set search_path = " $user" , public, pg_catalog;
22
33
```
23
34
24
35
** One command setup:**
Original file line number Diff line number Diff line change @@ -2183,8 +2183,8 @@ presets:
2183
2183
pg_stat_activity_autovacuum : 5
2184
2184
pg_stat_activity_autovacuum_active : 5
2185
2185
pg_gin_index : 5
2186
- pg_table_bloat : 86400
2187
- pg_btree_bloat : 86400
2186
+ pg_table_bloat : 60
2187
+ pg_btree_bloat : 60
2188
2188
pg_invalid_indexes : 60
2189
2189
redundant_indexes : 60
2190
2190
unused_indexes : 60
Original file line number Diff line number Diff line change @@ -19,12 +19,24 @@ INSERT INTO sample_data (name) VALUES
19
19
CREATE USER monitor WITH PASSWORD ' monitor_pass' ;
20
20
GRANT CONNECT ON DATABASE target_database TO monitor;
21
21
GRANT USAGE ON SCHEMA public TO monitor;
22
- GRANT SELECT ON ALL TABLES IN SCHEMA public TO monitor;
23
- GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO monitor;
22
+
23
+ -- Create a public view for pg_statistic access
24
+ CREATE VIEW public .pg_statistic AS
25
+ SELECT pg_statistic .stawidth ,
26
+ pg_statistic .stanullfrac ,
27
+ pg_statistic .starelid ,
28
+ pg_statistic .staattnum
29
+ FROM pg_statistic;
30
+
31
+ -- Grant specific access instead of all tables
32
+ GRANT SELECT ON public .pg_statistic TO pg_monitor;
24
33
25
34
-- Grant access to monitoring views
26
35
GRANT SELECT ON pg_stat_statements TO monitor;
27
36
GRANT SELECT ON pg_stat_database TO monitor;
28
37
GRANT SELECT ON pg_stat_user_tables TO monitor;
29
38
-- Grant pg_monitor role to monitor user for enhanced monitoring capabilities
30
39
GRANT pg_monitor TO monitor;
40
+
41
+ -- Set search path for the monitor user
42
+ ALTER USER monitor SET search_path = " $user" , public, pg_catalog;
You can’t perform that action at this time.
0 commit comments