mirror of
https://github.com/dj-wasabi/ansible-telegraf.git
synced 2025-07-17 08:46:37 +00:00
Better sub inputs handling (#193)
* 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>
This commit is contained in:
@ -342,13 +342,13 @@ sqs:
|
|||||||
- statistic_include = ["average"]
|
- statistic_include = ["average"]
|
||||||
sub_inputs:
|
sub_inputs:
|
||||||
metrics:
|
metrics:
|
||||||
- names = [
|
- names: [
|
||||||
"ApproximateAgeOfOldestMessage",
|
"ApproximateAgeOfOldestMessage",
|
||||||
"ApproximateNumberOfMessagesVisible",
|
"ApproximateNumberOfMessagesVisible",
|
||||||
]
|
]
|
||||||
metrics.dimensions:
|
metrics.dimensions:
|
||||||
- name = "QueueName"
|
- name: "QueueName"
|
||||||
- value = "*"
|
value: "*"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
@ -56,10 +56,16 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.value.sub_inputs is defined and item.value.sub_inputs is iterable %}
|
{% if item.value.sub_inputs is defined and item.value.sub_inputs is iterable %}
|
||||||
{% for sub_input, config in item.value.sub_inputs.items() %}
|
{% for sub_input_key, sub_input_list in item.value.sub_inputs.items() %}
|
||||||
[[inputs.{{ item.value.plugin | default(item.key) }}.{{ sub_input }}]]
|
{% for block in sub_input_list %}
|
||||||
{% for items in config %}
|
[[inputs.{{ item.value.plugin | default(item.key) }}.{{ sub_input_key }}]]
|
||||||
{{ items }}
|
{% 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 %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Reference in New Issue
Block a user