-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Zstd compression support to S3 plugin (#439)
adds support for Zstd compression in the Fluentd S3 plugin. Changes - Implemented Zstd compression using the `zstd-ruby` library. - Introduced the `ZstdCompressor` class to handle log compression before uploading to S3. - Updated the example configuration to demonstrate the use of `store_as zstd`. - Ensured that the `Zstd` module is properly loaded to avoid uninitialized constant errors. Why this feature? Zstd compression provides a better compression ratio and performance compared to gzip, making it a valuable option for users who want efficient log storage on S3. --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: yongwoo.kim <[email protected]> Signed-off-by: ddukbg <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: yongwoo.kim <[email protected]> Co-authored-by: Daijiro Fukuda <[email protected]>
- Loading branch information
1 parent
803cac2
commit 66c8d72
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'zstd-ruby' | ||
|
||
module Fluent::Plugin | ||
class S3Output | ||
class ZstdCompressor < Compressor | ||
S3Output.register_compressor('zstd', self) | ||
|
||
config_section :compress, param_name: :compress_config, init: true, multi: false do | ||
desc "Compression level for zstd (1-22)" | ||
config_param :level, :integer, default: 3 | ||
end | ||
|
||
def ext | ||
'zst'.freeze | ||
end | ||
|
||
def content_type | ||
'application/x-zst'.freeze | ||
end | ||
|
||
def compress(chunk, tmp) | ||
compressed = Zstd.compress(chunk.read, level: @compress_config.level) | ||
tmp.write(compressed) | ||
rescue => e | ||
log.warn "zstd compression failed: #{e.message}" | ||
raise | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters