]> git.openstreetmap.org Git - chef.git/commitdiff
Use a connection URI for postgres monitoring
authorTom Hughes <tom@compton.nu>
Tue, 6 Oct 2020 19:34:05 +0000 (20:34 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 6 Oct 2020 19:37:11 +0000 (20:37 +0100)
cookbooks/postgresql/recipes/default.rb

index 5dbc00c48f781ba608e9e344d866f7b72649a54c..b192080fb00a7e5f3a3806bb00540ca65ed5e093 100644 (file)
@@ -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