fluent-plugin-elb-access-log 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23af18097699523eb79eacdfff39c155e14a074e
|
4
|
+
data.tar.gz: 9132f72caaa0e09e2bbbad4fefef5bb6654642ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3273e599277bb2ee5367e8934a4c8cb32d6337145c5eee60114558d2d111f4fde60149b3ef2ed811144ab35cdf5fb6e20a2cdbe2f8a8e3b6b8ccd5d4ad49c6d
|
7
|
+
data.tar.gz: 4c44fdc553b5afddb444cdead9a2c6bf00304059a4eea0f9abe2d6550588679536122afe2ffe36e5e52c9e0640841a3d287815c43d2096d01fec33d9f82fc842
|
@@ -88,7 +88,7 @@ class Fluent::ElbAccessLogInput < Fluent::Input
|
|
88
88
|
end
|
89
89
|
|
90
90
|
if @history.length > @history_length
|
91
|
-
@history.shift(history.length - @history_length)
|
91
|
+
@history.shift(@history.length - @history_length)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -179,10 +179,14 @@ class Fluent::ElbAccessLogInput < Fluent::Input
|
|
179
179
|
record['request.uri'] = uri
|
180
180
|
record['request.http_version'] = http_version
|
181
181
|
|
182
|
-
|
182
|
+
begin
|
183
|
+
uri = URI.parse(uri)
|
183
184
|
|
184
|
-
|
185
|
-
|
185
|
+
[:scheme ,:userinfo, :host, :port, :registry, :path, :opaque, :query, :fragment].each do |key|
|
186
|
+
record["request.uri.#{key}"] = uri.send(key)
|
187
|
+
end
|
188
|
+
rescue => e
|
189
|
+
@log.warn(e.message)
|
186
190
|
end
|
187
191
|
end
|
188
192
|
|
@@ -216,6 +216,131 @@ describe Fluent::ElbAccessLogInput do
|
|
216
216
|
end
|
217
217
|
|
218
218
|
it { is_expected.to eq expected_emits }
|
219
|
+
|
220
|
+
context 'when include bad URI' do
|
221
|
+
let(:today_access_log) do
|
222
|
+
<<-EOS
|
223
|
+
2015-05-24T19:55:36.000000Z hoge 14.14.124.20:57673 10.0.199.184:80 0.000053 0.000913 0.000036 200 200 0 3 "GET http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/ HTTP/1.1" "curl/7.30.0" - -
|
224
|
+
2015-05-24T19:55:36.000000Z hoge 14.14.124.20:57673 10.0.199.184:80 0.000053 0.000913 0.000036 200 200 0 3 "GET http://'hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/ HTTP/1.1" "curl/7.30.0" - -
|
225
|
+
EOS
|
226
|
+
end
|
227
|
+
|
228
|
+
let(:expected_emits) do
|
229
|
+
[["elb.access_log",
|
230
|
+
Time.parse('2015-05-24 19:55:36 UTC').to_i,
|
231
|
+
{"timestamp"=>"2015-05-24T19:55:36.000000Z",
|
232
|
+
"elb"=>"hoge",
|
233
|
+
"client"=>"14.14.124.20",
|
234
|
+
"client_port"=>57673,
|
235
|
+
"backend"=>"10.0.199.184",
|
236
|
+
"backend_port"=>80,
|
237
|
+
"request_processing_time"=>5.3e-05,
|
238
|
+
"backend_processing_time"=>0.000913,
|
239
|
+
"response_processing_time"=>3.6e-05,
|
240
|
+
"elb_status_code"=>200,
|
241
|
+
"backend_status_code"=>200,
|
242
|
+
"received_bytes"=>0,
|
243
|
+
"sent_bytes"=>3,
|
244
|
+
"request"=>
|
245
|
+
"GET http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/ HTTP/1.1",
|
246
|
+
"request.method"=>"GET",
|
247
|
+
"request.uri"=>
|
248
|
+
"http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/",
|
249
|
+
"request.http_version"=>"HTTP/1.1",
|
250
|
+
"request.uri.scheme"=>"http",
|
251
|
+
"request.uri.userinfo"=>nil,
|
252
|
+
"request.uri.host"=>"hoge-1876938939.ap-northeast-1.elb.amazonaws.com",
|
253
|
+
"request.uri.port"=>80,
|
254
|
+
"request.uri.registry"=>nil,
|
255
|
+
"request.uri.path"=>"/",
|
256
|
+
"request.uri.opaque"=>nil,
|
257
|
+
"request.uri.query"=>nil,
|
258
|
+
"request.uri.fragment"=>nil}],
|
259
|
+
["elb.access_log",
|
260
|
+
Time.parse('2015-05-24 19:55:36 UTC').to_i,
|
261
|
+
{"timestamp"=>"2015-05-24T19:55:36.000000Z",
|
262
|
+
"elb"=>"hoge",
|
263
|
+
"client"=>"14.14.124.20",
|
264
|
+
"client_port"=>57673,
|
265
|
+
"backend"=>"10.0.199.184",
|
266
|
+
"backend_port"=>80,
|
267
|
+
"request_processing_time"=>5.3e-05,
|
268
|
+
"backend_processing_time"=>0.000913,
|
269
|
+
"response_processing_time"=>3.6e-05,
|
270
|
+
"elb_status_code"=>200,
|
271
|
+
"backend_status_code"=>200,
|
272
|
+
"received_bytes"=>0,
|
273
|
+
"sent_bytes"=>3,
|
274
|
+
"request"=>
|
275
|
+
"GET http://'hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/ HTTP/1.1",
|
276
|
+
"request.method"=>"GET",
|
277
|
+
"request.uri"=>
|
278
|
+
"http://'hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/",
|
279
|
+
"request.http_version"=>"HTTP/1.1"}],
|
280
|
+
["elb.access_log",
|
281
|
+
Time.parse('2015-05-25 19:55:36 UTC').to_i,
|
282
|
+
{"timestamp"=>"2015-05-25T19:55:36.000000Z",
|
283
|
+
"elb"=>"hoge",
|
284
|
+
"client"=>"14.14.124.20",
|
285
|
+
"client_port"=>57673,
|
286
|
+
"backend"=>"10.0.199.184",
|
287
|
+
"backend_port"=>80,
|
288
|
+
"request_processing_time"=>5.3e-05,
|
289
|
+
"backend_processing_time"=>0.000913,
|
290
|
+
"response_processing_time"=>3.6e-05,
|
291
|
+
"elb_status_code"=>200,
|
292
|
+
"backend_status_code"=>200,
|
293
|
+
"received_bytes"=>0,
|
294
|
+
"sent_bytes"=>3,
|
295
|
+
"request"=>
|
296
|
+
"GET http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/ HTTP/1.1",
|
297
|
+
"request.method"=>"GET",
|
298
|
+
"request.uri"=>
|
299
|
+
"http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/",
|
300
|
+
"request.http_version"=>"HTTP/1.1",
|
301
|
+
"request.uri.scheme"=>"http",
|
302
|
+
"request.uri.userinfo"=>nil,
|
303
|
+
"request.uri.host"=>"hoge-1876938939.ap-northeast-1.elb.amazonaws.com",
|
304
|
+
"request.uri.port"=>80,
|
305
|
+
"request.uri.registry"=>nil,
|
306
|
+
"request.uri.path"=>"/",
|
307
|
+
"request.uri.opaque"=>nil,
|
308
|
+
"request.uri.query"=>nil,
|
309
|
+
"request.uri.fragment"=>nil}],
|
310
|
+
["elb.access_log",
|
311
|
+
Time.parse('2015-05-25 19:55:36 UTC').to_i,
|
312
|
+
{"timestamp"=>"2015-05-25T19:55:36.000000Z",
|
313
|
+
"elb"=>"hoge",
|
314
|
+
"client"=>"14.14.124.20",
|
315
|
+
"client_port"=>57673,
|
316
|
+
"backend"=>"10.0.199.184",
|
317
|
+
"backend_port"=>80,
|
318
|
+
"request_processing_time"=>5.3e-05,
|
319
|
+
"backend_processing_time"=>0.000913,
|
320
|
+
"response_processing_time"=>3.6e-05,
|
321
|
+
"elb_status_code"=>200,
|
322
|
+
"backend_status_code"=>200,
|
323
|
+
"received_bytes"=>0,
|
324
|
+
"sent_bytes"=>3,
|
325
|
+
"request"=>
|
326
|
+
"GET http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/ HTTP/1.1",
|
327
|
+
"request.method"=>"GET",
|
328
|
+
"request.uri"=>
|
329
|
+
"http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/",
|
330
|
+
"request.http_version"=>"HTTP/1.1",
|
331
|
+
"request.uri.scheme"=>"http",
|
332
|
+
"request.uri.userinfo"=>nil,
|
333
|
+
"request.uri.host"=>"hoge-1876938939.ap-northeast-1.elb.amazonaws.com",
|
334
|
+
"request.uri.port"=>80,
|
335
|
+
"request.uri.registry"=>nil,
|
336
|
+
"request.uri.path"=>"/",
|
337
|
+
"request.uri.opaque"=>nil,
|
338
|
+
"request.uri.query"=>nil,
|
339
|
+
"request.uri.fragment"=>nil}]]
|
340
|
+
end
|
341
|
+
|
342
|
+
it { is_expected.to eq expected_emits }
|
343
|
+
end
|
219
344
|
end
|
220
345
|
|
221
346
|
context 'when access log exists (with tag option)' do
|
@@ -402,4 +527,48 @@ describe Fluent::ElbAccessLogInput do
|
|
402
527
|
|
403
528
|
it { is_expected.to be_empty }
|
404
529
|
end
|
530
|
+
|
531
|
+
describe 'history#length' do
|
532
|
+
let(:today_access_log) do
|
533
|
+
<<-EOS
|
534
|
+
2015-05-24T19:55:36.000000Z hoge 14.14.124.20:57673 10.0.199.184:80 0.000053 0.000913 0.000036 200 200 0 3 "GET http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/ HTTP/1.1" "curl/7.30.0" - -
|
535
|
+
EOS
|
536
|
+
end
|
537
|
+
|
538
|
+
let(:history) { driver.instance.instance_variable_get(:@history) }
|
539
|
+
|
540
|
+
before do
|
541
|
+
expect(client).to receive(:list_objects).with(bucket: s3_bucket, prefix: yesterday_prefix) { [] }
|
542
|
+
expect(client).to receive(:list_objects).with(bucket: s3_bucket, prefix: tomorrow_prefix) { [] }
|
543
|
+
|
544
|
+
expect(client).to receive(:list_objects).with(bucket: s3_bucket, prefix: today_prefix) do
|
545
|
+
[double('today_objects', contents: [double('today_object', key: today_object_key)])]
|
546
|
+
end
|
547
|
+
|
548
|
+
expect(client).to receive(:get_object).with(bucket: s3_bucket, key: today_object_key) do
|
549
|
+
[double('today_s3_object', body: StringIO.new(today_access_log))]
|
550
|
+
end
|
551
|
+
|
552
|
+
expect(driver.instance).to receive(:save_timestamp).with(today)
|
553
|
+
end
|
554
|
+
|
555
|
+
subject { history.length }
|
556
|
+
|
557
|
+
context 'when history.length <= 100' do
|
558
|
+
before do
|
559
|
+
driver.run
|
560
|
+
end
|
561
|
+
|
562
|
+
it { is_expected.to eq 1 }
|
563
|
+
end
|
564
|
+
|
565
|
+
context 'when history.length > 100' do
|
566
|
+
before do
|
567
|
+
history.concat (1..100).map(&:to_s)
|
568
|
+
driver.run
|
569
|
+
end
|
570
|
+
|
571
|
+
it { is_expected.to eq 100 }
|
572
|
+
end
|
573
|
+
end
|
405
574
|
end
|