Class: Fluent::Plugin::SqlFingerprintFilter

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

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



12
13
14
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 12

def configure(conf)
  super
end

#filter(tag, time, record) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 24

def filter(tag, time, record)
  sql = hash_get(record, @target_key)
  if !sql.nil? && !sql.empty?
    record[@added_key] = fingerprint(sql)
  end
  record
end

#fingerprint(sql) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 32

def fingerprint(sql)
  unless sql.empty?
    o, s = Open3.capture2(@fingerprint_tool_path, :stdin_data => sql)
    if s.success?
      o.chomp!
      sql = o unless o.empty? 
    end
  end
  sql
end

#hash_get(hash, key) ⇒ Object



43
44
45
46
47
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 43

def hash_get(hash, key)
  return hash[key.to_sym] if hash.key?(key.to_sym)
  return hash[key] if hash.key?(key)
  nil
end

#shutdownObject



20
21
22
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 20

def shutdown
  super
end

#startObject



16
17
18
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 16

def start
  super
end