Class: LogStash::Outputs::Riemann

Inherits:
Base show all
Defined in:
lib/logstash/outputs/riemann.rb

Overview

Riemann is a network event stream processing system.

While Riemann is very similar conceptually to Logstash, it has much more in terms of being a monitoring system replacement.

Riemann is used in Logstash much like statsd or other metric-related outputs

You can learn about Riemann here:

You can see the author talk about it here:

Constant Summary

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#handle, #handle_worker, #initialize, #worker_setup, #workers_not_supported

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::Outputs::Base

Instance Method Details

#receive(event) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/logstash/outputs/riemann.rb', line 81

def receive(event)
  return unless output?(event)

  # Let's build us an event, shall we?
  r_event = Hash.new
  r_event[:host] = event.sprintf(@sender)
  # riemann doesn't handle floats so we reduce the precision here
  r_event[:time] = event["@timestamp"].to_i
  r_event[:description] = event["message"]
  if @riemann_event
    @riemann_event.each do |key, val|
      if ["ttl","metric"].include?(key)
        r_event[key.to_sym] = event.sprintf(val).to_f
      else
        r_event[key.to_sym] = event.sprintf(val)
      end
    end
  end
  r_event[:tags] = event["tags"] if event["tags"].is_a?(Array)
  @logger.debug("Riemann event: ", :riemann_event => r_event)
  begin
    proto_client = @client.instance_variable_get("@#{@protocol}")
    @logger.debug("Riemann client proto: #{proto_client.to_s}")
    proto_client << r_event
  rescue Exception => e
    @logger.debug("Unhandled exception", :error => e)
  end
end

#registerObject



75
76
77
78
# File 'lib/logstash/outputs/riemann.rb', line 75

def register
  require 'riemann/client'
  @client = Riemann::Client.new(:host => @host, :port => @port)
end