Class: Fluent::RiemannOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::RiemannOutput
- Defined in:
- lib/fluent/plugin/out_riemann.rb
Instance Method Summary collapse
- #client ⇒ Object
- #configure(c) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ RiemannOutput
constructor
A new instance of RiemannOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ RiemannOutput
Returns a new instance of RiemannOutput.
15 16 17 |
# File 'lib/fluent/plugin/out_riemann.rb', line 15 def initialize super end |
Instance Method Details
#client ⇒ Object
42 43 44 45 |
# File 'lib/fluent/plugin/out_riemann.rb', line 42 def client @_client ||= Riemann::Client.new :host => @host, :port => @port, :timeout => @timeout @protocol == 'tcp' ? @_client.tcp : @_client.udp end |
#configure(c) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fluent/plugin/out_riemann.rb', line 19 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
47 48 49 |
# File 'lib/fluent/plugin/out_riemann.rb', line 47 def format(tag, time, record) [tag, time, record].to_msgpack end |
#shutdown ⇒ Object
38 39 40 |
# File 'lib/fluent/plugin/out_riemann.rb', line 38 def shutdown super end |
#start ⇒ Object
34 35 36 |
# File 'lib/fluent/plugin/out_riemann.rb', line 34 def start super end |
#write(chunk) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fluent/plugin/out_riemann.rb', line 51 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 |