Class: LogStash::Filters::Jdbc::Lookup
- Inherits:
-
Object
- Object
- LogStash::Filters::Jdbc::Lookup
- Includes:
- Util::Loggable
- Defined in:
- lib/logstash/filters/jdbc/lookup.rb
Defined Under Namespace
Classes: Getfier, Sprintfier
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
- #enhance(local, event) ⇒ Object
- #formatted_errors ⇒ Object
- #id_used_as_target? ⇒ Boolean
-
#initialize(options, globals, default_id) ⇒ Lookup
constructor
A new instance of Lookup.
- #valid? ⇒ Boolean
Constructor Details
#initialize(options, globals, default_id) ⇒ Lookup
Returns a new instance of Lookup.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/logstash/filters/jdbc/lookup.rb', line 54 def initialize(, globals, default_id) @id = ["id"] || default_id @target = ["target"] @id_used_as_target = @target.nil? if @id_used_as_target @target = @id end @options = @globals = globals @valid = false @option_errors = [] @default_result = nil end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
52 53 54 |
# File 'lib/logstash/filters/jdbc/lookup.rb', line 52 def id @id end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
52 53 54 |
# File 'lib/logstash/filters/jdbc/lookup.rb', line 52 def parameters @parameters end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
52 53 54 |
# File 'lib/logstash/filters/jdbc/lookup.rb', line 52 def query @query end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
52 53 54 |
# File 'lib/logstash/filters/jdbc/lookup.rb', line 52 def target @target end |
Class Method Details
.find_validation_errors(array_of_options) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/logstash/filters/jdbc/lookup.rb', line 37 def self.find_validation_errors() if !.is_a?(Array) return "The options must be an Array" end errors = [] .each_with_index do |, i| instance = new(, {}, "lookup-#{i.next}") unless instance.valid? errors << instance.formatted_errors end end return nil if errors.empty? errors.join("; ") end |
Instance Method Details
#enhance(local, event) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/logstash/filters/jdbc/lookup.rb', line 81 def enhance(local, event) result = fetch(local, event) # should return a LookupResult if result.failed? || result.parameters_invalid? tag_failure(event) end if result.valid? if @use_default && result.empty? tag_default(event) process_event(event, @default_result) else process_event(event, result) end true else false end end |
#formatted_errors ⇒ Object
77 78 79 |
# File 'lib/logstash/filters/jdbc/lookup.rb', line 77 def formatted_errors @option_errors.join(", ") end |
#id_used_as_target? ⇒ Boolean
69 70 71 |
# File 'lib/logstash/filters/jdbc/lookup.rb', line 69 def id_used_as_target? @id_used_as_target end |
#valid? ⇒ Boolean
73 74 75 |
# File 'lib/logstash/filters/jdbc/lookup.rb', line 73 def valid? @valid end |