Set node name as prometheus instance name

And DRY up the recipe so it's easy and expressive to add more
metrics/targets
This commit is contained in:
2026-07-05 12:41:31 +02:00
parent e29d90d3d0
commit 821b56e6ab
3 changed files with 27 additions and 17 deletions
@@ -14,11 +14,13 @@ scrape_configs:
<% end %>
metrics_path: "<%= job.fetch('metrics_path', '/metrics') %>"
static_configs:
- targets: <%= Array(job['targets']) %>
<% if job['labels'] %>
<% job['targets'].each do |t| %>
- targets:
- <%= t['target'] %>
labels:
<% job['labels'].each do |label, label_config| %>
<%= label %>: <%= label_config %>
instance: <%= t['instance'] %>
<% if t['env'] %>
env: <%= t['env'] %>
<% end %>
<% end %>
<% end %>