Class: LogStash::Filters::Punct

Inherits:
Base show all
Defined in:
lib/logstash/filters/punct.rb

Overview

Strip everything but punctuation from a field and store the remainder in the a separate field. This is often used for fingerprinting log events.

Constant Summary

Constants inherited from Base

Base::RESERVED

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#execute, #initialize, #threadsafe?

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s

Constructor Details

This class inherits a constructor from LogStash::Filters::Base

Instance Method Details

#filter(event) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/logstash/filters/punct.rb', line 23

def filter(event)
  return unless filter?(event)

  original_value = event[@source]

  # If for some reason the field is an array of values, take the first only.
  original_value = original_value.first if original_value.is_a?(Array)
  event[@target] = original_value.tr('A-Za-z0-9 \t','')
end

#registerObject



18
19
20
# File 'lib/logstash/filters/punct.rb', line 18

def register
  # Nothing to do
end