]> git.openstreetmap.org Git - chef.git/commitdiff
Configure prometheus scraping for discourse servers
authorTom Hughes <tom@compton.nu>
Sun, 13 Mar 2022 22:51:34 +0000 (22:51 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 13 Mar 2022 22:51:34 +0000 (22:51 +0000)
cookbooks/community/recipes/default.rb
cookbooks/prometheus/recipes/server.rb
cookbooks/prometheus/templates/default/prometheus.yml.erb

index 5178f1617505d08483b91ef916eef4d7c65a0e34..003e69f1e8e4b48931a0ab4efe191987ed207b55 100644 (file)
@@ -112,3 +112,9 @@ template "/etc/cron.daily/community-backup" do
   group "root"
   mode "750"
 end
+
+node.default[:prometheus][:exporters][443] = {
+  :name => "community",
+  :address => "#{node[:prometheus][:address]}:443",
+  :sni => "community.openstreetmap.org"
+}
index 0b6e2a0d2d13a6dfc7a3ef11aa255b5c510e966a..6214f1858e7d0d282054a232c958d038fb08f6a5 100644 (file)
@@ -229,16 +229,19 @@ search(:node, "recipes:prometheus\\:\\:default").sort_by(&:name).each do |client
     if exporter.is_a?(Hash)
       name = exporter[:name]
       address = exporter[:address]
+      sni = exporter[:sni]
       metric_relabel = exporter[:metric_relabel] || []
     else
       name = key
       address = exporter
+      sni = nil
       metric_relabel = []
     end
 
     jobs[name] ||= []
     jobs[name] << {
       :address => address,
+      :sni => sni,
       :instance => client.name.split(".").first,
       :metric_relabel => metric_relabel
     }
index d5a8debaf5f4eff2f2f1a56ea89c5d7ec2d0579a..9b24a4d459e5b1b69b51ea9cb0d16747749f9067 100644 (file)
@@ -57,6 +57,13 @@ scrape_configs:
         replacement: 127.0.0.1:9219
 <% @jobs.sort.each do |name, targets| -%>
   - job_name: <%= name %>
+<% if targets.first[:sni] -%>
+    tls_config:
+      server_name: <%= targets.first[:sni] %>
+    relabel_configs:
+      - target_label: __scheme__
+        replacement: https
+<% end -%>
     static_configs:
 <% targets.each do |target| -%>
       - targets: