]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/postgresql/recipes/default.rb
Restart postgres exporter when the configuration changes
[chef.git] / cookbooks / postgresql / recipes / default.rb
index 6a05f34e4fad6412a3b5e8f6c4ff75b23be5366e..5dbc00c48f781ba608e9e344d866f7b72649a54c 100644 (file)
@@ -158,7 +158,11 @@ ports = clusters.collect do |_, details|
   "port=#{details[:port]}"
 end
 
-template "/etc/prometheus/collectors/postgres_queries.yml" do
+file "/etc/prometheus/collectors/postgres_queries.yml" do
+  action :delete
+end
+
+template "/etc/prometheus/exporters/postgres_queries.yml" do
   source "postgres_queries.yml.erb"
   owner "root"
   group "root"
@@ -168,7 +172,8 @@ end
 prometheus_exporter "postgres" do
   port 9187
   user "postgres"
-  options "--extend.query-path=/etc/prometheus/collectors/postgres_queries.yml"
+  options "--extend.query-path=/etc/prometheus/exporters/postgres_queries.yml"
   environment "DATA_SOURCE_NAME" => "user=postgres host=/run/postgresql #{ports.join(',')}",
               "PG_EXPORTER_EXCLUDE_DATABASES" => "postgres,template0,template1"
+  subscribes :restart, "template[/etc/prometheus/exporters/postgres_queries.yml]"
 end