fluent-plugin-riak2 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +13 -0
- data/VERSION +1 -1
- data/fluent-plugin-riak2.gemspec +1 -1
- data/lib/fluent/plugin/out_riak2.rb +47 -24
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad3f880d225f6869f8b4086695341e479f7535ed
|
4
|
+
data.tar.gz: a3b7636d8e86ce1afffb5aa91947c5e242b8ed3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fed5a2cbbd620bc2b682ac5de6b91267c8ea09a9829c0ed08c3af7d34a42c4a8147afc74e77533acfe7c6601fc74b87612cf4170a945806c9ff592da7bd16604
|
7
|
+
data.tar.gz: 1af9e4bbc5f851f53730106c962e52d676cc821ef975e02f87dc57ad20e77b2817dcb15652e35a70fc2e142b450dde7b9db380080fe3e12b320861dcdedd8654
|
data/CHANGELOG
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
0.0.5
|
2
|
+
=====
|
3
|
+
|
4
|
+
- update to support riak 2.0 bucket types
|
5
|
+
- update record to support riak search 2.0 (yokozuna) style json extraction
|
6
|
+
- write to a metadata crdt map bucket names
|
7
|
+
|
8
|
+
0.0.4
|
9
|
+
=====
|
10
|
+
|
11
|
+
- hard fork from https://github.com/kuenishi/fluent-plugin-riak , see README for more info
|
12
|
+
- bare minimum to support riak-ruby-client v2.1
|
13
|
+
- change UUID to v1 (timestamp based)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/fluent-plugin-riak2.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
|
20
20
|
gem.add_dependency "fluentd", "~> 0.10"
|
21
21
|
gem.add_dependency "riak-client", "~> 2.1.0"
|
22
|
-
gem.add_dependency "uuidtools", "
|
22
|
+
gem.add_dependency "uuidtools", "~> 2.1.3"
|
23
23
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
24
24
|
gem.add_development_dependency "simplecov", ">= 0.5.4"
|
25
25
|
gem.add_development_dependency "rr", ">= 1.0.0"
|
@@ -8,7 +8,9 @@ class Riak2Output < BufferedOutput
|
|
8
8
|
include SetTagKeyMixin
|
9
9
|
config_set_default :include_time_key, true
|
10
10
|
|
11
|
+
config_param :bucket_type, :string, :default => "fluentlog" # we assume that search is on and this bucket type has an search index attached to it.
|
11
12
|
config_param :bucket_name, :string, :default => "fluentlog"
|
13
|
+
config_param :riak2_metadata_bucket_type, :string, :default => ""
|
12
14
|
config_param :nodes, :string, :default => "localhost:8087"
|
13
15
|
|
14
16
|
def initialize
|
@@ -30,10 +32,31 @@ class Riak2Output < BufferedOutput
|
|
30
32
|
|
31
33
|
def start
|
32
34
|
$log.debug " => #{@buffer.chunk_limit} #{@buffer.queue_limit} "
|
33
|
-
@
|
34
|
-
@bucket = @
|
35
|
+
@client = Riak::Client.new(:nodes => @nodes)
|
36
|
+
@bucket = @client.bucket(@bucket_name)
|
35
37
|
@buf = {}
|
36
38
|
|
39
|
+
# $log.debug "riak2_metadata_bucket_type => #{@riak2_metadata_bucket_type}"
|
40
|
+
# $log.debug "bucket_type => #{@bucket_type}"
|
41
|
+
|
42
|
+
if not @riak2_metadata_bucket_type.empty? then
|
43
|
+
# Here we are storing our bucket type and bucket name in a metadata map. This allows clients to query that map to see a list of all fluentd buckets.
|
44
|
+
|
45
|
+
# bucket_type/name/key is returns a metadata map
|
46
|
+
metadata_bucket_type = @riak2_metadata_bucket_type # config defined bucket type
|
47
|
+
metadata_bucket_name = "fluent-plugin-riak2-metadata" # bucket name
|
48
|
+
metadata_key = "fluent-plugin-riak2-metadata-key" # root level key for our metadata map
|
49
|
+
|
50
|
+
# our metadata map has a kv where:
|
51
|
+
# 1. key is set_of_logfile_buckets_key
|
52
|
+
# 2. value is a set of strings. each string represents the bucket type and name for a single logfile
|
53
|
+
set_of_logfile_buckets_key = "all_buckets" # inner key for our set of all logfile bucket type/name
|
54
|
+
|
55
|
+
mdbucket = @client.bucket(metadata_bucket_name)
|
56
|
+
Riak::Crdt::DEFAULT_BUCKET_TYPES[:map] = metadata_bucket_type
|
57
|
+
map = Riak::Crdt::Map.new(mdbucket, metadata_key)
|
58
|
+
map.sets[set_of_logfile_buckets_key].add "#{@bucket_type} #{@bucket_name}"
|
59
|
+
end
|
37
60
|
super
|
38
61
|
end
|
39
62
|
|
@@ -43,38 +66,38 @@ class Riak2Output < BufferedOutput
|
|
43
66
|
|
44
67
|
def write(chunk)
|
45
68
|
$log.debug " <<<<<===========\n"
|
46
|
-
|
47
69
|
records = []
|
48
|
-
tags = []
|
49
70
|
chunk.msgpack_each { |time, tag, record|
|
50
71
|
record[@tag_key] = tag
|
51
|
-
tags << tag
|
52
72
|
records << record
|
53
73
|
$log.debug record
|
54
74
|
}
|
55
|
-
put_now(records
|
75
|
+
put_now(records)
|
56
76
|
end
|
57
77
|
|
58
78
|
private
|
59
79
|
|
60
|
-
|
61
|
-
def put_now(records, tags)
|
80
|
+
def put_now(records)
|
62
81
|
if not records.empty? then
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
tags.each do |tag|
|
70
|
-
robj.indexes['tag_bin'] << tag
|
71
|
-
end
|
72
|
-
robj.content_type = 'application/json'
|
73
|
-
robj.store
|
74
|
-
robj
|
75
|
-
end
|
76
|
-
end
|
82
|
+
threads = []
|
83
|
+
records.each { |record|
|
84
|
+
#if you put log statements here, you must take care to NOT forward fluentd's logs to riak. you will trigger a recursive avalance of riak storage activity.
|
85
|
+
now = DateTime.now.iso8601(9)
|
86
|
+
key = "#{now}-#{UUIDTools::UUID.timestamp_create.to_s}"
|
87
|
+
# $log.debug "#{@bucket_name} #{key} \n"
|
77
88
|
|
78
|
-
|
89
|
+
# we are doing the somewhat granular storage, instead of chunked, at the record level. This probably should be a config option.
|
90
|
+
threads << Thread.new {
|
91
|
+
robj = Riak::RObject.new(@bucket, key)
|
92
|
+
robj.content_type = "application/json"
|
93
|
+
raw_data = "{\"msg_s\":\"#{record["msg"]}\",\"time_dt\":\"#{record["time"]}\",\"src_s\":\"fluentd\"}"
|
94
|
+
# $log.debug "raw_data #{raw_data}\n"
|
95
|
+
robj.raw_data = raw_data
|
96
|
+
robj.store(type: @bucket_type)
|
97
|
+
}
|
98
|
+
}
|
99
|
+
end # if
|
100
|
+
end # put_now
|
101
|
+
end # class Riak2Output
|
79
102
|
|
80
|
-
end
|
103
|
+
end # Module
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-riak2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kota UENISHI
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
12
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
name: uuidtools
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: 2.1.3
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 2.1.3
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -102,6 +102,7 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- .gitignore
|
105
|
+
- CHANGELOG
|
105
106
|
- Gemfile
|
106
107
|
- LICENSE
|
107
108
|
- README.md
|