mirror of
https://github.com/dj-wasabi/ansible-telegraf.git
synced 2025-07-17 08:46:37 +00:00
* Support for sub_inputs in extra plugins * fix: properly handle lists as TOML arrays - Updated the Jinja template to detect and serialize lists using |to_json, ensuring Telegraf interprets them correctly (e.g. names = ["item1","item2"]). - Removed fallback logic for single items, so we consistently treat all sub_input values as lists of dictionaries. --------- Co-authored-by: Michał Lisowski <mlisowski@sentient.ie>
72 lines
2.6 KiB
Django/Jinja
72 lines
2.6 KiB
Django/Jinja
### MANAGED BY {{ role_path|basename }} ANSIBLE ROLE ###
|
|
|
|
[[inputs.{{ item.value.plugin | default(item.key) }}]]
|
|
{% if item.value.interval is defined %}
|
|
interval = "{{ item.value.interval }}s"
|
|
{% endif %}
|
|
{% if item.value.config is defined and item.value.config is iterable %}
|
|
{% for items in item.value.config %}
|
|
{{ items }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if item.value.tags is defined and item.value.tags is iterable %}
|
|
[inputs.{{ item.value.plugin | default(item.key) }}.tags]
|
|
{% for items in item.value.tags %}
|
|
{{ items }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if item.value.tagpass is defined and item.value.tagpass is iterable %}
|
|
[inputs.{{ item.value.plugin | default(item.key) }}.tagpass]
|
|
{% for items in item.value.tagpass %}
|
|
{{ items }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if item.value.tagdrop is defined and item.value.tagdrop is iterable %}
|
|
[inputs.{{ item.value.plugin | default(item.key) }}.tagdrop]
|
|
{% for items in item.value.tagdrop %}
|
|
{{ items }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if item.value.filter is defined %}
|
|
{% if item.value.filter.name is defined %}
|
|
[inputs.{{ item.value.plugin | default(item.key) }}.{{ item.value.filter.name | default("grok") }}]
|
|
{% if item.value.filter.config is defined and item.value.filter.config is iterable %}
|
|
{% for items in item.value.filter.config %}
|
|
{{ items }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if item.value.objects is defined and item.value.objects is iterable %}
|
|
{% for object in item.value.objects %}
|
|
[[inputs.{{ item.value.plugin | default(item.key) }}.object]]
|
|
ObjectName = {{ object.name | to_json }}
|
|
Instances = {{ object.instances | default(["*"]) | to_json }}
|
|
Counters = {{ object.counters | default(["*"]) | to_json }}
|
|
Measurement = {{ object.measurement | default("win_perf_counters") | to_json }}
|
|
IncludeTotal = {{ object.total | default(false) | string | lower }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if item.value.queries is defined and item.value.queries is iterable %}
|
|
{% for query in item.value.queries %}
|
|
[[inputs.{{ item.value.plugin | default(item.key) }}.query]]
|
|
{% for item in item.value.queries[query] %}
|
|
{{ item }}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if item.value.sub_inputs is defined and item.value.sub_inputs is iterable %}
|
|
{% for sub_input_key, sub_input_list in item.value.sub_inputs.items() %}
|
|
{% for block in sub_input_list %}
|
|
[[inputs.{{ item.value.plugin | default(item.key) }}.{{ sub_input_key }}]]
|
|
{% for param_key, param_value in block.items() %}
|
|
{% if param_value is sequence and param_value is not string %}
|
|
{{ param_key }} = {{ param_value | to_json }}
|
|
{% else %}
|
|
{{ param_key }} = "{{ param_value }}"
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
{% endfor %}
|
|
{% endif %}
|