class LogStash::Outputs::Dogstatsd

dogstatsd is a fork of the statsd protocol which aggregates statistics, such as counters and timers, and ships them over UDP to the dogstatsd-server running as part of the Datadog Agent. Dogstatsd adds support for metric tags, which are used to slice metrics along various dimensions.

You can learn about statsd here:

Typical examples of how this can be used with Logstash include counting HTTP hits by response code, summing the total number of bytes of traffic served, and tracking the 50th and 95th percentile of the processing time of requests.

Example:

source,ruby

output {

dogstatsd {
  metric_tags => ["host:%{host}","role:foo"]
  count => {
    "http.bytes" => "%{bytes}"
  }
}

}

Constants

RESERVED_CHARACTERS_REGEX

Regex stolen from statsd code

Public Instance Methods

close() click to toggle source
# File lib/logstash/outputs/dogstatsd.rb, line 112
def close
  @client.close
end
receive(event) click to toggle source
# File lib/logstash/outputs/dogstatsd.rb, line 78
def receive(event)
  @logger.debug? and @logger.debug("Event: #{event}")

  metric_opts = {
    :sample_rate => @sample_rate,
    :tags => @metric_tags.map { |t| event.sprintf(t) }
  }

  @increment.each do |metric|
    @client.increment(event.sprintf(metric), metric_opts)
  end

  @decrement.each do |metric|
    @client.decrement(event.sprintf(metric), metric_opts)
  end

  @count.each do |metric, val|
    @client.count(event.sprintf(metric), event.sprintf(val), metric_opts)
  end

  @histogram.each do |metric, val|
    @client.histogram(event.sprintf(metric), event.sprintf(val), metric_opts)
  end

  @set.each do |metric, val|
    @client.set(event.sprintf(metric), event.sprintf(val), metric_opts)
  end

  @gauge.each do |metric, val|
    @client.gauge(event.sprintf(metric), event.sprintf(val), metric_opts)
  end
end
register() click to toggle source
# File lib/logstash/outputs/dogstatsd.rb, line 73
def register
  @client = Datadog::Statsd.new(@host, @port)
end