fluent-plugin-out_hosted_graphite 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c47d09f556c25b46724b421aa5481270f400a1b
4
+ data.tar.gz: 13bee6efbf793ceca4ff93c051b71b7eef1fc35c
5
+ SHA512:
6
+ metadata.gz: 51cb0fb2a4d3315d00c99ed1b3ce41a1c49f17ce5684526bd7cd30e3b0703c6bfb0aa7a9e71a5079f9da7467ac97769abde6b3f3a6d751679c19efa076df2f47
7
+ data.tar.gz: 796e0f60ab0aa9e765c30084c2be617dfe8ab4f1701990e395c04233763669ef25d87f708b467f62a961956e225bf9354294ec29cca75d47de4957e40095e576
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /vendor/bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-out_hosted_graphite.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 TODO: Write your name
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,54 @@
1
+ # Fluent::Plugin::OutHostedGraphite
2
+
3
+ fluentd plugin for [Hosted Graphite](https://www.hostedgraphite.com/).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fluent-plugin-out_hosted_graphite'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fluent-plugin-out_hosted_graphite
20
+
21
+ ## Configure
22
+
23
+ ### fluentd.conf
24
+
25
+ ```
26
+ <match *.*>
27
+ type hosted_graphite
28
+ api_key xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxxx
29
+ metric_key foo.bar
30
+ protocol udp
31
+ </match>
32
+ ```
33
+
34
+ ### api_key
35
+
36
+ * required
37
+
38
+ ### metric_key
39
+
40
+ * required
41
+
42
+ ### protocol
43
+
44
+ * UDP
45
+ * TCP
46
+ * HTTP(Default)
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork it ( https://github.com/[my-github-username]/fluent-plugin-out_hosted_graphite/fork )
51
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
52
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 4. Push to the branch (`git push origin my-new-feature`)
54
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+ Rake::TestTask.new(:test) do |test|
4
+ test.libs << 'lib' << 'test'
5
+ test.pattern = 'test/**/test_*.rb'
6
+ test.verbose = true
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ #require 'fluent/plugin/out_hosted_graphite/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fluent-plugin-out_hosted_graphite"
8
+ spec.version = "0.0.1"
9
+ spec.authors = ["inokappa"]
10
+ spec.email = ["inokappa"]
11
+ spec.summary = %q{fluentd output plugin for post to Hosted Graphite}
12
+ spec.description = %q{fluentd output plugin for post to Hosted Graphite}
13
+ spec.homepage = "https://github.com/inokappa/fluent-plugin-out_hosted_graphite"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "fluentd"
22
+ spec.add_dependency "hosted_graphite"
23
+
24
+ spec.rubyforge_project = "fluent-plugin-out_hosted_graphite"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.7"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0.0"
29
+ end
@@ -0,0 +1,56 @@
1
+ require "hosted_graphite"
2
+
3
+ module Fluent
4
+ class OutHostedGraphite < Fluent::Output
5
+ Fluent::Plugin.register_output('hosted_graphite', self)
6
+
7
+ config_param :api_key, :string
8
+ config_param :metric_key, :string, default: nil
9
+ config_param :protocol, :string, default: "http"
10
+
11
+ def configure(conf)
12
+ super
13
+ #
14
+ end
15
+
16
+ def start
17
+ super
18
+ # ...
19
+ end
20
+
21
+ def shutdown
22
+ super
23
+ # ...
24
+ end
25
+
26
+ def emit(tag, es, chain)
27
+ chain.next
28
+ es.each {|time,record|
29
+ unless record.include?(@metric_key)
30
+ log.warn "metric_key does not exists."
31
+ else
32
+ metric_key = @metric_key
33
+ metric = record[@metric_key].to_f
34
+ post_metrics(metric_key, metric)
35
+ end
36
+ }
37
+ end
38
+
39
+
40
+ def post_metrics(metric_key, metric)
41
+ HostedGraphite.api_key = @api_key
42
+ case @protocol
43
+ when "http"
44
+ HostedGraphite.protocol = HostedGraphite::HTTP
45
+ when "tcp"
46
+ HostedGraphite.protocol = HostedGraphite::TCP
47
+ when "udp"
48
+ HostedGraphite.protocol = HostedGraphite::UDP
49
+ end
50
+ HostedGraphite.send_metric(metric_key, metric)
51
+ #result = HostedGraphite.send_metric(metric_key, metric)
52
+ #puts "debug_out: #{@api_key} #{@protocol} #{result} - #{metric_key} - #{metric}"
53
+ end
54
+
55
+ end
56
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+ require 'fluent/test'
15
+ unless ENV.has_key?('VERBOSE')
16
+ nulllogger = Object.new
17
+ nulllogger.instance_eval {|obj|
18
+ def method_missing(method, *args)
19
+ # pass
20
+ end
21
+ }
22
+ $log = nulllogger
23
+ end
24
+
25
+ require 'fluent/plugin/out_hosted_graphite'
26
+
27
+ class Test::Unit::TestCase
28
+ end
@@ -0,0 +1,40 @@
1
+ require 'helper'
2
+
3
+ class OutHostedGraphite < Test::Unit::TestCase
4
+ def setup
5
+ Fluent::Test.setup
6
+ end
7
+
8
+ CONFIG = %[
9
+ api_key xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
10
+ metric_key foo.bar
11
+ protocol http
12
+ ]
13
+ # CONFIG = %[
14
+ # path #{TMP_DIR}/out_file_test
15
+ # compress gz
16
+ # utc
17
+ # ]
18
+
19
+ def create_driver(conf = CONFIG, tag='test')
20
+ Fluent::Test::OutputTestDriver.new(Fluent::OutHostedGraphite, tag).configure(conf)
21
+ end
22
+
23
+ def test_configure
24
+ d = create_driver(CONFIG)
25
+ assert_equal d.instance.api_key, 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
26
+ assert_equal d.instance.metric_key, 'foo.bar'
27
+ assert_equal d.instance.protocol, 'http'
28
+ end
29
+
30
+ def test_post_metrics
31
+ metric_key = 'foo.bar'
32
+ record = {
33
+ 'foo.bar' => '0.01'
34
+ }
35
+ d = create_driver
36
+ p = d.instance.post_metrics(metric_key, record)
37
+ assert_equal p, { 'foo.bar' => 0.01 }
38
+ end
39
+
40
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-out_hosted_graphite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - inokappa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hosted_graphite
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
83
+ description: fluentd output plugin for post to Hosted Graphite
84
+ email:
85
+ - inokappa
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - fluent-plugin-out_hosted_graphite.gemspec
97
+ - lib/fluent/plugin/out_hosted_graphite.rb
98
+ - test/helper.rb
99
+ - test/plugin/test_out_hosted_graphite.rb
100
+ homepage: https://github.com/inokappa/fluent-plugin-out_hosted_graphite
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project: fluent-plugin-out_hosted_graphite
120
+ rubygems_version: 2.2.2
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: fluentd output plugin for post to Hosted Graphite
124
+ test_files:
125
+ - test/helper.rb
126
+ - test/plugin/test_out_hosted_graphite.rb