From 1bd5723cd238c45c3c84322c5f2d7fdf97a56f42 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 18 Mar 2022 15:46:29 -0400 Subject: [PATCH] puppet: Add a prometheus monitor for tornado processes. --- puppet/zulip/manifests/common.pp | 9 +++++ .../files/tornado_process_exporter.yaml | 6 +++ .../manifests/app_frontend_monitoring.pp | 1 + .../zulip_ops/manifests/prometheus/tornado.pp | 38 +++++++++++++++++++ ...metheus_tornado_exporter.conf.template.erb | 8 ++++ 5 files changed, 62 insertions(+) create mode 100644 puppet/zulip_ops/files/tornado_process_exporter.yaml create mode 100644 puppet/zulip_ops/manifests/prometheus/tornado.pp create mode 100644 puppet/zulip_ops/templates/supervisor/conf.d/prometheus_tornado_exporter.conf.template.erb diff --git a/puppet/zulip/manifests/common.pp b/puppet/zulip/manifests/common.pp index a34ae8a7a1..fa254baee1 100644 --- a/puppet/zulip/manifests/common.pp +++ b/puppet/zulip/manifests/common.pp @@ -96,6 +96,15 @@ class zulip::common { }, }, + # https://github.com/ncabatoff/process-exporter/releases + 'process_exporter' => { + 'version' => '0.7.10', + 'sha256' => { + 'amd64' => '52503649649c0be00e74e8347c504574582b95ad428ff13172d658e82b3da1b5', + 'aarch64' => 'b377e673558bd0d51f5f771c2b3b3be44b60fcac0689709f47d8c7ca8136f6f5', + } + }, + # https://prometheus.io/download/#prometheus 'prometheus' => { 'version' => '2.34.0', diff --git a/puppet/zulip_ops/files/tornado_process_exporter.yaml b/puppet/zulip_ops/files/tornado_process_exporter.yaml new file mode 100644 index 0000000000..f6f881a83e --- /dev/null +++ b/puppet/zulip_ops/files/tornado_process_exporter.yaml @@ -0,0 +1,6 @@ +process_names: + - name: "tornado-{{.Matches.Port}}" + comm: + - python3 + cmdline: + - runtornado\s+127\.0\.0\.1:(?P\S+) diff --git a/puppet/zulip_ops/manifests/app_frontend_monitoring.pp b/puppet/zulip_ops/manifests/app_frontend_monitoring.pp index 3a99af152a..e7879dac14 100644 --- a/puppet/zulip_ops/manifests/app_frontend_monitoring.pp +++ b/puppet/zulip_ops/manifests/app_frontend_monitoring.pp @@ -3,6 +3,7 @@ class zulip_ops::app_frontend_monitoring { include zulip_ops::prometheus::rabbitmq include zulip_ops::prometheus::uwsgi + include zulip_ops::prometheus::tornado zulip_ops::firewall_allow { 'grok_exporter': port => '9144' } include zulip_ops::munin_node $munin_plugins = [ diff --git a/puppet/zulip_ops/manifests/prometheus/tornado.pp b/puppet/zulip_ops/manifests/prometheus/tornado.pp new file mode 100644 index 0000000000..97fbbc7806 --- /dev/null +++ b/puppet/zulip_ops/manifests/prometheus/tornado.pp @@ -0,0 +1,38 @@ +# @summary Prometheus monitoring of tornado processes +# +class zulip_ops::prometheus::tornado { + $version = $zulip::common::versions['process_exporter']['version'] + $dir = "/srv/zulip-process_exporter-${version}" + $bin = "${dir}/process-exporter" + $conf = '/etc/zulip/tornado_process_exporter.yaml' + + zulip::external_dep { 'process_exporter': + version => $version, + url => "https://github.com/ncabatoff/process-exporter/releases/download/v${version}/process-exporter-${version}.linux-${zulip::common::goarch}.tar.gz", + tarball_prefix => "process-exporter-${version}.linux-${zulip::common::goarch}", + } + + zulip_ops::firewall_allow { 'tornado_exporter': port => '9256' } + file { $conf: + ensure => file, + require => User[zulip], + owner => 'zulip', + group => 'zulip', + mode => '0644', + source => 'puppet:///modules/zulip_ops/tornado_process_exporter.yaml', + } + file { "${zulip::common::supervisor_conf_dir}/prometheus_tornado_exporter.conf": + ensure => file, + require => [ + User[zulip], + Package[supervisor], + Zulip::External_Dep['process_exporter'], + File[$conf], + ], + owner => 'root', + group => 'root', + mode => '0644', + content => template('zulip_ops/supervisor/conf.d/prometheus_tornado_exporter.conf.template.erb'), + notify => Service[supervisor], + } +} diff --git a/puppet/zulip_ops/templates/supervisor/conf.d/prometheus_tornado_exporter.conf.template.erb b/puppet/zulip_ops/templates/supervisor/conf.d/prometheus_tornado_exporter.conf.template.erb new file mode 100644 index 0000000000..00cce99203 --- /dev/null +++ b/puppet/zulip_ops/templates/supervisor/conf.d/prometheus_tornado_exporter.conf.template.erb @@ -0,0 +1,8 @@ +[program:prometheus_tornado_exporter] +command=<%= @bin %> -config.path <%= @conf %> +priority=10 +autostart=true +autorestart=true +user=zulip +redirect_stderr=true +stdout_logfile=/var/log/zulip/tornado_exporter.log