Permalink
Browse files

Merge pull request #46 from mleinart/LOGSTASH-176

LOGSTASH-176 - add type and tag filtering to graphite output
  • Loading branch information...
2 parents b1ec14f + a6b72f2 commit 4f67292f55f495cfd2cc0e4fe9991301c87850e3 @fetep fetep committed Sep 8, 2011
Showing with 14 additions and 1 deletion.
  1. +14 −1 lib/logstash/outputs/graphite.rb
View
15 lib/logstash/outputs/graphite.rb
@@ -17,6 +17,16 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
# The port to connect on your graphite server.
config :port, :validate => :number, :default => 2003
+ # Only handle these events matching all of these tags
+ # Optional.
+ config :tags, :validate => :array, :default => []
+
+ # The type to act on. If a type is given, then this output will only
+ # act on messages with the same type. See any input plugin's "type"
+ # attribute for more.
+ # Optional.
+ config :type, :validate => :string, :default => ""
+
# The metric(s) to use. This supports dynamic strings like %{@source_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:
@@ -45,8 +55,11 @@ def connect
public
def receive(event)
+ return unless !event.type.empty? or event.type == @type
+ return unless !@tags.empty? or (event.tags & @tags).size() == @tags.size()
+
# Graphite message format: metric value timestamp\n
-
+
# Catch exceptions like ECONNRESET and friends, reconnect on failure.
@metrics.each do |metric, value|
message = [event.sprintf(metric), event.sprintf(value).to_f,

0 comments on commit 4f67292

Please sign in to comment.