Add vm_host label to prometheus targets

This commit is contained in:
2026-07-05 16:19:36 +02:00
parent c762dfe8c1
commit 0e9bcca72d
2 changed files with 4 additions and 0 deletions
@@ -79,6 +79,7 @@ jobs = node["kosmos_prometheus"]["jobs"].merge(
"targets" => search(:node, config["query"]).map do |n|
target = { "target" => "#{n['knife_zero']['host']}:#{config['port']}", "instance" => n.name }
target["env"] = n.chef_environment if n.chef_environment
target["vm_host"] = n["vm_host"] if n["vm_host"]
target
end.compact.sort_by { |t| t["instance"] },
}
@@ -36,6 +36,9 @@ scrape_configs:
<% if t['env'] %>
env: <%= t['env'] %>
<% end %>
<% if t['vm_host'] %>
vm_host: <%= t['vm_host'] %>
<% end %>
<% end %>
<% end %>