Skip to content
Closed
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
11 changes: 9 additions & 2 deletions lib/logstash/filters/split.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ def filter(event)
# Using -1 for 'limit' on String#split makes ruby not drop trailing empty
# splits.
splits = original_value.split(@terminator, -1)
elsif original_value.is_a?(Hash)
splits = original_value.keys
else
raise LogStash::ConfigurationError, "Only String and Array types are splittable. field:#{@field} is of type = #{original_value.class}"
raise LogStash::ConfigurationError, "Only String, Array, and Hash types are splittable. field:#{@field} is of type = #{original_value.class}"
end

# Skip filtering if splitting this event resulted in only one thing found.
Expand All @@ -55,7 +57,12 @@ def filter(event)

event_split = event.clone
@logger.debug("Split event", :value => value, :field => @field)
event_split[(@target || @field)] = value

if original_value.is_a?(Hash)
event_split[(@target || @field)] = { value => original_value[value] }
else
event_split[(@target || @field)] = value
end
filter_matched(event_split)

# Push this new event onto the stack at the LogStash::FilterWorker
Expand Down