Class: Fluent::QueryParamsExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/query_params_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plugin, conf) ⇒ QueryParamsExtractor

Returns a new instance of QueryParamsExtractor.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fluent/plugin/query_params_extractor.rb', line 10

def initialize(plugin, conf)
  @log = plugin.log

  if plugin.instance_of?(Fluent::ExtractQueryParamsOutput)
    unless have_tag_option?(plugin)
      raise ConfigError, "out_extract_query_params: At least one of remove_tag_prefix/remove_tag_suffix/add_tag_prefix/add_tag_suffix is required to be set."
    end
  end

  @key = plugin.key
  @only = plugin.only
  @except = plugin.except
  @discard_key = plugin.discard_key
  @add_field_prefix = plugin.add_field_prefix
  @permit_blank_key = plugin.permit_blank_key

  @add_url_scheme = plugin.add_url_scheme
  @add_url_host = plugin.add_url_host
  @add_url_port = plugin.add_url_port
  @add_url_path = plugin.add_url_path

  if @only
    @include_keys = @only.split(/\s*,\s*/).inject({}) do |hash, i|
      hash[i] = true
      hash
    end
  end

  if @except
    @exclude_keys = @except.split(/\s*,\s*/).inject({}) do |hash, i|
      hash[i] = true
      hash
    end
  end
end

Instance Attribute Details

#logObject (readonly)

Returns the value of attribute log.



8
9
10
# File 'lib/fluent/plugin/query_params_extractor.rb', line 8

def log
  @log
end

Instance Method Details

#add_query_params_field(record) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fluent/plugin/query_params_extractor.rb', line 46

def add_query_params_field(record)
  return record unless record[@key]
  url = parse_url(record[@key])
  add_url_scheme(url, record)
  add_url_host(url, record)
  add_url_port(url, record)
  add_url_path(url, record)
  add_query_params(url, record)
  record.delete(@key) if @discard_key
  record
end