infrastructure/roles/telegraf/templates/telegraf.conf

104 lines
3.6 KiB
Text

{{ ansible_managed | comment }}
# Source: https://github.com/dj-wasabi/ansible-telegraf/blob/master/templates/telegraf.conf.j2
[global_tags]
{% if telegraf_global_tags is defined and telegraf_global_tags is iterable %}
{% for item in telegraf_global_tags %}
{{ item.tag_name }} = "{{ item.tag_value }}"
{% endfor %}
{% endif %}
# Configuration for telegraf agent
[agent]
interval = "{{ telegraf_agent_interval }}s"
debug = {{ telegraf_agent_debug | lower }}
hostname = "{{ telegraf_agent_hostname }}"
round_interval = {{ telegraf_agent_round_interval | lower }}
flush_interval = "{{ telegraf_agent_flush_interval }}s"
flush_jitter = "{{ telegraf_agent_flush_jitter }}s"
collection_jitter = "{{ telegraf_agent_collection_jitter }}s"
metric_batch_size = {{ telegraf_agent_metric_batch_size }}
metric_buffer_limit = {{ telegraf_agent_metric_buffer_limit }}
omit_hostname = {{ telegraf_agent_omit_hostname | lower }}
###############################################################################
# OUTPUTS #
###############################################################################
{% if telegraf_output is defined and telegraf_output is iterable %}
{% for item in telegraf_output %}
[[outputs.{{ item.type }}]]
{% for items in item.config %}
{{ items }}
{% endfor %}
{% if item.tagpass is defined and item.tagpass is iterable %}
[outputs.{{ item.type }}.tagpass]
{% for items in item.tagpass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagdrop is defined and item.tagdrop is iterable %}
[outputs.{{ item.type }}.tagdrop]
{% for items in item.tagdrop %}
{{ items }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
###############################################################################
# INPUTS #
###############################################################################
{% if telegraf_plugins is defined and telegraf_plugins is iterable %}
{% for item in telegraf_plugins + telegraf_plugins_extra %}
[[inputs.{{ item.plugin }}]]
{% if item.interval is defined %}
interval = "{{ item.interval }}s"
{% endif %}
{% if item.config is defined and item.config is iterable %}
{% for items in item.config %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tags is defined and item.tags is iterable %}
[inputs.{{ item.plugin }}.tags]
{% for items in item.tags %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagpass is defined and item.tagpass is iterable %}
[inputs.{{ item.plugin }}.tagpass]
{% for items in item.tagpass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagdrop is defined and item.tagdrop is iterable %}
[inputs.{{ item.plugin }}.tagdrop]
{% for items in item.tagdrop %}
{{ items }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% if telegraf_plugins is defined and telegraf_plugins|length == 0 %}
# No plugins configured, added a mem plugin so telegraf doesn't stop working.
[[inputs.mem]]
{% endif %}
###############################################################################
# PROCESSORS #
###############################################################################
{% if telegraf_processors is defined and telegraf_processors is iterable %}
{% for item in telegraf_processors %}
[[processors.{{ item.processor }}]]
{% if item.config is defined and item.config is iterable %}
{% for items in item.config %}
{{ items }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}