Class: Fluent::Plugin::SflowParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/fluent/plugin/parser_sflow.rb

Instance Method Summary collapse

Instance Method Details

#parse(raw, remote_host) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/fluent/plugin/parser_sflow.rb', line 13

def parse(raw, remote_host)
  data = JSON.load(Sflowtool.parse(raw, remote_host))

  # NOTE: sFlow datagram doesn't have timestamp field, but sysUpTime only
  time = Fluent::EventTime.new(data['header']['unix_seconds_utc'])

  data['samples'].each do |sample|
    yield time, data['header'].merge(sample)
  end
end