Last active
August 29, 2015 14:06
-
-
Save rafrombrc/8d7b5713a694b7f8ca11 to your computer and use it in GitHub Desktop.
Revisions
-
rafrombrc revised this gist
Sep 18, 2014 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,10 @@ local fields = { } local msg = { Fields = fields, Timestamp = nil, Hostname = nil, Type = "metric_message_type" } function process_message() @@ -28,8 +31,6 @@ function process_message() msg.Timestamp = time msg.Hostname = metric.host inject_message(msg) end return 0 end -
rafrombrc revised this gist
Sep 18, 2014 . 1 changed file with 2 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ require "cjson" local fields = { @@ -26,12 +25,8 @@ function process_message() fields.type = metric.type fields.type_instance = metric.type_instance local time = tonumber(metric.time) msg.Timestamp = time msg.Hostname = metric.host inject_message(msg) msg.Timestamp = nil msg.Hostname = nil -
rafrombrc revised this gist
Sep 18, 2014 . 1 changed file with 16 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,30 @@ require "cjson" local fields = { values = {}, interval = 0, plugin = "", plugin_instance = "", ["type"] = "", type_instance = "" } local msg = { Fields = fields } function process_message() local payload = read_message("Payload") local ok, metrics = pcall(cjson.decode, payload) if not ok then return -1 end for i, metric in ipairs(metrics) do fields.values = metric.values fields.interval = metric.interval fields.plugin = metric.plugin fields.plugin_instance = metric.plugin_instance fields.type = metric.type fields.type_instance = metric.type_instance local time = tonumber(metric.time) if time then msg.Timestamp = time @@ -21,6 +33,8 @@ function process_message() msg.Hostname = metric.host end inject_message(msg) msg.Timestamp = nil msg.Hostname = nil end return 0 end -
rafrombrc created this gist
Sep 18, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ require "cjson" function process_message() local payload = read_message("Payload") local ok, metrics = pcall(cjson.decode, payload) if not ok then return -1 end for i, metric in ipairs(metrics) do local fields = {} fields.values = metric.values fields.interval = metric.interval fields.plugin = metric.plugin fields.plugin_instance = metric.plugin_instance fields.type = metric.type fields.type_instance = metric.type_instance local msg = {Fields = fields} local time = tonumber(metric.time) if time then msg.Timestamp = time end if metric.host then msg.Hostname = metric.host end inject_message(msg) end return 0 end