Class: Fluent::RiemannOutput

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

Instance Method Summary collapse

Constructor Details

#initializeRiemannOutput

Returns a new instance of RiemannOutput.



14
15
16
# File 'lib/fluent/plugin/out_riemann.rb', line 14

def initialize
  super
end

Instance Method Details

#clientObject



41
42
43
44
# File 'lib/fluent/plugin/out_riemann.rb', line 41

def client
  @_client ||= Riemann::Client.new :host => @host, :port => @riemannport, :timeout => @timeout
  @protocol == 'tcp' ? @_client.tcp : @_client.udp
end

#configure(c) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fluent/plugin/out_riemann.rb', line 18

def configure(c)
  super

  @_types = parse_map(@types) do |k, t|
    case t
    when "string" then "to_s"
    when "integer" then "to_i"
    when "float" then "to_f"
    else t
    end
  end

  @_fields = parse_map(@fields) { |k, f| (f || k).to_sym }
end

#format(tag, time, record) ⇒ Object



46
47
48
# File 'lib/fluent/plugin/out_riemann.rb', line 46

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

#shutdownObject



37
38
39
# File 'lib/fluent/plugin/out_riemann.rb', line 37

def shutdown
  super
end

#startObject



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

def start
  super
end

#write(chunk) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fluent/plugin/out_riemann.rb', line 50

def write(chunk)
  chunk.msgpack_each do |tag, time, record|
    event = {
      :time => time,
      :service => @service,
      :tags => tag.split('.')
    }

    @_fields.each { |k,v| event[v] = record[k] }
    @_types.each { |k,t| event[k] = event[k].send(t) }

    client << event
  end
end