Howto forward to S3 Bucket


The configuration of the component is very versatile and depends on how you intend to use it. You could hardcode the s3 bucket and endpoint directly in the config section, but using environment variables allows you to easily adapt to multi cluster setups.

  s3_bucket: <NAME_OF_S3_BUCKET>
  s3_endpoint: <URL_TO_S3_STORAGE>

  shared_key: '?{vaultkv:${cluster:tenant}/${cluster:name}/fluentd-forwarder/${_instance}/sharedkey}'
  s3_accesskey: '?{vaultkv:${cluster:tenant}/${cluster:name}/fluentd-forwarder/${_instance}/s3_accesskey}'
  s3_secretkey: '?{vaultkv:${cluster:tenant}/${cluster:name}/fluentd-forwarder/${_instance}/s3_secretkey}'

Using config_vars helps reducing recurring configuration values, for example if you want to filter different namespaces. In this example each namespace will be stored in a different directory.

config: |
    log_level info
    @type forward
    port 24224
      shared_key "#{ENV['SHARED_KEY']}"
      self_hostname "#{ENV['HOSTNAME']}"

  <match kubernetes.**>
    @type rewrite_tag_filter
      key \$['kubernetes']['namespace_name']
      pattern ^(.+)$
      tag kube.$1

  <match kube.my_namespace>
    path my_namespace/

  <match kube.my_other_namespace>
    path my_namespace/

The repetitive part of the <match> configuration can be exported using config_vars.

  match_tmpl: |
    @type s3
      @type json
    aws_key_id "#{ENV['S3_ACCESSKEY']}"
    aws_sec_key "#{ENV['S3_SECRETKEY']}"
    s3_bucket "#{ENV['S3_BUCKET']}"
    s3_endpoint "#{ENV['S3_ENDPOINT']}"
    time_slice_format %Y-%m-%d_%H%M
    <buffer time>
      @type memory
      compress text
      chunk_limit_size 256m
      timekey 5m
      timekey_wait 1m
      timekey_use_utc true