From f111e5e0fd74ad8fb84147ea97fdbaabc75e68aa Mon Sep 17 00:00:00 2001 From: Richard Grainger Date: Fri, 29 May 2020 13:24:36 +0100 Subject: [PATCH] Add pgbouncer_exporter parameter --- REFERENCE.md | 8 ++++++++ manifests/init.pp | 2 ++ manifests/omnibus_config.pp | 2 +- spec/classes/init_spec.rb | 12 ++++++++++++ templates/gitlab.rb.erb | 9 +++++++++ 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/REFERENCE.md b/REFERENCE.md index 78c18991..7779b098 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -393,6 +393,14 @@ Hash of 'postgres_exporter' config parameters. Default value: `undef` +##### `pgbouncer_exporter` + +Data type: `Optional[Hash]` + +Hash of 'pgbouncer_exporter' config parameters. + +Default value: `undef` + ##### `gitlab_monitor` Data type: `Optional[Hash]` diff --git a/manifests/init.pp b/manifests/init.pp index 80b07d9c..7a2d0f80 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -45,6 +45,7 @@ # @param node_exporter Hash of 'node_exporter' config parameters. # @param redis_exporter Hash of 'redis_exporter' config parameters. # @param postgres_exporter Hash of 'postgres_exporter' config parameters. +# @param pgbouncer_exporter Hash of 'pgbouncer_exporter' config parameters. # @param gitlab_monitor Deprecated if using Gitlab > 12.3 and < 13.0, unsupported by gitlab omnibus using Gitlab 13+. Hash of 'gitlab_monitor' config parameters. # @param gitlab_exporter Hash of 'gitlab_exporter' config parameters. # @param pages_external_url External URL of Gitlab Pages. @@ -144,6 +145,7 @@ Enum['absent', 'present'] $pgpass_file_ensure = 'absent', Stdlib::Absolutepath $pgpass_file_location = '/home/gitlab-consul/.pgpass', Optional[Hash] $postgres_exporter = undef, + Optional[Hash] $pgbouncer_exporter = undef, Optional[Hash] $gitlab_monitor = undef, Optional[Hash] $gitlab_exporter = undef, Optional[String] $package_name = undef, diff --git a/manifests/omnibus_config.pp b/manifests/omnibus_config.pp index b778af72..8663cf87 100644 --- a/manifests/omnibus_config.pp +++ b/manifests/omnibus_config.pp @@ -1,4 +1,3 @@ -# @summary This class is used to configure the gitlab omnibus package on a node # # @param config_manage Should Puppet manage the config? # @param config_file Path of the Gitlab Omnibus config file. @@ -40,6 +39,7 @@ $node_exporter = $gitlab::node_exporter $redis_exporter = $gitlab::redis_exporter $postgres_exporter = $gitlab::postgres_exporter + $pgbouncer_exporter = $gitlab::pgbouncer_exporter $gitlab_monitor = $gitlab::gitlab_monitor $gitlab_exporter = $gitlab::gitlab_exporter $pages_external_url = $gitlab::pages_external_url diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 44b1bfe4..0439cbb5 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -420,6 +420,18 @@ with_content(%r{^\s*puma\['worker_timeout'\] = 60$}) } end + describe 'pgbouncer_exporter' do + let(:params) do + { pgbouncer_exporter: { + 'enable' => true + } } + end + + it { + is_expected.to contain_file('/etc/gitlab/gitlab.rb'). \ + with_content(%r{^\s*pgbouncer_exporter\['enable'\] = true$}) + } + end end end end diff --git a/templates/gitlab.rb.erb b/templates/gitlab.rb.erb index daddd70f..e6111b12 100644 --- a/templates/gitlab.rb.erb +++ b/templates/gitlab.rb.erb @@ -344,6 +344,15 @@ redis_exporter['<%= k -%>'] = <%= decorate(@redis_exporter[k]) %> <%- @postgres_exporter.keys.sort.each do |k| -%> postgres_exporter['<%= k -%>'] = <%= decorate(@postgres_exporter[k]) %> <%- end end -%> +<%- if @pgbouncer_exporter -%> + +################################################################################ +## Prometheus PgBouncer exporter (EE only) +##! Docs: https://docs.gitlab.com/ee/administration/monitoring/prometheus/pgbouncer_exporter.html + +<%- @pgbouncer_exporter.keys.sort.each do |k| -%> +pgbouncer_exporter['<%= k -%>'] = <%= decorate(@pgbouncer_exporter[k]) %> +<%- end end -%> <%- if @alertmanager -%> ################################################################################