fluent-plugin-elb-log 1.4.0 → 1.4.1
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.
- checksums.yaml +4 -4
- data/fluent-plugin-elb-log.gemspec +1 -1
- data/lib/fluent/plugin/in_elb_log.rb +36 -10
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 27ca22f138e46f8b033a674791600cafd324adcb87a0514d4189cf2e8cd112c2
|
|
4
|
+
data.tar.gz: 21beb83010ab4273a8e8eb7d1f3b923526a967c9fed8a03eae2e9bde06d1d14a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6e6fc7a9042cd756b9521be3bce5ea37e06f2f7d489a440d575977df03a240199ed836ddb8109db7e28817348e1848833201742330109ec1a627efed1345286d
|
|
7
|
+
data.tar.gz: a65c3a910d2f6ddd794e8e5555f0ef294f012b54097a5da07cf68dc0e5d47e9dc5bd3a267f22ab205bd72a70ea385c74bfc9be28fcf54da32f4b6d513a656b67
|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "fluent-plugin-elb-log"
|
|
7
|
-
spec.version = "1.4.
|
|
7
|
+
spec.version = "1.4.1"
|
|
8
8
|
spec.authors = ["shinsaka","jazzl0ver"]
|
|
9
9
|
spec.email = ["shinx1265@gmail.com"]
|
|
10
10
|
spec.summary = "Amazon ELB log input plugin"
|
|
@@ -13,7 +13,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
13
13
|
helpers :timer
|
|
14
14
|
|
|
15
15
|
LOGFILE_REGEXP = /^((?<prefix>.+?)\/|)AWSLogs\/(?<account_id>[0-9]{12})\/elasticloadbalancing\/(?<region>.+?)\/(?<logfile_date>[0-9]{4}\/[0-9]{2}\/[0-9]{2})\/[0-9]{12}_elasticloadbalancing_.+?_(?<logfile_elb_name>[^_]+)_(?<logfile_timestamp>[0-9]{8}T[0-9]{4}Z)_(?<elb_ip_address>.+?)_(?<logfile_hash>.+)\.log(.gz)?$/
|
|
16
|
-
ACCESSLOG_REGEXP = /^((?<type>[a-z0-9]+) )?(?<time>\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\.\d{6}Z) (?<elb>\S+) (?<client>\S+)\:(?<client_port>\S+) (?<target>[^:\s]+)(?::(?<target_port>\S+))? (?<request_processing_time>\S+) (?<target_processing_time>\S+) (?<response_processing_time>\S+) (?<elb_status_code>\S+) (?<target_status_code>\S+) (?<received_bytes>\S+) (?<sent_bytes>\S+) \"(?<request_method>\S+) (?<request_uri>\S+) (?<request_protocol>\S+)\" \"(?<user_agent
|
|
16
|
+
ACCESSLOG_REGEXP = /^((?<type>[a-z0-9]+) )?(?<time>\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\.\d{6}Z) (?<elb>\S+) (?<client>\S+)\:(?<client_port>\S+) (?<target>[^:\s]+)(?::(?<target_port>\S+))? (?<request_processing_time>\S+) (?<target_processing_time>\S+) (?<response_processing_time>\S+) (?<elb_status_code>\S+) (?<target_status_code>\S+) (?<received_bytes>\S+) (?<sent_bytes>\S+) \"(?<request_method>\S+) (?<request_uri>\S+) (?<request_protocol>\S+)\" \"(?<user_agent>.*?)\" (?<ssl_cipher>\S+) (?<ssl_protocol>\S+) (?<target_group_arn>\S+) \"(?<trace_id>\S+)\" \"(?<domain_name>\S+)\" \"(?<chosen_cert_arn>\S+)\" (?<matched_rule_priority>\S+) (?<request_creation_time>\S+) \"(?<actions_executed>\S+)\" \"(?<redirect_url>\S+)\" \"(?<error_reason>\S+)\" \"(?<target_port_list>\S+)\" \"(?<target_status_code_list>\S+)\" \"(?<classification>\S+)\" \"(?<classification_reason>\S+)\" (?<conn_trace_id>\S+)/
|
|
17
17
|
config_param :access_key_id, :string, default: nil, secret: true
|
|
18
18
|
config_param :secret_access_key, :string, default: nil, secret: true
|
|
19
19
|
config_param :region, :string
|
|
@@ -62,9 +62,10 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
62
62
|
|
|
63
63
|
Signal.trap('INT') { shutdown }
|
|
64
64
|
|
|
65
|
+
refresh_aws_clients!
|
|
66
|
+
|
|
65
67
|
if @use_sqs
|
|
66
68
|
input
|
|
67
|
-
@sqs_client = sqs_client
|
|
68
69
|
setup_sqs_timer
|
|
69
70
|
else
|
|
70
71
|
setup_input_timer
|
|
@@ -73,16 +74,22 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
73
74
|
|
|
74
75
|
private
|
|
75
76
|
|
|
77
|
+
def refresh_aws_clients!
|
|
78
|
+
log.debug "Refreshing AWS credentials"
|
|
79
|
+
@s3_client = s3_client
|
|
80
|
+
@sqs_client = sqs_client if @use_sqs
|
|
81
|
+
end
|
|
82
|
+
|
|
76
83
|
def shutdown
|
|
77
84
|
log.debug "shutdown"
|
|
78
85
|
if @running
|
|
79
86
|
@running = false
|
|
80
|
-
|
|
87
|
+
if @use_sqs
|
|
81
88
|
log.debug "pausing shutdown for 2x#{@refresh_interval}"
|
|
82
89
|
sleep 2*@refresh_interval
|
|
83
90
|
unset_sqs if @queue_url && @queue_url != ""
|
|
84
91
|
else
|
|
85
|
-
|
|
92
|
+
log.debug "pausing shutdown for 30 seconds"
|
|
86
93
|
sleep 30
|
|
87
94
|
end
|
|
88
95
|
end
|
|
@@ -91,13 +98,17 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
91
98
|
def setup_sqs_timer
|
|
92
99
|
if @running
|
|
93
100
|
setup_sqs
|
|
101
|
+
return unless @running
|
|
94
102
|
timer_execute(:in_elb_log, @refresh_interval) do
|
|
95
103
|
if @running
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
refresh_aws_clients!
|
|
105
|
+
process_sqs
|
|
106
|
+
log.debug "sleeping for #{@refresh_interval}"
|
|
98
107
|
else
|
|
108
|
+
if @queue_url && @queue_url != ""
|
|
99
109
|
log.debug "Unsetting SQS"
|
|
100
|
-
unset_sqs
|
|
110
|
+
unset_sqs
|
|
111
|
+
end
|
|
101
112
|
end
|
|
102
113
|
end
|
|
103
114
|
end
|
|
@@ -107,6 +118,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
107
118
|
if @running
|
|
108
119
|
timer_execute(:in_elb_log, @refresh_interval) do
|
|
109
120
|
if @running
|
|
121
|
+
refresh_aws_clients!
|
|
110
122
|
input
|
|
111
123
|
log.debug "sleeping input for #{@refresh_interval}"
|
|
112
124
|
end
|
|
@@ -120,6 +132,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
120
132
|
!ec2.config.credentials.nil?
|
|
121
133
|
rescue => e
|
|
122
134
|
log.warn "EC2 Client error occurred: #{e.message}"
|
|
135
|
+
@running = false
|
|
123
136
|
end
|
|
124
137
|
end
|
|
125
138
|
|
|
@@ -128,7 +141,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
128
141
|
timestamp = Time.now.to_i
|
|
129
142
|
queue_name = "fluent-plugin-elb-log-#{timestamp}"
|
|
130
143
|
|
|
131
|
-
sts_client = Aws::STS::Client.new
|
|
144
|
+
sts_client = Aws::STS::Client.new(region: @region)
|
|
132
145
|
account_id = sts_client.get_caller_identity.account
|
|
133
146
|
|
|
134
147
|
queue_policy = {
|
|
@@ -142,13 +155,13 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
142
155
|
"Service": "s3.amazonaws.com"
|
|
143
156
|
},
|
|
144
157
|
"Action": "SQS:SendMessage",
|
|
145
|
-
"Resource": "arn:aws:sqs
|
|
158
|
+
"Resource": "arn:aws:sqs:#{@region}:#{account_id}:#{queue_name}",
|
|
146
159
|
"Condition": {
|
|
147
160
|
"StringEquals": {
|
|
148
161
|
"aws:SourceAccount": "#{account_id}"
|
|
149
162
|
},
|
|
150
163
|
"ArnLike": {
|
|
151
|
-
"aws:SourceArn": "arn:aws:s3:*:*:#{@
|
|
164
|
+
"aws:SourceArn": "arn:aws:s3:*:*:#{@s3_bucketname}"
|
|
152
165
|
}
|
|
153
166
|
}
|
|
154
167
|
}
|
|
@@ -195,11 +208,14 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
195
208
|
|
|
196
209
|
rescue Aws::SQS::Errors::InvalidAttributeValue => e
|
|
197
210
|
log.debug "SQS error: #{e.message}"
|
|
211
|
+
@running = false
|
|
198
212
|
|
|
199
213
|
rescue Aws::S3::Errors::InvalidArgument => e
|
|
200
214
|
log.debug "S3 Event error: #{e.message}"
|
|
201
215
|
sqs_client.delete_queue(queue_url: @queue_url)
|
|
216
|
+
@queue_url = ""
|
|
202
217
|
log.debug "#{queue_arn} deleted"
|
|
218
|
+
@running = false
|
|
203
219
|
end
|
|
204
220
|
end
|
|
205
221
|
|
|
@@ -234,6 +250,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
234
250
|
return timestamp
|
|
235
251
|
rescue => e
|
|
236
252
|
log.warn "timestamp file get and parse error occurred: #{e.message}"
|
|
253
|
+
@running = false
|
|
237
254
|
end
|
|
238
255
|
end
|
|
239
256
|
|
|
@@ -245,6 +262,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
245
262
|
end
|
|
246
263
|
rescue => e
|
|
247
264
|
log.warn "timestamp file get and parse error occurred: #{e.message}"
|
|
265
|
+
@running = false
|
|
248
266
|
end
|
|
249
267
|
end
|
|
250
268
|
|
|
@@ -264,6 +282,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
264
282
|
Aws::S3::Client.new(options)
|
|
265
283
|
rescue => e
|
|
266
284
|
log.warn "S3 Client error occurred: #{e.message}"
|
|
285
|
+
@running = false
|
|
267
286
|
end
|
|
268
287
|
end
|
|
269
288
|
|
|
@@ -275,6 +294,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
275
294
|
!(get_object_list(1).nil?)
|
|
276
295
|
rescue => e
|
|
277
296
|
log.warn "error occurred: #{e.message}"
|
|
297
|
+
@running = false
|
|
278
298
|
false
|
|
279
299
|
end
|
|
280
300
|
end
|
|
@@ -295,6 +315,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
295
315
|
Aws::SQS::Client.new(options)
|
|
296
316
|
rescue => e
|
|
297
317
|
log.warn "SQS Client error occurred: #{e.message}"
|
|
318
|
+
@running = false
|
|
298
319
|
end
|
|
299
320
|
end
|
|
300
321
|
|
|
@@ -334,6 +355,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
334
355
|
end
|
|
335
356
|
rescue => e
|
|
336
357
|
log.warn "error occurred: #{e.message}"
|
|
358
|
+
@running = false
|
|
337
359
|
end
|
|
338
360
|
end
|
|
339
361
|
|
|
@@ -417,6 +439,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
417
439
|
end
|
|
418
440
|
rescue => e
|
|
419
441
|
log.warn "error occurred: #{e.message}"
|
|
442
|
+
@running = false
|
|
420
443
|
end
|
|
421
444
|
end
|
|
422
445
|
|
|
@@ -427,6 +450,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
427
450
|
end
|
|
428
451
|
rescue => e
|
|
429
452
|
log.warn "error occurred: #{e.message}"
|
|
453
|
+
@running = false
|
|
430
454
|
end
|
|
431
455
|
end
|
|
432
456
|
|
|
@@ -531,6 +555,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
531
555
|
end
|
|
532
556
|
rescue => e
|
|
533
557
|
log.warn "error occurred: #{e.message}, #{e.backtrace}"
|
|
558
|
+
@running = false
|
|
534
559
|
end
|
|
535
560
|
end
|
|
536
561
|
|
|
@@ -570,6 +595,7 @@ class Fluent::Plugin::Elb_LogInput < Fluent::Plugin::Input
|
|
|
570
595
|
end
|
|
571
596
|
rescue => e
|
|
572
597
|
log.warn "error occurred: #{e.message}"
|
|
598
|
+
@running = false
|
|
573
599
|
end
|
|
574
600
|
end
|
|
575
601
|
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-elb-log
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.4.
|
|
4
|
+
version: 1.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- shinsaka
|
|
8
8
|
- jazzl0ver
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2026-06-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: fluentd
|
|
@@ -151,7 +151,7 @@ homepage: https://github.com/jazzl0ver/fluent-plugin-elb-log
|
|
|
151
151
|
licenses:
|
|
152
152
|
- MIT
|
|
153
153
|
metadata: {}
|
|
154
|
-
post_install_message:
|
|
154
|
+
post_install_message:
|
|
155
155
|
rdoc_options: []
|
|
156
156
|
require_paths:
|
|
157
157
|
- lib
|
|
@@ -166,8 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
166
166
|
- !ruby/object:Gem::Version
|
|
167
167
|
version: '0'
|
|
168
168
|
requirements: []
|
|
169
|
-
rubygems_version: 3.
|
|
170
|
-
signing_key:
|
|
169
|
+
rubygems_version: 3.5.22
|
|
170
|
+
signing_key:
|
|
171
171
|
specification_version: 4
|
|
172
172
|
summary: Amazon ELB log input plugin
|
|
173
173
|
test_files:
|