This repository was archived by the owner on Feb 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Bugzilla 1149666 #57
Merged
Merged
Bugzilla 1149666 #57
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 characters
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 characters
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") | ||
return 0 | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
andTimestamp
are likely to be of interest.There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.