fluent-plugin-solr 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +31 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/lib/fluent/plugin/out_solr.rb +93 -0
- metadata +123 -0
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.6.4"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.6.4)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rake (0.9.2)
|
10
|
+
rcov (0.9.10)
|
11
|
+
shoulda (2.11.3)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 1.0.0)
|
18
|
+
jeweler (~> 1.6.4)
|
19
|
+
rcov
|
20
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Nobutaka Nakazawa
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
= fluent-plugin-solr
|
2
|
+
|
3
|
+
= Solr output plugin for Fluent
|
4
|
+
|
5
|
+
== Configuration
|
6
|
+
|
7
|
+
<match solr.**> # solr's key is hostname + tags + event.time.
|
8
|
+
type solr #
|
9
|
+
|
10
|
+
# following attibutes are optional
|
11
|
+
host localhost # solr's hostname. default localhost
|
12
|
+
port 8983 # solr's port. default 8983
|
13
|
+
core # solr's core name.
|
14
|
+
|
15
|
+
</match>
|
16
|
+
|
17
|
+
== Contributing to fluent-plugin-solr
|
18
|
+
|
19
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
20
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
21
|
+
* Fork the project
|
22
|
+
* Start a feature/bugfix branch
|
23
|
+
* Commit and push until you are happy with your contribution
|
24
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
25
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
26
|
+
|
27
|
+
== Copyright
|
28
|
+
|
29
|
+
Copyright (c) 2011 Nobutaka Nakazawa. See LICENSE.txt for
|
30
|
+
further details.
|
31
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "fluent-plugin-solr"
|
18
|
+
gem.homepage = "http://github.com/btigit/fluent-plugin-solr"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "Solr output plugin for Fluent event collector"
|
21
|
+
gem.description = "Solr output plugin for Fluent event collector"
|
22
|
+
gem.email = "nakazawa.nobutaka@brains-tech.co.jp"
|
23
|
+
gem.authors = ["Nobutaka Nakazawa"]
|
24
|
+
gem.version = '0.1.1'
|
25
|
+
gem.add_dependency("fluentd", "~> 0.10.0")
|
26
|
+
gem.add_dependency("solr-ruby", "~> 0.0.8")
|
27
|
+
gem.files = FileList['lib/fluent/plugin/out_solr.rb', '[A-Z]*'].to_a
|
28
|
+
gem.bindir = '/etc/fluent/plugin'
|
29
|
+
|
30
|
+
end
|
31
|
+
Jeweler::RubygemsDotOrgTasks.new
|
32
|
+
|
33
|
+
require 'rake/testtask'
|
34
|
+
Rake::TestTask.new(:test) do |test|
|
35
|
+
# test.libs << 'lib' << 'test'
|
36
|
+
# test.pattern = 'test/**/test_*.rb'
|
37
|
+
# test.verbose = true
|
38
|
+
end
|
39
|
+
|
40
|
+
require 'rcov/rcovtask'
|
41
|
+
Rcov::RcovTask.new do |test|
|
42
|
+
# test.libs << 'test'
|
43
|
+
# test.pattern = 'test/**/test_*.rb'
|
44
|
+
# test.verbose = true
|
45
|
+
# test.rcov_opts << '--exclude "gems/*"'
|
46
|
+
end
|
47
|
+
|
48
|
+
task :default => :test
|
49
|
+
|
50
|
+
require 'rake/rdoctask'
|
51
|
+
Rake::RDocTask.new do |rdoc|
|
52
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
53
|
+
|
54
|
+
rdoc.rdoc_dir = 'rdoc'
|
55
|
+
rdoc.title = "fluent-plugin-solr #{version}"
|
56
|
+
rdoc.rdoc_files.include('README*')
|
57
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Fluent
|
2
|
+
|
3
|
+
require 'solr'
|
4
|
+
|
5
|
+
class SolrOutput < Fluent::BufferedOutput
|
6
|
+
Fluent::Plugin.register_output('solr', self)
|
7
|
+
include SetTimeKeyMixin
|
8
|
+
include SetTagKeyMixin
|
9
|
+
config_set_default :include_time_key, true
|
10
|
+
config_set_default :include_tag_key, true
|
11
|
+
config_set_default :time_format, "%Y%m%d%H%M%S%L"
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
require 'msgpack'
|
16
|
+
require 'socket'
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure(conf)
|
20
|
+
super
|
21
|
+
|
22
|
+
@host = conf.has_key?('host') ? conf['host'] : 'localhost'
|
23
|
+
@port = conf.has_key?('port') ? conf['port'] : '8983'
|
24
|
+
@core = conf.has_key?('core') ? conf['core'] : ''
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def start
|
29
|
+
super
|
30
|
+
@connection = Solr::Connection.new('http://'+@host+':'+@port+'/solr/'+@core)
|
31
|
+
end
|
32
|
+
|
33
|
+
def shutdown
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
def format(tag, time, record)
|
38
|
+
record.to_msgpack
|
39
|
+
end
|
40
|
+
|
41
|
+
def write(chunk)
|
42
|
+
chunk.msgpack_each { |record|
|
43
|
+
doc = Solr::Document.new(
|
44
|
+
:id => record["tag"] + "_" + Socket::gethostname + "_" + record["core"] + "_" + record["thread"] + "_" + record["timestamp"].gsub(/[\s\.:-]/, ""),
|
45
|
+
:host_s => Socket::gethostname,
|
46
|
+
:timestamp_s => record["timestamp"],
|
47
|
+
:level_s => record["level"],
|
48
|
+
:thread_s => record["thread"],
|
49
|
+
:class_s => record["class"],
|
50
|
+
:core_s => record["core"],
|
51
|
+
:webapp_s => record["webapp"],
|
52
|
+
:path_s => record["path"],
|
53
|
+
:params_s => record["params"],
|
54
|
+
:hits_tl => record["hits"],
|
55
|
+
:status_ti => record["status"],
|
56
|
+
:qtime_tl => record["qtime"],
|
57
|
+
:time_tl => record["time"],
|
58
|
+
:tag_s => record["tag"]
|
59
|
+
)
|
60
|
+
request = Solr::Request::AddDocument.new(doc)
|
61
|
+
response = @connection.send(request)
|
62
|
+
if response.ok?
|
63
|
+
options={}
|
64
|
+
options.update(:softCommit => "true")
|
65
|
+
response = @connection.send(Solr::Request::Commit4.new(options))
|
66
|
+
end
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
class Solr::Request::Commit4 < Solr::Request::Update
|
73
|
+
|
74
|
+
def initialize(options={})
|
75
|
+
@wait_searcher = options[:wait_searcher] || true
|
76
|
+
@soft_commit = options[:soft_commit] || false
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
def to_s
|
81
|
+
e = Solr::XML::Element.new('commit')
|
82
|
+
e.attributes['waitSearcher'] = @wait_searcher ? 'true' : 'false'
|
83
|
+
e.attributes['softCommit'] = @soft_commit ? 'true' : 'false'
|
84
|
+
|
85
|
+
e.to_s
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
class Solr::Response::Commit4 < Solr::Response::Xml
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-solr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nobutaka Nakazawa
|
9
|
+
autorequire:
|
10
|
+
bindir: /etc/fluent/plugin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: shoulda
|
16
|
+
requirement: &70225542349820 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70225542349820
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
27
|
+
requirement: &70225542348160 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70225542348160
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jeweler
|
38
|
+
requirement: &70225542346260 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.6.4
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70225542346260
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rcov
|
49
|
+
requirement: &70225542344120 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70225542344120
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: fluentd
|
60
|
+
requirement: &70225542342180 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.10.0
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70225542342180
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: solr-ruby
|
71
|
+
requirement: &70225542356260 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.0.8
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70225542356260
|
80
|
+
description: Solr output plugin for Fluent event collector
|
81
|
+
email: nakazawa.nobutaka@brains-tech.co.jp
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files:
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.rdoc
|
87
|
+
files:
|
88
|
+
- Gemfile
|
89
|
+
- Gemfile.lock
|
90
|
+
- LICENSE.txt
|
91
|
+
- README.rdoc
|
92
|
+
- Rakefile
|
93
|
+
- VERSION
|
94
|
+
- lib/fluent/plugin/out_solr.rb
|
95
|
+
homepage: http://github.com/btigit/fluent-plugin-solr
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
hash: 2520684016853676840
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 1.8.11
|
120
|
+
signing_key:
|
121
|
+
specification_version: 3
|
122
|
+
summary: Solr output plugin for Fluent event collector
|
123
|
+
test_files: []
|