postgres_exporter: Build from source for per-index stats.

This builds prometheus-community/postgres_exporter#843 to track
per-index statistics.
This commit is contained in:
Alex Vandiver
2023-09-11 17:29:27 +00:00
committed by Tim Abbott
parent 5f74b9051e
commit 0c88cfca63
3 changed files with 47 additions and 8 deletions

View File

@@ -121,6 +121,12 @@ class zulip::common {
},
},
# https://github.com/prometheus-community/postgres_exporter/pull/843
'postgres_exporter-src' => {
'version' => '4881e566207b1675f8b2ceae9bcd71f61800ccd1',
'sha256' => '1b0aaf32e3834f02e5448fb21c0de114a4e42cc0937300e307899efb8438bf16',
},
# https://github.com/ncabatoff/process-exporter/releases
'process_exporter' => {
'version' => '0.7.10',

View File

@@ -3,15 +3,48 @@
class zulip_ops::prometheus::postgresql {
include zulip_ops::prometheus::base
include zulip::supervisor
include zulip::golang
$version = $zulip::common::versions['postgres_exporter']['version']
$dir = "/srv/zulip-postgres_exporter-${version}"
$bin = "${dir}/postgres_exporter"
$version = $zulip::common::versions['postgres_exporter-src']['version']
$dir = "/srv/zulip-postgres_exporter-src-${version}"
$bin = "/usr/local/bin/postgres_exporter-${version}-go-${zulip::golang::version}"
zulip::external_dep { 'postgres_exporter':
# Binary builds: https://github.com/prometheus-community/postgres_exporter/releases/download/v${version}/postgres_exporter-${version}.linux-${zulip::common::goarch}.tar.gz
zulip::external_dep { 'postgres_exporter-src':
version => $version,
url => "https://github.com/prometheus-community/postgres_exporter/releases/download/v${version}/postgres_exporter-${version}.linux-${zulip::common::goarch}.tar.gz",
tarball_prefix => "postgres_exporter-${version}.linux-${zulip::common::goarch}",
url => "https://github.com/Sticksman/postgres_exporter/archive/${version}.tar.gz",
tarball_prefix => "postgres_exporter-${version}",
}
exec { 'compile postgres_exporter':
command => "make build && cp ./postgres_exporter ${bin}",
cwd => $dir,
# GOCACHE is required; nothing is written to GOPATH, but it is required to be set
environment => ['GOCACHE=/tmp/gocache', 'GOPATH=/root/go'],
path => [
"${zulip::golang::dir}/bin",
'/usr/local/bin',
'/usr/bin',
'/bin',
],
creates => $bin,
require => [
Zulip::External_Dep['golang'],
Zulip::External_Dep['postgres_exporter-src'],
]
}
# This resource exists purely so it doesn't get tidied; it is
# created by the 'compile postgres_exporter' step.
file { $bin:
ensure => file,
require => Exec['compile postgres_exporter'],
}
tidy { '/usr/local/bin/postgres_exporter-*':
path => '/usr/local/bin',
recurse => 1,
matches => 'postgres_exporter-*',
require => Exec['compile postgres_exporter'],
}
exec { 'create prometheus postgres user':
@@ -27,7 +60,7 @@ class zulip_ops::prometheus::postgresql {
Exec['create prometheus postgres user'],
User[prometheus],
Package[supervisor],
Zulip::External_Dep['postgres_exporter'],
File[$bin],
],
owner => 'root',
group => 'root',

View File

@@ -1,5 +1,5 @@
[program:prometheus_postgres_exporter]
command=<%= @bin %>
command=<%= @bin %> --collector.stat_user_indexes
environment=DATA_SOURCE_NAME="postgresql://prometheus@:5432/zulip?host=/var/run/postgresql"
priority=10
autostart=true