No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Fluentd In/Out plugin to forward log through AWS(S3/SNS/SQS)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9.2.2
~> 3.12
>= 3.1.0

Runtime

~> 1.8.2
< 2, >= 0.10.58
 Project Readme

Fluent::Plugin::Forward-AWS, a plugin for Fluentd

Forward-AWS plugin forwards log through Amazon Web Service.
It uses S3 as log storage, and SNS+SQS for notification.

Please see wiki to understand the concept.

Installation

Use ruby gem as :

$ gem install fluent-plugin-forward-aws

Or, if you're using td-client, you can call td-client's gem

$ /usr/lib64/fluent/ruby/bin/gem install fluent-plugin-forward-aws

AWS Configuration

IAM

It is recommended to create IAM user for logging.
Create IAM user with credential, and memorize following parameters

  • aws_access_key_id
  • aws_secret_access_key

S3

Create bucket, and memorize following parameters

  • aws_s3_endpoint
  • aws_s3_bucketname

SNS

Create SNS Topic, and memorize following parameters

  • aws_sns_endpoint
  • aws_sns_topic_arn

SQS

Create SQS Queue, subscribe to SNS, and memorize following parameters

  • aws_sqs_endpoint
  • aws_sqs_queue_url

How to configure SQS as SNS subscriber

In short, change SQS's access policy to accept "SendMessage" from your SNS ARN, And add SQS ARN to SNS subscribers. You can do the above step in one shot from SQS Management Console.
For more detail, check amazon official document

Common Configuration

Parameters

name type description
type string (required) type of plugin should be forward_aws
aws_access_key_id string (required) AWS Acccess Key ID
aws_secret_access_key string (required) AWS Secket Access Key
aws_s3_endpoint string (required) s3 Endpoint for your bucket
aws_s3_bucketname string (required) S3 Bucketname
aws_s3_skiptest bool (default = false) Skip S3 Related test at startup
channel string (default = "default") Tag that Forward-AWS plugin uses for grouping logs.

Parameters by supported by HandleTagNameMixin

name type
remove_tag_prefix string (default = nil)
add_tag_prefix string (default = nil)
remove_tag_suffix string (default = nil)
add_tag_suffix string (default = nil)

Out Plugin Configuration

Parameters

name type description
aws_sns_endpoint string (required) SNS Endpoint for your topic
aws_sns_topic_arn string (required) SNS Topic ARN
aws_sns_skiptest bool (default = false) Skip SNS Related test at startup

###Required AWS permission

  • s3:PutObject
  • sns:Publish

Basic configuration

Use "default" channel for all the log data.

<match **>
  type forward_aws
  aws_access_key_id     XXXXXXXXXXXXXXXXXXXX
  aws_secret_access_key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  aws_s3_endpoint       s3-ap-northeast-1.amazonaws.com
  aws_s3_bucketname     XXXXXXXXXXXXXXXXXXXX

  aws_sns_endpoint      sns.ap-northeast-1.amazonaws.com
  aws_sns_topic_arn     arn:aws:sns:ap-northeast-1:XXXXXXXXXXXXXXXXXXXX

  # Time Sliced Output options
  buffer_path           /var/log/td-agent/buffer/forward_aws
  time_slice_wait       1m
  time_slice_format     %Y/%m/%d/%H/%M
  utc
  flush_at_shutdown     true
</match>

Advanced configuration using forest plugin

Use tag as forward-AWS channel

<match **>
  type forest
  subtype forward_aws
  <template>
    channel               ${tag}
    aws_access_key_id     XXXXXXXXXXXXXXXXXXXX
    aws_secret_access_key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    aws_s3_endpoint       s3-ap-northeast-1.amazonaws.com
    aws_s3_bucketname     XXXXXXXXXXXXXXXXXXXX

    aws_sns_endpoint      sns.ap-northeast-1.amazonaws.com
    aws_sns_topic_arn     arn:aws:sns:ap-northeast-1:XXXXXXXXXXXXXXXXXXXX

    # Time Sliced Output options
    buffer_path           /var/log/td-agent/buffer/forward_aws-${tag}
    time_slice_wait       1m
    time_slice_format     %Y/%m/%d/%H/%M
    utc
    flush_at_shutdown     true
  </template>
</match>

In Plugin Configuration

Parameters

name type description
aws_sqs_endpoint string (required) SQS Endpoint for your topic
aws_sqs_queue_url string (required) SQS Queue URL (not ARN)
aws_sqs_skiptest bool (default = false) Skip SQS Related test at startup
aws_sqs_wait_time_seconds integer(default = 5) long polling
aws_sqs_limit integer(default = 10) The maximum number of messages to receive
aws_sqs_visibilitiy_timeout integer(default = 300) Duration that the received messages are hidden

channelEnableRegEx | bool (default = false) | Enabled Regular Expression when checking channel dry_run | bool (default = false) | Do not delete notification after processing

###Required AWS permission

  • s3:GetObject
  • sqs:ReceiveMessage
  • sqs:DeleteMessage

Basic configuration

Default config is to listen to "default" channel.

<source>
  type forward_aws
  aws_access_key_id     XXXXXXXXXXXXXXXXXXXX
  aws_secret_access_key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  aws_s3_endpoint       s3-ap-northeast-1.amazonaws.com
  aws_s3_bucketname     XXXXXXXXXXXXXXXXXXXX
  
  aws_sqs_endpoint      sqs.ap-northeast-1.amazonaws.com
  aws_sqs_queue_url     https://sqs.ap-northeast-1.amazonaws.com/XXXXXXXXXXXXXXXXXXXX
</source>

Advanced configuration

Use regex to filter channel

<source>
  type forward_aws
  channel .*
  channelEnableRegEx true
  aws_access_key_id     XXXXXXXXXXXXXXXXXXXX
  aws_secret_access_key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  aws_s3_endpoint       s3-ap-northeast-1.amazonaws.com
  aws_s3_bucketname     XXXXXXXXXXXXXXXXXXXX
  
  aws_sqs_endpoint      sqs.ap-northeast-1.amazonaws.com
  aws_sqs_queue_url     https://sqs.ap-northeast-1.amazonaws.com/XXXXXXXXXXXXXXXXXXXX
</source>

Tips

How to delete buffer objects on S3

Forward-AWS plugin do not delete buffer objects on S3.
Use S3's lifecycle management to automatically archive or delete old buffer objects.

SQS long polling

forward-AWS uses SQS long polling by default. Long polling could slow down fluentd shutdown sequence.

How to use buffer objects as raw input

Each buffer object is msgpack stream object with gzip compression.

Want to forward log per minute, but have archive per day

You can configure forward per minute, and setup another receiver for archiving.

Skipping test at startup

You can control startup test by following optional parameters. Default value is false

  • aws_s3_skiptest
  • aws_sns_skiptest
  • aws_sqs_skiptest

Contributing

I am newbie for both of Ruby and Fluentd.
Feel free to send me pull request.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

Copyright:: Copyright (c) 2013 Tomohisa Ota License:: Apache License, Version 2.0