Skip to content

Commit

Permalink
out_s3: added static file path configuration option
Browse files Browse the repository at this point in the history
By default, when a dynamic key formatter like $UUID is not specified in s3_key_format,
a UUID is automatically appended to the end of the key.

If static_file_path is set to true, this behavior is disabled.

This patch has been tested using test configuration files using various input plugins
(exec, random, etc) as well as valgrind.

Signed-off-by: Stephen Lee <[email protected]>
  • Loading branch information
Stephen Lee authored and PettitWesley committed Jul 26, 2021
1 parent e5bcfc2 commit 5d9125e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion plugins/out_s3/s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ static int s3_put_object(struct flb_s3 *ctx, const char *tag, time_t create_time
}

len = strlen(s3_key);
if ((len + 16) <= 1024 && !ctx->key_fmt_has_uuid &&
if ((len + 16) <= 1024 && !ctx->key_fmt_has_uuid && !ctx->static_file_path &&
!ctx->key_fmt_has_seq_index) {
append_random = FLB_TRUE;
len += 16;
Expand Down Expand Up @@ -2282,6 +2282,14 @@ static struct flb_config_map config_map[] = {
"that key will be sent to S3."
},

{
FLB_CONFIG_MAP_BOOL, "static_file_path", "false",
0, FLB_TRUE, offsetof(struct flb_s3, static_file_path),
"Disables behavior where UUID string is automatically appended to end of S3 key name when "
"$UUID is not provided in s3_key_format. $UUID, time formatters, $TAG, and other dynamic "
"key formatters all work as expected while this feature is set to true."
},

/* EOF */
{0}
};
Expand Down
1 change: 1 addition & 0 deletions plugins/out_s3/s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ struct flb_s3 {
int free_endpoint;
int use_put_object;
int send_content_md5;
int static_file_path;

struct flb_aws_provider *provider;
struct flb_aws_provider *base_provider;
Expand Down

0 comments on commit 5d9125e

Please sign in to comment.