Skip to content

Commit d3175b1

Browse files
committed
Make postgres exporter connect as the prometheus user
1 parent 23961a3 commit d3175b1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cookbooks/postgresql/recipes/default.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# limitations under the License.
1818
#
1919

20+
require "uri"
21+
2022
include_recipe "apt::postgresql"
2123
include_recipe "munin"
2224
include_recipe "prometheus"
@@ -131,7 +133,6 @@
131133
labels "cluster" => name
132134
scrape_interval "1m"
133135
scrape_timeout "1m"
134-
user "postgres"
135136
options %w[
136137
--collector.database_wraparound
137138
--collector.long_running_transactions
@@ -140,9 +141,8 @@
140141
--collector.stat_wal_receiver
141142
--collector.statio_user_indexes
142143
]
143-
environment "DATA_SOURCE_NAME" => "postgres:///#{prometheus_database}?host=/run/postgresql&port=#{details[:port]}"
144+
environment "DATA_SOURCE_NAME" => "postgres:///#{prometheus_database}?host=/run/postgresql&port=#{details[:port]}&user=prometheus&password=#{URI.encode_uri_component(passwords['prometheus'])}"
144145
restrict_address_families "AF_UNIX"
145-
remove_ipc false
146146
subscribes :restart, "template[/etc/prometheus/exporters/postgres_queries.yml]"
147147
end
148148

0 commit comments

Comments
 (0)