class Fluent::DeisGraphiteOutput

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_deis-graphite.rb, line 17
def initialize

  #Get the cluster name from Google metadata service
  begin
    response = RestClient::Request.execute(method: :get, url: 'http://metadata.google.internal/computeMetadata/v1/instance/attributes/cluster-name',
                        timeout: 10, headers: { "Metadata-Flavor" => "Google"})
    if response.code == 200
      @cluster_name=response.body
    end
  rescue
    p "Couldn't determine cluster name."
  end

  super
end

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_deis-graphite.rb, line 44
def configure(conf)
  super
end
emit(tag, es, chain) click to toggle source
# File lib/fluent/plugin/out_deis-graphite.rb, line 48
def emit(tag, es, chain)
  es.each do |time,record|
    if record.key? "kubernetes"
      if record["kubernetes"]["container_name"] == "deis-router"
        begin
          split_message = record["log"].split(" - ")
          app = split_message[1].strip
          status_code = split_message[4].strip
          #bytes_sent = split_message[6].strip.to_f
          #response_time = split_message[12].strip.to_f
          #request_time = split_message[13].strip.to_f

          Metriks.meter("response_rates.#{@cluster_name}.#{record["kubernetes"]["pod_name"]}.#{app}.#{status_code}").mark
        rescue Exception => e
          puts "Failed to parse: \'#{record}\'. Got exception #{e}"
        end
      end
     end
  end
  chain.next
end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_deis-graphite.rb, line 40
def shutdown
  super
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_deis-graphite.rb, line 33
def start
  super
  puts "Starting reporter: #{@graphite_url}:#{@graphite_port}/#{@graphite_interval}"
  @reporter = Metriks::Reporter::Graphite.new @graphite_url, @graphite_port,:interval => @graphite_interval
  @reporter.start
end