Class: Fluent::LibratoOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::LibratoOutput
- Defined in:
- lib/fluent/plugin/out_librato.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Instance Method Details
#configure(conf) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/fluent/plugin/out_librato.rb', line 12 def configure(conf) super require 'librato/metrics' Librato::Metrics.authenticate @email, @apikey @queue = Librato::Metrics::Queue.new end |
#format(tag, time, record) ⇒ Object
49 50 51 |
# File 'lib/fluent/plugin/out_librato.rb', line 49 def format(tag, time, record) [tag, time, record].to_msgpack end |
#shutdown ⇒ Object
25 26 27 28 |
# File 'lib/fluent/plugin/out_librato.rb', line 25 def shutdown super @queue.submit end |
#start ⇒ Object
19 20 21 22 23 |
# File 'lib/fluent/plugin/out_librato.rb', line 19 def start # This is where you instantiate resources specific to the output, e.g. # database connections, client library, etc. super end |
#write(chunk) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fluent/plugin/out_librato.rb', line 30 def write(chunk) chunk.msgpack_each { |tag, time, record| missing_keys = [@measurement_key, @value_key, @source_key].select { |k| !record[k] } if missing_keys.length > 0 log.warn "missing the required field(s) " + missing_keys.join(",") next end @queue.add( record[@measurement_key].to_s => { :source => record[@source_key] || tag, :value => record[@value_key], :type => record[@type_key] || "gauge" }) } @queue.submit end |