Skip to content
This repository was archived by the owner on Feb 15, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/build_pipeline_heka.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ cp -R $BASE/heka/cmd/heka-export ./cmd/
cp -R $BASE/heka/cmd/heka-s3list ./cmd/
cp -R $BASE/heka/cmd/heka-s3cat ./cmd/

echo 'Installing/updating lua filters/modules/decoders'
echo 'Installing/updating lua filters/modules/decoders/encoders'
rsync -vr $BASE/heka/sandbox/ ./sandbox/lua/

echo 'Updating plugins with local changes'
Expand Down
34 changes: 34 additions & 0 deletions heka/sandbox/encoders/combine_telemetry_objects.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.

require "cjson"
local l = require "lpeg"

local grammar = (l.C"payload" + l.C"environment") * l.P"." * l.C(l.P(1)^1)

function process_message()
local raw = read_message("raw")
local ok, msg = pcall(decode_message, raw)
if not ok then return -1, msg end

if type(msg.Fields) ~= "table" then return -1, "missing Fields" end

local ok, json = pcall(cjson.decode, read_message("Payload"))
if not ok then return -1, json end

for i=1, #msg.Fields do
local section, name = grammar:match(msg.Fields[i].name)
if section then
local ok, object = pcall(cjson.decode, msg.Fields[i].value[1])
if ok then
json[section][name] = object
end
end
end
local ok, payload = pcall(cjson.encode, json)
if not ok then return -1, payload end

inject_payload("txt", "output", msg.clientId, "\t", payload, "\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous data export included the leftover Fields in the output - there are a few things that are not inside the payload that could be useful, though I'm not sure whether they are neccessary or not. geoCountry and Timestamp are likely to be of interest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to pass back the original structure, correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to provide everything in the heka message, with the payload combined back into its original structure.

return 0
end