]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/postgresql/recipes/default.rb
Add alerts for planet dumps and replication feeds
[chef.git] / cookbooks / postgresql / recipes / default.rb
index 6a05f34e4fad6412a3b5e8f6c4ff75b23be5366e..47ec3e80bfffee64cc580f0b8e09747adc339fa6 100644 (file)
@@ -154,11 +154,11 @@ 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/collectors/postgres_queries.yml" do
+template "/etc/prometheus/exporters/postgres_queries.yml" do
   source "postgres_queries.yml.erb"
   owner "root"
   group "root"
@@ -168,7 +168,9 @@ end
 prometheus_exporter "postgres" do
   port 9187
   user "postgres"
-  options "--extend.query-path=/etc/prometheus/collectors/postgres_queries.yml"
-  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