r/scrape-collectd: collectd scrape targets config

The *scrape-collectd* role generates the
`/etc/prometheus/scrape-collectd.yml` file.  This file can be read by
Prometheus/Victoria Metrics/vmagent to identify the hosts running
*collectd* with the *write_prometheus* plugin, using the
`files_sd_configs` scrape configuration option.

All hosts in the *collectd-prometheus* group are listed as scrape
targets.
btop
Dustin 2022-08-11 21:39:50 -05:00
parent 4ddbc9f256
commit 993e29c0fe
3 changed files with 14 additions and 0 deletions

View File

@ -14,3 +14,7 @@
- import_playbook: victoria-metrics.yml - import_playbook: victoria-metrics.yml
- import_playbook: alertmanager.yml - import_playbook: alertmanager.yml
- import_playbook: grafana.yml - import_playbook: grafana.yml
- hosts: metricspi
roles:
- scrape-collectd

View File

@ -0,0 +1,8 @@
- name: ensure scrape hosts file is populated
copy:
dest: /etc/prometheus/scrape-collectd.yml
content: |+
{{ scrape_collectd_config | to_nice_yaml }}
mode: u=rw,go=r
owner: root
group: root

View File

@ -0,0 +1,2 @@
scrape_collectd_config:
- targets: '{{ groups["collectd-prometheus"] }}'