infra-konstrukt/roles/prometheus/templates/prometheus.yml.j2

39 lines
1.1 KiB
Django/Jinja

global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets:
- 'localhost:9090'
- job_name: 'node_exporter'
static_configs:
- targets:
{% for host in groups['all'] %}
- '{{ hostvars[host].ansible_host }}:9100'
{% endfor %}
- job_name: 'postfix_exporter'
static_configs:
- targets:
{% for host in groups['vps_servers'] %}
# Hier filtern wir idealerweise, ob Postfix drauf ist.
# Einfachheitshalber nehmen wir erstmal an, prodVPS ist der Mailserver.
# Oder wir nutzen eine Variable im Inventory: postfix_enabled=true
{% if hostvars[host]['postfix_enabled'] is defined and hostvars[host]['postfix_enabled'] %}
- '{{ hostvars[host].ansible_host }}:9154'
{% endif %}
{% endfor %}
- job_name: 'nginx_exporter'
static_configs:
- targets:
{% for host in groups['vps_servers'] %}
{% if hostvars[host]['nginx_enabled'] is defined and hostvars[host]['nginx_enabled'] %}
- '{{ hostvars[host].ansible_host }}:9113'
{% endif %}
{% endfor %}