blob: c93b7f3b79805f4019cf3ba78caca712daf727d0 [file] [log] [blame]
{%- from "telegraf/map.jinja" import agent with context -%}
{%- if agent.output is defined %}
{%- if agent.output.prometheus_client is defined %}
{%- if agent.output.prometheus_client.bind.address == '0.0.0.0' %}
{%- set fqdn_ip4_addresses = [] %}
{%- for addr in grains['fqdn_ip4'] %}
{%- if not addr.startswith('127.') %}
{%- do fqdn_ip4_addresses.append(addr) %}
{%- endif %}
{%- endfor %}
{%- set address = fqdn_ip4_addresses[0] %}
{%- else %}
{%- set address = agent.output.prometheus_client.bind.address %}
{%- endif %}
{%- endif %}
{%- endif %}
server:
alert:
NodeDown:
if: >-
sum by (host, url) (label_replace((up{job=~"telegraf|fluentd"}), "url", "$1", "instance", "(.*):.*")) + on (url) group_left abs(clamp_max(ping_result_code, 1) - 1) == 0
labels:
severity: critical
service: system
annotations:
{%- raw %}
summary: "The {{ $labels.host }} node is down"
description: "The {{ $labels.host }} node is unreachable at {{ $labels.url }}, the Telegraf and Fluentd targets on the {{ $labels.host }} node are down."
{%- endraw %}
{%- if address is defined %}
target:
static:
telegraf:
{%- if agent.output.prometheus_client.scheme is defined %}
scheme: {{ agent.output.prometheus_client.scheme }}
{%- endif %}
{%- if agent.output.prometheus_client.tls_config is defined %}
tls_config:
{%- if agent.output.prometheus_client.tls_config.skip_verify is defined %}
skip_verify: {{ agent.output.prometheus_client.tls_config.skip_verify }}
{%- endif %}
{%- if agent.output.prometheus_client.tls_config.ca_file is defined %}
ca_file: {{ agent.output.prometheus_client.tls_config.ca_file }}
{%- endif %}
{%- if agent.output.prometheus_client.tls_config.cert_name is defined %}
cert_name: {{ agent.output.prometheus_client.tls_config.cert_name }}
{%- endif %}
{%- if agent.output.prometheus_client.tls_config.key_name is defined %}
key_name: {{ agent.output.prometheus_client.tls_config.key_name }}
{%- endif %}
{%- endif %}
endpoint:
- address: {{ address }}
port: {{ agent.output.prometheus_client.bind.port }}
relabel_configs:
- regex: {{ address }}:{{ agent.output.prometheus_client.bind.port }}
replacement: {{ grains['host'] }}
source_labels: "__address__"
target_label: "host"
honor_labels: true
{%- endif %}