]> git.openstreetmap.org Git - chef.git/commitdiff
Enable prometheus postgres exporter
authorTom Hughes <tom@compton.nu>
Sun, 4 Oct 2020 18:28:37 +0000 (19:28 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 4 Oct 2020 18:30:22 +0000 (19:30 +0100)
cookbooks/postgresql/metadata.rb
cookbooks/postgresql/recipes/default.rb

index 4233b15893b1455069bbc53e712119f2be49ffd3..a145daf0e1794c967b9f236f25cc213153bf422f 100644 (file)
@@ -9,3 +9,4 @@ supports          "ubuntu"
 depends           "apt"
 depends           "munin"
 depends           "ohai"
+depends           "prometheus"
index 4e5068712259a4366f4cdacd886649f0e6539f3d..b70d167140093e612afc541199bfcc1b398a0fae 100644 (file)
@@ -19,6 +19,7 @@
 
 include_recipe "apt"
 include_recipe "munin"
+include_recipe "prometheus"
 
 package "locales-all"
 package "postgresql-common"
@@ -152,3 +153,12 @@ clusters.each do |name, details|
     conf_variables :port => details[:port]
   end
 end
+
+ports = clusters.collect do |_, details|
+  "port=#{details[:port]}"
+end
+
+prometheus_exporter "postgres" do
+  port 9187
+  environment "DATA_SOURCE_NAME" => "user=postgres host=/run/postgresql #{ports.join(',')}"
+end