class Fluent::LibratoOutput

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# 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) click to toggle source
# File lib/fluent/plugin/out_librato.rb, line 49
def format(tag, time, record)
  [tag, time, record].to_msgpack
end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_librato.rb, line 25
def shutdown
  super
  @queue.submit
end
start() click to toggle source
Calls superclass method
# 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) click to toggle source
# 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