Class: LogStash::Filters::Clone
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::Clone
- Defined in:
- lib/logstash/filters/clone.rb
Overview
The clone filter is for duplicating events. A clone will be created for each type in the clone list. The original event is left unchanged. Created events are inserted into the pipeline as normal events and will be processed by the remaining pipeline configuration starting from the filter that generated them (i.e. this plugin).
ECS disabled: set the value of the root-level ‘type` (undefined in ECS) of each resulting event to one of the values provided in its `clones` directive. ECS enabled: add a `tags` of each resulting event to one of the values provided in its `clones` directive.
Instance Method Summary collapse
- #add_event_tag(event, clone_type) ⇒ Object
- #filter(event) ⇒ Object
-
#initialize(*params) ⇒ Clone
constructor
A new instance of Clone.
- #register ⇒ Object
- #set_event_type(event, type) ⇒ Object
Constructor Details
#initialize(*params) ⇒ Clone
Returns a new instance of Clone.
26 27 28 29 |
# File 'lib/logstash/filters/clone.rb', line 26 def initialize(*params) super @enhance_clone_type_method = method( ecs_select[disabled: :set_event_type, v1: :add_event_tag] ) end |
Instance Method Details
#add_event_tag(event, clone_type) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/logstash/filters/clone.rb', line 53 def add_event_tag(event, clone_type) = Array(event.get("tags")) << clone_type event.set("tags", ) event end |
#filter(event) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/logstash/filters/clone.rb', line 36 def filter(event) @clones.each do |type| clone = event.clone @enhance_clone_type_method.(clone, type) filter_matched(clone) @logger.debug("Cloned event", :clone => clone, :event => event) # Push this new event onto the stack at the LogStash::FilterWorker yield clone end end |
#register ⇒ Object
31 32 33 |
# File 'lib/logstash/filters/clone.rb', line 31 def register logger.warn("The parameter 'clones' is empty, so no clones will be created.") if @clones.empty? end |
#set_event_type(event, type) ⇒ Object
48 49 50 51 |
# File 'lib/logstash/filters/clone.rb', line 48 def set_event_type(event, type) event.set("type", type) event end |