class LogStash::Outputs::MetricCatcher

This output ships metrics to MetricCatcher, allowing you to utilize Coda Hale's Metrics.

More info on MetricCatcher: github.com/clearspring/MetricCatcher

At Clearspring, we use it to count the response codes from Apache logs:

source,ruby

metriccatcher {

host => "localhost"
port => "1420"
type => "apache-access"
fields => [ "response" ]
meter => {
    "%{host}.apache.response.%{response}" => "1"
    }

}

Public Instance Methods

receive(event) click to toggle source
# File lib/logstash/outputs/metriccatcher.rb, line 87
def receive(event)
  @@metric_types.each do |metric_type|
    if instance_variable_defined?("@#{metric_type}")
      instance_variable_get("@#{metric_type}").each do |metric_name, metric_value|
        message = [{
          "name"      => event.sprintf(metric_name),
          "type"      => event.sprintf(metric_type),
          "value"     => event.sprintf(metric_value).to_f,
          "timestamp" => event.sprintf("%{+%s}.") + Time.now.usec.to_s
        }]

        @socket.send(LogStash::Json.dump(message), 0, @host, @port)
      end # instance_variable_get("@#{metric_type}").each_slice
    end # if
  end # @metric_types.each
end
register() click to toggle source
# File lib/logstash/outputs/metriccatcher.rb, line 82
def register
  @socket = UDPSocket.new
end