From a07b42ee411f8952561cf6d3b52caa3067d6b281 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 15 Oct 2023 18:42:31 +0100 Subject: [PATCH] Make postgres exporter connect as the prometheus user --- cookbooks/postgresql/recipes/default.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cookbooks/postgresql/recipes/default.rb b/cookbooks/postgresql/recipes/default.rb index 6d966cd33..d2c94d1ed 100644 --- a/cookbooks/postgresql/recipes/default.rb +++ b/cookbooks/postgresql/recipes/default.rb @@ -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 -- 2.39.5