Module: Fluent::ExceptionDetectorConfig

Defined in:
lib/fluent/plugin/exception_detector.rb

Overview

Configuration of the state machine that detects exceptions.

Defined Under Namespace

Classes: RuleTarget

Constant Summary collapse

JAVA_RULES =
[
  rule(:start_state, /(?:Exception|Error|Throwable|V8 errors stack trace)[:\r\n]/, :java),
  rule(:start_state, /(?:ERROR|WARN)(\s+\[)/, :java_stack_begin),
  rule(:java_stack_begin, /(?:Exception|Error|Throwable|V8 errors stack trace)[:\r\n]/, :java),
  rule(:java, /^[\t ]+(?:eval )?at /, :java),
  rule(:java, /^(?:eval )?! at/, :java),
  rule(:java, /^[\t ]*(?:Caused by|Suppressed):/, :java),
  rule(:java, /^[\t ]*... \d+\ (more|common frames omitted)/, :java)
].freeze
KAFKA_RULES =
[
  rule(:start_state, /(?:ERROR|WARN)(\s+\[).*kafka/, :kafka_failure_info),
  rule(:start_state, /^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z (?:ERROR|WARN)/, :kafka_failure_info),
  rule(:kafka_failure_info, /NoKafkaConnectionError/, :kafka_failure_info),
  rule(:kafka_failure_info, /^(\s)*server: 'kafka/, :kafka_failure_info),
  rule(:kafka_failure_info, /^(\s)*message:/, :kafka_failure_info),
  rule(:kafka_failure_info, /^Message-Timestamp: /, :kafka_failure_info),
  rule(:kafka_failure_info, /^Message-Type: /, :kafka_failure_info),
  rule(:kafka_failure_info, /^Origin-System-Id: /, :kafka_failure_info),
  rule(:kafka_failure_info, /^Origin-Host-Location: /, :kafka_failure_info),
  rule(:kafka_failure_info, /^Content-Type: /, :kafka_failure_info),
  rule(:kafka_failure_info, /^Origin-Host: /, :kafka_failure_info),
  rule(:kafka_failure_info, /^{*.+}+*.partitionKey*.+topic/, :kafka_failure_info),
  rule(:kafka_failure_info, /^Message-Id: [a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/, :java),
  rule(:kafka_failure_info, /^\[at /, :java),
  rule(:kafka_failure_info, /(?:Exception|Error|Throwable|V8 errors stack trace)[:\r\n]/, :java),
  rule(:java, /^(?:eval )?! at/, :java)      
].freeze
PYTHON_RULES =
[
  rule(:start_state, /Traceback \(most recent call last\)/, :python),
  rule(:python, /^[\t ]+File /, :python_code),
  rule(:python_code, /[^\t ]/, :python),
  rule(:python, /^(?:[^\s.():]+\.)*[^\s.():]+:/, :start_state)
].freeze
ELIXIR_RULES =
[
  rule(:start_state, /^\d{2}:\d{2}:\d{2}\.\d{3} \[error\] /, :elixir_failure_info),
  rule(:elixir_failure_info, /^[^\d]/, :elixir_failure_info)
].freeze
PHP_RULES =
[
  rule(:start_state, /
    (?:PHP\ (?:Notice|Parse\ error|Fatal\ error|Warning):)|
    (?:exception\ '[^']+'\ with\ message\ ')/x, :php_stack_begin),
  rule(:php_stack_begin, /^Stack trace:/, :php_stack_frames),
  rule(:php_stack_frames, /^#\d/, :php_stack_frames),
  rule(:php_stack_frames, /^\s+thrown in /, :start_state)
].freeze
GO_RULES =
[
  rule(:start_state, /panic: /, :go_before_goroutine),
  rule(:go_before_goroutine, /^$/, :go_goroutine),
  rule(:go_goroutine, /^goroutine \d+ \[[^\]]+\]:$/, :go_frame_1),
  rule(:go_frame_1, /(?:[^\s.():]+\.)*[^\s.():]\(/, :go_frame_2),
  rule(:go_frame_1, /^$/, :go_before_goroutine),
  rule(:go_frame_2, /^\s/, :go_frame_1)
].freeze
RUBY_RULES =
[
  rule(:start_state, /Error \(.*\):$/, :ruby),
  rule(:ruby, /^[\t ]+.*?\.rb:\d+:in `/, :ruby)
].freeze
ALL_RULES =
(
KAFKA_RULES + JAVA_RULES + PYTHON_RULES + PHP_RULES + GO_RULES + RUBY_RULES + ELIXIR_RULES).freeze
RULES_BY_LANG =
{
  java: JAVA_RULES + KAFKA_RULES,
  javascript: JAVA_RULES + KAFKA_RULES,
  js: JAVA_RULES + KAFKA_RULES,
  csharp: JAVA_RULES,
  py: PYTHON_RULES,
  python: PYTHON_RULES,
  php: PHP_RULES,
  go: GO_RULES,
  rb: RUBY_RULES,
  ruby: RUBY_RULES,
  elixir: ELIXIR_RULES,
  all: ALL_RULES
}.freeze
DEFAULT_FIELDS =
%w(message log).freeze

Class Method Summary collapse

Class Method Details

.rule(from_state, pattern, to_state) ⇒ Object



44
45
46
# File 'lib/fluent/plugin/exception_detector.rb', line 44

def self.rule(from_state, pattern, to_state)
  Struct::Rule.new(from_state, pattern, to_state)
end

.supportedObject



48
49
50
# File 'lib/fluent/plugin/exception_detector.rb', line 48

def self.supported
  RULES_BY_LANG.keys
end