Class: Fluent::HatoholOutput

Inherits:
BufferedOutput
  • Object
show all
Defined in:
lib/fluent/plugin/out_hatohol.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



33
34
35
36
# File 'lib/fluent/plugin/out_hatohol.rb', line 33

def configure(conf)
  super
  validate_configuraiton
end

#format(tag, time, record) ⇒ Object



56
57
58
# File 'lib/fluent/plugin/out_hatohol.rb', line 56

def format(tag, time, record)
  [tag, time, record].to_msgpack
end

#shutdownObject



51
52
53
54
# File 'lib/fluent/plugin/out_hatohol.rb', line 51

def shutdown
  super
  @connection.close
end

#startObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fluent/plugin/out_hatohol.rb', line 38

def start
  super
  options = {
    :tls_cert            => @tls_cert,
    :tls_key             => @tls_key,
    :tls_ca_certificates => @tls_ca_certificates,
  }
  @connection = Bunny.new(url || {}, options)
  @connection.start
  @channel = @connection.create_channel
  @queue = @channel.queue(@queue_name)
end

#write(chunk) ⇒ Object



60
61
62
63
64
65
# File 'lib/fluent/plugin/out_hatohol.rb', line 60

def write(chunk)
  chunk.msgpack_each do |tag, time, record|
    @queue.publish(JSON.generate(build_message(tag, time, record)),
                   :content_type => "application/json")
  end
end