servers/roles/collector/templates/prometheus-job.yml.j2
Timotej Lazar da3db8cc02 Add collector role
Sets up prometheus to pull metrics, with telegraf to process SNMP data.
2025-10-17 22:12:02 +02:00

20 lines
613 B
Django/Jinja

{% set devices = query("netbox.netbox.nb_lookup", "devices", api_filter="{{ item.nb_filter }}", raw_data=true)
| selectattr("primary_ip")
| map(attribute="name")
| map("extract", hostvars) -%}
scrape_configs:
- job_name: "{{ item.name }}"
relabel_configs:
- source_labels: [__address__]
regex: '([^.]+).*'
target_label: name
replacement: ${1}
static_configs:
- targets:
{% for address in devices
| selectattr("dns_name", "defined")
| map(attribute="dns_name")
| reject("none") | sort | unique %}
- "{{ address }}:9100"
{% endfor %}