Files
ansible-docker/roles/prometheus/templates/prometheus.yml.j2
2023-12-21 01:32:53 +02:00

66 lines
1.7 KiB
Django/Jinja

---
# {{ ansible_managed }}
# my global config
global:
scrape_interval: {{ prometheus_scrape_interval }}
evaluation_interval: {{ prometheus_evaluation_interval }}
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
{% if prometheus_install_alertmanager %}
- alertmanager:9093
{%- endif %}
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "/etc/prometheus/recording/*.yaml"
- "/etc/prometheus/alerting/*.yaml"
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "blackbox"
static_configs:
- targets: ["blackbox_exporter:9115"]
{% if prometheus_ping_hosts | length > 0 %}
- job_name: "icmp"
metrics_path: "/probe"
params:
module: ["icmp"]
static_configs:
- targets:
{% for host in prometheus_ping_hosts %}
- "{{ host.name }}::{{ host.type | default('monitored') }}"
{% endfor %}
relabel_configs:
- source_labels: [__address__]
regex: '(.+)::(.+)'
target_label: __param_target
replacement: '${1}'
- source_labels: [__address__]
regex: '(.+)::(.+)'
target_label: host_type
replacement: '${2}'
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: blackbox_exporter:9115
{%- endif %}
{% if prometheus_hcloud_enabled %}
- job_name: hcloud
hetzner_sd_configs:
- role: hcloud
authorization:
credentials: {{ prometheus_hcloud_token }}
relabel_configs: {{ prometheus_hcloud_relabel_configs }}
{%- endif %}