Class: Fluent::KubernetesTaggedRemoteSyslogOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::KubernetesTaggedRemoteSyslogOutput
- Defined in:
- lib/fluent/plugin/out_kubernetes_tagged_remote_syslog.rb
Instance Method Summary collapse
- #emit(tag, es, chain) ⇒ Object
-
#initialize ⇒ KubernetesTaggedRemoteSyslogOutput
constructor
A new instance of KubernetesTaggedRemoteSyslogOutput.
- #shutdown ⇒ Object
Constructor Details
#initialize ⇒ KubernetesTaggedRemoteSyslogOutput
Returns a new instance of KubernetesTaggedRemoteSyslogOutput.
14 15 16 17 18 |
# File 'lib/fluent/plugin/out_kubernetes_tagged_remote_syslog.rb', line 14 def initialize super require "remote_syslog_logger" @loggers = {} end |
Instance Method Details
#emit(tag, es, chain) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fluent/plugin/out_kubernetes_tagged_remote_syslog.rb', line 25 def emit(tag, es, chain) es.each do |_time, record| record.each_pair do |_k, v| if v.is_a?(String) v.force_encoding('utf-8') end end next if skip_namespaces.include?(record.dig('kubernetes', 'namespace_name')) @loggers[tag] ||= RemoteSyslogLogger::UdpSender.new( @host, @port, facility: record['facility'] || @facility, severity: record['severity'] || @severity, program: (record.dig('kubernetes', @program) || @program)[0...31], local_hostname: (record.dig('kubernetes', @hostname) || @hostname)[0...31]) @loggers[tag].transmit((if record.key?('log') then record['log'] else record end).to_s) end chain.next end |
#shutdown ⇒ Object
20 21 22 23 |
# File 'lib/fluent/plugin/out_kubernetes_tagged_remote_syslog.rb', line 20 def shutdown @loggers.values.each(&:close) super end |