fluent-plugin-leftronic 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 69c268534dec78cb300a614d123e8ff2754e2e5e
4
+ data.tar.gz: 808b3cb862c768e4e1d24ca7a7b06cdd52f6601a
5
+ SHA512:
6
+ metadata.gz: 5bc5d31bce1c3848b70d1f3ea139f3c045f14425d7ecbe0ff691e43c30e4b8e472b377557a849bd5bd804dca6ed5d18d362f60f8a73c51bacba2e62e3ebfa6c4
7
+ data.tar.gz: ed56d17b25b5ea3922b462dd8399a226fda0150f410d1752196c211e8b9e5db023111d61be4e6b5058e35101407da61a1a976644b8f342e4dd4400ad89e0a1f1
@@ -0,0 +1,6 @@
1
+ Gemfile.lock
2
+ nbproject/
3
+ .project
4
+ *.gem
5
+ pkg
6
+ test/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-leftronic.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 toyama0919
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.
@@ -0,0 +1,51 @@
1
+ # Fluent::Plugin::Leftronic
2
+
3
+ Leftronic output plugin for Fluentd.
4
+
5
+ ## Installation
6
+
7
+ $ fluent-gem install fluent-plugin-leftronic
8
+
9
+ ## Configuration
10
+
11
+ <match leftronic.**>
12
+ type leftronic
13
+ access_key ${leftronic-access-key} # leftronic access key
14
+ stream_name ${leftronic-stream-name} # leftronic stream_name
15
+ count key_name
16
+ </match>
17
+
18
+ <match groupcounter.merged.apache.pv>
19
+ type copy
20
+ <store>
21
+ type leftronic
22
+ access_key ${leftronic-access-key} # leftronic access key
23
+ stream_name ${leftronic-stream-name} # leftronic stream_name
24
+ graph_type bar # default => line
25
+ name_key_pattern .*_(count)$ # enable => Googlebot_count,Yahoo! Japan_count,smartphone_count disable => Googlebot_rate
26
+ display_keys {'Yahoo! Japan_count' => 'yahoo','Googlebot_count' => 'google','smartphone_count' => 'スマートフォン数'}
27
+ </store>
28
+ <store>
29
+ type leftronic
30
+ access_key ${leftronic-access-key} # leftronic access key
31
+ stream_name ${leftronic-stream-name} # leftronic stream_name
32
+ graph_type line # default => line
33
+ value Yahoo! Japan_count
34
+ </store>
35
+ <store>
36
+ type leftronic
37
+ access_key ${leftronic-access-key} # leftronic access key
38
+ stream_name ${leftronic-stream-name} # leftronic stream_name
39
+ graph_type number # default => line
40
+ value Googlebot_count
41
+ </store>
42
+ </match>
43
+
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create new Pull Request
@@ -0,0 +1,17 @@
1
+ require "bundler"
2
+ require "bundler/gem_tasks"
3
+ Bundler::GemHelper.install_tasks
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |test|
7
+ test.libs << 'lib' << 'test'
8
+ test.test_files = FileList['test/plugin/*.rb']
9
+ test.verbose = true
10
+ end
11
+
12
+ task :coverage do |t|
13
+ ENV['COVERAGE'] = '1'
14
+ Rake::Task["test"].invoke
15
+ end
16
+
17
+ task :default => [:build]
@@ -0,0 +1,23 @@
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-leftronic"
7
+ spec.version = "0.0.4"
8
+ spec.authors = ["toyama0919"]
9
+ spec.email = ["toyama0919@gmail.com"]
10
+ spec.description = %q{Leftronic output plugin for Fluentd.}
11
+ spec.summary = spec.description
12
+ spec.homepage = "https://github.com/toyama0919/fluent-plugin-leftronic/"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
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_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_dependency "leftronic"
23
+ end
@@ -0,0 +1,84 @@
1
+ module Fluent
2
+ class LeftronicOutput < Fluent::BufferedOutput
3
+ Fluent::Plugin.register_output('leftronic', self)
4
+
5
+ config_param :access_key
6
+ config_param :stream_name
7
+ config_param :value, :default => nil
8
+ config_param :graph_type, :default => "line"
9
+ config_param :display_keys, :default => nil
10
+ config_param :name_key_pattern, :default => nil
11
+
12
+ def initialize
13
+ Encoding.default_internal = "UTF-8"
14
+ require 'uri'
15
+ require 'json'
16
+ require 'leftronic'
17
+ super
18
+ end
19
+
20
+ def configure(conf)
21
+ super
22
+ if @access_key.nil? || @access_key.empty?
23
+ raise ConfigError, "leftronic configure requires 'access_key'"
24
+ end
25
+
26
+ if @stream_name.nil? || @stream_name.empty?
27
+ raise ConfigError, "leftronic configure requires 'stream_name'"
28
+ end
29
+
30
+ if @graph_type == 'number' or @graph_type == 'line'
31
+ if @value.nil? || @value.size == 0
32
+ raise ConfigError, "leftronic configure requires 'value'"
33
+ end
34
+ end
35
+
36
+ unless @display_keys.nil?
37
+ @default_key = false
38
+ @leftronic_display_hash = eval(@display_keys)
39
+ $log.info @leftronic_display_hash
40
+ else
41
+ @default_key = true
42
+ end
43
+ @leftronic = Leftronic.new @access_key
44
+ end
45
+
46
+ def start
47
+ super
48
+ end
49
+
50
+ def shutdown
51
+ super
52
+ end
53
+
54
+ def format(tag, time, record)
55
+ [tag, time, record].to_msgpack
56
+ end
57
+
58
+ def write(chunk)
59
+ chunk.msgpack_each do |tag, time, record|
60
+ next if record.nil? || record.empty?
61
+ if @graph_type == 'number' or @graph_type == 'line'
62
+ next unless record.has_key? @value
63
+ @leftronic.number(@stream_name ,record[@value].to_i)
64
+ elsif @graph_type == 'leaderboard' or @graph_type == 'bar' or @graph_type == 'pie'
65
+ result = Hash.new
66
+ record.each {|key,value|
67
+ unless name_key_pattern.nil?
68
+ next if key !~ /#{@name_key_pattern}/
69
+ end
70
+
71
+ unless @default_key
72
+ display_key = @leftronic_display_hash.has_key?(key) ? @leftronic_display_hash[key] : key
73
+ else
74
+ display_key = key
75
+ end
76
+ result[display_key] = value.to_i
77
+ }
78
+ $log.info result
79
+ @leftronic.leaderboard(@stream_name,[result])
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-leftronic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - toyama0919
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: leftronic
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Leftronic output plugin for Fluentd.
56
+ email:
57
+ - toyama0919@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - fluent-plugin-leftronic.gemspec
68
+ - lib/fluent/plugin/out_leftronic.rb
69
+ - test/plugin/test_out_leftronic.rb
70
+ - test/test_helper.rb
71
+ homepage: https://github.com/toyama0919/fluent-plugin-leftronic/
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.0.3
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Leftronic output plugin for Fluentd.
95
+ test_files:
96
+ - test/plugin/test_out_leftronic.rb
97
+ - test/test_helper.rb