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;
1919grant select on pg_stat_statements to postgres_ai_mon;
2020grant select on pg_stat_database to postgres_ai_mon;
2121grant 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;
2233```
2334
2435** One command setup:**
Original file line number Diff line number Diff line change @@ -2183,8 +2183,8 @@ presets:
21832183 pg_stat_activity_autovacuum : 5
21842184 pg_stat_activity_autovacuum_active : 5
21852185 pg_gin_index : 5
2186- pg_table_bloat : 86400
2187- pg_btree_bloat : 86400
2186+ pg_table_bloat : 60
2187+ pg_btree_bloat : 60
21882188 pg_invalid_indexes : 60
21892189 redundant_indexes : 60
21902190 unused_indexes : 60
Original file line number Diff line number Diff line change @@ -19,12 +19,24 @@ INSERT INTO sample_data (name) VALUES
1919CREATE USER monitor WITH PASSWORD ' monitor_pass' ;
2020GRANT CONNECT ON DATABASE target_database TO monitor;
2121GRANT 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;
2433
2534-- Grant access to monitoring views
2635GRANT SELECT ON pg_stat_statements TO monitor;
2736GRANT SELECT ON pg_stat_database TO monitor;
2837GRANT SELECT ON pg_stat_user_tables TO monitor;
2938-- Grant pg_monitor role to monitor user for enhanced monitoring capabilities
3039GRANT 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