fluentd 1.2.0.pre1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e457fdb0637a4e2ca90d91766e53db7d1a35b44c
4
- data.tar.gz: 71aad06bb2784901e8e1517b6433536321fdeeae
3
+ metadata.gz: 784878757e32d7abd7c3bed9bcb4f081524502b0
4
+ data.tar.gz: 89205de62e14d5b3210888a40656df87c6bc8d15
5
5
  SHA512:
6
- metadata.gz: 98f12edb338eb087180087c0d10ed0d23070d06333ee39784faf24c4190ae39cce899e43f0644728a50768743b872954ad90fbd9a962caf67efe0c8ea0b12547
7
- data.tar.gz: 7ce0e7b63dcbd094c3c9452851fc91c3660e44ed69fbc3cc7aa67d53cf96ac615f9c172957d0092c054250aa4c12a09837c0f1965e3caa02153a7d092070e449
6
+ metadata.gz: fcbe5512f4ce1ffef0af5948dd4a6a1b81095f2d3032dee86692db4eb1164f13a2710786562980d2d44f3d289f9120d53c222b4ca796eae58fbc15e0354a657a
7
+ data.tar.gz: 918b3cad26663a13c5ccba5e4fea2494124d793e5744e1c4e7e2b2d844a758638a3b78843e3718af7e1c95ee8420c60c06b469531dc0bba5151504817e970c64
@@ -1,5 +1,33 @@
1
1
  # v1.1
2
2
 
3
+ ## Release v1.2.0 - 2018/04/30
4
+
5
+ ### New Features
6
+
7
+ * New Counter API
8
+ https://github.com/fluent/fluentd/pull/1857
9
+ * output: Backup for broken chunks
10
+ https://github.com/fluent/fluentd/pull/1952
11
+ * filter_grep: Support `<and>` and `<or>` support
12
+ https://github.com/fluent/fluentd/pull/1897
13
+ * config: Support `regexp` type in configuration parameter
14
+ https://github.com/fluent/fluentd/pull/1927
15
+
16
+ ### Enhancements
17
+
18
+ * parser_nginx: Support optional `http-x-forwarded-for` field
19
+ https://github.com/fluent/fluentd/pull/1932
20
+ * filter_grep: Improve the performance
21
+ https://github.com/fluent/fluentd/pull/1940
22
+
23
+ ### Bug fixes
24
+
25
+ * log: Fix unexpected implementation bug when log rotation setting is applied
26
+ https://github.com/fluent/fluentd/pull/1957
27
+ * server helper: Close invalid socket when ssl error happens on reading
28
+ https://github.com/fluent/fluentd/pull/1942
29
+ * output: Buffer chunk's unique id should be formatted as hex in the log
30
+
3
31
  ## Release v1.1.3 - 2018/04/03
4
32
 
5
33
  ### Enhancements
@@ -1,6 +1,7 @@
1
- - Sadayuki Furuhashi <frsyuki@gmail.com>
2
- - Masahiro Nakagawa <repeatedly@gmail.com>
3
- - Kiyoto Tamura <me@ktamura.com>
4
- - Kazuki Ohta <kazuki.ohta@gmail.com>
5
- - Satoshi "Moris" Tagomori <tagomoris@gmail.com>
6
- - Eduardo Silva <eduardo@treasure-data.com>
1
+ # Fluentd Maintainers
2
+
3
+ - [Naotoshi Seo](https://github.com/sonots), [DeNA](http://dena.com/intl/)
4
+ - [Okkez](https://github.com/okkez), [Clearcode](https://www.clear-code.com/)
5
+ - [Hiroshi Hatake](https://github.com/cosmo0920), [Clearcode](https://www.clear-code.com/)
6
+ - [Masahiro Nakagawa](https://github.com/repeatedly), [Treasure Data](https://www.treasuredata.com/)
7
+ - [Satoshi Tagomori](https://github.com/tagomoris), [Treasure Data](https://www.treasuredata.com/)
@@ -0,0 +1,18 @@
1
+ <system>
2
+ <counter_server>
3
+ scope server1
4
+ bind 127.0.0.1
5
+ port 24321
6
+ path tmp/back
7
+ </counter_server>
8
+ </system>
9
+
10
+ <source>
11
+ @type dummy
12
+ tag "test.data"
13
+ auto_increment_key number
14
+ </source>
15
+
16
+ <match>
17
+ @type stdout
18
+ </match>
@@ -22,9 +22,10 @@
22
22
  @type forward
23
23
 
24
24
  <buffer time,tag,message>
25
- type memory
25
+ @type memory
26
26
  timekey 2s
27
27
  timekey_wait 1s
28
+ flush_mode interval
28
29
  flush_interval 1s
29
30
  </buffer>
30
31
 
@@ -34,7 +35,7 @@
34
35
  </server>
35
36
 
36
37
  <secondary>
37
- type secondary_file
38
+ @type secondary_file
38
39
  directory log/secondary/
39
40
  basename ${tag}_%Y%m%d%L_${message}
40
41
  </secondary>
@@ -0,0 +1,23 @@
1
+ #
2
+ # Fluentd
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'fluent/counter/client'
18
+ require 'fluent/counter/server'
19
+
20
+ module Fluent
21
+ module Counter
22
+ end
23
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Fluentd
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'cool.io'
18
+ require 'fluent/msgpack_factory'
19
+
20
+ module Fluent
21
+ module Counter
22
+ class BaseSocket < Coolio::TCPSocket
23
+ include Fluent::MessagePackFactory::Mixin
24
+
25
+ def packed_write(data)
26
+ write pack(data)
27
+ end
28
+
29
+ def on_read(data)
30
+ msgpack_unpacker.feed_each(data) do |d|
31
+ on_message d
32
+ end
33
+ end
34
+
35
+ def on_message(data)
36
+ raise NotImplementedError
37
+ end
38
+
39
+ private
40
+
41
+ def pack(data)
42
+ msgpack_packer.pack(data)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,288 @@
1
+ #
2
+ # Fluentd
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'cool.io'
18
+ require 'fluent/counter/base_socket'
19
+ require 'timeout'
20
+
21
+ module Fluent
22
+ module Counter
23
+ class Client
24
+ DEFAULT_PORT = 24321
25
+ DEFAULT_ADDR = '127.0.0.1'
26
+ DEFAULT_TIMEOUT = 5
27
+ ID_LIMIT_COUNT = 1 << 31
28
+
29
+ def initialize(loop = nil, opt = {})
30
+ @loop = loop || Coolio::Loop.new
31
+ @port = opt[:port] || DEFAULT_PORT
32
+ @host = opt[:host] || DEFAULT_ADDR
33
+ @log = opt[:log] || $log
34
+ @timeout = opt[:timeout] || DEFAULT_TIMEOUT
35
+ @conn = Connection.connect(@host, @port, method(:on_message))
36
+ @responses = {}
37
+ @id = 0
38
+ @id_mutex = Mutex.new
39
+ @loop_mutex = Mutex.new
40
+ end
41
+
42
+ def start
43
+ @loop.attach(@conn)
44
+ @log.debug("starting counter client: #{@host}:#{@port}")
45
+ self
46
+ rescue => e
47
+ if @log
48
+ @log.error e
49
+ else
50
+ STDERR.puts e
51
+ end
52
+ end
53
+
54
+ def stop
55
+ @conn.close
56
+ @log.debug("calling stop in counter client: #{@host}:#{@port}")
57
+ end
58
+
59
+ def establish(scope)
60
+ scope = Timeout.timeout(@timeout) {
61
+ response = send_request('establish', nil, [scope])
62
+ raise response.errors.first if response.errors?
63
+ data = response.data
64
+ data.first
65
+ }
66
+ @scope = scope
67
+ rescue Timeout::Error
68
+ raise "Can't establish the connection to counter server due to timeout"
69
+ end
70
+
71
+ # === Example
72
+ # `init` receives various arguments.
73
+ #
74
+ # 1. init(name: 'name')
75
+ # 2. init({ name: 'name',reset_interval: 20 }, options: {})
76
+ # 3. init([{ name: 'name1',reset_interval: 20 }, { name: 'name2',reset_interval: 20 }])
77
+ # 4. init([{ name: 'name1',reset_interval: 20 }, { name: 'name2',reset_interval: 20 }], options: {})
78
+ # 5. init([{ name: 'name1',reset_interval: 20 }, { name: 'name2',reset_interval: 20 }]) { |res| ... }
79
+ def init(params, options: {})
80
+ exist_scope!
81
+ params = [params] unless params.is_a?(Array)
82
+ res = send_request('init', @scope, params, options)
83
+
84
+ # if `async` is false or missing, block at this method and return a Future::Result object.
85
+ if block_given?
86
+ Thread.start do
87
+ yield res.get
88
+ end
89
+ else
90
+ res
91
+ end
92
+ end
93
+
94
+ def delete(*params, options: {})
95
+ exist_scope!
96
+ res = send_request('delete', @scope, params, options)
97
+
98
+ if block_given?
99
+ Thread.start do
100
+ yield res.get
101
+ end
102
+ else
103
+ res
104
+ end
105
+ end
106
+
107
+ # === Example
108
+ # `inc` receives various arguments.
109
+ #
110
+ # 1. inc(name: 'name')
111
+ # 2. inc({ name: 'name',value: 20 }, options: {})
112
+ # 3. inc([{ name: 'name1',value: 20 }, { name: 'name2',value: 20 }])
113
+ # 4. inc([{ name: 'name1',value: 20 }, { name: 'name2',value: 20 }], options: {})
114
+ def inc(params, options: {})
115
+ exist_scope!
116
+ params = [params] unless params.is_a?(Array)
117
+ res = send_request('inc', @scope, params, options)
118
+
119
+ if block_given?
120
+ Thread.start do
121
+ yield res.get
122
+ end
123
+ else
124
+ res
125
+ end
126
+ end
127
+
128
+ def get(*params, options: {})
129
+ exist_scope!
130
+ res = send_request('get', @scope, params, options)
131
+
132
+ if block_given?
133
+ Thread.start do
134
+ yield res.get
135
+ end
136
+ else
137
+ res
138
+ end
139
+ end
140
+
141
+ def reset(*params, options: {})
142
+ exist_scope!
143
+ res = send_request('reset', @scope, params, options)
144
+
145
+ if block_given?
146
+ Thread.start do
147
+ yield res.get
148
+ end
149
+ else
150
+ res
151
+ end
152
+ end
153
+
154
+ private
155
+
156
+ def exist_scope!
157
+ raise 'Call `establish` method to get a `scope` before calling this method' unless @scope
158
+ end
159
+
160
+ def on_message(data)
161
+ if response = @responses.delete(data['id'])
162
+ response.set(data)
163
+ else
164
+ @log.warn("Receiving missing id data: #{data}")
165
+ end
166
+ end
167
+
168
+ def send_request(method, scope, params, opt = {})
169
+ id = generate_id
170
+ res = Future.new(@loop, @loop_mutex)
171
+ @responses[id] = res # set a response value to this future object at `on_message`
172
+ request = build_request(method, id, scope, params, opt)
173
+ @log.debug(request)
174
+ @conn.send_data request
175
+ res
176
+ end
177
+
178
+ def build_request(method, id, scope = nil, params = nil, options = nil)
179
+ r = { id: id, method: method }
180
+ r[:scope] = scope if scope
181
+ r[:params] = params if params
182
+ r[:options] = options if options
183
+ r
184
+ end
185
+
186
+ def generate_id
187
+ id = 0
188
+ @id_mutex.synchronize do
189
+ id = @id
190
+ @id += 1
191
+ @id = 0 if ID_LIMIT_COUNT < @id
192
+ end
193
+ id
194
+ end
195
+ end
196
+
197
+ class Connection < Fluent::Counter::BaseSocket
198
+ def initialize(io, on_message)
199
+ super(io)
200
+ @connection = false
201
+ @buffer = ''
202
+ @on_message = on_message
203
+ end
204
+
205
+ def send_data(data)
206
+ if @connection
207
+ packed_write data
208
+ else
209
+ @buffer += pack(data)
210
+ end
211
+ end
212
+
213
+ def on_connect
214
+ @connection = true
215
+ write @buffer
216
+ @buffer = ''
217
+ end
218
+
219
+ def on_close
220
+ @connection = false
221
+ end
222
+
223
+ def on_message(data)
224
+ @on_message.call(data)
225
+ end
226
+ end
227
+
228
+ class Future
229
+ class Result
230
+ attr_reader :data, :errors
231
+
232
+ def initialize(result)
233
+ @errors = result['errors']
234
+ @data = result['data']
235
+ end
236
+
237
+ def success?
238
+ @errors.nil? || @errors.empty?
239
+ end
240
+
241
+ def error?
242
+ !success?
243
+ end
244
+ end
245
+
246
+ def initialize(loop, mutex)
247
+ @set = false
248
+ @result = nil
249
+ @mutex = mutex
250
+ @loop = loop
251
+ end
252
+
253
+ def set(v)
254
+ @result = Result.new(v)
255
+ @set = true
256
+ end
257
+
258
+ def errors
259
+ get.errors
260
+ end
261
+
262
+ def errors?
263
+ es = errors
264
+ es && !es.empty?
265
+ end
266
+
267
+ def data
268
+ get.data
269
+ end
270
+
271
+ def get
272
+ # Block until `set` method is called and @result is set
273
+ join if @result.nil?
274
+ @result
275
+ end
276
+
277
+ private
278
+
279
+ def join
280
+ until @set
281
+ @mutex.synchronize do
282
+ @loop.run_once(0.0001) # retun a lock as soon as possible
283
+ end
284
+ end
285
+ end
286
+ end
287
+ end
288
+ end