Class: Fluent::Plugin::ParseMultipleValueQueryOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::ParseMultipleValueQueryOutput
- Defined in:
- lib/fluent/plugin/out_parse_multiple_value_query.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ ParseMultipleValueQueryOutput
constructor
A new instance of ParseMultipleValueQueryOutput.
- #multi_workers_ready? ⇒ Boolean
- #parse_query_string(record, query_string) ⇒ Object
- #parse_uri(record) ⇒ Object
- #process(tag, es) ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ ParseMultipleValueQueryOutput
Returns a new instance of ParseMultipleValueQueryOutput.
16 17 18 19 |
# File 'lib/fluent/plugin/out_parse_multiple_value_query.rb', line 16 def initialize super require 'rack' end |
Instance Method Details
#configure(conf) ⇒ Object
24 25 26 |
# File 'lib/fluent/plugin/out_parse_multiple_value_query.rb', line 24 def configure(conf) super end |
#multi_workers_ready? ⇒ Boolean
36 37 38 |
# File 'lib/fluent/plugin/out_parse_multiple_value_query.rb', line 36 def multi_workers_ready? true end |
#parse_query_string(record, query_string) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/fluent/plugin/out_parse_multiple_value_query.rb', line 66 def parse_query_string(record, query_string) begin target = sub_key ? (record[sub_key] ||= {}) : record parsed_query = Rack::Utils.parse_nested_query(query_string) parsed_query.each do |key, value| if value == '' target[key] = '' else if value.class == Array && remove_empty_array if value.empty? || value == [''] || value == [nil] target.delete(key) else target[key] = value end else target[key] = value end end end rescue StandardError => e log.warn("out_parse_multiple_value_uri_query: error_class:#{e.class} error_message:#{e.message} record:#{record} bactrace:#{e.backtrace.first}") end record end |
#parse_uri(record) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fluent/plugin/out_parse_multiple_value_query.rb', line 54 def parse_uri(record) return unless record[key] if only_query_string parse_query_string(record, record[key]) else url = without_host ? "http://example.com#{record[key]}" : record[key] query = URI.parse(url).query parse_query_string(record, query) end end |
#process(tag, es) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fluent/plugin/out_parse_multiple_value_query.rb', line 40 def process(tag, es) es.each do |time, record| t = tag.dup new_record = parse_uri(record) t = @tag_prefix + t unless @tag_prefix.nil? router.emit(t, time, new_record) end chain.next rescue StandardError => e log.warn("out_parse_multiple_value_uri_query: error_class:#{e.class} error_message:#{e.message} tag:#{tag} es:#{es} bactrace:#{e.backtrace.first}") end |
#shutdown ⇒ Object
32 33 34 |
# File 'lib/fluent/plugin/out_parse_multiple_value_query.rb', line 32 def shutdown super end |
#start ⇒ Object
28 29 30 |
# File 'lib/fluent/plugin/out_parse_multiple_value_query.rb', line 28 def start super end |