Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .overcommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
PreCommit:
HardTabs:
enabled: true

RuboCop:
enabled: true
command: ['bundle', 'exec', 'rubocop']

TrailingWhitespace:
enabled: true

# Overcommit will use the repo's Gemfile when loading the Bundler context
gemfile: Gemfile
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jruby-9.2.0.0
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.1.0
- improved test design to be more rspec3 friendly, including the usage
of random ports to avoid colisions in integration test.
# 2.0.0
- Updates from logstash-output-statsd v2.0.5.
- Upgraded logstash-core dependency to 2.0.
- Upgraded dogstatsd-ruby dependency to 1.6.

# 0.9.0
- First version of logstash-output-dogstatsd, forked from v1.1.0 of
logstash-output-statsd.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
source 'https://rubygems.org'
gemspec
gemspec
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Logstash Plugin

This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
This is a plugin for [Logstash](https://github.com/elastic/logstash).

It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.

## Documentation

Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).

- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide

## Need Help?

Expand Down Expand Up @@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and

It is more important to the community that you are able to contribute.

For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
115 changes: 115 additions & 0 deletions lib/logstash/outputs/dogstatsd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# encoding: utf-8
require "logstash/outputs/base"
require "logstash/namespace"
require "datadog/statsd"

# 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:
#
# * https://codeascraft.com/2011/02/15/measure-anything-measure-everything/[Etsy blog post announcing statsd]
# * https://github.com/etsy/statsd[statsd on github]
#
# 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}"
# }
# }
# }
class LogStash::Outputs::Dogstatsd < LogStash::Outputs::Base
## Regex stolen from statsd code
RESERVED_CHARACTERS_REGEX = /[\:\|\@]/
config_name "dogstatsd"

# The hostname or IP address of the dogstatsd server.
config :host, :validate => :string, :default => "localhost"

# The port to connect to on your dogstatsd server.
config :port, :validate => :number, :default => 8125

# An increment metric. Metric names as array. `%{fieldname}` substitutions are
# allowed in the metric names.
config :increment, :validate => :array, :default => []

# A decrement metric. Metric names as array. `%{fieldname}` substitutions are
# allowed in the metric names.
config :decrement, :validate => :array, :default => []

# A histogram metric, which a statsd timing but conceptually maps to any
# numeric value, not just durations. `metric_name => value` as hash. `%{fieldname}`
# substitutions are allowed in the metric names.
config :histogram, :validate => :hash, :default => {}

# A count metric. `metric_name => count` as hash. `%{fieldname}` substitutions are
# allowed in the metric names.
config :count, :validate => :hash, :default => {}

# A set metric. `metric_name => "string"` to append as hash. `%{fieldname}`
# substitutions are allowed in the metric names.
config :set, :validate => :hash, :default => {}

# A gauge metric. `metric_name => gauge` as hash. `%{fieldname}` substitutions are
# allowed in the metric names.
config :gauge, :validate => :hash, :default => {}

# The sample rate for the metric.
config :sample_rate, :validate => :number, :default => 1

# The tags to apply to each metric.
config :metric_tags, :validate => :array, :default => []

public
def register
@client = Datadog::Statsd.new(@host, @port)
end # def register

public
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 # def receive

public
def close
@client.close
end # def close
end # class LogStash::Outputs::Statsd
128 changes: 0 additions & 128 deletions lib/logstash/outputs/statsd.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Gem::Specification.new do |s|

s.name = 'logstash-output-statsd'
s.version = '1.1.0'
s.name = 'logstash-output-dogstatsd'
s.version = '6.0.0'
s.licenses = ['Apache License (2.0)']
s.summary = "Send metrics to StatsD"
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
s.authors = ["Elastic"]
s.authors = ["Tom Dooner"]
s.email = '[email protected]'
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
s.require_paths = ["lib"]

# Files
s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
s.files = Dir['lib/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']

# Tests
s.test_files = s.files.grep(%r{^(test|spec|features)/})
Expand All @@ -20,11 +20,11 @@ Gem::Specification.new do |s|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }

# Gem dependencies
s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
s.add_runtime_dependency "logstash-core", "~> 6.0"
s.add_runtime_dependency 'logstash-input-generator'

s.add_runtime_dependency 'statsd-ruby', ['1.2.0']
s.add_runtime_dependency 'dogstatsd-ruby', '~> 4.0'

s.add_development_dependency 'logstash-devutils'
s.add_development_dependency 'overcommit'
end

Loading