fluent-plugin-riak 0.0.1 → 0.0.2

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.
data/Gemfile CHANGED
@@ -3,3 +3,4 @@ source :rubygems
3
3
  gemspec
4
4
 
5
5
  gem "simplecov", :require => false
6
+ gem "uuidtools", :require => ">= 2.1.3"
data/README.md CHANGED
@@ -5,6 +5,36 @@ fluent-plugin-riak is a alternative for people who are not sufficient with mongo
5
5
 
6
6
  Current status is still proof-of-concept: index setting and its configuration are to be decided. Also performance optimization is required. Another idea is in_tail_riak by using riak post-commit.
7
7
 
8
+
9
+ fluent.conf example
10
+ -------------------
11
+
12
+ ```
13
+ <match riak.**>
14
+ type riak
15
+
16
+ buffer_type memory
17
+ flush_interval 10s
18
+ retry_limit 5
19
+ retry_wait 1s
20
+ buffer_chunk_limit 256m
21
+ buffer_queue_limit 8096
22
+
23
+ # pb port
24
+ nodes 127.0.0.1:8087
25
+ #for cluster, define multiple machines
26
+ #nodes 192.168.100.128:10018 129.168.100.128:10028
27
+ </match>
28
+
29
+ ```
30
+
31
+ key format -> 2013-02-<uuid>
32
+ value format -> [records] in JSON
33
+ index:
34
+ year_int -> year
35
+ month_bin -> <year>-<month>
36
+ tag_bin -> tags
37
+
8
38
  Pros
9
39
  ----
10
40
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -18,6 +18,7 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.add_dependency "fluentd", "~> 0.10.7"
20
20
  gem.add_dependency "riak-client", "~> 1.0.0"
21
+ gem.add_dependency "uuidtools", ">= 2.1.3"
21
22
  gem.add_development_dependency "rake", ">= 0.9.2"
22
23
  gem.add_development_dependency "simplecov", ">= 0.5.4"
23
24
  gem.add_development_dependency "rr", ">= 1.0.0"
@@ -4,16 +4,17 @@ class RiakOutput < BufferedOutput
4
4
 
5
5
  Fluent::Plugin.register_output('riak', self)
6
6
  include SetTimeKeyMixin
7
- config_set_default :include_tag_key, false
7
+ config_set_default :include_tag_key, true
8
8
  include SetTagKeyMixin
9
9
  config_set_default :include_time_key, true
10
10
 
11
- config_param :nodes, :string, :default => "localhost:8081"
11
+ config_param :nodes, :string, :default => "localhost:8087"
12
12
 
13
13
  def initialize
14
14
  super
15
15
  require 'riak'
16
16
  require 'msgpack'
17
+ require 'uuidtools'
17
18
  end
18
19
 
19
20
  def configure(conf)
@@ -36,31 +37,39 @@ class RiakOutput < BufferedOutput
36
37
  end
37
38
 
38
39
  def format(tag, time, record)
39
- [time, record].to_msgpack
40
+ [time, tag, record].to_msgpack
40
41
  end
41
42
 
42
43
  def write(chunk)
43
- $log.warn " <<<<<===========\n"
44
+ $log.debug " <<<<<===========\n"
44
45
 
45
46
  records = []
46
- chunk.msgpack_each { |time, record|
47
- # TODO: time processing and tag processing
47
+ tags = []
48
+ chunk.msgpack_each { |time, tag, record|
49
+ record[@tag_key] = tag
50
+ tags << tag
48
51
  records << record
49
52
  $log.debug record
50
53
  }
51
- put_now(records)
54
+ put_now(records, tags)
52
55
  end
53
56
 
54
57
  private
55
58
 
56
59
  # TODO: add index for some analysis
57
- def put_now(obj)
58
- key = Time.now.to_i.to_s
60
+ def put_now(records, tags)
61
+ today = Date.today
62
+ key = "#{today.to_s}-#{UUIDTools::UUID.random_create.to_s}"
59
63
  robj = Riak::RObject.new(@bucket, key)
60
- robj.raw_data = obj.to_json
61
- robj.content_type = 'text/json'
64
+ robj.raw_data = records.to_json
65
+ robj.indexes['year_int'] << today.year
66
+ robj.indexes['month_bin'] << "#{today.year}-#{today.month}"
67
+ tags.each do |tag|
68
+ robj.indexes['tag_bin'] << tag
69
+ end
70
+ robj.content_type = 'application/json'
62
71
  robj.store
63
- key
72
+ robj
64
73
  end
65
74
 
66
75
  end
data/listkeys.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'riak'
2
2
 
3
- nodes = [{ :host => "192.168.62.129",
4
- :pb_port => 8081 }]
3
+ nodes = [{ :host => "127.0.0.1",
4
+ :pb_port => 8087 }]
5
5
 
6
6
 
7
7
  c = Riak::Client.new( :nodes => nodes, :protocol => "pbc" )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-riak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: 1.0.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: uuidtools
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 2.1.3
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.1.3
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: rake
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
136
  version: '0'
121
137
  segments:
122
138
  - 0
123
- hash: -2864304810169974857
139
+ hash: 2812051443307104688
124
140
  required_rubygems_version: !ruby/object:Gem::Requirement
125
141
  none: false
126
142
  requirements:
@@ -129,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
145
  version: '0'
130
146
  segments:
131
147
  - 0
132
- hash: -2864304810169974857
148
+ hash: 2812051443307104688
133
149
  requirements: []
134
150
  rubyforge_project:
135
151
  rubygems_version: 1.8.23