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

- old
+ new

@@ -49,10 +49,15 @@ config :include_metrics, :validate => :array, :default => [ ".*" ] # Exclude regex matched metric names, by default exclude unresolved %{field} strings. config :exclude_metrics, :validate => :array, :default => [ "%\{[^}]+\}" ] + # Use this field for the timestamp instead of '@timestamp' which is the + # default. Useful when backfilling or just getting more accurate data into + # graphite since you probably have a cache layer infront of Logstash. + config :timestamp_field, :validate => :string, :default => '@timestamp' + # Enable debug output. config :debug, :validate => :boolean, :default => false, :deprecated => "This setting was never used by this plugin. It will be removed soon." # Defines the format of the metric string. The placeholder '*' will be # replaced with the name of the actual metric. @@ -100,10 +105,10 @@ return unless output?(event) # Graphite message format: metric value timestamp\n messages = [] - timestamp = event.sprintf("%{+%s}") + timestamp = event[@timestamp_field].to_i if @fields_are_metrics @logger.debug("got metrics event", :metrics => event.to_hash) event.to_hash.each do |metric,value| next if EXCLUDE_ALWAYS.include?(metric)