Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 May 2024 16:05:24 GMT
From:      Joel Bodenmann <jbo@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: d387fce6b513 - main - databases/prometheus-postgres-exporter: New port
Message-ID:  <202405271605.44RG5OD2060426@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jbo:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d387fce6b513cdb86d73cf8b7ab3e7ce6a3c3a97

commit d387fce6b513cdb86d73cf8b7ab3e7ce6a3c3a97
Author:     Lexi Winter <lexi.freebsd@le-fay.org>
AuthorDate: 2024-04-20 21:51:03 +0000
Commit:     Joel Bodenmann <jbo@FreeBSD.org>
CommitDate: 2024-05-27 16:04:11 +0000

    databases/prometheus-postgres-exporter: New port
    
    PostgreSQL metric exporter for Prometheus.
    
    PR:                     276996
    Approved by:            tcberner (mentor)
    Differential Revision:  https://reviews.freebsd.org/D44888
---
 databases/Makefile                                 |  1 +
 databases/prometheus-postgres-exporter/Makefile    | 28 +++++++++
 databases/prometheus-postgres-exporter/distinfo    |  5 ++
 .../files/pkg-message.in                           | 29 +++++++++
 .../files/postgres_exporter.in                     | 73 ++++++++++++++++++++++
 .../files/postgres_exporter.yml.sample             | 12 ++++
 databases/prometheus-postgres-exporter/pkg-descr   |  3 +
 7 files changed, 151 insertions(+)

diff --git a/databases/Makefile b/databases/Makefile
index c6fe4dc0d10e..95aa602b2d35 100644
--- a/databases/Makefile
+++ b/databases/Makefile
@@ -706,6 +706,7 @@
     SUBDIR += proftpd-mod_sql_sqlite
     SUBDIR += proftpd-mod_sql_tds
     SUBDIR += prometheus-postgresql-adapter
+    SUBDIR += prometheus-postgres-exporter
     SUBDIR += proxysql
     SUBDIR += pspg
     SUBDIR += puppetdb-terminus7
diff --git a/databases/prometheus-postgres-exporter/Makefile b/databases/prometheus-postgres-exporter/Makefile
new file mode 100644
index 000000000000..c4a6baabe114
--- /dev/null
+++ b/databases/prometheus-postgres-exporter/Makefile
@@ -0,0 +1,28 @@
+PORTNAME=	prometheus-postgres-exporter
+DISTVERSIONPREFIX=	v
+DISTVERSION=	0.15.0
+CATEGORIES=	databases
+
+MAINTAINER=	lexi.freebsd@le-fay.org
+COMMENT=	PostgreSQL metric exporter for Prometheus
+WWW=		https://github.com/prometheus-community/postgres_exporter
+
+LICENSE=	APACHE20
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+USES=		go:modules
+USE_RC_SUBR=	postgres_exporter
+GO_MODULE=	github.com/prometheus-community/postgres_exporter
+GO_TARGET=	./cmd/postgres_exporter:${PREFIX}/bin/postgres_exporter
+
+SUB_FILES=	pkg-message
+
+PLIST_FILES=	bin/postgres_exporter \
+				etc/postgres_exporter.yml.sample
+
+post-install:
+	@${MKDIR} ${STAGEDIR}${PREFIX}/etc
+	${INSTALL_DATA} ${PATCHDIR}/postgres_exporter.yml.sample \
+		${STAGEDIR}${PREFIX}/etc/postgres_exporter.yml.sample
+
+.include <bsd.port.mk>
diff --git a/databases/prometheus-postgres-exporter/distinfo b/databases/prometheus-postgres-exporter/distinfo
new file mode 100644
index 000000000000..f0f8d8aeffb4
--- /dev/null
+++ b/databases/prometheus-postgres-exporter/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1708907285
+SHA256 (go/databases_prometheus-postgres-exporter/prometheus-postgres-exporter-v0.15.0/v0.15.0.mod) = 2eca3234e2449a0b04bf99c4761b5b62e6ddd6be2b9083b89837a57087fb0a59
+SIZE (go/databases_prometheus-postgres-exporter/prometheus-postgres-exporter-v0.15.0/v0.15.0.mod) = 1853
+SHA256 (go/databases_prometheus-postgres-exporter/prometheus-postgres-exporter-v0.15.0/v0.15.0.zip) = cbe281e1764b5df206eafd0ae5e5fee0b569afb3883b1502d2b1793694a53dd5
+SIZE (go/databases_prometheus-postgres-exporter/prometheus-postgres-exporter-v0.15.0/v0.15.0.zip) = 151785
diff --git a/databases/prometheus-postgres-exporter/files/pkg-message.in b/databases/prometheus-postgres-exporter/files/pkg-message.in
new file mode 100644
index 000000000000..8887b3fe3433
--- /dev/null
+++ b/databases/prometheus-postgres-exporter/files/pkg-message.in
@@ -0,0 +1,29 @@
+[
+{ type: install
+  message: <<EOM
+A sample configuration file has been installed in
+%%PREFIX%%/etc/postgres_exporter.yml.sample.
+
+To use postgres_exporter, copy this config file to "postgres_exporter.yml"
+and edit as needed, then enable and start the service:
+
+# service postgres_exporter enable
+# service postgres_exporter start
+
+For rc(8) options which can be used to configure the service, refer to
+%%PREFIX%%/etc/rc.d/postgres_exporter.
+
+For example, to log output to the 'local5' syslog facility instead of the
+default 'daemon':
+
+# sysrc postgres_exporter_syslog_output_facility=local5
+
+By default, the exporter runs as the 'nobody' user and listens on
+localhost:9187.  These defaults can be changed via rc(8).
+
+For documentation on the configuration file format and how to integrate the
+exporter into Prometheus, refer to the documentation at:
+https://github.com/prometheus-community/postgres_exporter
+EOM
+}
+]
diff --git a/databases/prometheus-postgres-exporter/files/postgres_exporter.in b/databases/prometheus-postgres-exporter/files/postgres_exporter.in
new file mode 100644
index 000000000000..e96e638fa152
--- /dev/null
+++ b/databases/prometheus-postgres-exporter/files/postgres_exporter.in
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# PROVIDE: postgres_exporter
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# postgres_exporter_enable (bool):          Set to NO by default.
+#               Set it to YES to enable postgres_exporter.
+# postgres_exporter_config_file (string):   Set the configuration file.
+#               Default is "%%PREFIX%%/etc/postgres_exporter.yml".
+# postgres_exporter_user (string):          Set user that postgres_exporter will run under
+#               Default is "nobody".
+# postgres_exporter_group (string):         Set group that postgres_exporter will run under
+#               Default is "nobody".
+# postgres_exporter_args (string):          Set extra arguments to pass to postgres_exporter
+#               Default is "".
+# postgres_exporter_listen_address (string):Set ip:port that postgres_exporter will listen on
+#               Default is "localhost:9187".
+# postgres_exporter_syslog_output_tag (str):      Set syslog tag.
+#               Default is "postgres_exporter". See daemon(8).
+# postgres_exporter_syslog_output_priority (str): Set syslog priority.
+#               Default is "notice". See daemon(8).
+# postgres_exporter_syslog_output_facility (str): Set syslog facility.
+#               Default is "daemon". See daemon(8).
+
+
+. /etc/rc.subr
+
+name=postgres_exporter
+rcvar=postgres_exporter_enable
+
+load_rc_config $name
+
+: ${postgres_exporter_enable:="NO"}
+: ${postgres_exporter_config_file:="%%PREFIX%%/etc/postgres_exporter.yml"}
+: ${postgres_exporter_user:="nobody"}
+: ${postgres_exporter_group:="nobody"}
+: ${postgres_exporter_args:=""}
+: ${postgres_exporter_listen_address:="localhost:9187"}
+: ${postgres_exporter_syslog_output_tag=${name}}
+: ${postgres_exporter_syslog_output_priority=notice}
+: ${postgres_exporter_syslog_output_facility=daemon}
+
+pidfile=/var/run/postgres_exporter.pid
+command="/usr/sbin/daemon"
+procname="%%PREFIX%%/bin/postgres_exporter"
+command_args="-f -p ${pidfile} -t ${name} \
+    -T ${postgres_exporter_syslog_output_tag} \
+    -s ${postgres_exporter_syslog_output_priority} \
+    -l ${postgres_exporter_syslog_output_facility} \
+    /usr/bin/env ${procname} \
+    --web.listen-address=${postgres_exporter_listen_address} \
+    --config.file=${postgres_exporter_config_file} \
+    ${postgres_exporter_args}"
+
+start_precmd=postgres_exporter_startprecmd
+
+postgres_exporter_startprecmd()
+{
+    if [ ! -e ${pidfile} ]; then
+        install \
+            -o ${postgres_exporter_user} \
+            -g ${postgres_exporter_group} \
+            /dev/null ${pidfile};
+    fi
+}
+
+load_rc_config $name
+run_rc_command "$1"
+
diff --git a/databases/prometheus-postgres-exporter/files/postgres_exporter.yml.sample b/databases/prometheus-postgres-exporter/files/postgres_exporter.yml.sample
new file mode 100644
index 000000000000..9bc8e9372c30
--- /dev/null
+++ b/databases/prometheus-postgres-exporter/files/postgres_exporter.yml.sample
@@ -0,0 +1,12 @@
+
+# use auth_modules to provide authentication data for connections:
+
+#auth_modules:
+#  my_module:
+#    type: userpass
+#    userpass:
+#      username: prometheus
+#      password: 'a-good-password'
+#    options:
+#      dbname: template1
+#      sslmode: verify-full
diff --git a/databases/prometheus-postgres-exporter/pkg-descr b/databases/prometheus-postgres-exporter/pkg-descr
new file mode 100644
index 000000000000..a5fff9418b69
--- /dev/null
+++ b/databases/prometheus-postgres-exporter/pkg-descr
@@ -0,0 +1,3 @@
+postgres_exporter is a Prometheus exporter for the PostgreSQL database. It can
+connect to multiple PostgreSQL databases as configured in Prometheus, and
+reports system-level metrics.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202405271605.44RG5OD2060426>