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.



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

def initialize(conf:)
  @conf = conf
end

Instance Attribute Details

#confObject (readonly)

Returns the value of attribute conf.



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

def conf
  @conf
end

Instance Method Details

#process(_tag, log_es) ⇒ Object



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

def process(_tag, log_es)
  metric_es = []

  log_es.each do |time, 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_es << [time, new_record] }
  end
  metric_es
end