From ce136e365e7258d85a27d44eb2817f881d78d25f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 6 Oct 2020 20:34:05 +0100 Subject: [PATCH] Use a connection URI for postgres monitoring --- cookbooks/postgresql/recipes/default.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cookbooks/postgresql/recipes/default.rb b/cookbooks/postgresql/recipes/default.rb index 5dbc00c48..b192080fb 100644 --- a/cookbooks/postgresql/recipes/default.rb +++ b/cookbooks/postgresql/recipes/default.rb @@ -155,11 +155,7 @@ clusters.each do |name, details| end ports = clusters.collect do |_, details| - "port=#{details[:port]}" -end - -file "/etc/prometheus/collectors/postgres_queries.yml" do - action :delete + details[:port] end template "/etc/prometheus/exporters/postgres_queries.yml" do @@ -173,7 +169,8 @@ prometheus_exporter "postgres" do port 9187 user "postgres" options "--extend.query-path=/etc/prometheus/exporters/postgres_queries.yml" - environment "DATA_SOURCE_NAME" => "user=postgres host=/run/postgresql #{ports.join(',')}", + environment "DATA_SOURCE_URI" => "postgres@:#{ports.join(',:')}/postgres?host=/run/postgresql", + "PG_EXPORTER_AUTO_DISCOVER_DATABASES" => "true", "PG_EXPORTER_EXCLUDE_DATABASES" => "postgres,template0,template1" subscribes :restart, "template[/etc/prometheus/exporters/postgres_queries.yml]" end -- 2.43.2