Skip to content

Commit b2f9c7b

Browse files
authored
Add pg_stat_statements view for non-superuser instructions
1 parent e2df41f commit b2f9c7b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,18 @@ AS
255255
SELECT * FROM get_pg_stat_replication();
256256

257257
GRANT SELECT ON postgres_exporter.pg_stat_replication TO postgres_exporter;
258+
259+
CREATE OR REPLACE FUNCTION get_pg_stat_statements() RETURNS SETOF pg_stat_statements AS
260+
$$ SELECT * FROM public.pg_stat_statements; $$
261+
LANGUAGE sql
262+
VOLATILE
263+
SECURITY DEFINER;
264+
265+
CREATE OR REPLACE VIEW postgres_exporter.pg_stat_statements
266+
AS
267+
SELECT * FROM get_pg_stat_statements();
268+
269+
GRANT SELECT ON postgres_exporter.pg_stat_statements TO postgres_exporter;
258270
```
259271

260272
> **NOTE**

0 commit comments

Comments
 (0)