fluent-plugin-forward-aws 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +55 -6
- data/fluent-plugin-forward-aws.gemspec +1 -1
- data/lib/fluent/plugin/forward_aws_util.rb +22 -0
- data/lib/fluent/plugin/in_forward_aws.rb +8 -3
- data/lib/fluent/plugin/out_forward_aws.rb +8 -3
- data/test/plugin/test_forward_aws_util.rb +35 -0
- data/test/plugin/test_out_foward_aws.rb +22 -0
- metadata +5 -2
data/README.md
CHANGED
@@ -42,14 +42,49 @@ In short, change SQS's access policy to accept "SendMessage" from your SNS ARN,
|
|
42
42
|
You can do the above step in one shot from SQS Management Console.
|
43
43
|
For more detail, check [amazon official document](http://docs.aws.amazon.com/sns/latest/gsg/SendMessageToSQS.html)
|
44
44
|
|
45
|
+
## Common Configuration
|
46
|
+
### Parameters
|
47
|
+
+ **aws_access_key_id** (required)
|
48
|
+
AWS Acccess Key ID
|
49
|
+
|
50
|
+
+ **aws_secret_access_key** (required)
|
51
|
+
AWS Secket Access Key
|
52
|
+
|
53
|
+
+ **aws_s3_endpoint** (required)
|
54
|
+
[s3 Endpoint](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region) for your bucket
|
55
|
+
|
56
|
+
+ **aws_s3_bucketname** (required)
|
57
|
+
S3 Bucketname
|
58
|
+
|
59
|
+
+ **aws_s3_skiptest** (optional, default = false)
|
60
|
+
Skip S3 Related test at startup
|
61
|
+
|
62
|
+
+ **add_tag_prefix** (optional)
|
63
|
+
Add specified prefix to tag before processing log
|
64
|
+
|
65
|
+
+ **remove_tag_prefix** (optional)
|
66
|
+
Remove specified prefix from tag before processing log
|
67
|
+
|
68
|
+
+ **channel** (optional, default = "default")
|
69
|
+
Tag that Forward-AWS plugin uses for grouping logs.
|
70
|
+
|
45
71
|
## Out Plugin Configuration
|
72
|
+
### Parameters
|
73
|
+
+ **aws_sns_endpoint** (required)
|
74
|
+
[SNS Endpoint](http://docs.aws.amazon.com/general/latest/gr/rande.html#sns_region) for your topic
|
75
|
+
|
76
|
+
+ **aws_sns_topic_arn** (required)
|
77
|
+
SNS Topic ARN
|
78
|
+
|
79
|
+
+ **aws_sns_skiptest** (optional, default = false)
|
80
|
+
Skip SNS Related test at startup
|
46
81
|
|
47
82
|
###Required AWS permission
|
48
83
|
+ s3:PutObject
|
49
84
|
+ sns:Publish
|
50
85
|
|
51
86
|
### Basic configuration
|
52
|
-
Use "default" channel for all the log data
|
87
|
+
Use "default" channel for all the log data.
|
53
88
|
```
|
54
89
|
<match **>
|
55
90
|
type forward_aws
|
@@ -62,16 +97,17 @@ Use "default" channel for all the log data
|
|
62
97
|
aws_sns_endpoint sns.ap-northeast-1.amazonaws.com
|
63
98
|
aws_sns_topic_arn arn:aws:sns:ap-northeast-1:XXXXXXXXXXXXXXXXXXXX
|
64
99
|
|
65
|
-
|
100
|
+
# Time Sliced Output options
|
66
101
|
buffer_path /var/log/td-agent/buffer/forward_aws
|
67
102
|
time_slice_wait 1m
|
68
|
-
utc
|
69
103
|
time_slice_format %Y/%m/%d/%H/%M
|
104
|
+
utc
|
105
|
+
flush_at_shutdown true
|
70
106
|
</match>
|
71
107
|
```
|
72
108
|
|
73
109
|
### Advanced configuration using forest plugin
|
74
|
-
Use tag as channel
|
110
|
+
Use tag as forward-AWS channel
|
75
111
|
```
|
76
112
|
<match **>
|
77
113
|
type forest
|
@@ -87,16 +123,29 @@ Use tag as channel
|
|
87
123
|
aws_sns_endpoint sns.ap-northeast-1.amazonaws.com
|
88
124
|
aws_sns_topic_arn arn:aws:sns:ap-northeast-1:XXXXXXXXXXXXXXXXXXXX
|
89
125
|
|
90
|
-
|
126
|
+
# Time Sliced Output options
|
91
127
|
buffer_path /var/log/td-agent/buffer/forward_aws-${tag}
|
92
128
|
time_slice_wait 1m
|
93
|
-
utc
|
94
129
|
time_slice_format %Y/%m/%d/%H/%M
|
130
|
+
utc
|
131
|
+
flush_at_shutdown true
|
95
132
|
</template>
|
96
133
|
</match>
|
97
134
|
```
|
98
135
|
|
99
136
|
## In Plugin Configuration
|
137
|
+
### Parameters
|
138
|
+
+ **aws_sqs_endpoint** (required)
|
139
|
+
[SQS Endpoint](http://docs.aws.amazon.com/general/latest/gr/rande.html#sqs_region) for your topic
|
140
|
+
|
141
|
+
+ **aws_sqs_queue_url** (required)
|
142
|
+
SQS Queue URL (not ARN)
|
143
|
+
|
144
|
+
+ **aws_sqs_skiptest** (optional, default = false)
|
145
|
+
Skip SQS Related test at startup
|
146
|
+
|
147
|
+
+ **channelEnableRegEx** (optional, default = false)
|
148
|
+
Enabled Regular Expression for channel value.
|
100
149
|
|
101
150
|
###Required AWS permission
|
102
151
|
+ s3:GetObject
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "fluent-plugin-forward-aws"
|
7
|
-
gem.version = "0.1.
|
7
|
+
gem.version = "0.1.2"
|
8
8
|
gem.authors = ["Tomohisa Ota"]
|
9
9
|
gem.email = ["tomohisa.ota+github@gmail.com"]
|
10
10
|
gem.description = "Fluentd Forward Plugin using Amazon Web Service"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ForwardAWSUtil
|
2
|
+
|
3
|
+
def self.filtertag(tag,add_prefix=nil,remove_prefix=nil)
|
4
|
+
# Remove Prefix First
|
5
|
+
if remove_prefix && tag
|
6
|
+
tag = tag.sub(/^#{Regexp.escape(remove_prefix)}\b\.?/,"")
|
7
|
+
end
|
8
|
+
|
9
|
+
# Add Prefix
|
10
|
+
if add_prefix
|
11
|
+
if tag && tag.length > 0
|
12
|
+
tag = "#{add_prefix}.#{tag}"
|
13
|
+
else
|
14
|
+
tag = add_prefix
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Return Result
|
19
|
+
return tag
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
class Fluent::ForwardAWSInput < Fluent::Input
|
2
2
|
Fluent::Plugin.register_input('forward_aws', self)
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
|
4
|
+
require_relative "forward_aws_util"
|
5
|
+
include ForwardAWSUtil
|
6
|
+
|
6
7
|
def initialize
|
7
8
|
super
|
8
9
|
require 'aws-sdk'
|
@@ -26,6 +27,9 @@ class Fluent::ForwardAWSInput < Fluent::Input
|
|
26
27
|
config_param :aws_sqs_queue_url, :string, :default => nil
|
27
28
|
config_param :aws_sqs_skiptest, :bool, :default => false
|
28
29
|
|
30
|
+
config_param :add_tag_prefix, :string, :default => nil
|
31
|
+
config_param :remove_tag_prefix, :string, :default => nil
|
32
|
+
|
29
33
|
# Not documented parameters. Subject to change in future release
|
30
34
|
config_param :aws_sqs_process_interval, :integer, :default => 1
|
31
35
|
config_param :aws_sqs_monitor_interval, :integer, :default => 10
|
@@ -135,6 +139,7 @@ class Fluent::ForwardAWSInput < Fluent::Input
|
|
135
139
|
streamUnpacker.feed(reader.read())
|
136
140
|
streamUnpacker.each {|event|
|
137
141
|
(tag, time, record) = event
|
142
|
+
tag = ForwardAWSUtil.filtertag(tag,@add_tag_prefix,@remove_tag_prefix)
|
138
143
|
Fluent::Engine.emit(tag,time,record)
|
139
144
|
}
|
140
145
|
}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
class Fluent::ForwardAWSOutput < Fluent::TimeSlicedOutput
|
2
2
|
Fluent::Plugin.register_output('forward_aws', self)
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
|
4
|
+
require_relative "forward_aws_util"
|
5
|
+
include ForwardAWSUtil
|
6
|
+
|
6
7
|
config_param :channel, :string, :default => "default"
|
7
8
|
|
8
9
|
config_param :aws_access_key_id, :string, :default => nil
|
@@ -16,6 +17,9 @@ class Fluent::ForwardAWSOutput < Fluent::TimeSlicedOutput
|
|
16
17
|
config_param :aws_sns_topic_arn, :string, :default => nil
|
17
18
|
config_param :aws_sns_skiptest, :bool, :default => false
|
18
19
|
|
20
|
+
config_param :add_tag_prefix, :string, :default => nil
|
21
|
+
config_param :remove_tag_prefix, :string, :default => nil
|
22
|
+
|
19
23
|
# Not documented parameters. Subject to change in future release
|
20
24
|
config_param :aws_s3_testobjectname, :string, :default => "Config Check Test Object"
|
21
25
|
config_param :aws_sns_emailsubject, :string, :default => "SNS Message"
|
@@ -86,6 +90,7 @@ class Fluent::ForwardAWSOutput < Fluent::TimeSlicedOutput
|
|
86
90
|
end
|
87
91
|
|
88
92
|
def format(tag, time, record)
|
93
|
+
tag = ForwardAWSUtil.filtertag(tag,@add_tag_prefix,@remove_tag_prefix)
|
89
94
|
[tag, time, record].to_msgpack
|
90
95
|
end
|
91
96
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ForwardAWSUtilTest < Test::Unit::TestCase
|
4
|
+
require_relative "../../lib/fluent/plugin/forward_aws_util"
|
5
|
+
include ForwardAWSUtil
|
6
|
+
|
7
|
+
def test_filtertag
|
8
|
+
assert_equal('aaa',ForwardAWSUtil.filtertag("aaa"))
|
9
|
+
assert_equal('aaa.bbb',ForwardAWSUtil.filtertag("aaa.bbb"))
|
10
|
+
assert_equal('aaa.bbb.ccc',ForwardAWSUtil.filtertag("aaa.bbb.ccc"))
|
11
|
+
|
12
|
+
# Add prefix
|
13
|
+
assert_equal('ddd.aaa',ForwardAWSUtil.filtertag("aaa","ddd"))
|
14
|
+
assert_equal('ddd.aaa.bbb',ForwardAWSUtil.filtertag("aaa.bbb","ddd"))
|
15
|
+
assert_equal('ddd.aaa.bbb.ccc',ForwardAWSUtil.filtertag("aaa.bbb.ccc","ddd"))
|
16
|
+
|
17
|
+
# Remove prefix
|
18
|
+
assert_equal('',ForwardAWSUtil.filtertag("aaa",nil,"aaa"))
|
19
|
+
assert_equal('bbb',ForwardAWSUtil.filtertag("aaa.bbb",nil,"aaa"))
|
20
|
+
assert_equal('bbb.ccc',ForwardAWSUtil.filtertag("aaa.bbb.ccc",nil,"aaa"))
|
21
|
+
|
22
|
+
# Add and remove
|
23
|
+
assert_equal('ccc.bbb',ForwardAWSUtil.filtertag("aaa.bbb","ccc","aaa"))
|
24
|
+
|
25
|
+
# Corner cases
|
26
|
+
# Do not remove tag in middle
|
27
|
+
assert_equal('aaa.bbb.ccc',ForwardAWSUtil.filtertag("aaa.bbb.ccc",nil,"bbb"))
|
28
|
+
# Do not remove incomplete tag
|
29
|
+
assert_equal('aaaa.bbb',ForwardAWSUtil.filtertag("aaaa.bbb",nil,"aaa"))
|
30
|
+
# Remove tag does not affect newly added tag
|
31
|
+
assert_equal('ccc.ddd.aaa.bbb',ForwardAWSUtil.filtertag("aaa.bbb","ccc.ddd","ccc"))
|
32
|
+
assert_equal('ccc.ddd.bbb',ForwardAWSUtil.filtertag("aaa.bbb","ccc.ddd","aaa"))
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -72,6 +72,28 @@ class ForwardAWSOutputTest < Test::Unit::TestCase
|
|
72
72
|
d.expect_format ["test",time,{"a"=>2}].to_msgpack
|
73
73
|
d.run
|
74
74
|
end
|
75
|
+
|
76
|
+
def test_format_addprefixtest
|
77
|
+
d = create_driver(DUMMYCONFIG + "add_tag_prefix addprefixtest")
|
78
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
79
|
+
d.emit({"a"=>1}, time)
|
80
|
+
d.emit({"a"=>2}, time)
|
81
|
+
|
82
|
+
d.expect_format ["addprefixtest.test",time,{"a"=>1}].to_msgpack
|
83
|
+
d.expect_format ["addprefixtest.test",time,{"a"=>2}].to_msgpack
|
84
|
+
d.run
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_format_removeprefixtest
|
88
|
+
d = create_driver(DUMMYCONFIG + "remove_tag_prefix test")
|
89
|
+
time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
90
|
+
d.emit({"a"=>1}, time)
|
91
|
+
d.emit({"a"=>2}, time)
|
92
|
+
|
93
|
+
d.expect_format ["",time,{"a"=>1}].to_msgpack
|
94
|
+
d.expect_format ["",time,{"a"=>2}].to_msgpack
|
95
|
+
d.run
|
96
|
+
end
|
75
97
|
|
76
98
|
def test_check_aws_s3
|
77
99
|
unless(@CONFIG)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-forward-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -56,10 +56,12 @@ files:
|
|
56
56
|
- README.md
|
57
57
|
- Rakefile
|
58
58
|
- fluent-plugin-forward-aws.gemspec
|
59
|
+
- lib/fluent/plugin/forward_aws_util.rb
|
59
60
|
- lib/fluent/plugin/in_forward_aws.rb
|
60
61
|
- lib/fluent/plugin/out_forward_aws.rb
|
61
62
|
- test/awsconfig.yml.sample
|
62
63
|
- test/helper.rb
|
64
|
+
- test/plugin/test_forward_aws_util.rb
|
63
65
|
- test/plugin/test_in_foward_aws.rb
|
64
66
|
- test/plugin/test_out_foward_aws.rb
|
65
67
|
homepage: ''
|
@@ -89,5 +91,6 @@ summary: Fluentd Forward Plugin using Amazon Web Service
|
|
89
91
|
test_files:
|
90
92
|
- test/awsconfig.yml.sample
|
91
93
|
- test/helper.rb
|
94
|
+
- test/plugin/test_forward_aws_util.rb
|
92
95
|
- test/plugin/test_in_foward_aws.rb
|
93
96
|
- test/plugin/test_out_foward_aws.rb
|