Class: LogStash::Inputs::Graphite

Inherits:
Tcp show all
Defined in:
lib/logstash/inputs/graphite.rb

Overview

Receive graphite metrics. This plugin understands the text-based graphite carbon protocol. Both ‘N’ and specific-timestamp forms are supported, example:

mysql.slow_query.count 204 N
haproxy.live_backends 7 1364608909

‘N’ means ‘now’ for a timestamp. This plugin also supports having the time specified in the metric payload:

For every metric received from a client, a single event will be emitted with the metric name as the field (like ‘mysql.slow_query.count’) and the metric value as the field’s value.

Constant Summary collapse

ISO8601_STRFTIME =
"%04d-%02d-%02dT%02d:%02d:%02d.%06d%+03d:00".freeze

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes inherited from Base

#params, #threadable

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Tcp

#initialize, #register, #run_client, #run_server, #teardown

Methods inherited from Base

#initialize, #register, #tag

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s

Constructor Details

This class inherits a constructor from LogStash::Inputs::Tcp

Instance Method Details

#<<(event) ⇒ Object

This is a silly hack to make the superclass (Tcp) give us a finished event so that we can parse it accordingly.



31
32
33
34
35
36
37
38
39
40
# File 'lib/logstash/inputs/graphite.rb', line 31

def <<(event)
  name, value, time = event["message"].split(" ")
  event[name] = value.to_f

  if time != "N"
    event["@timestamp"] = Time.at(time.to_i).gmtime
  end

  @queue << event
end

#run(output_queue) ⇒ Object



24
25
26
27
# File 'lib/logstash/inputs/graphite.rb', line 24

def run(output_queue)
  @queue = output_queue
  super(self)
end