blob: 66e6b67be38e7acdf23297ac5b9d4d99925b21f2 [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 %}
{%- if address is defined %}
server:
target:
static:
telegraf:
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 %}