Adding support for aggregators (#156)

* templates/telegraf.conf.j2: Adding aggregator support.

Adding aggregator support and tagpass/tagdrop support for
processors and aggregators.

* Adding test for aggregator templating
This commit is contained in:
Simo Tuomisto
2022-03-21 17:45:54 +02:00
committed by GitHub
parent 554434c7ad
commit f329d9e207
3 changed files with 48 additions and 1 deletions

View File

@ -52,6 +52,13 @@ provisioner:
name: grok
config:
- patterns = ["invoked oom-killer"]
telegraf_aggregators:
- aggregator: basicstats
config:
- drop_original = false
- stats = ['mean']
tagpass:
- cpu = ["cpu-total"]
scenario:
name: default

View File

@ -24,6 +24,7 @@ def test_telegraf_dot_conf(host):
assert telegraf.contains('[[outputs.influxdb]]')
assert telegraf.contains('["http://influxdb:8086"]')
assert telegraf.contains('[[inputs.net]]')
assert telegraf.contains('[[aggregators.basicstats]]')
def test_telegraf_dot_d_dir(host):

View File

@ -118,7 +118,7 @@
{% endif %}
###############################################################################
# PROCESSORS #
# PROCESSORS #
###############################################################################
{% if telegraf_processors is defined and telegraf_processors is iterable %}
@ -129,5 +129,44 @@
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagpass is defined and item.tagpass is iterable %}
[processors.{{ item.processor }}.tagpass]
{% for items in item.tagpass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagdrop is defined and item.tagdrop is iterable %}
[processors.{{ item.processor }}.tagdrop]
{% for items in item.tagdrop %}
{{ items }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
###############################################################################
# AGGREGATORS #
###############################################################################
{% if telegraf_aggregators is defined and telegraf_aggregators is iterable %}
{% for item in telegraf_aggregators %}
[[aggregators.{{ item.aggregator }}]]
{% if item.config is defined and item.config is iterable %}
{% for items in item.config %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagpass is defined and item.tagpass is iterable %}
[aggregators.{{ item.aggregator }}.tagpass]
{% for items in item.tagpass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagdrop is defined and item.tagdrop is iterable %}
[aggregators.{{ item.aggregator }}.tagdrop]
{% for items in item.tagdrop %}
{{ items }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}