Fix fatal error in metric_collector execution

Change-Id: I5aaa06866005b73182217b754fd487c3f8543951
diff --git a/heka/files/lua/decoders/collectd.lua b/heka/files/lua/decoders/collectd.lua
index 8647cd8..9c1ff31 100644
--- a/heka/files/lua/decoders/collectd.lua
+++ b/heka/files/lua/decoders/collectd.lua
@@ -463,10 +463,10 @@
 
                 -- check if the hostname field should be kept or not (eg for
                 -- cluster metrics, discard_hostname == true)
-                if sample['meta']['discard_hostname'] then
+                if sample['meta'] and sample['meta']['discard_hostname'] then
                     msg['Fields']['hostname'] = nil
+                    sample['meta']['discard_hostname'] = nil
                 end
-                sample['meta']['discard_hostname'] = nil
 
                 -- add meta fields as tag_fields
                 for k, v in pairs(sample['meta'] or {}) do