From: Tom Hughes Date: Sun, 4 Oct 2020 18:28:37 +0000 (+0100) Subject: Enable prometheus postgres exporter X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/65902c2f5a35a64a2159a4a9bb19c39a5f5bd097 Enable prometheus postgres exporter --- diff --git a/cookbooks/postgresql/metadata.rb b/cookbooks/postgresql/metadata.rb index 4233b1589..a145daf0e 100644 --- a/cookbooks/postgresql/metadata.rb +++ b/cookbooks/postgresql/metadata.rb @@ -9,3 +9,4 @@ supports "ubuntu" depends "apt" depends "munin" depends "ohai" +depends "prometheus" diff --git a/cookbooks/postgresql/recipes/default.rb b/cookbooks/postgresql/recipes/default.rb index 4e5068712..b70d16714 100644 --- a/cookbooks/postgresql/recipes/default.rb +++ b/cookbooks/postgresql/recipes/default.rb @@ -19,6 +19,7 @@ include_recipe "apt" include_recipe "munin" +include_recipe "prometheus" package "locales-all" package "postgresql-common" @@ -152,3 +153,12 @@ clusters.each do |name, details| conf_variables :port => details[:port] end end + +ports = clusters.collect do |_, details| + "port=#{details[:port]}" +end + +prometheus_exporter "postgres" do + port 9187 + environment "DATA_SOURCE_NAME" => "user=postgres host=/run/postgresql #{ports.join(',')}" +end