Class: Fluent::Plugin::FormatDruidAuditLog2Filter
- Inherits:
-
Filter
- Object
- Filter
- Fluent::Plugin::FormatDruidAuditLog2Filter
- Defined in:
- lib/fluent/plugin/filter_format_druid_audit_log_2.rb
Constant Summary collapse
- NAME =
'format_druid_audit_log_2'- DEFAULT_QUERY_KEY =
'query'- DEFAULT_QUERY_RESULT_KEY =
'query_result'
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #filter(_tag, _time, record) ⇒ Object
- #fix_record(record) ⇒ Object
- #fix_record_query_granularity(record) ⇒ Object
- #format_record(record) ⇒ Object
- #guess_query_type(record) ⇒ Object
- #multi_workers_ready? ⇒ Boolean
Instance Method Details
#configure(conf) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/fluent/plugin/filter_format_druid_audit_log_2.rb', line 21 def configure(conf) super return unless query_key.nil? and query_result.nil? raise Fluent::ConfigError, 'query_key should be specified' end |
#filter(_tag, _time, record) ⇒ Object
33 34 35 36 37 |
# File 'lib/fluent/plugin/filter_format_druid_audit_log_2.rb', line 33 def filter(_tag, _time, record) new_record = format_record(record.dup) fix_record(new_record) new_record end |
#fix_record(record) ⇒ Object
57 58 59 |
# File 'lib/fluent/plugin/filter_format_druid_audit_log_2.rb', line 57 def fix_record(record) fix_record_query_granularity(record) end |
#fix_record_query_granularity(record) ⇒ Object
61 62 63 64 65 |
# File 'lib/fluent/plugin/filter_format_druid_audit_log_2.rb', line 61 def fix_record_query_granularity(record) return if record.dig(query_key, 'granularity').nil? record[query_key]['granularity'] = record[query_key]['granularity'].to_s end |
#format_record(record) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fluent/plugin/filter_format_druid_audit_log_2.rb', line 39 def format_record(record) [query_key, query_result_key].each do |key| record[key] = JSON.parse(record[key]) if record[key].is_a? String end query_type = guess_query_type(record) record['query_type'] = query_type record end |
#guess_query_type(record) ⇒ Object
50 51 52 53 54 55 |
# File 'lib/fluent/plugin/filter_format_druid_audit_log_2.rb', line 50 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
29 30 31 |
# File 'lib/fluent/plugin/filter_format_druid_audit_log_2.rb', line 29 def multi_workers_ready? true end |