zulip/puppet/zulip_ops/manifests/prometheus/postgresql.pp

39 lines
1.4 KiB
ObjectPascal
Raw Normal View History

2023-03-30 19:50:28 +02:00
# @summary Prometheus monitoring of postgresql servers
#
class zulip_ops::prometheus::postgresql {
include zulip_ops::prometheus::base
include zulip::supervisor
$version = $zulip::common::versions['postgres_exporter']['version']
$dir = "/srv/zulip-postgres_exporter-${version}"
$bin = "${dir}/postgres_exporter"
zulip::external_dep { 'postgres_exporter':
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}",
}
exec { 'create prometheus postgres user':
command => '/usr/bin/createuser -g pg_monitor prometheus',
unless => '/usr/bin/psql -tAc "select usename from pg_user" | /bin/grep -xq prometheus',
user => 'postgres',
}
zulip_ops::firewall_allow { 'postgres_exporter': port => '9187' }
file { "${zulip::common::supervisor_conf_dir}/prometheus_postgres_exporter.conf":
ensure => file,
require => [
Exec['create prometheus postgres user'],
User[prometheus],
Package[supervisor],
Zulip::External_Dep['postgres_exporter'],
],
owner => 'root',
group => 'root',
mode => '0644',
content => template('zulip_ops/supervisor/conf.d/prometheus_postgres_exporter.conf.template.erb'),
notify => Service[supervisor],
}
}