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



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fluent/plugin/out_hosted_graphite.rb', line 26

def emit(tag, es, chain)
  chain.next
  es.each {|time,record|
    unless record.include?(@metric_key)
      log.warn "metric_key does not exists."
    else
      metric_key = @metric_key
      metric = record[@metric_key].to_f
      post_metrics(metric_key, metric)
    end
  }
end

#post_metrics(metric_key, metric) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fluent/plugin/out_hosted_graphite.rb', line 40

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} #{result} - #{metric_key} - #{metric}"
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