Class: LogStash::Outputs::Jut

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/jut.rb

Instance Method Summary collapse

Instance Method Details

#receive(event) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/logstash/outputs/jut.rb', line 41

def receive(event)
  return unless output?(event)

  # logstash wants to create "@timestamp", but jut wants "time"
  # you could of course do this with a mutate filter but lets make
  # the common case easy...
  if event.include?('@timestamp')
    event['time'] = event.remove('@timestamp')
  end

  if event.include?('@version')
    event.remove('@version')
  end

  evt = event.to_hash
  @batcher.receive(evt)

rescue Exception => e
  @logger.warn("Unhandled exception", :exception => e, :stacktrace => e.backtrace)
end

#registerObject



36
37
38
# File 'lib/logstash/outputs/jut.rb', line 36

def register
  @batcher = LogStash::Outputs::HTTPBatcher.new(@url, @interval, @logger, @headers, @limit, @threads, @verbose)
end

#teardownObject



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/logstash/outputs/jut.rb', line 63

def teardown
  if @verbose
    puts "tearing down jut output plugin"
  end

  @batcher.stop

  if @verbose
    puts "finished"
  end
end