X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/b4b80ec4ce3e502101f6dc4f1a8aba4fb6e69b6b..699e157e3d708f38064eea9072aa210fe5ccac30:/cookbooks/postgresql/recipes/default.rb diff --git a/cookbooks/postgresql/recipes/default.rb b/cookbooks/postgresql/recipes/default.rb index 0e29b2042..47ec3e80b 100644 --- a/cookbooks/postgresql/recipes/default.rb +++ b/cookbooks/postgresql/recipes/default.rb @@ -154,12 +154,23 @@ clusters.each do |name, details| end end -ports = clusters.collect do |_, details| - "port=#{details[:port]}" +uris = clusters.collect do |_, details| + "postgres@:#{details[:port]}/postgres?host=/run/postgresql" +end + +template "/etc/prometheus/exporters/postgres_queries.yml" do + source "postgres_queries.yml.erb" + owner "root" + group "root" + mode "644" end prometheus_exporter "postgres" do port 9187 user "postgres" - environment "DATA_SOURCE_NAME" => "user=postgres host=/run/postgresql #{ports.join(',')}" + options "--extend.query-path=/etc/prometheus/exporters/postgres_queries.yml" + 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