fluent-plugin-elb-access-log 0.3.5 → 0.3.6.beta1
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: b6eaa3c13f77a8734ed7221b6d9a27dfcbc2d8c3
|
4
|
+
data.tar.gz: 6e4f32e43b6ff3a9299a8172fb5645466c5b8322
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bf817d46c52c8d70016c14add800602af362b71ea2de5c3420b66641766bdb5138d08090abf4d5d0b8f4a1036f049fcaec739dfa8a578b84400bb85a5df0ce6
|
7
|
+
data.tar.gz: 371117dac3d925ec4ed8d214311cfc8c3b24daac639a46a71bec779faa1d2b78ecd8662acb7f6de5b37eb2bfde179e3012d48291e402220b5d703448f99e9681
|
@@ -166,7 +166,7 @@ class Fluent::ElbAccessLogInput < Fluent::Input
|
|
166
166
|
|
167
167
|
parsed_access_log = []
|
168
168
|
|
169
|
-
|
169
|
+
access_log.split("\n").each do |line|
|
170
170
|
line = parse_line(line)
|
171
171
|
parsed_access_log << line if line
|
172
172
|
end
|
@@ -183,8 +183,13 @@ class Fluent::ElbAccessLogInput < Fluent::Input
|
|
183
183
|
|
184
184
|
parse_request!(record)
|
185
185
|
|
186
|
-
|
187
|
-
|
186
|
+
begin
|
187
|
+
time = Time.parse(record['timestamp'])
|
188
|
+
router.emit(@tag, time.to_i, record)
|
189
|
+
rescue ArgumentError => e
|
190
|
+
@log.warn("#{e.message}: #{line}")
|
191
|
+
@log.warn('A record that has bad timestamp is not emitted.')
|
192
|
+
end
|
188
193
|
end
|
189
194
|
end
|
190
195
|
|
@@ -215,32 +220,6 @@ class Fluent::ElbAccessLogInput < Fluent::Input
|
|
215
220
|
parsed
|
216
221
|
end
|
217
222
|
|
218
|
-
# This method is required because fields of user-agent are sometimes separated
|
219
|
-
# to several lines like flollowing example,
|
220
|
-
# 2017-06-07T22:47:14.827494Z baby 162.243.126.163:37036 10.6.49.1:80 0.000042 0.004133 0.00002 301 301 0 232 "GET http://example.com:80/ HTTP/1.0" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133
|
221
|
-
# Safari/537.36
|
222
|
-
#" - -
|
223
|
-
def normalize_line_feeds(str)
|
224
|
-
in_quotation = false
|
225
|
-
normalized_str = ''
|
226
|
-
previous_ch = nil
|
227
|
-
|
228
|
-
str.each_char do |current_ch|
|
229
|
-
if in_quotation && current_ch == "\n"
|
230
|
-
normalized_str << ' '
|
231
|
-
else
|
232
|
-
normalized_str << current_ch
|
233
|
-
end
|
234
|
-
|
235
|
-
if current_ch == '"' && previous_ch != '"'
|
236
|
-
in_quotation = !in_quotation
|
237
|
-
end
|
238
|
-
previous_ch = current_ch
|
239
|
-
end
|
240
|
-
|
241
|
-
normalized_str
|
242
|
-
end
|
243
|
-
|
244
223
|
def sampling(access_log)
|
245
224
|
access_log.split("\n").each_with_index.select {|row, i| (i % @sampling_interval).zero? }.map {|row, i| row }.join("\n")
|
246
225
|
end
|
@@ -678,68 +678,4 @@ describe Fluent::ElbAccessLogInput do
|
|
678
678
|
|
679
679
|
it { is_expected.to eq expected_emits }
|
680
680
|
end
|
681
|
-
|
682
|
-
context 'when a record has a line feed in an user-agent quotation' do
|
683
|
-
let(:today_access_log) do
|
684
|
-
<<-'EOS'
|
685
|
-
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" "Dummy user agent
|
686
|
-
""7.30.0""
|
687
|
-
- " ssl_cipher ssl_protocol
|
688
|
-
EOS
|
689
|
-
end
|
690
|
-
|
691
|
-
before do
|
692
|
-
expect(client).to receive(:list_objects).with(bucket: s3_bucket, prefix: yesterday_prefix) { [] }
|
693
|
-
expect(client).to receive(:list_objects).with(bucket: s3_bucket, prefix: tomorrow_prefix) { [] }
|
694
|
-
|
695
|
-
expect(client).to receive(:list_objects).with(bucket: s3_bucket, prefix: today_prefix) do
|
696
|
-
[double('today_objects', contents: [double('today_object', key: today_object_key)])]
|
697
|
-
end
|
698
|
-
|
699
|
-
expect(client).to receive(:get_object).with(bucket: s3_bucket, key: today_object_key) do
|
700
|
-
double('today_s3_object', body: StringIO.new(today_access_log))
|
701
|
-
end
|
702
|
-
|
703
|
-
expect(driver.instance).to receive(:save_timestamp).with(today)
|
704
|
-
expect(driver.instance).to receive(:save_history)
|
705
|
-
|
706
|
-
driver.run
|
707
|
-
end
|
708
|
-
|
709
|
-
let(:expected_emits) do
|
710
|
-
[["elb.access_log",
|
711
|
-
Time.parse('2015-05-24 19:55:36 UTC').to_i,
|
712
|
-
{"timestamp"=>"2015-05-24T19:55:36.000000Z",
|
713
|
-
"elb"=>"hoge",
|
714
|
-
"client"=>"14.14.124.20",
|
715
|
-
"client_port"=>57673,
|
716
|
-
"backend"=>"10.0.199.184",
|
717
|
-
"backend_port"=>80,
|
718
|
-
"request_processing_time"=>5.3e-05,
|
719
|
-
"backend_processing_time"=>0.000913,
|
720
|
-
"response_processing_time"=>3.6e-05,
|
721
|
-
"elb_status_code"=>200,
|
722
|
-
"backend_status_code"=>200,
|
723
|
-
"received_bytes"=>0,
|
724
|
-
"sent_bytes"=>3,
|
725
|
-
"request"=>
|
726
|
-
"GET http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/ HTTP/1.1",
|
727
|
-
"user_agent"=>'Dummy user agent "7.30.0" - ',
|
728
|
-
"ssl_cipher"=>"ssl_cipher",
|
729
|
-
"ssl_protocol"=>"ssl_protocol",
|
730
|
-
"request.method"=>"GET",
|
731
|
-
"request.uri"=>
|
732
|
-
"http://hoge-1876938939.ap-northeast-1.elb.amazonaws.com:80/",
|
733
|
-
"request.http_version"=>"HTTP/1.1",
|
734
|
-
"request.uri.scheme"=>"http",
|
735
|
-
"request.uri.user"=>nil,
|
736
|
-
"request.uri.host"=>"hoge-1876938939.ap-northeast-1.elb.amazonaws.com",
|
737
|
-
"request.uri.port"=>80,
|
738
|
-
"request.uri.path"=>"/",
|
739
|
-
"request.uri.query"=>nil,
|
740
|
-
"request.uri.fragment"=>nil}]]
|
741
|
-
end
|
742
|
-
|
743
|
-
it { is_expected.to eq expected_emits }
|
744
|
-
end
|
745
681
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-elb-access-log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -157,9 +157,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
159
|
requirements:
|
160
|
-
- - "
|
160
|
+
- - ">"
|
161
161
|
- !ruby/object:Gem::Version
|
162
|
-
version:
|
162
|
+
version: 1.3.1
|
163
163
|
requirements: []
|
164
164
|
rubyforge_project:
|
165
165
|
rubygems_version: 2.6.11
|