Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Created June 1, 2015 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matschaffer/bd54aa8d0b91ca4c4c0c to your computer and use it in GitHub Desktop.
Save matschaffer/bd54aa8d0b91ca4c4c0c to your computer and use it in GitHub Desktop.
heka decoder harness - expects "payload" and "config.json" to be in pwd
return {
send = function(ns, message)
print("alert - " .. ns .. ": " .. message)
end
}
#!/usr/bin/env lua
local sandbox_file = arg[1]
local sandbox_file_path = string.gsub(sandbox_file, "(.*/)(.*)", "%1")
local sandbox_module = string.gsub(sandbox_file, "(.*/)(.*)%.(.*)", "%2")
package.path = sandbox_file_path .. "?.lua;" .. package.path
local cj = require "cjson"
local config_file = io.open("config.json", "rb")
local config = cj.decode(config_file:read("*all"))
config_file:close()
function read_config (key)
return config[key]
end
local payload_file = io.open("payload", "rb")
local payload = payload_file:read("*all")
payload_file:close()
function read_message (key)
local message = {
Timestamp = 1420070400000000000,
Payload = payload
}
return message[key]
end
require(sandbox_module)
process_message()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment