Transforms a generic lua table into the Heka message schema.
The configuration allows a grammar or a function to be specified for the initial parse and a map configuration allows the resulting table to be transformed; variables renamed, moved, and cast to their desired types.
1. Decoder Configuration Table
decoders_heka_table_to_message = {
module_name = "lpeg.logfmt"
module_grammar = "grammar" -- or -- module_function = "decode"
map = { -- optional if not provided a default mapping will be used
-- see https://mozilla-services.github.io/lua_sandbox_extensions/heka/modules/heka/util.html#table_to_message
time = {header = "Timestamp"},
len = {field = "length", type = "int", representation = "inches"}
}
}
2. Functions
2.1. decode
Decode and inject the resulting message
Arguments
- data (string) - input data to be parsed
- default_headers (optional table) - Heka message table containing the default header values to use, if they are not populated by the decoder. If 'Fields' is specified it should be in the hashed based format see: http://mozilla-services.github.io/lua_sandbox/heka/message.html
Return
- nil - throws an error on an invalid data type, parse error, inject_message failure etc.
source code: table_to_message.lua