fluent-plugin-riemann 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ fluent.conf
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-riemann.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Will Farrell
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Fluent::Plugin::Riemann
2
+
3
+ `fluent-plugin-riemann` is a [fluentd](http://fluentd.org/ "Fluentd") output plugin that allows you to forward logs collected with fluentd to [riemann](http://riemann.io "Riemann").
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fluent-plugin-riemann'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fluent-plugin-riemann
18
+
19
+ ## Usage
20
+
21
+ <match riemann.**>
22
+ type riemann
23
+ host localhost
24
+ port 5555
25
+ timeout 5
26
+ protocol tcp
27
+ service test log messages
28
+ fields message:description,level:state,metric
29
+ types metric:float
30
+ flush_interval 10s
31
+ </match>
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( http://github.com/wkf/fluent-plugin-riemann/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-riemann"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Will Farrell"]
9
+ spec.email = ["will@mojotech.com"]
10
+ spec.summary = %q{Riemann output plugin for Fluent}
11
+ spec.description = spec.summary
12
+ spec.homepage = "https://github.com/wkf/fluent-plugin-riemann"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency 'fluentd', '~> 0'
21
+ spec.add_runtime_dependency 'riemann-client', '~> 0'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "pry"
26
+ end
@@ -0,0 +1,78 @@
1
+ require 'pry'
2
+ require 'riemann/client'
3
+
4
+ class Fluent::RiemannOutput < Fluent::BufferedOutput
5
+ Fluent::Plugin.register_output('riemann', self)
6
+
7
+ config_param :host, :string, :default => 'localhost'
8
+ config_param :post, :integer, :default => 5555
9
+ config_param :timeout, :integer, :default => 5
10
+ config_param :protocol, :string, :default => 'tcp'
11
+ config_param :service, :string, :default => nil
12
+ config_param :types, :string, :default => 'metric:float'
13
+ config_param :fields, :string, :default => 'message:description,level:state,metric'
14
+
15
+ def initialize
16
+ super
17
+ end
18
+
19
+ def configure(c)
20
+ super
21
+
22
+ @_types = parse_map(@types) do |k, t|
23
+ case t
24
+ when "string" then "to_s"
25
+ when "integer" then "to_i"
26
+ when "float" then "to_f"
27
+ else t
28
+ end
29
+ end
30
+
31
+ @_fields = parse_map(@fields) { |k, f| (f || k).to_sym }
32
+ end
33
+
34
+ def start
35
+ super
36
+ end
37
+
38
+ def shutdown
39
+ super
40
+ end
41
+
42
+ def client
43
+ @_client ||= Riemann::Client.new :host => @host, :port => @port, :timeout => @timeout
44
+ @protocol == 'tcp' ? @_client.tcp : @_client.udp
45
+ end
46
+
47
+ def format(tag, time, record)
48
+ [tag, time, record].to_msgpack
49
+ end
50
+
51
+ def write(chunk)
52
+ chunk.msgpack_each do |tag, time, record|
53
+ event = {
54
+ :time => time,
55
+ :service => @service,
56
+ :tags => tag.split('.')
57
+ }
58
+
59
+ @_fields.each { |k,v| event[v] = record[k] }
60
+ @_types.each { |k,t| event[k] = event[k].send(t) }
61
+
62
+ client << event
63
+ end
64
+ end
65
+
66
+ private
67
+
68
+ def parse_map(map, &block)
69
+ Hash[map.split(',').map do |m|
70
+ k, v = m.split(':').map(&:strip)
71
+ if block_given?
72
+ [k, yield(k, v)]
73
+ else
74
+ [k, v]
75
+ end
76
+ end]
77
+ end
78
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-riemann
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Will Farrell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: fluentd
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: riemann-client
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.5'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: pry
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Riemann output plugin for Fluent
95
+ email:
96
+ - will@mojotech.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - LICENSE.txt
104
+ - README.md
105
+ - Rakefile
106
+ - VERSION
107
+ - fluent-plugin-riemann.gemspec
108
+ - lib/fluent/plugin/out_riemann.rb
109
+ homepage: https://github.com/wkf/fluent-plugin-riemann
110
+ licenses:
111
+ - MIT
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 1.8.23.2
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: Riemann output plugin for Fluent
134
+ test_files: []