Deserialize bulk metrics based on the source field

Using the Logger field isn't convenient because the Logger value is
set by the name of the filter plugin in the TOML configuration. If we
were to change the naming format for filters, it would break the
deserialization of metrics.

Change-Id: Ie95618acc97e5dfa16c0286253709d359aea6af1
diff --git a/heka/files/lua/decoders/metric.lua b/heka/files/lua/decoders/metric.lua
index 9b26158..75cec5e 100644
--- a/heka/files/lua/decoders/metric.lua
+++ b/heka/files/lua/decoders/metric.lua
@@ -18,19 +18,19 @@
 local l = require 'lpeg'
 l.locale(l)
 
-local loggers_pattern = l.Ct( (l.C((l.P(1) - l.space)^1) * l.space^0)^1 * -1)
-local loggers_list = loggers_pattern:match(read_config('deserialize_bulk_metric_for_loggers') or '')
+local split_on_space = l.Ct( (l.C((l.P(1) - l.space)^1) * l.space^0)^1 * -1)
+local sources_list = split_on_space:match(read_config('deserialize_for_sources') or '')
 
-local loggers = {}
-for _, logger in ipairs(loggers_list) do
-    loggers[logger] = true
+local sources = {}
+for _, s in ipairs(sources_list) do
+    sources[s] = true
 end
 
 local utils = require 'lma_utils'
 
 function process_message ()
     local msg = decode_message(read_message("raw"))
-    if string.match(msg.Type, 'bulk_metric$') and loggers[msg.Logger] ~= nil then
+    if string.match(msg.Type, 'bulk_metric$') and sources[msg.Fields.source] then
 
         local ok, metrics = pcall(cjson.decode, msg.Payload)
         if not ok then
diff --git a/heka/meta/heka.yml b/heka/meta/heka.yml
index b981d50..23d82a1 100644
--- a/heka/meta/heka.yml
+++ b/heka/meta/heka.yml
@@ -78,7 +78,7 @@
       module_file: /usr/share/lma_collector/decoders/metric.lua
       module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
       config:
-        deserialize_bulk_metric_for_loggers: 'aggregated_http_metrics_filter hdd_errors_filter log_counter_filter'
+        deserialize_for_sources: 'log_collector'
   input:
     heka_collectd:
       engine: http