Enable scraping of additional hosts from Prometheus

This commit is contained in:
David Stephens 2023-04-02 23:24:51 +01:00
parent 02d5ef138a
commit 2a1d7fc718
3 changed files with 18 additions and 1 deletions

View file

@ -32,3 +32,7 @@ stats_grafana_memory: 1g
stats_prometheus_retention_time: 365d
stats_prometheus_retention_size: 30GB
stats_collection_interval: 15s
# uncomment to scrape more hosts
# stats_prometheus_additional_hosts:
# - 192.168.1.1:9100

View file

@ -18,7 +18,7 @@
- name: Template Prometheus config
template:
src: prometheus.yml
src: prometheus.yml.j2
dest: "{{ stats_prometheus_config_directory }}/prometheus.yml"
register: prometheus_config

View file

@ -43,3 +43,16 @@ scrape_configs:
"{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ stats_speedtest_exporter_port }}"
]
{% if stats_prometheus_additional_hosts is defined %}
- job_name: "additional_hosts"
static_configs:
- targets: [
{% for host in stats_prometheus_additional_hosts %}
{{ host }}
{% if not loop.last %}
,
{% endif %}
]
{% endfor %}
{% endif %}