aboutsummaryrefslogtreecommitdiff
path: root/apks/prometheus-postgres-exporter/README.Alpine
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2022-12-12 22:07:14 +0100
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2022-12-12 22:12:00 +0100
commiteed21034efae03ee661e06122f96dc01e53afaa4 (patch)
tree77d08583f538a9f87bc1a34e6fe29c3e2f3fd13a /apks/prometheus-postgres-exporter/README.Alpine
parentae0a676dd82ad2c842437ee3cd36526f4951f998 (diff)
downloadapkbuilds-eed21034efae03ee661e06122f96dc01e53afaa4.tar.gz
apkbuilds-eed21034efae03ee661e06122f96dc01e53afaa4.tar.bz2
apkbuilds-eed21034efae03ee661e06122f96dc01e53afaa4.zip
feat: Add prometheus-postgres-exporter
Diffstat (limited to 'apks/prometheus-postgres-exporter/README.Alpine')
-rw-r--r--apks/prometheus-postgres-exporter/README.Alpine48
1 files changed, 48 insertions, 0 deletions
diff --git a/apks/prometheus-postgres-exporter/README.Alpine b/apks/prometheus-postgres-exporter/README.Alpine
new file mode 100644
index 0000000..6e09049
--- /dev/null
+++ b/apks/prometheus-postgres-exporter/README.Alpine
@@ -0,0 +1,48 @@
+This document is adapted from README.Debian contained in Debian package.
+
+To use the PostgreSQL exporter, you need to connect to the database with
+superuser (postgres) privileges, or with an user that has been granted enough
+permissions.
+
+The recommended way to do this, is to create a `prometheus` user with no
+password, and then connect using UNIX domain sockets.
+
+To do that, set this connection string in
+/etc/conf.d/prometheus-postgres-exporter:
+
+ DATA_SOURCE_NAME='user=prometheus host=/run/postgresql dbname=postgres'
+
+And use psql (doas -u postgres psql) to execute these SQL commands to create
+the user:
+
+ CREATE USER prometheus;
+ ALTER USER prometheus SET SEARCH_PATH TO prometheus,pg_catalog;
+
+ CREATE SCHEMA prometheus AUTHORIZATION prometheus;
+
+ CREATE FUNCTION prometheus.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 prometheus.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 prometheus.pg_stat_replication
+ AS
+ SELECT * FROM prometheus.f_select_pg_stat_replication();
+
+ CREATE VIEW prometheus.pg_stat_activity
+ AS
+ SELECT * FROM prometheus.f_select_pg_stat_activity();
+
+ GRANT SELECT ON prometheus.pg_stat_replication TO prometheus;
+ GRANT SELECT ON prometheus.pg_stat_activity TO prometheus;