lib/fluent/plugin/parser_sflow.rb in fluent-plugin-sflow-0.2.1 vs lib/fluent/plugin/parser_sflow.rb in fluent-plugin-sflow-0.3.0
- old
+ new
@@ -1,20 +1,21 @@
-require 'fluent/parser'
+require 'fluent/plugin/parser'
+require 'fluent/time'
require 'json'
require 'sflowtool'
module Fluent
- class TextParser
+ module Plugin
class SflowParser < Parser
Plugin.register_parser('sflow', self)
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 = data['header']['unix_seconds_utc']
+ time = Fluent::EventTime.new(data['header']['unix_seconds_utc'])
data['samples'].each do |sample|
yield time, data['header'].merge(sample)
end
end