Class: Fluent::Plugin::PostgreSQLRedactor

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

Instance Method Summary collapse

Instance Method Details

#filter(_tag, _time, record) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fluent/plugin/filter_postgresql_redactor.rb', line 19

def filter(_tag, _time, record)
  statement = record[@input_key]

  return record unless statement

  normalized = PgQuery.normalize(statement)
  record[@fingerprint_key] = PgQuery.parse(normalized).fingerprint if @fingerprint_key

  record.delete(@input_key)
  record[@output_key] = normalized

  record
rescue PgQuery::ParseError
  record['pg_query_error'] = true
  record
end