Skip to content

Commit

Permalink
Support for sub_inputs in extra plugins (#184)
Browse files Browse the repository at this point in the history
Co-authored-by: Michał Lisowski <[email protected]>
  • Loading branch information
lisuml and Michał Lisowski authored Feb 28, 2024
1 parent b5179f4 commit bfe52cd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ Telegraf plugin options:
* `interval`: How often to gather this metric. Normal plugins use a single global interval, but if one particular plugin should be run less or more often, you can configure that here.
* `filter.name`: Like when there is an extra filter that needs to be configured, like `grok` for a `logparser` plugin.
* `filter.config`: The extra configuration for the - in the `filter.name` example - `grok` filter. (See example below)
* `sub_inputs`: If the input requires other sub inputs, you can add them here (see example below).

An example might look like this:

Expand Down Expand Up @@ -325,6 +326,30 @@ When you want to make use of the `grok` filter for the logparser:
config:
- patterns = ["invoked oom-killer"]

When you want to include a sub inputs with their own configuration:
```yaml
sqs:
plugin: cloudwatch
config:
- region = "eu-west-1"
- access_key = "foo"
- secret_key = "bar"
- period = "1m"
- delay = "2m"
- interval = "1m"
- namespace = "AWS/SQS"
- statistic_include = ["average"]
sub_inputs:
metrics:
- names = [
"ApproximateAgeOfOldestMessage",
"ApproximateNumberOfMessagesVisible",
]
metrics.dimensions:
- name = "QueueName"
- value = "*"
```
## Dependencies
No dependencies
Expand Down
8 changes: 8 additions & 0 deletions templates/telegraf-extra-plugin.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,11 @@
{% endfor %}
{% 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 }}
{% endfor %}
{% endfor %}
{% endif %}

0 comments on commit bfe52cd

Please sign in to comment.