Class: Fluent::Plugin::ElasticLog::AuditLogToMetricProcessor

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

Overview

convert audit log event stream to metric event stream

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf:) ⇒ AuditLogToMetricProcessor

Returns a new instance of AuditLogToMetricProcessor.



14
15
16
# File 'lib/fluent/plugin/elastic_log/audit_log_to_metric_processor.rb', line 14

def initialize(conf:)
  @conf = conf
end

Instance Attribute Details

#confObject (readonly)

Returns the value of attribute conf.



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

def conf
  @conf
end

Instance Method Details

#process(_tag, log_es) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fluent/plugin/elastic_log/audit_log_to_metric_processor.rb', line 18

def process(_tag, log_es)
  metric_acc = new_metric_accumulator

  log_es.each_value do |record|
    next unless record
    next unless (category = record[conf.category_key])
    next unless conf.categories.include? category

    new_records = send("generate_#{category.downcase}_metrics_for", record)
    new_records&.each { |new_record| metric_acc << new_record }
  end
  metric_acc.to_a
end