Skip to content

Commit ae25901

Browse files
alexmvfreshpex
authored andcommitted
postgres_exporter: Build from source for per-index stats.
This builds prometheus-community/postgres_exporter#843 to track per-index statistics.
1 parent a79704a commit ae25901

File tree

3 files changed

+47
-8
lines changed

3 files changed

+47
-8
lines changed

Diff for: puppet/zulip/manifests/common.pp

+6
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@
121121
},
122122
},
123123

124+
# https://github.com/prometheus-community/postgres_exporter/pull/843
125+
'postgres_exporter-src' => {
126+
'version' => '4881e566207b1675f8b2ceae9bcd71f61800ccd1',
127+
'sha256' => '1b0aaf32e3834f02e5448fb21c0de114a4e42cc0937300e307899efb8438bf16',
128+
},
129+
124130
# https://github.com/ncabatoff/process-exporter/releases
125131
'process_exporter' => {
126132
'version' => '0.7.10',

Diff for: puppet/zulip_ops/manifests/prometheus/postgresql.pp

+40-7
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,48 @@
33
class zulip_ops::prometheus::postgresql {
44
include zulip_ops::prometheus::base
55
include zulip::supervisor
6+
include zulip::golang
67

7-
$version = $zulip::common::versions['postgres_exporter']['version']
8-
$dir = "/srv/zulip-postgres_exporter-${version}"
9-
$bin = "${dir}/postgres_exporter"
8+
$version = $zulip::common::versions['postgres_exporter-src']['version']
9+
$dir = "/srv/zulip-postgres_exporter-src-${version}"
10+
$bin = "/usr/local/bin/postgres_exporter-${version}-go-${zulip::golang::version}"
1011

11-
zulip::external_dep { 'postgres_exporter':
12+
# Binary builds: https://github.com/prometheus-community/postgres_exporter/releases/download/v${version}/postgres_exporter-${version}.linux-${zulip::common::goarch}.tar.gz
13+
14+
zulip::external_dep { 'postgres_exporter-src':
1215
version => $version,
13-
url => "https://github.com/prometheus-community/postgres_exporter/releases/download/v${version}/postgres_exporter-${version}.linux-${zulip::common::goarch}.tar.gz",
14-
tarball_prefix => "postgres_exporter-${version}.linux-${zulip::common::goarch}",
16+
url => "https://github.com/Sticksman/postgres_exporter/archive/${version}.tar.gz",
17+
tarball_prefix => "postgres_exporter-${version}",
18+
}
19+
20+
exec { 'compile postgres_exporter':
21+
command => "make build && cp ./postgres_exporter ${bin}",
22+
cwd => $dir,
23+
# GOCACHE is required; nothing is written to GOPATH, but it is required to be set
24+
environment => ['GOCACHE=/tmp/gocache', 'GOPATH=/root/go'],
25+
path => [
26+
"${zulip::golang::dir}/bin",
27+
'/usr/local/bin',
28+
'/usr/bin',
29+
'/bin',
30+
],
31+
creates => $bin,
32+
require => [
33+
Zulip::External_Dep['golang'],
34+
Zulip::External_Dep['postgres_exporter-src'],
35+
]
36+
}
37+
# This resource exists purely so it doesn't get tidied; it is
38+
# created by the 'compile postgres_exporter' step.
39+
file { $bin:
40+
ensure => file,
41+
require => Exec['compile postgres_exporter'],
42+
}
43+
tidy { '/usr/local/bin/postgres_exporter-*':
44+
path => '/usr/local/bin',
45+
recurse => 1,
46+
matches => 'postgres_exporter-*',
47+
require => Exec['compile postgres_exporter'],
1548
}
1649

1750
exec { 'create prometheus postgres user':
@@ -27,7 +60,7 @@
2760
Exec['create prometheus postgres user'],
2861
User[prometheus],
2962
Package[supervisor],
30-
Zulip::External_Dep['postgres_exporter'],
63+
File[$bin],
3164
],
3265
owner => 'root',
3366
group => 'root',

Diff for: puppet/zulip_ops/templates/supervisor/conf.d/prometheus_postgres_exporter.conf.template.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[program:prometheus_postgres_exporter]
2-
command=<%= @bin %>
2+
command=<%= @bin %> --collector.stat_user_indexes
33
environment=DATA_SOURCE_NAME="postgresql://prometheus@:5432/zulip?host=/var/run/postgresql"
44
priority=10
55
autostart=true

0 commit comments

Comments
 (0)