commit 87cdafc54647458de03bd428ef1cfcdff03bcf4b Author: Martina Ferrari Date: Mon Jan 20 13:25:39 2020 +0100 Import prometheus-postgres-exporter_0.8.0+ds-1.debian.tar.xz [dgit import tarball prometheus-postgres-exporter 0.8.0+ds-1 prometheus-postgres-exporter_0.8.0+ds-1.debian.tar.xz] diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..a6ec43b --- /dev/null +++ b/NEWS @@ -0,0 +1,37 @@ +prometheus-postgres-exporter (0.4.1+ds-2) unstable; urgency=medium + + The daemon now accepts command-line flags with two dashes, check + your /etc/default/prometheus-postgres-exporter to avoid errors. + + -- Martina Ferrari Thu, 14 Dec 2017 17:07:03 +0000 + +prometheus-postgres-exporter (0.2.0+ds-1) unstable; urgency=medium + + * Major change - use pg_settings to retrieve runtime variables. Adds >180 new + metrics and descriptions (big thanks to Matt Bostock for this work). + + Removes the following metrics: + + pg_runtime_variable_max_connections + pg_runtime_variable_max_files_per_process + pg_runtime_variable_max_function_args + pg_runtime_variable_max_identifier_length + pg_runtime_variable_max_index_keys + pg_runtime_variable_max_locks_per_transaction + pg_runtime_variable_max_pred_locks_per_transaction + pg_runtime_variable_max_prepared_transactions + pg_runtime_variable_max_standby_archive_delay_milliseconds + pg_runtime_variable_max_standby_streaming_delay_milliseconds + pg_runtime_variable_max_wal_senders + + They are replaced by equivalent names under `pg_settings` with the exception of + + pg_runtime_variable_max_standby_archive_delay_milliseconds + pg_runtime_variable_max_standby_streaming_delay_milliseconds + + which are replaced with + + pg_settings_max_standby_archive_delay_seconds + pg_settings_max_standby_streaming_delay_seconds + + -- Martina Ferrari Fri, 19 May 2017 21:43:00 +0000 diff --git a/README.Debian b/README.Debian new file mode 100644 index 0000000..2e3e271 --- /dev/null +++ b/README.Debian @@ -0,0 +1,46 @@ +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/default/prometheus-postgres-exporter: + + DATA_SOURCE_NAME='user=prometheus host=/run/postgresql dbname=postgres' + +And use psql (sudo -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; diff --git a/changelog b/changelog new file mode 100644 index 0000000..b1703a9 --- /dev/null +++ b/changelog @@ -0,0 +1,110 @@ +prometheus-postgres-exporter (0.8.0+ds-1) unstable; urgency=medium + + [ Daniel Swarbrick ] + * New upstream release. + * Add myself to uploaders. + * Bump minimum required version of golang-github-lib-pq to support + SCRAM-SHA-256 authentication. + * Update description (now supports Postgres 9.4 and up). + * lintian: fix rules-requires-root. + + [ Debian Janitor ] + * Set debhelper-compat version in Build-Depends. + * Set upstream metadata fields: Bug-Database, Bug-Submit. + + [ Martina Ferrari ] + * Update initscript. + * Update my name. + + -- Martina Ferrari Mon, 20 Jan 2020 12:25:39 +0000 + +prometheus-postgres-exporter (0.5.1+ds-2) unstable; urgency=medium + + * Name update. + * Add missing sphinxdoc dependency. + * Install sample queries.yaml file. Closes: #939507 + * Fix spelling mistake in source. + * Update Standards-Version and Compat level. Add needed Pre-Depends for + sysvinit. + + -- Martina Ferrari Mon, 28 Oct 2019 16:59:41 +0000 + +prometheus-postgres-exporter (0.5.1+ds-1) unstable; urgency=medium + + [ Sven Hoexter ] + * New upstream release. + + -- Martina Ferrari Fri, 02 Aug 2019 16:01:05 +0000 + +prometheus-postgres-exporter (0.4.7+ds-2) unstable; urgency=medium + + * Use correct namespace for version metadata and remove unused vars. + + -- Martina Ferrari Sun, 10 Feb 2019 18:58:09 +0000 + +prometheus-postgres-exporter (0.4.7+ds-1) unstable; urgency=medium + + * New upstream release. Closes: #920346. + * debian/gbp.conf: Update repo layout. + * Update Standards-Version with no changes. + * Add manpage and version metadata, + + -- Martina Ferrari Tue, 05 Feb 2019 04:51:10 +0000 + +prometheus-postgres-exporter (0.4.6+ds-2) unstable; urgency=medium + + * Update Standards-Version with no changes. + * Add missing --inherit flag to daemon; can't work without it! + + -- Martina Ferrari Mon, 08 Oct 2018 19:03:30 +0000 + +prometheus-postgres-exporter (0.4.6+ds-1) unstable; urgency=medium + + [ Alexandre Viau ] + * Point Vcs-* urls to salsa.debian.org. + + [ Martina Ferrari ] + * New upstream release. + * debian/rules: Install test files. + * Bump debhelper compat level to 11. + * debian/copyright: Document Files-Excluded. + * debian/control: Bump Standards-Version (no changes). + * debian/postinst: Do not change permissions recursively. + + -- Martina Ferrari Tue, 07 Aug 2018 16:07:06 +0000 + +prometheus-postgres-exporter (0.4.1+ds-2) unstable; urgency=medium + + * Update defaults for new cmdline flags format. + + -- Martina Ferrari Thu, 14 Dec 2017 17:08:11 +0000 + +prometheus-postgres-exporter (0.4.1+ds-1) unstable; urgency=medium + + * New upstream release. + * Add test fixtures. + * Packaging updates from cme; compat bump; make dep on daemon + conditional. + * Remove unused lintian overrides. + * Use automatic autopkgtests + * Use pkg-info.mk and XS-Go-Import-Path. + + -- Martina Ferrari Thu, 14 Dec 2017 16:59:24 +0000 + +prometheus-postgres-exporter (0.2.0+ds-2) unstable; urgency=medium + + * Add autopkgtest. + + -- Martina Ferrari Sun, 21 May 2017 00:07:32 +0200 + +prometheus-postgres-exporter (0.2.0+ds-1) unstable; urgency=medium + + * New upstream release. + + -- Martina Ferrari Fri, 19 May 2017 22:25:36 +0000 + +prometheus-postgres-exporter (0.1.1+ds-1) unstable; urgency=medium + + * Initial packaging. (Closes: #854014). + + -- Martina Ferrari Sat, 04 Feb 2017 16:50:34 +0000 diff --git a/control b/control new file mode 100644 index 0000000..a2335f5 --- /dev/null +++ b/control @@ -0,0 +1,35 @@ +Source: prometheus-postgres-exporter +Maintainer: Debian Go Packaging Team +Uploaders: Martina Ferrari , + Daniel Swarbrick , +Section: net +Testsuite: autopkgtest-pkg-go +Priority: optional +Build-Depends: debhelper-compat (= 12), + dh-golang, + golang-any, + golang-github-blang-semver-dev, + golang-github-lib-pq-dev (>= 1.2.0~), + golang-github-prometheus-client-golang-dev, + golang-github-prometheus-common-dev, + golang-gopkg-alecthomas-kingpin.v2-dev, + golang-gopkg-check.v1-dev, + golang-gopkg-yaml.v2-dev, +Standards-Version: 4.4.1 +Rules-Requires-Root: no +Vcs-Browser: https://salsa.debian.org/go-team/packages/prometheus-postgres-exporter +Vcs-Git: https://salsa.debian.org/go-team/packages/prometheus-postgres-exporter.git +Homepage: https://github.com/wrouesnel/postgres_exporter/ +XS-Go-Import-Path: github.com/wrouesnel/postgres_exporter + +Package: prometheus-postgres-exporter +Architecture: any +Pre-Depends: ${misc:Pre-Depends}, +Depends: daemon | systemd-sysv, + ${misc:Depends}, + ${shlibs:Depends}, + ${sphinxdoc:Depends}, +Built-Using: ${misc:Built-Using}, +Description: Prometheus exporter for PostgreSQL server metrics + Prometheus exporter for PostgreSQL server metrics, written in Go. + Supports Postgres versions 9.4 and up. diff --git a/copyright b/copyright new file mode 100644 index 0000000..9309e00 --- /dev/null +++ b/copyright @@ -0,0 +1,31 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: prometheus-postgres-exporter +Source: https://github.com/wrouesnel/postgres_exporter +Files-Excluded: + vendor/*/* + tools/vendor/*/* + tools/src + +Files: * +Copyright: 2015-2017 Will Rouesnel +License: Apache-2.0 + +Files: debian/* +Copyright: 2017 Martina Ferrari +License: Apache-2.0 + +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian systems, the full text of the Apache License version 2 can be found + in the file `/usr/share/common-licenses/Apache-2.0'. diff --git a/default b/default new file mode 100644 index 0000000..bcf10b0 --- /dev/null +++ b/default @@ -0,0 +1,18 @@ +# Connection string for the PostgreSQL database. You need to either connect as +# superuser, or create a user with enough rights, as described in +# /usr/share/doc/prometheus-postgres-exporter/README.Debian + +# DATA_SOURCE_NAME='postgresql://login:password@hostname:port/' +# DATA_SOURCE_NAME='user=prometheus host=/run/postgresql dbname=postgres' +DATA_SOURCE_NAME='' + +# Set the command-line arguments to pass to the server. +ARGS='' + +# Available flags: +# --web.listen-address=":9187" Address to listen on for web interface and telemetry. +# --web.telemetry-path="/metrics" +# Path under which to expose metrics. +# --extend.query-path="" Path to custom queries to run. +# --log.level="info" Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal] +# --log.format="logger:stderr" Set the log target and format. Example: "logger:syslog?appname=bob&local=7" or "logger:stdout?json=true" diff --git a/dirs b/dirs new file mode 100644 index 0000000..71cd52c --- /dev/null +++ b/dirs @@ -0,0 +1,3 @@ +usr/bin +var/lib/prometheus +var/log/prometheus diff --git a/docs b/docs new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/docs @@ -0,0 +1 @@ +README.md diff --git a/examples b/examples new file mode 100644 index 0000000..4509c36 --- /dev/null +++ b/examples @@ -0,0 +1 @@ +queries.yaml diff --git a/gbp.conf b/gbp.conf new file mode 100644 index 0000000..a559d1b --- /dev/null +++ b/gbp.conf @@ -0,0 +1,6 @@ +[DEFAULT] +debian-branch = debian/sid + +[buildpackage] +dist = DEP14 +upstream-tag = upstream/%(version)s diff --git a/gitlab-ci.yml b/gitlab-ci.yml new file mode 100644 index 0000000..5c8c31b --- /dev/null +++ b/gitlab-ci.yml @@ -0,0 +1,28 @@ + +# auto-generated, DO NOT MODIFY. +# The authoritative copy of this file lives at: +# https://salsa.debian.org/go-team/ci/blob/master/cmd/ci/gitlabciyml.go + +# TODO: publish under debian-go-team/ci +image: stapelberg/ci2 + +test_the_archive: + artifacts: + paths: + - before-applying-commit.json + - after-applying-commit.json + script: + # Create an overlay to discard writes to /srv/gopath/src after the build: + - "rm -rf /cache/overlay/{upper,work}" + - "mkdir -p /cache/overlay/{upper,work}" + - "mount -t overlay overlay -o lowerdir=/srv/gopath/src,upperdir=/cache/overlay/upper,workdir=/cache/overlay/work /srv/gopath/src" + - "export GOPATH=/srv/gopath" + - "export GOCACHE=/cache/go" + # Build the world as-is: + - "ci-build -exemptions=/var/lib/ci-build/exemptions.json > before-applying-commit.json" + # Copy this package into the overlay: + - "GBP_CONF_FILES=:debian/gbp.conf gbp buildpackage --git-no-pristine-tar --git-ignore-branch --git-ignore-new --git-export-dir=/tmp/export --git-no-overlay --git-tarball-dir=/nonexistant --git-cleaner=/bin/true --git-builder='dpkg-buildpackage -S -d --no-sign'" + - "pgt-gopath -dsc /tmp/export/*.dsc" + # Rebuild the world: + - "ci-build -exemptions=/var/lib/ci-build/exemptions.json > after-applying-commit.json" + - "ci-diff before-applying-commit.json after-applying-commit.json" diff --git a/init b/init new file mode 100644 index 0000000..1ebde49 --- /dev/null +++ b/init @@ -0,0 +1,70 @@ +#!/bin/sh +# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing. +if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then + set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script +fi +### BEGIN INIT INFO +# Provides: prometheus-postgres-exporter +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Prometheus exporter for machine metrics +# Description: Prometheus exporter for machine metrics, written in Go +# with pluggable metric collectors. +### END INIT INFO + +# Author: Martina Ferrari + +DESC="Prometheus exporter for PostgreSQL metrics" +DAEMON=/usr/bin/prometheus-postgres-exporter +NAME=prometheus-postgres-exporter +USER=prometheus +PIDFILE=/var/run/prometheus/prometheus-postgres-exporter.pid +LOGFILE=/var/log/prometheus/prometheus-postgres-exporter.log + +ARGS="" +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +HELPER=/usr/bin/daemon +HELPER_ARGS="--name=$NAME --output=$LOGFILE --pidfile=$PIDFILE --user=$USER + --inherit" + +do_start_prepare() +{ + mkdir -p `dirname $PIDFILE` + chown $USER: `dirname $LOGFILE` + chown $USER: `dirname $PIDFILE` + if test -z "$DATA_SOURCE_NAME"; then + log_failure_msg \ + "missing \$DATA_SOURCE_NAME -- please edit /etc/default/$NAME" + exit + fi +} + +do_start_cmd_override() +{ + # Return + # 0 if daemon has been started or already running + # 2 if daemon could not be started + $HELPER $HELPER_ARGS --running && return 0 + $HELPER $HELPER_ARGS -- $DAEMON $ARGS || return 2 + return 0 +} + +do_stop_cmd_override() +{ + # Return + # 0 if daemon has been stopped or already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + $HELPER $HELPER_ARGS --running || return 0 + $HELPER $HELPER_ARGS --stop || return 2 + # wait for the process to really terminate + for n in 1 2 3 4 5; do + sleep $n + $HELPER $HELPER_ARGS --running || break + done + $HELPER $HELPER_ARGS --running || return 0 + return 2 +} diff --git a/install b/install new file mode 100644 index 0000000..facc863 --- /dev/null +++ b/install @@ -0,0 +1 @@ +build/bin/prometheus-postgres-exporter usr/bin diff --git a/manpages b/manpages new file mode 100644 index 0000000..648718d --- /dev/null +++ b/manpages @@ -0,0 +1 @@ +build/prometheus-postgres-exporter.1 diff --git a/patches/01-Fix_spelling_errors.patch b/patches/01-Fix_spelling_errors.patch new file mode 100644 index 0000000..2a29e48 --- /dev/null +++ b/patches/01-Fix_spelling_errors.patch @@ -0,0 +1,21 @@ +Description: Fix spelling mistake in source. + +--- a/cmd/postgres_exporter/postgres_exporter.go ++++ b/cmd/postgres_exporter/postgres_exporter.go +@@ -987,14 +987,14 @@ + Namespace: namespace, + Subsystem: exporter, + Name: "last_scrape_duration_seconds", +- Help: "Duration of the last scrape of metrics from PostgresSQL.", ++ Help: "Duration of the last scrape of metrics from PostgreSQL.", + ConstLabels: e.constantLabels, + }) + e.totalScrapes = prometheus.NewCounter(prometheus.CounterOpts{ + Namespace: namespace, + Subsystem: exporter, + Name: "scrapes_total", +- Help: "Total number of times PostgresSQL was scraped for metrics.", ++ Help: "Total number of times PostgreSQL was scraped for metrics.", + ConstLabels: e.constantLabels, + }) + e.error = prometheus.NewGauge(prometheus.GaugeOpts{ diff --git a/patches/series b/patches/series new file mode 100644 index 0000000..ac211aa --- /dev/null +++ b/patches/series @@ -0,0 +1 @@ +01-Fix_spelling_errors.patch diff --git a/postinst b/postinst new file mode 100644 index 0000000..9055995 --- /dev/null +++ b/postinst @@ -0,0 +1,54 @@ +#!/bin/sh + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package +# +# quoting from the policy: +# Any necessary prompting should almost always be confined to the +# post-installation script, and should be protected with a conditional +# so that unnecessary prompting doesn't happen if a package's +# installation fails and the `postinst' is called with `abort-upgrade', +# `abort-remove' or `abort-deconfigure'. + +case "$1" in + configure) + # Add prometheus user + if ! getent passwd prometheus > /dev/null; then + adduser --quiet --system --home /var/lib/prometheus --no-create-home \ + --group --gecos "Prometheus daemon" prometheus || true + fi + + chown prometheus:prometheus /var/lib/prometheus || true + chown prometheus:prometheus /var/log/prometheus || true + chown prometheus:prometheus /etc/default/prometheus-postgres-exporter \ + || true + chmod 0640 /etc/default/prometheus-postgres-exporter || true + + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + : + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/postrm b/postrm new file mode 100644 index 0000000..6fc7eaf --- /dev/null +++ b/postrm @@ -0,0 +1,15 @@ +#!/bin/sh +# postrm script for prometheus-postgres-exporter +# Script executed after the package is removed. + +set -e + +case "$1" in + purge) + rm -rf /var/log/prometheus/prometheus-postgres-exporter.log \ + /var/run/prometheus/prometheus-postgres-exporter.pid + # We do NOT remove the system user. + ;; +esac + +#DEBHELPER# diff --git a/rules b/rules new file mode 100755 index 0000000..42700ce --- /dev/null +++ b/rules @@ -0,0 +1,32 @@ +#!/usr/bin/make -f +include /usr/share/dpkg/pkg-info.mk + +#export DH_VERBOSE=1 +export DH_GOLANG_INSTALL_EXTRA := cmd/postgres_exporter/tests/ + +BUILDDIR := $(CURDIR)/build + +BUILDTAGS := +BUILDFLAGS = -tags "$(BUILDTAGS)" -ldflags \ + " -X main.Version=$(DEB_VERSION_UPSTREAM)" + +%: + dh $@ --buildsystem=golang --with=golang \ + --builddirectory=$(BUILDDIR) + +BINNAME := $(DEB_SOURCE) +WHATIS := "$(BINNAME) \\- Prometheus exporter for PostgreSQL" + +override_dh_auto_build: + dh_auto_build -- $(BUILDFLAGS) + # Rename the binary to match the debian package. + cp -v $(BUILDDIR)/bin/postgres_exporter $(BUILDDIR)/bin/$(BINNAME) + build/bin/$(BINNAME) --help-man > build/$(BINNAME).1 + # Remove build user/build date/go version headers, which is ugly. + sed -i -e '/^ /d' build/$(BINNAME).1 + # Fix whatis entry. + sed -i '/^.SH "NAME"/,+1c.SH "NAME"\n'$(WHATIS) build/$(BINNAME).1 + # Remove default values as they create unwieldy long lines. + sed -i 's/\\fB--\(.*\)=".*"\\fR/\\fB--\1\\fR/' build/$(BINNAME).1 + +override_dh_auto_install: diff --git a/service b/service new file mode 100644 index 0000000..06f2bdd --- /dev/null +++ b/service @@ -0,0 +1,12 @@ +[Unit] +Description=Prometheus exporter for PostgreSQL +Documentation=https://github.com/wrouesnel/postgres_exporter + +[Service] +Restart=always +User=prometheus +EnvironmentFile=/etc/default/prometheus-postgres-exporter +ExecStart=/usr/bin/prometheus-postgres-exporter $ARGS + +[Install] +WantedBy=multi-user.target diff --git a/source/format b/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/upstream/metadata b/upstream/metadata new file mode 100644 index 0000000..0727623 --- /dev/null +++ b/upstream/metadata @@ -0,0 +1,2 @@ +Bug-Database: https://github.com/wrouesnel/postgres_exporter/issues +Bug-Submit: https://github.com/wrouesnel/postgres_exporter/issues/new diff --git a/watch b/watch new file mode 100644 index 0000000..a85a67a --- /dev/null +++ b/watch @@ -0,0 +1,5 @@ +version=3 + +opts="filenamemangle=s/(?:.*\/)?v?(\d[\d\.]*)\.tar\.gz/prometheus-postgres-exporter-$1.tar.gz/,dversionmangle=s/\+ds\d*$//" \ + https://github.com/wrouesnel/postgres_exporter/tags \ + (?:.*/)?v?(\d[\d\.]*)\.tar\.gz