X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/aeaa46f3071de018b5c5e0f5678cb5b4082e3ddc..7eb3680b81fdf339e466d9279584805f17a54c0f:/cookbooks/postgresql/recipes/default.rb diff --git a/cookbooks/postgresql/recipes/default.rb b/cookbooks/postgresql/recipes/default.rb index 4e5068712..47ec3e80b 100644 --- a/cookbooks/postgresql/recipes/default.rb +++ b/cookbooks/postgresql/recipes/default.rb @@ -19,6 +19,7 @@ include_recipe "apt" include_recipe "munin" +include_recipe "prometheus" package "locales-all" package "postgresql-common" @@ -152,3 +153,24 @@ clusters.each do |name, details| conf_variables :port => details[:port] end end + +uris = clusters.collect do |_, details| + "postgres@:#{details[:port]}/postgres?host=/run/postgresql" +end + +template "/etc/prometheus/exporters/postgres_queries.yml" do + source "postgres_queries.yml.erb" + owner "root" + group "root" + mode "644" +end + +prometheus_exporter "postgres" do + port 9187 + user "postgres" + options "--extend.query-path=/etc/prometheus/exporters/postgres_queries.yml" + environment "DATA_SOURCE_URI" => uris.sort.uniq.first, + "PG_EXPORTER_AUTO_DISCOVER_DATABASES" => "true", + "PG_EXPORTER_EXCLUDE_DATABASES" => "postgres,template0,template1" + subscribes :restart, "template[/etc/prometheus/exporters/postgres_queries.yml]" +end