Class: Fluent::OutHostedGraphite

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_hosted_graphite.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



11
12
13
14
# File 'lib/fluent/plugin/out_hosted_graphite.rb', line 11

def configure(conf)
  super
  #
end

#emit(tag, es, chain) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fluent/plugin/out_hosted_graphite.rb', line 34

def emit(tag, es, chain)
  chain.next
  es.each do |time,record|
    @metric_key.each do |metric_key|
      record.select do |k,v|
        if metric_key.include?(k)
          metric = record[k].to_f
          post_metrics(k, metric)
        end
      end
    end
  end
end

#post_metrics(metric_key, metric) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fluent/plugin/out_hosted_graphite.rb', line 48

def post_metrics(metric_key, metric)
  HostedGraphite.api_key = @api_key
  case @protocol
  when "http"
    HostedGraphite.protocol = HostedGraphite::HTTP
  when "tcp"
    HostedGraphite.protocol = HostedGraphite::TCP
  when "udp"
    HostedGraphite.protocol = HostedGraphite::UDP
  end
  HostedGraphite.send_metric(metric_key, metric)
  #result = HostedGraphite.send_metric(metric_key, metric)
  #puts "debug_out: #{@api_key} #{@protocol} - #{metric_key} - #{metric}\n"
end

#shutdownObject



21
22
23
24
# File 'lib/fluent/plugin/out_hosted_graphite.rb', line 21

def shutdown
  super
  # ...
end

#startObject



16
17
18
19
# File 'lib/fluent/plugin/out_hosted_graphite.rb', line 16

def start
  super
  # ...
end