Class: Fluent::Plugin::FormatDruidAuditLog1Filter

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

Constant Summary collapse

NAME =
'format_druid_audit_log_1'
DEFAULT_QUERY_KEY =
'query'

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object

Raises:

  • (Fluent::ConfigError)


18
19
20
21
22
23
24
# File 'lib/fluent/plugin/filter_format_druid_audit_log_1.rb', line 18

def configure(conf)
  super

  return unless query_key.nil?

  raise Fluent::ConfigError, 'query_key should be specified'
end

#filter(_tag, _time, record) ⇒ Object



30
31
32
33
34
# File 'lib/fluent/plugin/filter_format_druid_audit_log_1.rb', line 30

def filter(_tag, _time, record)
  new_record = format_record(record)
  fix_timeseries_record(new_record)
  new_record
end

#fix_timeseries_record(record) ⇒ Object



52
53
54
55
56
57
# File 'lib/fluent/plugin/filter_format_druid_audit_log_1.rb', line 52

def fix_timeseries_record(record)
  return unless record['query_type'] == 'timeseries'
  return unless record['timeseries_query']['granularity']

  record['timeseries_query']['granularity'] = record['timeseries_query']['granularity'].to_s
end

#format_record(record) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/fluent/plugin/filter_format_druid_audit_log_1.rb', line 36

def format_record(record)
  query_type = guess_query_type(record)

  new_record = record.except(query_key)
  new_record['query_type'] = query_type
  new_record["#{query_type}_query".downcase] = record[query_key].dup
  new_record
end

#guess_query_type(record) ⇒ Object



45
46
47
48
49
50
# File 'lib/fluent/plugin/filter_format_druid_audit_log_1.rb', line 45

def guess_query_type(record)
  record.dig(query_key,
             'queryType') || (record.dig('query_result',
                                         'sqlQuery/time') && 'sql') || (record.dig(query_key,
                                                                                   'query') && 'sql') || 'unknown'
end

#multi_workers_ready?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/fluent/plugin/filter_format_druid_audit_log_1.rb', line 26

def multi_workers_ready?
  true
end