fluent-plugin-elb-access-log 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/fluent/plugin/in_elb_access_log.rb +25 -16
- data/lib/fluent_plugin_elb_access_log/version.rb +1 -1
- data/spec/in_elb_access_log_config_spec.rb +4 -0
- data/spec/in_elb_access_log_spec.rb +18 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96510ed8b34e1025ead147d989eefc4459404ae8
|
4
|
+
data.tar.gz: f44e0a4c33aa20267fa604fe181f1861c24b1ed5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0375b94759d747d2f3bbdf0cec1b048cb1ec81149f1db9f111edc66726563b4cb75316ecb45a3c87b248ae8215076f0b32b00457779aacb3c04e6b635d2d495
|
7
|
+
data.tar.gz: 573db4ec038fb669d091e4125a7f09d0c485d619f28db67aea3e120f2439d9d9386d1f065790ebd085bd0f1e90c286fde90b224c95f56182474abc5ed8453a4f
|
data/README.md
CHANGED
@@ -29,22 +29,23 @@ class Fluent::ElbAccessLogInput < Fluent::Input
|
|
29
29
|
define_method('router') { Fluent::Engine }
|
30
30
|
end
|
31
31
|
|
32
|
-
config_param :aws_key_id,
|
33
|
-
config_param :aws_sec_key,
|
34
|
-
config_param :profile,
|
35
|
-
config_param :credentials_path,
|
36
|
-
config_param :http_proxy,
|
37
|
-
config_param :account_id,
|
38
|
-
config_param :region,
|
39
|
-
config_param :s3_bucket,
|
40
|
-
config_param :s3_prefix,
|
41
|
-
config_param :tag,
|
42
|
-
config_param :tsfile_path,
|
43
|
-
config_param :interval,
|
44
|
-
config_param :start_datetime,
|
45
|
-
config_param :buffer_sec,
|
46
|
-
config_param :history_length,
|
47
|
-
config_param :
|
32
|
+
config_param :aws_key_id, :string, :default => nil
|
33
|
+
config_param :aws_sec_key, :string, :default => nil
|
34
|
+
config_param :profile, :string, :default => nil
|
35
|
+
config_param :credentials_path, :string, :default => nil
|
36
|
+
config_param :http_proxy, :string, :default => nil
|
37
|
+
config_param :account_id, :string
|
38
|
+
config_param :region, :string
|
39
|
+
config_param :s3_bucket, :string
|
40
|
+
config_param :s3_prefix, :string, :default => nil
|
41
|
+
config_param :tag, :string, :default => 'elb.access_log'
|
42
|
+
config_param :tsfile_path, :string, :default => '/var/tmp/fluent-plugin-elb-access-log.ts'
|
43
|
+
config_param :interval, :time, :default => 300
|
44
|
+
config_param :start_datetime, :string, :default => nil
|
45
|
+
config_param :buffer_sec, :time, :default => 600
|
46
|
+
config_param :history_length, :integer, :default => 100
|
47
|
+
config_param :sampling_interval, :integer, :default => 1
|
48
|
+
config_param :debug, :bool, :default => false
|
48
49
|
|
49
50
|
def initialize
|
50
51
|
super
|
@@ -146,6 +147,10 @@ class Fluent::ElbAccessLogInput < Fluent::Input
|
|
146
147
|
end
|
147
148
|
|
148
149
|
def emit_access_log(access_log)
|
150
|
+
if @sampling_interval > 1
|
151
|
+
access_log = sampling(access_log)
|
152
|
+
end
|
153
|
+
|
149
154
|
access_log = CSV.parse(access_log, :col_sep => ' ')
|
150
155
|
|
151
156
|
access_log.each do |row|
|
@@ -165,6 +170,10 @@ class Fluent::ElbAccessLogInput < Fluent::Input
|
|
165
170
|
end
|
166
171
|
end
|
167
172
|
|
173
|
+
def sampling(access_log)
|
174
|
+
access_log.split("\n").each_with_index.select {|row, i| (i % @sampling_interval).zero? }.map {|row, i| row }.join("\n")
|
175
|
+
end
|
176
|
+
|
168
177
|
def split_address_port!(record, prefix)
|
169
178
|
address, port = record["#{prefix}_port"].split(':', 2)
|
170
179
|
record[prefix] = address
|
@@ -38,6 +38,7 @@ describe 'Fluent::ElbAccessLogInput#configure' do
|
|
38
38
|
expect(driver.instance.start_datetime).to eq today
|
39
39
|
expect(driver.instance.buffer_sec).to eq 600
|
40
40
|
expect(driver.instance.history_length).to eq 100
|
41
|
+
expect(driver.instance.sampling_interval).to eq 1
|
41
42
|
expect(driver.instance.debug).to be_falsey
|
42
43
|
end
|
43
44
|
end
|
@@ -55,6 +56,7 @@ describe 'Fluent::ElbAccessLogInput#configure' do
|
|
55
56
|
let(:start_datetime) { today - 3600 }
|
56
57
|
let(:buffer_sec) { 1200 }
|
57
58
|
let(:history_length) { 200 }
|
59
|
+
let(:sampling_interval) { 100 }
|
58
60
|
|
59
61
|
let(:fluentd_conf) do
|
60
62
|
{
|
@@ -73,6 +75,7 @@ describe 'Fluent::ElbAccessLogInput#configure' do
|
|
73
75
|
start_datetime: start_datetime,
|
74
76
|
buffer_sec: buffer_sec,
|
75
77
|
history_length: history_length,
|
78
|
+
sampling_interval: sampling_interval,
|
76
79
|
debug: true,
|
77
80
|
}
|
78
81
|
end
|
@@ -92,6 +95,7 @@ describe 'Fluent::ElbAccessLogInput#configure' do
|
|
92
95
|
expect(driver.instance.start_datetime).to eq start_datetime
|
93
96
|
expect(driver.instance.buffer_sec).to eq buffer_sec
|
94
97
|
expect(driver.instance.history_length).to eq history_length
|
98
|
+
expect(driver.instance.sampling_interval).to eq sampling_interval
|
95
99
|
expect(driver.instance.debug).to be_truthy
|
96
100
|
end
|
97
101
|
end
|
@@ -217,6 +217,24 @@ describe Fluent::ElbAccessLogInput do
|
|
217
217
|
|
218
218
|
it { is_expected.to eq expected_emits }
|
219
219
|
|
220
|
+
context 'when sampling' do
|
221
|
+
let(:fluentd_conf) do
|
222
|
+
{
|
223
|
+
account_id: account_id,
|
224
|
+
s3_bucket: s3_bucket,
|
225
|
+
region: region,
|
226
|
+
start_datetime: (today - 1).to_s,
|
227
|
+
sampling_interval: 2,
|
228
|
+
}
|
229
|
+
end
|
230
|
+
|
231
|
+
it do
|
232
|
+
expected_emits.delete_at(3)
|
233
|
+
expected_emits.delete_at(1)
|
234
|
+
is_expected.to eq expected_emits
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
220
238
|
context 'when include bad URI' do
|
221
239
|
let(:today_access_log) do
|
222
240
|
<<-EOS
|