]> git.openstreetmap.org Git - chef.git/commitdiff
Attach extra labels to jobs
authorTom Hughes <tom@compton.nu>
Mon, 3 Jul 2023 23:51:58 +0000 (00:51 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 3 Jul 2023 23:51:58 +0000 (00:51 +0100)
cookbooks/prometheus/recipes/server.rb
cookbooks/prometheus/templates/default/prometheus.yml.erb

index ffe76117eff55d5b830e004d0a6d63e8549ca75c..07a96b912d0ded88f073def63669e66eea573b67 100644 (file)
@@ -136,6 +136,7 @@ search(:node, "recipes:prometheus\\:\\:default").sort_by(&:name).each do |client
       name = exporter[:name]
       address = exporter[:address]
       sni = exporter[:sni]
+      labels = Array(exporter[:labels])
       scrape_interval = exporter[:scrape_interval]
       scrape_timeout = exporter[:scrape_timeout]
       metric_relabel = exporter[:metric_relabel] || []
@@ -143,6 +144,7 @@ search(:node, "recipes:prometheus\\:\\:default").sort_by(&:name).each do |client
       name = key
       address = exporter
       sni = nil
+      labels = []
       scrape_interval = nil
       scrape_timeout = nil
       metric_relabel = []
@@ -153,6 +155,7 @@ search(:node, "recipes:prometheus\\:\\:default").sort_by(&:name).each do |client
       :address => address,
       :sni => sni,
       :instance => client.name.split(".").first,
+      :labels => labels,
       :scrape_interval => scrape_interval,
       :scrape_timeout => scrape_timeout,
       :metric_relabel => metric_relabel
index 922fa123b2b9c1fb51324acf70a83f3de7758f33..daa10a4959c2d2cf9964e1233b4658a8019755cc 100644 (file)
@@ -72,7 +72,7 @@ scrape_configs:
           - "<%= target[:address] %>"
         labels:
           instance: <%= target[:instance] %>
-<% Hash(target[:labels]).sort.each do |name, value| -%>
+<% target[:labels].sort.each do |name, value| -%>
           <%= name %>: <%= value %>
 <% end -%>
 <% end -%>