Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Want to use variable in s3_bucket #253

Open
TaLoN1x opened this issue Nov 14, 2018 · 8 comments
Open

Want to use variable in s3_bucket #253

TaLoN1x opened this issue Nov 14, 2018 · 8 comments

Comments

@TaLoN1x
Copy link

TaLoN1x commented Nov 14, 2018

It seems to be impossible to use variables in s3_bucket.

My use case is to store events in different s3 buckets based on the event tag.

When I'm trying to specify bucket name like this:
s3_bucket s3-${tag}

I've also tried to use parts of the tag like ${tag[1]} without success. Is there any option to make it possible with any workaround?

@TaLoN1x
Copy link
Author

TaLoN1x commented Nov 14, 2018

Example configuration:

<match test.**>
  @type s3

  aws_key_id somekey
  aws_sec_key someotherkey

  s3_bucket cf-${tag[1]}
  check_bucket true
  auto_create_bucket true

  ssl_verify_peer false
  force_path_style true
  compute_checksums true
  s3_endpoint https://s3.endpoint.local
  s3_object_key_format %{path}/${tag[3]}-%H_%{index}.%{file_extension}
  path cf/${tag[1]}_${tag[2]}/%Y/%m/%d
  time_slice_format %Y%m%d-%H
  <buffer tag,time>
    @type file
    path /opt/buffer/fluent/s3
    timekey 3600 # 1 hour partition
    timekey_wait 5m
    timekey_use_utc false # use utc
    chunk_limit_size 5120m
  </buffer>
</match>

The event I've tested has TAG like this:
test.application1.audit.access

So I expect to have bucket named: cf-application1
and Path: cf/application1_audit/2018/11/14/access-11_0.gz (resolution of variables in Path works fine)

@TaLoN1x
Copy link
Author

TaLoN1x commented Nov 14, 2018

P.S. using td-agent 3.2.1

@repeatedly
Copy link
Member

I've also tried to use parts of the tag like ${tag[1]} without success. Is there any option to make it possible with any workaround?

Currently, no way because out_s3 uses static bucket value in start.
To support dynamic bucket, need to move getting bucket in write and need to use extract_placeholder for it.

@bucket = @s3.bucket(@s3_bucket)

@github-actions
Copy link

github-actions bot commented Jul 6, 2021

This issue has been automatically marked as stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 30 days

@github-actions github-actions bot added the stale label Jul 6, 2021
@github-actions
Copy link

github-actions bot commented Aug 6, 2021

This issue was automatically closed because of stale in 30 days

@github-actions github-actions bot closed this as completed Aug 6, 2021
@anonymous-trader
Copy link

anonymous-trader commented Mar 13, 2024

I am also facing same issue. I also want to configure the bucket name dynamically. plugin should pick up this bucket name dynamically from records. can someone please help me on this. I got stuck with same issue since long time

@anonymous-trader
Copy link

Is there any workaround for this?

@daipom daipom reopened this Mar 13, 2024
@daipom
Copy link
Contributor

daipom commented Mar 13, 2024

So you need to configure s3_bucket dynamically from the actual records.

I don't think there is any good way for this. 😢
We need to implement it.

If the patterns are limited, you can prepare multiple match settings, and route the records properly to them using tags or lables.

@daipom daipom added enhancement and removed stale labels Mar 13, 2024
@daipom daipom changed the title impossible to use variable in s3_bucket Want ot use variable in s3_bucket Mar 13, 2024
@daipom daipom changed the title Want ot use variable in s3_bucket Want to use variable in s3_bucket Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants