fluent-plugin-azurestorage-gen2 0.2.10 → 0.3.0
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/README.md +22 -0
- data/VERSION +1 -1
- data/lib/fluent/plugin/out_azurestorage_gen2.rb +83 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2ae08b739ba4ac4992427d2f87e8c5dc923d39b
|
4
|
+
data.tar.gz: 658ff0d35909232a1741d43bfa95bfd00cef3957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a122fb0024c716cfbe9a6aa45f733ec938a28a0059bbb66f2d49ae885533ddb529247b757927abcc4784bfc9b78ab5f3593146cad5fbd562ac972cff15503bc
|
7
|
+
data.tar.gz: 99103e68b7c4995a7c495069eb302cfd006378c5477642bb03d76d5b9ea2462e3820a11ebc21a38c5383dc26ba5d5f3a4151f24ebf1788ddccf5f93eb3ef52e4
|
data/README.md
CHANGED
@@ -152,6 +152,7 @@ The format of Azure Storage object keys. You can use several built-in variables:
|
|
152
152
|
- %{time_slice}
|
153
153
|
- %{index}
|
154
154
|
- %{file_extension}
|
155
|
+
- %{upload_timestamp}
|
155
156
|
|
156
157
|
to decide keys dynamically.
|
157
158
|
|
@@ -159,6 +160,7 @@ to decide keys dynamically.
|
|
159
160
|
%{time_slice} is the time-slice in text that are formatted with *time_slice_format*.
|
160
161
|
%{index} is the sequential number starts from 0, increments when multiple files are uploaded to Azure Storage in the same time slice.
|
161
162
|
%{file_extention} is always "gz" for now.
|
163
|
+
%{upload_timestamp} is an upload timestamp in text that are formatted with *upload_timestamp_format*. Difference between time_slice and upload_timestamp is that the second one is the actual system timestamp (other one is from the metadata)
|
162
164
|
|
163
165
|
The default format is "%{path}%{time_slice}_%{index}.%{file_extension}".
|
164
166
|
|
@@ -283,10 +285,30 @@ Format of the time used as the file name. Default is '%Y%m%d'. Use '%Y%m%d%H' to
|
|
283
285
|
|
284
286
|
The time to wait old logs. Default is 10 minutes.
|
285
287
|
|
288
|
+
### upload_timestamp_format
|
289
|
+
|
290
|
+
Format of the upload timestamp used as the file name. Can be used instead of index in case of `write_only` option is enabled. Default value is '%H%M%S%L'.
|
291
|
+
|
286
292
|
### utc
|
287
293
|
|
288
294
|
Use UTC instead of local time.
|
289
295
|
|
296
|
+
### write_only
|
297
|
+
|
298
|
+
If that option is enabled, HEAD calls are skipped during blob operations. (so make sure to set the chunk limit to 4MB in order to avoid HEAD operation because of the append operation needs the last position of the uploaded blobs).
|
299
|
+
|
300
|
+
### proxy_url
|
301
|
+
|
302
|
+
Proxy URL for Azure endpoint.
|
303
|
+
|
304
|
+
### proxy_username
|
305
|
+
|
306
|
+
Proxy username for Azure proxy endpoint (used only if `proxy_url` is filled)
|
307
|
+
|
308
|
+
### proxy_password
|
309
|
+
|
310
|
+
Proxy password for Azure `proxy_username` (used only if `proxy_url` is filled)
|
311
|
+
|
290
312
|
## TODOs
|
291
313
|
|
292
314
|
- add storage key support
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -44,6 +44,11 @@ module Fluent::Plugin
|
|
44
44
|
config_param :time_slice_format, :string, :default => '%Y%m%d'
|
45
45
|
config_param :hex_random_length, :integer, default: 4
|
46
46
|
config_param :command_parameter, :string, :default => nil
|
47
|
+
config_param :proxy_url, :string, :default => nil
|
48
|
+
config_param :proxy_username, :string, :default => nil
|
49
|
+
config_param :proxy_password, :string, :default => nil, :secret => true
|
50
|
+
config_param :write_only, :bool, :default => false
|
51
|
+
config_param :upload_timestamp_format, :string, :default => '%H%M%S%L'
|
47
52
|
|
48
53
|
DEFAULT_FORMAT_TYPE = "out_file"
|
49
54
|
ACCESS_TOKEN_API_VERSION = "2018-02-01"
|
@@ -158,11 +163,16 @@ module Fluent::Plugin
|
|
158
163
|
private
|
159
164
|
def upload_blob(content, chunk)
|
160
165
|
log.debug "azurestorage_gen2: Uploading blob: #{@azure_storage_path}"
|
161
|
-
|
162
|
-
if existing_content_length == 0
|
166
|
+
if @write_only
|
163
167
|
create_blob(@azure_storage_path)
|
168
|
+
append_blob(content, chunk, 0)
|
169
|
+
else
|
170
|
+
existing_content_length = get_blob_properties(@azure_storage_path)
|
171
|
+
if existing_content_length == 0
|
172
|
+
create_blob(@azure_storage_path)
|
173
|
+
end
|
174
|
+
append_blob(content, chunk, existing_content_length)
|
164
175
|
end
|
165
|
-
append_blob(content, chunk, existing_content_length)
|
166
176
|
end
|
167
177
|
|
168
178
|
private
|
@@ -175,8 +185,10 @@ module Fluent::Plugin
|
|
175
185
|
end
|
176
186
|
if @localtime
|
177
187
|
hms_slicer = Time.now.strftime("%H%M%S")
|
188
|
+
upload_timestamp = Time.now.strftime(@upload_timestamp_format)
|
178
189
|
else
|
179
190
|
hms_slicer = Time.now.utc.strftime("%H%M%S")
|
191
|
+
upload_timestamp = Time.now.utc.strftime(@upload_timestamp_format)
|
180
192
|
end
|
181
193
|
|
182
194
|
@values_for_object_chunk[chunk.unique_id] ||= {
|
@@ -186,7 +198,8 @@ module Fluent::Plugin
|
|
186
198
|
"%{path}" => @path,
|
187
199
|
"%{index}" => index,
|
188
200
|
"%{uuid_flush}" => uuid_random,
|
189
|
-
"%{file_extension}" => @final_file_extension
|
201
|
+
"%{file_extension}" => @final_file_extension,
|
202
|
+
"%{upload_timestamp}" => upload_timestamp,
|
190
203
|
}
|
191
204
|
values_for_object_key_post = {
|
192
205
|
"%{date_slice}" => time_slice,
|
@@ -255,7 +268,12 @@ module Fluent::Plugin
|
|
255
268
|
unless @azure_instance_msi.nil?
|
256
269
|
params[:msi_res_id] = @azure_instance_msi
|
257
270
|
end
|
258
|
-
|
271
|
+
req_opts = {
|
272
|
+
:params => params,
|
273
|
+
:headers => { Metadata: "true" }
|
274
|
+
}
|
275
|
+
add_proxy_options(req_opts)
|
276
|
+
request = Typhoeus::Request.new("http://169.254.169.254/metadata/identity/oauth2/token", req_opts)
|
259
277
|
request.on_complete do |response|
|
260
278
|
if response.success?
|
261
279
|
data = JSON.parse(response.body)
|
@@ -273,7 +291,13 @@ module Fluent::Plugin
|
|
273
291
|
params = { :"api-version" => ACCESS_TOKEN_API_VERSION, :resource => "#{@url_storage_resource}"}
|
274
292
|
headers = {:"Content-Type" => "application/x-www-form-urlencoded"}
|
275
293
|
content = "grant_type=client_credentials&client_id=#{@azure_oauth_app_id}&client_secret=#{@azure_oauth_secret}&resource=#{@url_storage_resource}"
|
276
|
-
|
294
|
+
req_opts = {
|
295
|
+
:params => params,
|
296
|
+
:body => content,
|
297
|
+
:headers => headers
|
298
|
+
}
|
299
|
+
add_proxy_options(req_opts)
|
300
|
+
request = Typhoeus::Request.new("https://login.microsoftonline.com/#{@azure_oauth_tenant_id}/oauth2/token", req_opts)
|
277
301
|
request.on_complete do |response|
|
278
302
|
if response.success?
|
279
303
|
data = JSON.parse(response.body)
|
@@ -300,7 +324,13 @@ module Fluent::Plugin
|
|
300
324
|
params = {:resource => "filesystem" }
|
301
325
|
auth_header = create_auth_header("head", datestamp, "#{@azure_container}", headers, params)
|
302
326
|
headers[:Authorization] = auth_header
|
303
|
-
|
327
|
+
req_opts = {
|
328
|
+
:method => :head,
|
329
|
+
:params => params,
|
330
|
+
:headers => headers
|
331
|
+
}
|
332
|
+
add_proxy_options(req_opts)
|
333
|
+
request = Typhoeus::Request.new("https://#{azure_storage_account}#{@url_domain_suffix}/#{@azure_container}", req_opts)
|
304
334
|
request.on_complete do |response|
|
305
335
|
if response.success?
|
306
336
|
log.info "azurestorage_gen2: Container '#{@azure_container}' exists."
|
@@ -327,7 +357,13 @@ module Fluent::Plugin
|
|
327
357
|
params = {:resource => "filesystem" }
|
328
358
|
auth_header = create_auth_header("put", datestamp, "#{@azure_container}", headers, params)
|
329
359
|
headers[:Authorization] = auth_header
|
330
|
-
|
360
|
+
req_opts = {
|
361
|
+
:method => :put,
|
362
|
+
:params => params,
|
363
|
+
:headers => headers
|
364
|
+
}
|
365
|
+
add_proxy_options(req_opts)
|
366
|
+
request = Typhoeus::Request.new("https://#{azure_storage_account}#{@url_domain_suffix}/#{@azure_container}", req_opts)
|
331
367
|
request.on_complete do |response|
|
332
368
|
if response.success?
|
333
369
|
log.debug "azurestorage_gen2: Container '#{@azure_container}' created, response code: #{response.code}"
|
@@ -347,7 +383,13 @@ module Fluent::Plugin
|
|
347
383
|
params = {:resource => "file", :recursive => "false"}
|
348
384
|
auth_header = create_auth_header("put", datestamp, "#{@azure_container}#{blob_path}", headers, params)
|
349
385
|
headers[:Authorization] = auth_header
|
350
|
-
|
386
|
+
req_opts = {
|
387
|
+
:method => :put,
|
388
|
+
:params => params,
|
389
|
+
:headers => headers
|
390
|
+
}
|
391
|
+
add_proxy_options(req_opts)
|
392
|
+
request = Typhoeus::Request.new("https://#{azure_storage_account}#{@url_domain_suffix}/#{@azure_container}#{blob_path}", req_opts)
|
351
393
|
request.on_complete do |response|
|
352
394
|
if response.success?
|
353
395
|
log.debug "azurestorage_gen2: Blob '#{blob_path}' has been created, response code: #{response.code}"
|
@@ -370,7 +412,14 @@ module Fluent::Plugin
|
|
370
412
|
params = {:action => "append", :position => "#{position}"}
|
371
413
|
auth_header = create_auth_header("patch", datestamp, "#{@azure_container}#{blob_path}", headers, params)
|
372
414
|
headers[:Authorization] = auth_header
|
373
|
-
|
415
|
+
req_opts = {
|
416
|
+
:method => :patch,
|
417
|
+
:params => params,
|
418
|
+
:headers => headers,
|
419
|
+
:body => content
|
420
|
+
}
|
421
|
+
add_proxy_options(req_opts)
|
422
|
+
request = Typhoeus::Request.new("https://#{azure_storage_account}#{@url_domain_suffix}/#{@azure_container}#{blob_path}", req_opts)
|
374
423
|
request.on_complete do |response|
|
375
424
|
if response.success?
|
376
425
|
log.debug "azurestorage_gen2: Blob '#{blob_path}' has been appended, response code: #{response.code}"
|
@@ -395,7 +444,13 @@ module Fluent::Plugin
|
|
395
444
|
params = {:action => "flush", :position => "#{position}"}
|
396
445
|
auth_header = create_auth_header("patch", datestamp, "#{@azure_container}#{blob_path}",headers, params)
|
397
446
|
headers[:Authorization] = auth_header
|
398
|
-
|
447
|
+
req_opts = {
|
448
|
+
:method => :patch,
|
449
|
+
:params => params,
|
450
|
+
:headers => headers
|
451
|
+
}
|
452
|
+
add_proxy_options(req_opts)
|
453
|
+
request = Typhoeus::Request.new("https://#{azure_storage_account}#{@url_domain_suffix}/#{@azure_container}#{blob_path}", req_opts)
|
399
454
|
request.on_complete do |response|
|
400
455
|
if response.success?
|
401
456
|
log.debug "azurestorage_gen2: Blob '#{blob_path}' flush was successful, response code: #{response.code}"
|
@@ -416,7 +471,13 @@ module Fluent::Plugin
|
|
416
471
|
content_length = -1
|
417
472
|
auth_header = create_auth_header("head", datestamp, "#{@azure_container}#{blob_path}", headers, params)
|
418
473
|
headers[:Authorization] = auth_header
|
419
|
-
|
474
|
+
req_opts = {
|
475
|
+
:method => :head,
|
476
|
+
:params => params,
|
477
|
+
:headers => headers
|
478
|
+
}
|
479
|
+
add_proxy_options(req_opts)
|
480
|
+
request = Typhoeus::Request.new("https://#{azure_storage_account}#{@url_domain_suffix}/#{@azure_container}#{blob_path}", req_opts)
|
420
481
|
request.on_complete do |response|
|
421
482
|
if response.success?
|
422
483
|
log.debug "azurestorage_gen2: Get blob properties for '#{blob_path}', response headers: #{response.headers}"
|
@@ -484,6 +545,16 @@ module Fluent::Plugin
|
|
484
545
|
"SharedKey #{@azure_storage_account}:#{signed(method, datestamp, resource, headers, params)}"
|
485
546
|
end
|
486
547
|
end
|
548
|
+
|
549
|
+
private
|
550
|
+
def add_proxy_options(req_opts = {})
|
551
|
+
unless @proxy_url.nil?
|
552
|
+
req_opts[:proxy] = @proxy_url
|
553
|
+
unless @proxy_username.nil? || @proxy_password.nil?
|
554
|
+
req_opts[:proxyuserpwd] = "#{@proxy_username}:#{@proxy_password}"
|
555
|
+
end
|
556
|
+
end
|
557
|
+
end
|
487
558
|
|
488
559
|
private
|
489
560
|
def signed(method, datestamp, resource, headers, params)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-azurestorage-gen2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Szabo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|