Added support for collecting arbitrary sql queries.
Added metrics for locks per database per mode, pg_stat_activity, pg_stat_replication. Updated README.md with possible solution for running as non-superuser.
This commit is contained in:
39
README.md
39
README.md
@@ -41,3 +41,42 @@ for l in StringIO(x):
|
||||
```
|
||||
Adjust the value of the resultant prometheus value type appropriately. This helps build
|
||||
rich self-documenting metrics for the exporter.
|
||||
|
||||
|
||||
### Running as non-superuser
|
||||
|
||||
To be able to collect metrics from pg_stat_activity and pg_stat_replication as non-superuser you have to create functions and views to do so.
|
||||
|
||||
```sql
|
||||
CREATE USER postgres_exporter PASSWORD 'password';
|
||||
ALTER USER postgres_exporter SET SEARCH_PATH TO postgres_exporter,pg_catalog;
|
||||
|
||||
CREATE SCHEMA postgres_exporter AUTHORIZATION postgres_exporter;
|
||||
|
||||
CREATE FUNCTION postgres_exporter.f_select_pg_stat_activity()
|
||||
RETURNS setof pg_catalog.pg_stat_activity
|
||||
LANGUAGE sql
|
||||
SECURITY DEFINER
|
||||
AS $$
|
||||
SELECT * from pg_catalog.pg_stat_activity;
|
||||
$$;
|
||||
|
||||
CREATE FUNCTION postgres_exporter.f_select_pg_stat_replication()
|
||||
RETURNS setof pg_catalog.pg_stat_replication
|
||||
LANGUAGE sql
|
||||
SECURITY DEFINER
|
||||
AS $$
|
||||
SELECT * from pg_catalog.pg_stat_replication;
|
||||
$$;
|
||||
|
||||
CREATE VIEW postgres_exporter.pg_stat_replication
|
||||
AS
|
||||
SELECT * FROM postgres_exporter.f_select_pg_stat_replication();
|
||||
|
||||
CREATE VIEW postgres_exporter.pg_stat_activity
|
||||
AS
|
||||
SELECT * FROM postgres_exporter.f_select_pg_stat_activity();
|
||||
|
||||
GRANT SELECT ON postgres_exporter.pg_stat_replication TO postgres_exporter;
|
||||
GRANT SELECT ON postgres_exporter.pg_stat_activity TO postgres_exporter;
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user