Add collector role

Sets up prometheus to pull metrics, with telegraf to process SNMP data.
This commit is contained in:
Timotej Lazar 2025-10-17 22:00:42 +02:00
parent 6600a6fa36
commit da3db8cc02
11 changed files with 228 additions and 0 deletions

View file

@ -0,0 +1,20 @@
{% 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 %}