Class: LogStash::Outputs::MetricCatcher
- Inherits:
-
Base
- Object
- Base
- LogStash::Outputs::MetricCatcher
- Defined in:
- lib/logstash/outputs/metriccatcher.rb
Overview
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" }}
Instance Method Summary collapse
Instance Method Details
#receive(event) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# 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| = [{ "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(), 0, @host, @port) end # instance_variable_get("@#{metric_type}").each_slice end # if end # @metric_types.each end |
#register ⇒ Object
82 83 84 |
# File 'lib/logstash/outputs/metriccatcher.rb', line 82 def register @socket = UDPSocket.new end |