lib/logstash/outputs/metriccatcher.rb in logstash-output-metriccatcher-0.1.4 vs lib/logstash/outputs/metriccatcher.rb in logstash-output-metriccatcher-0.1.5

- old
+ new

@@ -1,9 +1,9 @@ # encoding: utf-8 require "logstash/outputs/base" require "logstash/namespace" -require "json" +require "logstash/json" # This output ships metrics to MetricCatcher, allowing you to # utilize Coda Hale's Metrics. # @@ -14,11 +14,13 @@ # metriccatcher { # host => "localhost" # port => "1420" # type => "apache-access" # fields => [ "response" ] -# meter => [ "%{host}.apache.response.%{response}", "1" ] +# meter => { +# "%{host}.apache.response.%{response}" => "1" +# } # } class LogStash::Outputs::MetricCatcher < LogStash::Outputs::Base config_name "metriccatcher" # The address of the MetricCatcher @@ -36,11 +38,11 @@ # The metrics to send. This supports dynamic strings like `%{host}` # for metric names and also for values. This is a hash field with key # of the metric name, value of the metric value. Example: # [source,ruby] - # counter => [ "%{host}.apache.hits.%{response}, "1" ] + # counter => { "%{host}.apache.hits.%{response} => "1" } # # The value will be coerced to a floating point value. Values which cannot be # coerced will zero (0) config :counter, :validate => :hash @@ -70,11 +72,11 @@ # The metrics to send. This supports dynamic strings like %{host} # for metric names and also for values. This is a hash field with key # of the metric name, value of the metric value. Example: # [source,ruby] - # timer => [ "%{host}.apache.response_time, "%{response_time}" ] + # timer => { "%{host}.apache.response_time => "%{response_time}" } # # The value will be coerced to a floating point value. Values which cannot be # coerced will zero (0) config :timer, :validate => :hash @@ -94,10 +96,10 @@ "type" => event.sprintf(metric_type), "value" => event.sprintf(metric_value).to_f, "timestamp" => event.sprintf("%{+%s}.") + Time.now.usec.to_s }] - @socket.send(message.to_json, 0, @host, @port) + @socket.send(LogStash::Json.dump(message), 0, @host, @port) end # instance_variable_get("@#{metric_type}").each_slice end # if end # @metric_types.each end # def receive end # class LogStash::Outputs::MetricCatcher