3 Commits

Author SHA1 Message Date
30ad547f9c Merge 084df32f10 into 8670792f6f 2025-02-11 14:24:21 +00:00
8670792f6f Updated CHANGELOG.md on "2025-02-07 17:54:47" 2025-02-07 17:54:47 +00:00
4803b33f89 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>
2025-02-07 18:54:09 +01:00
3 changed files with 15 additions and 8 deletions

View File

@ -6,6 +6,7 @@
**Merged pull requests:**
- Better sub inputs handling [\#193](https://github.com/dj-wasabi/ansible-telegraf/pull/193) ([lisuml](https://github.com/lisuml))
- Bump ansible-core from 2.18.0 to 2.18.1 [\#192](https://github.com/dj-wasabi/ansible-telegraf/pull/192) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump ansible-core from 2.16.8 to 2.18.0 [\#191](https://github.com/dj-wasabi/ansible-telegraf/pull/191) ([dependabot[bot]](https://github.com/apps/dependabot))
@ -181,7 +182,6 @@
- Some changes for fixing FreeBSD [\#101](https://github.com/dj-wasabi/ansible-telegraf/pull/101) ([dj-wasabi](https://github.com/dj-wasabi))
- basic FreeBSD support [\#100](https://github.com/dj-wasabi/ansible-telegraf/pull/100) ([langerma](https://github.com/langerma))
- Added the use\_proxy argument to use a proxy \(or not\) [\#98](https://github.com/dj-wasabi/ansible-telegraf/pull/98) ([dj-wasabi](https://github.com/dj-wasabi))
- Various small changes for molecule [\#97](https://github.com/dj-wasabi/ansible-telegraf/pull/97) ([dj-wasabi](https://github.com/dj-wasabi))
## [0.12.0](https://github.com/dj-wasabi/ansible-telegraf/tree/0.12.0) (2019-03-12)
@ -197,6 +197,7 @@
**Merged pull requests:**
- Various small changes for molecule [\#97](https://github.com/dj-wasabi/ansible-telegraf/pull/97) ([dj-wasabi](https://github.com/dj-wasabi))
- Add processors section in Telegraf config [\#94](https://github.com/dj-wasabi/ansible-telegraf/pull/94) ([ph4r5h4d](https://github.com/ph4r5h4d))
- Updated to Telegraf 1.10.0;Different installation methods [\#93](https://github.com/dj-wasabi/ansible-telegraf/pull/93) ([dj-wasabi](https://github.com/dj-wasabi))
- Updating Telegraf default to 1.9.5 [\#92](https://github.com/dj-wasabi/ansible-telegraf/pull/92) ([sdurrheimer](https://github.com/sdurrheimer))

View File

@ -342,13 +342,13 @@ sqs:
- statistic_include = ["average"]
sub_inputs:
metrics:
- names = [
- names: [
"ApproximateAgeOfOldestMessage",
"ApproximateNumberOfMessagesVisible",
]
metrics.dimensions:
- name = "QueueName"
- value = "*"
- name: "QueueName"
value: "*"
```
## Dependencies

View File

@ -56,10 +56,16 @@
{% endfor %}
{% endif %}
{% if item.value.sub_inputs is defined and item.value.sub_inputs is iterable %}
{% for sub_input, config in item.value.sub_inputs.items() %}
[[inputs.{{ item.value.plugin | default(item.key) }}.{{ sub_input }}]]
{% for items in config %}
{{ items }}
{% 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 %}