Merge branch 'master' of https://github.com/invadersmustdie/logstash into invadersmustdie-master

This commit is contained in:
Jordan Sissel 2012-12-27 16:35:45 -08:00
commit 3132c2a5fc
3 changed files with 10 additions and 2 deletions

View file

@ -1,7 +1,7 @@
require "json"
require "time"
require "date"
require "logstash/time"
require "logstash/time_addon"
require "logstash/namespace"
require "uri"
@ -234,7 +234,7 @@ class LogStash::Event
# Got %{+%s}, support for unix epoch time
if RUBY_ENGINE != "jruby"
# This is really slow. See LOGSTASH-217
Date.parse(self.timestamp).to_i
Time.parse(self.timestamp).to_i
else
datetime = @@date_parser.parseDateTime(self.timestamp)
(datetime.getMillis / 1000).to_i

View file

@ -28,6 +28,9 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
# coerced will zero (0)
config :metrics, :validate => :hash, :required => true
# Enable debug output
config :debug, :validate => :boolean, :default => false
def register
connect
end # def register
@ -52,8 +55,13 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
# Catch exceptions like ECONNRESET and friends, reconnect on failure.
@metrics.each do |metric, value|
@logger.debug("processing", :metric => metric, :value => value)
message = [event.sprintf(metric), event.sprintf(value).to_f,
event.sprintf("%{+%s}")].join(" ")
@logger.debug("Sending carbon message", :message => message, :host => @host, :port => @port)
# TODO(sissel): Test error cases. Catch exceptions. Find fortune and glory.
begin
@socket.puts(message)