Merge pull request #13 from elemoine/stacklight-influxdb

Make Heka send metrics to InfluxDB
diff --git a/heka/_service.sls b/heka/_service.sls
index e228165..9e649b4 100644
--- a/heka/_service.sls
+++ b/heka/_service.sls
@@ -149,18 +149,17 @@
 {% if salt['pillar.get']('heka:'+service_grain_name) %}
 
 {%- for service_action_name, service_action in service_grain.iteritems() %}
-{%- if salt['pillar.get']('heka:'+service_grain_name).get(service_action_name, False) is mapping %}
+{%- if salt['pillar.get']('heka:'+service_grain_name).get(service_action_name, None) is mapping %}
+
 {%- set grain_action_meta = salt['pillar.get']('heka:'+service_grain_name+':'+service_action_name) %}
-{#
-{%- set service_grains.get(service_grain_name).get(service_action_name) = salt['grains.filter_by']({'default': service_grains}, merge=grain_action_meta) %}
-#}
+{%- do service_grains.get(service_grain_name).get(service_action_name).update(grain_action_meta) %}
+
 {%- endif %}
 {%- endfor %}
 
 {%- endif %}
 {%- endfor %}
 
-
 heka_{{ service_name }}_grain:
   file.managed:
   - name: /etc/salt/grains.d/heka
diff --git a/heka/files/toml/output/http.toml b/heka/files/toml/output/influxdb.toml
similarity index 64%
rename from heka/files/toml/output/http.toml
rename to heka/files/toml/output/influxdb.toml
index a7cb3c1..005bf8e 100644
--- a/heka/files/toml/output/http.toml
+++ b/heka/files/toml/output/influxdb.toml
@@ -2,9 +2,11 @@
 type = "HttpOutput"
 message_matcher = "Fields[payload_type] == 'txt' && Fields[payload_name] == 'influxdb'"
 encoder = "influxdb_encoder"
-address = "http://{{ output.host }}:8086/write?db=lma&precision=ms"
-username = "influxdb"
-password = "influxdbpass"
+address = "http://{{ output.host }}:{{ output.port }}/write?db={{ output.database }}&precision=ms"
+{%- if output.username and output.password %}
+username = "{{ output.username }}"
+password = "{{ output.password }}"
+{%- endif %}
 http_timeout = 5000
 method = "POST"
 use_buffering = true
diff --git a/heka/meta/heka.yml b/heka/meta/heka.yml
index 1d5c8fe..8781888 100644
--- a/heka/meta/heka.yml
+++ b/heka/meta/heka.yml
@@ -68,6 +68,16 @@
       module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
       preserve_data: false
       message_matcher: "Type == 'heka.all-report'"
+    influxdb_accumulator:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/filters/influxdb_accumulator.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      preserve_data: false
+      message_matcher: "Fields[aggregator] == NIL && Type =~ /metric$/"
+      ticker_interval: 1
+      config:
+        tag_fields: "deployment_id environment_label tenant_id user_id"
+        time_precision: "ms"
   encoder:
     influxdb:
       engine: payload