X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/5f87e80390086757b4dbbf810e4417225751d7f9..06ab8b35ae718f27206f7244f944308f6f52b540:/cookbooks/postgresql/recipes/default.rb?ds=sidebyside diff --git a/cookbooks/postgresql/recipes/default.rb b/cookbooks/postgresql/recipes/default.rb index 5dbc00c48..47ec3e80b 100644 --- a/cookbooks/postgresql/recipes/default.rb +++ b/cookbooks/postgresql/recipes/default.rb @@ -154,12 +154,8 @@ clusters.each do |name, details| end end -ports = clusters.collect do |_, details| - "port=#{details[:port]}" -end - -file "/etc/prometheus/collectors/postgres_queries.yml" do - action :delete +uris = clusters.collect do |_, details| + "postgres@:#{details[:port]}/postgres?host=/run/postgresql" 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" => uris.sort.uniq.first, + "PG_EXPORTER_AUTO_DISCOVER_DATABASES" => "true", "PG_EXPORTER_EXCLUDE_DATABASES" => "postgres,template0,template1" subscribes :restart, "template[/etc/prometheus/exporters/postgres_queries.yml]" end