fluent-plugin-documentdb 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +26 -0
- data/README.md +13 -0
- data/VERSION +1 -1
- data/conf/fluent-sample-partioned-collection.conf +2 -1
- data/conf/fluent-sample-single-collection.conf +2 -1
- data/fluent-plugin-documentdb.gemspec +1 -1
- data/lib/fluent/plugin/out_documentdb.rb +45 -30
- data/test/helper.rb +1 -0
- data/test/plugin/test_documentdb.rb +31 -21
- metadata +6 -6
- data/ChangeLog +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8caba6ff7692f27f36840ce51b0b0c4b5bb5b20d
|
4
|
+
data.tar.gz: 50b0035e0f2e372ed8f71677edc31cbe6887ec74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7c415043e7f3282c197d86e3e7e484e11c767f9ae31141b46e0fd27a590698b7094d4bf9a72aeb7086c320c4894cbf5c420eeb9cbd8c0b2eb772dbd5c80fb56
|
7
|
+
data.tar.gz: c93403b5a961cdce8a72203975b7ced2cd1fa804784da8c7b2d86939f9577ec407896ad61f2f50f6eb14602d3ce207a4c890c3447a5aad506c12f62ae05860bd
|
data/ChangeLog.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## 0.3.0
|
2
|
+
|
3
|
+
* Migrate to use fluentd v0.14 API - [PR#4](https://github.com/yokawasa/fluent-plugin-documentdb/pull/4)
|
4
|
+
* Support plugin specific log level - [PR#3](https://github.com/yokawasa/fluent-plugin-documentdb/pull/3)
|
5
|
+
|
6
|
+
|
7
|
+
## 0.2.1
|
8
|
+
|
9
|
+
* Fixup bug on Single-Collection mode
|
10
|
+
|
11
|
+
## 0.2.0
|
12
|
+
|
13
|
+
* Support Partitioned Collection mode
|
14
|
+
* No longer depend on azure-documentdb-sdk instead use very tiny documentdb client library that included in the plugin
|
15
|
+
|
16
|
+
## 0.1.2
|
17
|
+
|
18
|
+
* Change gem package dependency option for azure-documentdb-sdk from add_development_dependency to add_dependency
|
19
|
+
|
20
|
+
## 0.1.1
|
21
|
+
|
22
|
+
* Security enhanced option: Added secret option to docdb_account_key
|
23
|
+
|
24
|
+
## 0.1.0
|
25
|
+
|
26
|
+
* Inital Release
|
data/README.md
CHANGED
@@ -26,6 +26,7 @@ To use Microsoft Azure DocumentDB, you must create a DocumentDB database account
|
|
26
26
|
|
27
27
|
<match documentdb.*>
|
28
28
|
@type documentdb
|
29
|
+
@log_level info
|
29
30
|
docdb_endpoint DOCUMENTDB_ACCOUNT_ENDPOINT
|
30
31
|
docdb_account_key DOCUMENTDB_ACCOUNT_KEY
|
31
32
|
docdb_database mydb
|
@@ -59,6 +60,7 @@ To use Microsoft Azure DocumentDB, you must create a DocumentDB database account
|
|
59
60
|
* **add\_tag\_field (optional)** - Default:true. This option allows to insert a tag field to record
|
60
61
|
* **tag\_field\_name (optional)** - Default:tag. Tag field name to be inserted
|
61
62
|
|
63
|
+
[note] @log_level is a fluentd built-in parameter (optional) that controls verbosity of logging: fatal|error|warn|info|debug|trace (See also [Logging of Fluentd](http://docs.fluentd.org/articles/logging#log-level))
|
62
64
|
|
63
65
|
## Configuration examples
|
64
66
|
|
@@ -174,6 +176,17 @@ An expected output record for sample input will be like this:
|
|
174
176
|
## TODOs
|
175
177
|
* Support automatic data expiration with TTL (Time-to-Live ). See [Expire data in DocumentDB collections automatically with time to live](https://azure.microsoft.com/en-us/documentation/articles/documentdb-time-to-live/)
|
176
178
|
|
179
|
+
|
180
|
+
## Change log
|
181
|
+
* [Changelog](ChangeLog.md)
|
182
|
+
|
183
|
+
## Links
|
184
|
+
|
185
|
+
* http://yokawasa.github.io/fluent-plugin-documentdb
|
186
|
+
* https://rubygems.org/gems/fluent-plugin-documentdb
|
187
|
+
* [Collecting logs into Azure DocumentDB using fluent-plugin-documentdb](http://unofficialism.info/posts/collecting-logs-into-azure-documentdb-using-fluent-plugin-documentdb/)
|
188
|
+
* [fluent-plugin-documentdb supports Partitioned collections](http://unofficialism.info/posts/fluent-plugin-documentdb-supports-partitioned-collections/)
|
189
|
+
|
177
190
|
## Contributing
|
178
191
|
|
179
192
|
Bug reports and pull requests are welcome on GitHub at https://github.com/yokawasa/fluent-plugin-documentdb.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -8,8 +8,9 @@
|
|
8
8
|
|
9
9
|
<match documentdb.*>
|
10
10
|
@type documentdb
|
11
|
+
@log_level info
|
11
12
|
docdb_endpoint https://yoichikademo1.documents.azure.com:443/
|
12
|
-
docdb_account_key
|
13
|
+
docdb_account_key EMwUa3EzsAtJ1qYfzwo9nQ3KxxfsXNm3xLh1SLffKkUHMFl80OZRZIVu4lxdKRKxkgVAj0c2mv9BZSyMN7tdg==
|
13
14
|
docdb_database mydb
|
14
15
|
docdb_collection mycollection
|
15
16
|
auto_create_database true
|
@@ -8,8 +8,9 @@
|
|
8
8
|
|
9
9
|
<match documentdb.*>
|
10
10
|
@type documentdb
|
11
|
+
@log_level info
|
11
12
|
docdb_endpoint https://yoichikademo1.documents.azure.com:443/
|
12
|
-
docdb_account_key
|
13
|
+
docdb_account_key EMwUa3EzsAtJ1qYfzwo9nQ3KxxfsXNm3xLh1SLffKkUHMFl80OZRZIVu4lxdKRKxkgVAj0c2mv9BZSyMN7tdg==
|
13
14
|
docdb_database mydb
|
14
15
|
docdb_collection mycollection
|
15
16
|
auto_create_database true
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.test_files = gem.files.grep(%r{^(test|gem|features)/})
|
20
20
|
gem.require_paths = ["lib"]
|
21
21
|
|
22
|
-
gem.add_dependency "fluentd", [">= 0.
|
22
|
+
gem.add_dependency "fluentd", [">= 0.14.15", "< 2"]
|
23
23
|
gem.add_dependency "rest-client"
|
24
24
|
gem.add_development_dependency "bundler", "~> 1.11"
|
25
25
|
gem.add_development_dependency "rake", "~> 10.0"
|
@@ -1,22 +1,22 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
require 'fluent/plugin/output'
|
3
|
+
require 'msgpack'
|
4
|
+
require 'time'
|
5
|
+
require 'securerandom'
|
6
|
+
require 'fluent/plugin/documentdb/client'
|
7
|
+
require 'fluent/plugin/documentdb/partitioned_coll_client'
|
8
|
+
require 'fluent/plugin/documentdb/header'
|
9
|
+
require 'fluent/plugin/documentdb/resource'
|
10
|
+
require 'fluent/plugin/documentdb/constants'
|
2
11
|
|
3
|
-
module Fluent
|
12
|
+
module Fluent::Plugin
|
4
13
|
|
5
|
-
|
14
|
+
class DocumentdbOutput < Output
|
15
|
+
Fluent::Plugin.register_output('documentdb', self)
|
6
16
|
|
7
|
-
|
8
|
-
Plugin.register_output('documentdb', self)
|
17
|
+
helpers :compat_parameters
|
9
18
|
|
10
|
-
|
11
|
-
super
|
12
|
-
require 'msgpack'
|
13
|
-
require 'time'
|
14
|
-
require 'securerandom'
|
15
|
-
require 'fluent/plugin/documentdb/client'
|
16
|
-
require 'fluent/plugin/documentdb/partitioned_coll_client'
|
17
|
-
require 'fluent/plugin/documentdb/header'
|
18
|
-
require 'fluent/plugin/documentdb/resource'
|
19
|
-
end
|
19
|
+
DEFAULT_BUFFER_TYPE = "memory"
|
20
20
|
|
21
21
|
config_param :docdb_endpoint, :string
|
22
22
|
config_param :docdb_account_key, :string, :secret => true
|
@@ -34,27 +34,34 @@ module Fluent
|
|
34
34
|
config_param :add_tag_field, :bool, :default => false
|
35
35
|
config_param :tag_field_name, :string, :default => 'tag'
|
36
36
|
|
37
|
+
config_section :buffer do
|
38
|
+
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
39
|
+
config_set_default :chunk_keys, ['tag']
|
40
|
+
end
|
41
|
+
|
37
42
|
def configure(conf)
|
43
|
+
compat_parameters_convert(conf, :buffer)
|
38
44
|
super
|
39
|
-
raise ConfigError, 'no docdb_endpoint' if @docdb_endpoint.empty?
|
40
|
-
raise ConfigError, 'no docdb_account_key' if @docdb_account_key.empty?
|
41
|
-
raise ConfigError, 'no docdb_database' if @docdb_database.empty?
|
42
|
-
raise ConfigError, 'no docdb_collection' if @docdb_collection.empty?
|
45
|
+
raise Fluent::ConfigError, 'no docdb_endpoint' if @docdb_endpoint.empty?
|
46
|
+
raise Fluent::ConfigError, 'no docdb_account_key' if @docdb_account_key.empty?
|
47
|
+
raise Fluent::ConfigError, 'no docdb_database' if @docdb_database.empty?
|
48
|
+
raise Fluent::ConfigError, 'no docdb_collection' if @docdb_collection.empty?
|
43
49
|
if @add_time_field and @time_field_name.empty?
|
44
|
-
raise ConfigError, 'time_field_name must be set if add_time_field is true'
|
50
|
+
raise Fluent::ConfigError, 'time_field_name must be set if add_time_field is true'
|
45
51
|
end
|
46
52
|
if @add_tag_field and @tag_field_name.empty?
|
47
|
-
raise ConfigError, 'tag_field_name must be set if add_tag_field is true'
|
53
|
+
raise Fluent::ConfigError, 'tag_field_name must be set if add_tag_field is true'
|
48
54
|
end
|
49
55
|
if @partitioned_collection
|
50
|
-
raise ConfigError, 'partition_key must be set in partitioned collection mode' if @partition_key.empty?
|
56
|
+
raise Fluent::ConfigError, 'partition_key must be set in partitioned collection mode' if @partition_key.empty?
|
51
57
|
if (@auto_create_collection &&
|
52
58
|
@offer_throughput < AzureDocumentDB::PARTITIONED_COLL_MIN_THROUGHPUT)
|
53
|
-
raise ConfigError, sprintf("offer_throughput must be more than and equals to %s",
|
54
|
-
AzureDocumentDB::PARTITIONED_COLL_MIN_THROUGHPUT)
|
59
|
+
raise Fluent::ConfigError, sprintf("offer_throughput must be more than and equals to %s",
|
60
|
+
AzureDocumentDB::PARTITIONED_COLL_MIN_THROUGHPUT)
|
55
61
|
end
|
56
62
|
end
|
57
|
-
|
63
|
+
raise Fluent::ConfigError, "'tag' in chunk_keys is required." if not @chunk_key_tag
|
64
|
+
@timef = Fluent::TimeFormatter.new(@time_format, @localtime)
|
58
65
|
end
|
59
66
|
|
60
67
|
def start
|
@@ -72,7 +79,7 @@ module Fluent
|
|
72
79
|
## initial operations for database
|
73
80
|
res = @client.find_databases_by_name(@docdb_database)
|
74
81
|
if( res[:body]["_count"].to_i == 0 )
|
75
|
-
raise "No database (#{docdb_database}) exists! Enable auto_create_database or create it by useself" if !@auto_create_database
|
82
|
+
raise "No database (#{docdb_database}) exists! Enable auto_create_database or create it by useself" if !@auto_create_database
|
76
83
|
# create new database as it doesn't exists
|
77
84
|
@client.create_database(@docdb_database)
|
78
85
|
end
|
@@ -94,7 +101,7 @@ module Fluent
|
|
94
101
|
@coll_resource = @client.get_collection_resource(database_resource, @docdb_collection)
|
95
102
|
|
96
103
|
rescue Exception =>ex
|
97
|
-
|
104
|
+
log.fatal "Error: '#{ex}'"
|
98
105
|
exit!
|
99
106
|
end
|
100
107
|
end
|
@@ -111,10 +118,18 @@ module Fluent
|
|
111
118
|
end
|
112
119
|
if @add_tag_field
|
113
120
|
record[@tag_field_name] = tag
|
114
|
-
end
|
121
|
+
end
|
115
122
|
record.to_msgpack
|
116
123
|
end
|
117
124
|
|
125
|
+
def formatted_to_msgpack_binary?
|
126
|
+
true
|
127
|
+
end
|
128
|
+
|
129
|
+
def multi_workers_ready?
|
130
|
+
true
|
131
|
+
end
|
132
|
+
|
118
133
|
def write(chunk)
|
119
134
|
chunk.msgpack_each { |record|
|
120
135
|
unique_doc_identifier = record["id"]
|
@@ -127,12 +142,12 @@ module Fluent
|
|
127
142
|
rescue RestClient::ExceptionWithResponse => rcex
|
128
143
|
exdict = JSON.parse(rcex.response)
|
129
144
|
if exdict['code'] == 'Conflict'
|
130
|
-
|
145
|
+
log.fatal "Duplicate Error: document #{unique_doc_identifier} already exists, data=>" + record.to_json
|
131
146
|
else
|
132
|
-
|
147
|
+
log.fatal "RestClient Error: '#{rcex.response}', data=>" + record.to_json
|
133
148
|
end
|
134
149
|
rescue => ex
|
135
|
-
|
150
|
+
log.fatal "UnknownError: '#{ex}', uniqueid=>#{unique_doc_identifier}, data=>" + record.to_json
|
136
151
|
end
|
137
152
|
}
|
138
153
|
end
|
data/test/helper.rb
CHANGED
@@ -28,41 +28,52 @@ class DocumentdbOutputTest < Test::Unit::TestCase
|
|
28
28
|
# utc
|
29
29
|
# ]
|
30
30
|
|
31
|
-
def create_driver(conf = CONFIG
|
32
|
-
Fluent::Test::
|
31
|
+
def create_driver(conf = CONFIG)
|
32
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::DocumentdbOutput).configure(conf)
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_configure
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
d = create_driver
|
37
|
+
|
38
|
+
assert_equal 'https://yoichikademo1.documents.azure.com:443', d.instance.docdb_endpoint
|
39
|
+
assert_equal 'EMwUa3EzsAtJ1qYfzwo9nQ3KudofsXNm3xLh1SLffKkUHMFl80OZRZIVu4lxdKRKxkgVAj0c2mv9BZSyMN7tdg==',
|
40
|
+
d.instance.docdb_account_key
|
41
|
+
assert_equal 'mydb', d.instance.docdb_database
|
42
|
+
assert_equal 'mycollection', d.instance.docdb_collection
|
43
|
+
assert_true d.instance.auto_create_database
|
44
|
+
assert_true d.instance.auto_create_collection
|
45
|
+
assert_equal 'host', d.instance.partition_key
|
46
|
+
assert_equal 10100, d.instance.offer_throughput
|
47
|
+
assert_equal '%Y%m%d-%H:%M:%S', d.instance.time_format
|
48
|
+
assert_false d.instance.localtime
|
49
|
+
assert_true d.instance.add_time_field
|
50
|
+
assert_equal 'time', d.instance.time_field_name
|
51
|
+
assert_true d.instance.add_tag_field
|
52
|
+
assert_equal 'tag', d.instance.tag_field_name
|
53
|
+
|
44
54
|
end
|
45
55
|
|
46
56
|
def test_format
|
47
57
|
d = create_driver
|
48
58
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
# d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
|
59
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
60
|
+
d.run(default_tag: 'documentdb.test') do
|
61
|
+
d.feed(time, {"a"=>1})
|
62
|
+
d.feed(time, {"a"=>2})
|
63
|
+
end
|
55
64
|
|
56
|
-
# d.
|
65
|
+
# assert_equal EXPECTED1, d.formatted[0]
|
66
|
+
# assert_equal EXPECTED2, d.formatted[1]
|
57
67
|
end
|
58
68
|
|
59
69
|
def test_write
|
60
70
|
d = create_driver
|
61
71
|
|
62
72
|
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
63
|
-
d.
|
64
|
-
|
65
|
-
|
73
|
+
data = d.run(default_tag: 'documentdb.test') do
|
74
|
+
d.feed(time, {"a"=>1})
|
75
|
+
d.feed(time, {"a"=>2})
|
76
|
+
end
|
66
77
|
puts data
|
67
78
|
# ### FileOutput#write returns path
|
68
79
|
# path = d.run
|
@@ -70,4 +81,3 @@ class DocumentdbOutputTest < Test::Unit::TestCase
|
|
70
81
|
# assert_equal expect_path, path
|
71
82
|
end
|
72
83
|
end
|
73
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-documentdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoichi Kawasaki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.14.15
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.14.15
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2'
|
@@ -94,7 +94,7 @@ extensions: []
|
|
94
94
|
extra_rdoc_files: []
|
95
95
|
files:
|
96
96
|
- ".gitignore"
|
97
|
-
- ChangeLog
|
97
|
+
- ChangeLog.md
|
98
98
|
- Gemfile
|
99
99
|
- LICENSE
|
100
100
|
- README.md
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.5.2
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Azure DocumentDB output plugin for Fluentd
|
data/ChangeLog
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
Release 0.2.1 - 2016/08/28
|
2
|
-
|
3
|
-
* Fixup bug on Single-Collection mode
|
4
|
-
|
5
|
-
Release 0.2.0 - 2016/08/17
|
6
|
-
|
7
|
-
* Support Partitioned Collection mode
|
8
|
-
* No longer depend on azure-documentdb-sdk instead use very tiny documentdb client library that included in the plugin
|
9
|
-
|
10
|
-
Release 0.1.2 - 2016/02/20
|
11
|
-
|
12
|
-
* Change gem package dependency option for azure-documentdb-sdk from add_development_dependency to add_dependency
|
13
|
-
|
14
|
-
Release 0.1.1 - 2016/02/20
|
15
|
-
|
16
|
-
* Security enhanced option: Added secret option to docdb_account_key
|
17
|
-
|
18
|
-
Release 0.1.0 - 2016/01/19
|
19
|
-
|
20
|
-
* Inital Release
|
21
|
-
* Add out_documentdb
|