Merge "Updating reference from github to gerrit - Changing Maintainer to dev@mirantis.com"
diff --git a/metadata/service/agent/output/prometheus_client.yml b/metadata/service/agent/output/prometheus_client.yml
index 5537b75..57b98bb 100644
--- a/metadata/service/agent/output/prometheus_client.yml
+++ b/metadata/service/agent/output/prometheus_client.yml
@@ -6,4 +6,5 @@
bind:
address: 0.0.0.0
port: 9126
+ string_as_label: false
engine: prometheus
diff --git a/metadata/service/agent/remote/output/prometheus.yml b/metadata/service/agent/remote/output/prometheus.yml
index 2c242f4..0feb428 100644
--- a/metadata/service/agent/remote/output/prometheus.yml
+++ b/metadata/service/agent/remote/output/prometheus.yml
@@ -6,4 +6,5 @@
bind:
address: 0.0.0.0
port: 9126
+ string_as_label: false
engine: prometheus
diff --git a/telegraf/agent.sls b/telegraf/agent.sls
index e082e6d..34a28eb 100644
--- a/telegraf/agent.sls
+++ b/telegraf/agent.sls
@@ -106,6 +106,37 @@
{%- endfor %}
+{%- for name,values in agent.processor.iteritems() %}
+
+processor_{{ name }}_agent:
+ file.managed:
+ - name: {{ agent.dir.config_d }}/processor-{{ name }}.conf
+ - source:
+{%- if values.template is defined %}
+ - salt://{{ values.template }}
+{%- endif %}
+ - salt://telegraf/files/processor/{{ name }}.conf
+ - user: root
+ - group: root
+ - mode: 644
+ - template: jinja
+ - require:
+ - pkg: telegraf_packages_agent
+ - file: config_d_dir_agent
+ - require_in:
+ - file: config_d_dir_agent_clean
+ - watch_in:
+ - service: telegraf_service_agent
+ - defaults:
+ name: {{ name }}
+{%- if values is mapping %}
+ values: {{ values }}
+{%- else %}
+ values: {}
+{%- endif %}
+
+{%- endfor %}
+
telegraf_service_agent:
service.running:
- name: telegraf
diff --git a/telegraf/files/input/http_response.conf b/telegraf/files/input/http_response.conf
index 40e1744..96adaf4 100644
--- a/telegraf/files/input/http_response.conf
+++ b/telegraf/files/input/http_response.conf
@@ -16,6 +16,7 @@
{%- endif -%}
{%- include 'telegraf/files/input/_common.conf' %}
+{%- include 'telegraf/files/input/_filters.conf' %}
{%- for endpoint, parameters in values.iteritems() %}
{%- if parameters.address is defined %}
[[inputs.http_response.checks]]
@@ -25,4 +26,3 @@
{%- endfor %}
{%- endif %}
{%- endfor %}
-{%- include 'telegraf/files/input/_filters.conf' %}
diff --git a/telegraf/files/input/ipmi_sensor.conf b/telegraf/files/input/ipmi_sensor.conf
new file mode 100644
index 0000000..22a8f70
--- /dev/null
+++ b/telegraf/files/input/ipmi_sensor.conf
@@ -0,0 +1,20 @@
+[[inputs.ipmi_sensor]]
+{%- include 'telegraf/files/input/_common.conf' %}
+
+{%- if values.path is defined %}
+path = "{{ values.path }}"
+{%- endif %}
+{%- if values.privilege is defined %}
+privilege = "{{ values.privilege }}"
+{%- endif %}
+{%- if values.servers is defined %}
+servers = {{ values.servers }}
+{%- endif %}
+{%- if values.timeout is defined %}
+timeout = "{{ values.timeout }}"
+{%- endif %}
+{%- if values.metric_version is defined %}
+metric_version = {{ values.metric_version }}
+{%- endif %}
+
+{%- include 'telegraf/files/input/_filters.conf' %}
diff --git a/telegraf/files/input/snmp.conf b/telegraf/files/input/snmp.conf
new file mode 100644
index 0000000..5b11e7a
--- /dev/null
+++ b/telegraf/files/input/snmp.conf
@@ -0,0 +1,99 @@
+[[inputs.snmp]]
+{%- include 'telegraf/files/input/_common.conf' %}
+
+agents = {{ values.agents }}
+{%- if values.version is defined %}
+version = {{ values.version }}
+{%- endif %}
+{%- if values.name is defined %}
+name = "{{ values.name }}"
+{%- endif %}
+{%- if values.community is defined %}
+community = "{{ values.community }}"
+{%- endif %}
+{%- if values.max_repetitions is defined %}
+max_repetitions = {{ values.max_repetitions }}
+{%- endif %}
+{%- if values.sec_name is defined %}
+sec_name = "{{ values.sec_name }}"
+{%- endif %}
+{%- if values.auth_protocol is defined %}
+auth_protocol = "{{ values.auth_protocol }}"
+{%- endif %}
+{%- if values.auth_password is defined %}
+auth_password = "{{ values.auth_password }}"
+{%- endif %}
+{%- if values.sec_level is defined %}
+sec_level = "{{ values.sec_level }}"
+{%- endif %}
+{%- if values.context_name is defined %}
+context_name = "{{ values.context_name }}"
+{%- endif %}
+{%- if values.priv_protocol is defined %}
+priv_protocol = "{{ values.priv_protocol }}"
+{%- endif %}
+{%- if values.priv_password is defined %}
+priv_password = "{{ values.priv_password }}"
+{%- endif %}
+
+{%- include 'telegraf/files/input/_filters.conf' %}
+
+{%- if values.fields is defined %}
+ {%- for field in values.fields %}
+ [[inputs.snmp.field]]
+ oid = "{{ field.oid }}"
+ {%- if field.name is defined %}
+ name = "{{ field.name }}"
+ {%- endif %}
+ {%- if field.oid_index_suffix is defined %}
+ oid_index_suffix = "{{ field.oid_index_suffix }}"
+ {%- endif %}
+ {%- if field.oid_index_length is defined %}
+ oid_index_length = {{ field.oid_index_length }}
+ {%- endif %}
+ {%- if field.is_tag is defined %}
+ is_tag = {{ field.is_tag }}
+ {%- endif %}
+ {%- if field.conversion is defined %}
+ conversion = "{{ field.conversion }}"
+ {%- endif %}
+ {%- endfor %}
+{%- endif %}
+
+{%- if values.tables is defined %}
+ {%- for table in values.tables %}
+ [[inputs.snmp.table]]
+ {%- if table.name is defined %}
+ name = "{{ table.name }}"
+ {%- endif %}
+ {%- if table.oid is defined %}
+ oid = "{{ table.oid }}"
+ {%- endif %}
+ {%- if table.inherit_tags is defined %}
+ inherit_tags = "{{ table.inherit_tags }}"
+ {%- endif %}
+ {%- if table.index_as_tag is defined %}
+ index_as_tag = {{ table.index_as_tag }}
+ {%- endif %}
+ {%- for field in table.fields %}
+ [[inputs.snmp.table.field]]
+ oid = "{{ field.oid }}"
+ {%- if field.name is defined %}
+ name = "{{ field.name }}"
+ {%- endif %}
+ {%- if field.oid_index_suffix is defined %}
+ oid_index_suffix = "{{ field.oid_index_suffix }}"
+ {%- endif %}
+ {%- if field.oid_index_length is defined %}
+ oid_index_length = {{ field.oid_index_length }}
+ {%- endif %}
+ {%- if field.is_tag is defined %}
+ is_tag = {{ field.is_tag }}
+ {%- endif %}
+ {%- if field.conversion is defined %}
+ conversion = "{{ field.conversion }}"
+ {%- endif %}
+ {%- endfor %}
+ {%- endfor %}
+{%- endif %}
+
diff --git a/telegraf/files/output/prometheus_client.conf b/telegraf/files/output/prometheus_client.conf
index eb7d7fc..bbac5f2 100644
--- a/telegraf/files/output/prometheus_client.conf
+++ b/telegraf/files/output/prometheus_client.conf
@@ -1,8 +1,11 @@
[[outputs.prometheus_client]]
{%- if values is defined %}
listen = "{{ values.bind.address }}:{{ values.bind.port }}"
-{%- if values.expiration_interval is defined %}
+ {%- if values.expiration_interval is defined %}
expiration_interval = "{{ values.expiration_interval }}"
-{%- endif %}
+ {%- endif %}
+ {%- if values.string_as_label is defined %}
+string_as_label = {{ values.string_as_label|lower }}
+ {%- endif %}
{%- endif %}
{%- include 'telegraf/files/input/_filters.conf' %}
diff --git a/telegraf/files/processor/_common.conf b/telegraf/files/processor/_common.conf
new file mode 100644
index 0000000..440106a
--- /dev/null
+++ b/telegraf/files/processor/_common.conf
@@ -0,0 +1,3 @@
+{%- if values.order is defined %}
+ order = {{ values.order }}
+{%- endif %}
diff --git a/telegraf/files/processor/enum.conf b/telegraf/files/processor/enum.conf
new file mode 100644
index 0000000..8174793
--- /dev/null
+++ b/telegraf/files/processor/enum.conf
@@ -0,0 +1,24 @@
+[[processors.enum]]
+{%- include 'telegraf/files/processor/_common.conf' %}
+{%- include 'telegraf/files/input/_filters.conf' -%}
+
+{%- if values.mapping is sequence %}
+ {%- for mapping in values.mapping %}
+ {%- if mapping is mapping %}
+ [[processors.enum.mapping]]
+ field = "{{ mapping.field }}"
+ {%- if mapping.dest is defined %}
+ dest = "{{ mapping.dest }}"
+ {%- endif %}
+ {%- if mapping.default is defined %}
+ default = {{ mapping.default }}
+ {%- endif %}
+ {%- if mapping.value_mappings is mapping %}
+ [processors.enum.mapping.value_mappings]
+ {%- for key, value in mapping.value_mappings.iteritems()|sort %}
+ {{ key }} = {{ value }}
+ {%- endfor %}
+ {%- endif %}
+ {%- endif %}
+ {%- endfor %}
+{%- endif %}
diff --git a/telegraf/map.jinja b/telegraf/map.jinja
index 3119a8d..4dc0c85 100644
--- a/telegraf/map.jinja
+++ b/telegraf/map.jinja
@@ -18,7 +18,7 @@
}, merge=salt['pillar.get']('telegraf:remote_agent')) %}
{# Collect configuration from */meta/telegraf.yml #}
-{%- set telegraf_grains = {'telegraf': {'agent': {'input': {}}, 'remote_agent': {'input':{}, 'output':{}}}} %}
+{%- set telegraf_grains = {'telegraf': {'agent': {'input': {}, 'output': {}, 'processor': {}}, 'remote_agent': {'input':{}, 'output':{}, 'processor': {}}}} %}
{%- for service_name, service in pillar.items() %}
{%- if service.get('_support', {}).get('telegraf', {}).get('enabled', False) %}
{%- set grains_fragment_file = service_name+'/meta/telegraf.yml' %}
diff --git a/telegraf/remote_agent.sls b/telegraf/remote_agent.sls
index 4d9a50d..d12ee94 100644
--- a/telegraf/remote_agent.sls
+++ b/telegraf/remote_agent.sls
@@ -133,6 +133,47 @@
{%- endfor %}
+{%- set remote_agent_processors = {} %}
+{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
+ {%- set remote_agent_processor = node_grains.get('telegraf', {}).get('remote_agent', {}).get('processor', {}) %}
+ {%- if remote_agent_processor %}
+ {%- do salt['defaults.merge'](remote_agent_processors, remote_agent_processor) %}
+ {%- endif %}
+{%- endfor %}
+{%- do salt['defaults.merge'](remote_agent_processors, remote_agent.processor) %}
+
+{%- for name,values in remote_agent_processors.iteritems() %}
+
+processor_{{ name }}_remote_agent:
+ file.managed:
+ - name: {{ remote_agent.dir.config_d }}/processor-{{ name }}.conf
+ - source:
+{%- if values.template is defined %}
+ - salt://{{ values.template }}
+{%- endif %}
+ - salt://telegraf/files/processor/{{ name }}.conf
+ - user: root
+ - group: root
+ - mode: 644
+ - template: jinja
+ - onchanges_in:
+{%- for docker_id in docker_ids.split() %}
+ - cmd: {{docker_id}}_remote_agent_reload
+{%- endfor %}
+ - require:
+ - file: config_d_dir_remote_agent
+ - require_in:
+ - file: config_d_dir_remote_agent_clean
+ - defaults:
+ name: {{ name }}
+{%- if values is mapping %}
+ values: {{ values }}
+{%- else %}
+ values: {}
+{%- endif %}
+
+{%- endfor %}
+
{%- for docker_id in docker_ids.split() %}
{{docker_id }}_remote_agent_reload:
cmd.run: