Merge "Redirect docker stderr to /dev/null"
diff --git a/telegraf/files/input/procstat.conf b/telegraf/files/input/procstat.conf
index d3d921e..11330ba 100644
--- a/telegraf/files/input/procstat.conf
+++ b/telegraf/files/input/procstat.conf
@@ -13,9 +13,7 @@
 {%- 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() %}
diff --git a/telegraf/map.jinja b/telegraf/map.jinja
index c49db55..3ca3e3e 100644
--- a/telegraf/map.jinja
+++ b/telegraf/map.jinja
@@ -17,16 +17,18 @@
     },
 }, merge=salt['pillar.get']('telegraf:remote_agent')) %}
 
-{%- set service_grains = {'telegraf': {'agent': {'input': {}}, 'remote_agent': {'input':{}}}} %}
+{# Collect configuration from */meta/telegraf.yml #}
+{%- set telegraf_grains = {'telegraf': {'agent': {'input': {}}, 'remote_agent': {'input':{}}}} %}
 {%- 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' %}
     {%- macro load_grains_file() %}{% include grains_fragment_file ignore missing %}{% endmacro %}
     {%- set grains_yaml = load_grains_file()|load_yaml %}
     {%- if grains_yaml is mapping %}
-      {%- set service_grains = salt['grains.filter_by']({'default': service_grains}, merge={'telegraf': grains_yaml}) %}
+      {%- set telegraf_grains = salt['grains.filter_by']({'default': telegraf_grains}, merge={'telegraf': grains_yaml}) %}
     {%- endif %}
   {%- endif %}
 {%- endfor %}
-{%- set telegraf_grains = salt['grains.filter_by']({'default': service_grains}, merge={'telegraf': {'agent': agent}}) %}
-{%- set telegraf_grains = salt['grains.filter_by']({'default': service_grains}, merge={'telegraf': {'remote_agent': remote_agent}}) %}
+
+{# Deep-merge the service configuration with the pillar data #}
+{%- do salt['defaults.merge'](telegraf_grains, {'telegraf': {'agent': agent, 'remote_agent': remote_agent}}) %}