Added possibility to pass tags from reclass to config
Change-Id: I3c3c569a013aff8c3ab8e46cffb93a60d74ddf09
diff --git a/telegraf/files/input/cpu.conf b/telegraf/files/input/cpu.conf
index 4c1dd90..e2b7926 100644
--- a/telegraf/files/input/cpu.conf
+++ b/telegraf/files/input/cpu.conf
@@ -6,4 +6,10 @@
{%- if values.percpu is defined %}
percpu = {{ values.percpu | lower }}
{%- endif %}
+{%- if values.tags is defined %}
+ [inputs.{{name}}.tags]
+ {%- for tag_name, tag_value in values.tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+{%- endif %}
{%- endif %}
diff --git a/telegraf/files/input/disk.conf b/telegraf/files/input/disk.conf
index 8ee733e..5308162 100644
--- a/telegraf/files/input/disk.conf
+++ b/telegraf/files/input/disk.conf
@@ -3,4 +3,10 @@
{%- if values.mount_points is defined%}
mount_points = {{ values.mount_points }}
{%- endif %}
+{%- if values.tags is defined %}
+ [inputs.{{name}}.tags]
+ {%- for tag_name, tag_value in values.tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+{%- endif %}
{%- endif %}
diff --git a/telegraf/files/input/diskio.conf b/telegraf/files/input/diskio.conf
index fa488c5..e608a5a 100644
--- a/telegraf/files/input/diskio.conf
+++ b/telegraf/files/input/diskio.conf
@@ -6,4 +6,10 @@
{%- if values.skip_serial_number is defined %}
skip_serial_number = {{ values.skip_serial_number | lower }}
{%- endif %}
+{%- if values.tags is defined %}
+ [inputs.{{name}}.tags]
+ {%- for tag_name, tag_value in values.tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+{%- endif %}
{%- endif %}
diff --git a/telegraf/files/input/docker.conf b/telegraf/files/input/docker.conf
index 8d27a55..7c05814 100644
--- a/telegraf/files/input/docker.conf
+++ b/telegraf/files/input/docker.conf
@@ -1,11 +1,21 @@
[[inputs.{{ name }}]]
{%- if values is defined %}
+{%- if values.endpoint is defined %}
endpoint = "{{ values.endpoint }}"
+{%- endif %}
+{%- if values.timeout is defined %}
timeout = "{{ values.timeout }}s"
+ {%- endif %}
{%- if values.perdevice is defined %}
perdevice = {{ values.perdevice | lower }}
{%- endif %}
{%- if values.total is defined %}
total = {{ values.total | lower }}
{%- endif %}
+{%- if values.tags is defined %}
+ [inputs.{{name}}.tags]
+ {%- for tag_name, tag_value in values.tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+{%- endif %}
{%- endif %}
diff --git a/telegraf/files/input/mem.conf b/telegraf/files/input/mem.conf
index b505dfc..a12e562 100644
--- a/telegraf/files/input/mem.conf
+++ b/telegraf/files/input/mem.conf
@@ -1 +1,9 @@
[[inputs.{{ name }}]]
+{%- if values is defined %}
+{%- if values.tags is defined %}
+ [inputs.{{name}}.tags]
+ {%- for tag_name, tag_value in values.tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+{%- endif %}
+{%- endif %}
diff --git a/telegraf/files/input/net.conf b/telegraf/files/input/net.conf
index b505dfc..a12e562 100644
--- a/telegraf/files/input/net.conf
+++ b/telegraf/files/input/net.conf
@@ -1 +1,9 @@
[[inputs.{{ name }}]]
+{%- if values is defined %}
+{%- if values.tags is defined %}
+ [inputs.{{name}}.tags]
+ {%- for tag_name, tag_value in values.tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+{%- endif %}
+{%- endif %}
diff --git a/telegraf/files/input/netstat.conf b/telegraf/files/input/netstat.conf
index b505dfc..a12e562 100644
--- a/telegraf/files/input/netstat.conf
+++ b/telegraf/files/input/netstat.conf
@@ -1 +1,9 @@
[[inputs.{{ name }}]]
+{%- if values is defined %}
+{%- if values.tags is defined %}
+ [inputs.{{name}}.tags]
+ {%- for tag_name, tag_value in values.tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+{%- endif %}
+{%- endif %}
diff --git a/telegraf/files/input/processes.conf b/telegraf/files/input/processes.conf
index b505dfc..a12e562 100644
--- a/telegraf/files/input/processes.conf
+++ b/telegraf/files/input/processes.conf
@@ -1 +1,9 @@
[[inputs.{{ name }}]]
+{%- if values is defined %}
+{%- if values.tags is defined %}
+ [inputs.{{name}}.tags]
+ {%- for tag_name, tag_value in values.tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+{%- endif %}
+{%- endif %}
diff --git a/telegraf/files/input/procstat.conf b/telegraf/files/input/procstat.conf
index 091a560..d3d921e 100644
--- a/telegraf/files/input/procstat.conf
+++ b/telegraf/files/input/procstat.conf
@@ -13,6 +13,14 @@
{%- if item.user is defined %}
user = "{{ item.user }}"
{%- endif %}
+{%- if item_name is defined %}
process_name = "{{ item_name }}"
{%- endif %}
+{%- if item.tags is defined %}
+ [inputs.{{name}}.tags]
+ {%- for tag_name, tag_value in item.tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+{%- endif %}
+{%- endif %}
{%- endfor %}
diff --git a/telegraf/files/input/system.conf b/telegraf/files/input/system.conf
index b505dfc..a12e562 100644
--- a/telegraf/files/input/system.conf
+++ b/telegraf/files/input/system.conf
@@ -1 +1,9 @@
[[inputs.{{ name }}]]
+{%- if values is defined %}
+{%- if values.tags is defined %}
+ [inputs.{{name}}.tags]
+ {%- for tag_name, tag_value in values.tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+{%- endif %}
+{%- endif %}
diff --git a/telegraf/files/telegraf.conf b/telegraf/files/telegraf.conf
index 941a86c..8325c41 100644
--- a/telegraf/files/telegraf.conf
+++ b/telegraf/files/telegraf.conf
@@ -1,10 +1,63 @@
{%- from "telegraf/map.jinja" import agent with context -%}
+[global_tags]
+
+ {%- if agent.global_tags is defined %}
+ {%- for tag_name, tag_value in agent.global_tags.iteritems() %}
+ {{ tag_name }} = "{{ tag_value }}"
+ {%- endfor %}
+ {%- endif %}
+
[agent]
+
+ {%- if agent.interval is defined %}
interval = "{{ agent.interval }}s"
+ {%- endif %}
+
+ {%- if agent.round_interval is defined %}
round_interval = {{ agent.round_interval | lower }}
+ {%- endif %}
+
+ {%- if agent.metric_batch_size is defined %}
metric_batch_size = {{ agent.metric_batch_size }}
+ {%- endif %}
+
+ {%- if agent.metric_buffer_limit is defined %}
metric_buffer_limit = {{ agent.metric_buffer_limit }}
+ {%- endif %}
+
+ {%- if agent.collection_jitter is defined %}
collection_jitter = "{{ agent.collection_jitter }}s"
- hostname = ""
- omit_hostname = false
+ {%- endif %}
+
+ {%- if agent.flush_interval is defined %}
+ flush_interval = "{{ agent.flush_interval }}s"
+ {%- endif %}
+
+ {%- if agent.flush_jitter is defined %}
+ flush_jitter = "{{ agent.flush_jitter }}s"
+ {%- endif %}
+
+ {%- if agent.precision is defined %}
+ precision = "{{ agent.precision }}"
+ {%- endif %}
+
+ {%- if agent.logfile is defined %}
+ logfile = "{{ agent.logfile }}"
+ {%- endif %}
+
+ {%- if agent.debug is defined %}
+ debug = {{ agent.debug | lower }}
+ {%- endif %}
+
+ {%- if agent.quiet is defined %}
+ quiet = {{ agent.quiet | lower }}
+ {%- endif %}
+
+ {%- if agent.hostname is defined %}
+ hostname = "{{ agent.hostname }}"
+ {%- endif %}
+
+ {%- if agent.omit_hostname is defined %}
+ omit_hostname = {{ agent.omit_hostname | lower }}
+ {%- endif %}