servers/roles/collector/templates/prometheus-job.yml.j2
Timotej Lazar f3eec5fcbf collector: support custom poll intervals
Also simplify config context schema for SNMP since we only use a single
instance.
2025-11-04 15:23:15 +01:00

24 lines
743 B
Django/Jinja

{% set devices = query("netbox.netbox.nb_lookup", "devices", api_filter="{{ item.hosts }}", raw_data=true)
| selectattr("primary_ip")
| map(attribute="name")
| map("extract", hostvars) -%}
scrape_configs:
- job_name: "{{ item.name }}"
{% if item.interval is defined %}
scrape_interval: {{ item.interval }}s
scrape_timeout: {{ item.interval // 5 }}s
{% endif %}
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 %}