Open warmfusion opened 4 years ago
Hello,
It looks like you want to set keep_key
to true
in your burrow configuration. You can read about that in the readme here https://github.com/vanilla/fluent-plugin-burrow/blob/master/README.md
action
can be one of 4 values: inplace
, overlay
, replace
, and prefix
. When using overlay
, the default behaviour is to remove the original encoded key, but keep_key
disables that.
Hope this fixes your issue.
That isn't what I need, that'd presumably keep the 'message' block for all events even if the nested value included a message
key or not.
The key being kept is the one from the object inside the message, not the original message itself.
I now see what you're saying. This might be a bug.
Could be that https://github.com/vanilla/fluent-plugin-burrow/blob/master/lib/fluent/plugin/filter_burrow.rb#L88-L93 is moved before the merger.
It still means that if you have a nested key you might overwrite the original value, but not sure theres anything that can be done about that if overlay
is chosen.
def filter(tag, time, record)
raw_value = record[@key_name]
if raw_value then
new_time, new_values = nil, nil
@parser.parse(raw_value) do |parsed_time, parsed_values|
new_time = parsed_time
new_values = parsed_values
end
if new_values then
original_time = record[@record_time_key]
new_time ||= original_time
# Remove the key before we merge the new values in case the merger re-creates the key
if ['overlay','replace','prefix'].include? @action
if not @keep_key and record.has_key?(@key_name)
record.delete(@key_name)
end
end
# Overlay new record on top of original record?
new_record = case @action
when 'inplace'
record.merge({@key_name => new_values})
when 'overlay'
record.merge(new_values)
when 'replace'
new_values
when 'prefix'
record.merge({@data_prefix => new_values})
end
# Preserve 'time' key?
if @keep_time
new_record[@record_time_key] = original_time
end
new_record
end
end
end
Given a json structured rsyslog event which has a field named
message
which includes a jsonformatted json string from an application. And fluent configuration such that themessage
field from rsyslog is parsed as json and overlayed over the original event. When an event is emitted by an app which includesmessage
as part of its log, Then the burrow plugin parses the json, overlays it onto the main record but removes the `message field (which was parsed out of the message.Rsyslog Configuration
FluentD Configuration
Python Test Code
Results
Fluent logs show (Formatted json for readability);
which includes the
message
from rsyslog, and the json formatted string.Once it parses the event we then get
Which does not include the
message
key anymore.Expected
The
message
key from the origin event is replaced with themessage
key parsed from the json-string the origin record contained.