fluent-plugin-mongo 0.7.7 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/README.rdoc +11 -0
- data/VERSION +1 -1
- data/lib/fluent/plugin/in_mongo_tail.rb +41 -4
- data/test/plugin/in_mongo_tail.rb +35 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c469055a5c4138143ee66c6498a061a089ec78f
|
4
|
+
data.tar.gz: f927fb01f37bbca5e922b0e579926f46cae940be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bab2b000d8b206c05f8ff30a6c9f2da916139a8b3955152bdde0460282828ea17e32975db1b8bc832c0c3dd39808a7d458a1fa390f9d563d8d400aab52ff0e93
|
7
|
+
data.tar.gz: aca3095ff0624546dd77ecb7580af9b3fa6098c0b0c01cafab0e61474402b1f2f6fe59dfed773686644c6680796049078acb73d65ff4abdd65fb8b65cdc13f5d
|
data/ChangeLog
CHANGED
data/README.rdoc
CHANGED
@@ -143,6 +143,17 @@ Use _mongo_tail_ type in source.
|
|
143
143
|
id_store_file /Users/repeatedly/devel/fluent-plugin-mongo/last_id
|
144
144
|
</source>
|
145
145
|
|
146
|
+
You can also use _url_ to specify the database to connect.
|
147
|
+
|
148
|
+
<source>
|
149
|
+
type mongo_tail
|
150
|
+
url mongodb://user:password@192.168.0.13:10249,192.168.0.14:10249/database
|
151
|
+
collection capped_log
|
152
|
+
...
|
153
|
+
</source>
|
154
|
+
|
155
|
+
This allows the plugin to read data from a replica set.
|
156
|
+
|
146
157
|
= NOTE
|
147
158
|
|
148
159
|
== Broken data as a BSON
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.8
|
@@ -5,11 +5,12 @@ module Fluent
|
|
5
5
|
require 'fluent/plugin/mongo_util'
|
6
6
|
include MongoUtil
|
7
7
|
|
8
|
-
config_param :database, :string
|
8
|
+
config_param :database, :string, :default => nil
|
9
9
|
config_param :collection, :string
|
10
10
|
config_param :host, :string, :default => 'localhost'
|
11
11
|
config_param :port, :integer, :default => 27017
|
12
12
|
config_param :wait_time, :integer, :default => 1
|
13
|
+
config_param :url, :string, :default => nil
|
13
14
|
|
14
15
|
config_param :tag, :string, :default => nil
|
15
16
|
config_param :tag_key, :string, :default => nil
|
@@ -41,6 +42,14 @@ module Fluent
|
|
41
42
|
raise ConfigError, "'tag' or 'tag_key' option is required on mongo_tail input"
|
42
43
|
end
|
43
44
|
|
45
|
+
if @database && @url
|
46
|
+
raise ConfigError, "Both 'database' and 'url' can not be set"
|
47
|
+
end
|
48
|
+
|
49
|
+
if !@database && !@url
|
50
|
+
raise ConfigError, "One of 'database' or 'url' must be specified"
|
51
|
+
end
|
52
|
+
|
44
53
|
@last_id = @id_store_file ? get_last_id : nil
|
45
54
|
@connection_options[:ssl] = @ssl
|
46
55
|
|
@@ -90,10 +99,10 @@ module Fluent
|
|
90
99
|
|
91
100
|
def get_capped_collection
|
92
101
|
begin
|
93
|
-
db =
|
94
|
-
raise ConfigError, "'#{
|
102
|
+
db = get_database
|
103
|
+
raise ConfigError, "'#{database_name}.#{@collection}' not found: node = #{node_string}" unless db.collection_names.include?(@collection)
|
95
104
|
collection = db.collection(@collection)
|
96
|
-
raise ConfigError, "'#{
|
105
|
+
raise ConfigError, "'#{database_name}.#{@collection}' is not capped: node = #{node_string}" unless collection.capped?
|
97
106
|
collection
|
98
107
|
rescue Mongo::ConnectionFailure => e
|
99
108
|
log.fatal "Failed to connect to 'mongod'. Please restart 'fluentd' after 'mongod' started: #{e}"
|
@@ -103,6 +112,34 @@ module Fluent
|
|
103
112
|
exit!
|
104
113
|
end
|
105
114
|
end
|
115
|
+
|
116
|
+
def get_database
|
117
|
+
case
|
118
|
+
when @database
|
119
|
+
authenticate(Mongo::Connection.new(@host, @port, @connection_options).db(@database))
|
120
|
+
when @url
|
121
|
+
parser = Mongo::URIParser.new(@url)
|
122
|
+
parser.connection.db(parser.db_name)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def database_name
|
127
|
+
case
|
128
|
+
when @database
|
129
|
+
@database
|
130
|
+
when @url
|
131
|
+
Mongo::URIParser.new(@url).db_name
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def node_string
|
136
|
+
case
|
137
|
+
when @database
|
138
|
+
"#{@host}:#{@port}"
|
139
|
+
when @url
|
140
|
+
@url
|
141
|
+
end
|
142
|
+
end
|
106
143
|
|
107
144
|
def process_document(doc)
|
108
145
|
time = if @time_key
|
@@ -29,6 +29,41 @@ class MongoTailInputTest < Test::Unit::TestCase
|
|
29
29
|
assert_equal('time', d.instance.time_key)
|
30
30
|
assert_equal('/tmp/fluent_mongo_last_id', d.instance.id_store_file)
|
31
31
|
end
|
32
|
+
|
33
|
+
def test_url_configration
|
34
|
+
config = %[
|
35
|
+
type mongo_tail
|
36
|
+
url mongodb://localhost:27017/test
|
37
|
+
collection log
|
38
|
+
tag_key tag
|
39
|
+
time_key time
|
40
|
+
id_store_file /tmp/fluent_mongo_last_id
|
41
|
+
]
|
42
|
+
|
43
|
+
d = create_driver(config)
|
44
|
+
assert_equal("mongodb://localhost:27017/test", d.instance.url)
|
45
|
+
assert_nil(d.instance.database)
|
46
|
+
assert_equal('log', d.instance.collection)
|
47
|
+
assert_equal('tag', d.instance.tag_key)
|
48
|
+
assert_equal('time', d.instance.time_key)
|
49
|
+
assert_equal('/tmp/fluent_mongo_last_id', d.instance.id_store_file)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_url_and_database_can_not_exist
|
53
|
+
config = %[
|
54
|
+
type mongo_tail
|
55
|
+
url mongodb://localhost:27017/test
|
56
|
+
database test2
|
57
|
+
collection log
|
58
|
+
tag_key tag
|
59
|
+
time_key time
|
60
|
+
id_store_file /tmp/fluent_mongo_last_id
|
61
|
+
]
|
62
|
+
|
63
|
+
assert_raises Fluent::ConfigError do
|
64
|
+
create_driver(config)
|
65
|
+
end
|
66
|
+
end
|
32
67
|
|
33
68
|
def test_emit
|
34
69
|
# TODO: write actual code
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Nakagawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|