]> git.openstreetmap.org Git - chef.git/commitdiff
Make postgres exporter connect as the prometheus user
authorTom Hughes <tom@compton.nu>
Sun, 15 Oct 2023 17:42:31 +0000 (18:42 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 15 Oct 2023 17:47:42 +0000 (18:47 +0100)
cookbooks/postgresql/recipes/default.rb

index 6d966cd33838f42df91e1e28feefe5d104bbf610..d2c94d1ed5dae55bcdbda2a9c2bac0e14092c874 100644 (file)
@@ -17,6 +17,8 @@
 # limitations under the License.
 #
 
+require "uri"
+
 include_recipe "apt::postgresql"
 include_recipe "munin"
 include_recipe "prometheus"
@@ -131,7 +133,6 @@ clusters.each do |name, details|
     labels "cluster" => name
     scrape_interval "1m"
     scrape_timeout "1m"
-    user "postgres"
     options %w[
       --collector.database_wraparound
       --collector.long_running_transactions
@@ -140,9 +141,8 @@ clusters.each do |name, details|
       --collector.stat_wal_receiver
       --collector.statio_user_indexes
     ]
-    environment "DATA_SOURCE_NAME" => "postgres:///#{prometheus_database}?host=/run/postgresql&port=#{details[:port]}"
+    environment "DATA_SOURCE_NAME" => "postgres:///#{prometheus_database}?host=/run/postgresql&port=#{details[:port]}&user=prometheus&password=#{URI.encode_www_form_component(passwords['prometheus'])}"
     restrict_address_families "AF_UNIX"
-    remove_ipc false
     subscribes :restart, "template[/etc/prometheus/exporters/postgres_queries.yml]"
   end