Skip to content

Commit

Permalink
fix: properly handle lists as TOML arrays
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Michał Lisowski committed Feb 6, 2025
1 parent 3cd5e9b commit 9453526
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,13 @@ sqs:
- statistic_include = ["average"]
sub_inputs:
metrics:
- names = [
- names: [
"ApproximateAgeOfOldestMessage",
"ApproximateNumberOfMessagesVisible",
]
metrics.dimensions:
- name = "QueueName"
- value = "*"
- name: "QueueName"
value: "*"
```
## Dependencies
Expand Down
14 changes: 10 additions & 4 deletions templates/telegraf-extra-plugin.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

0 comments on commit 9453526

Please # to comment.