fluent-plugin-amazon_sns 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +6 -0
- data/HISTORY.md +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +1 -0
- data/examples/fluentd.conf +12 -0
- data/fluent-plugin-amazon_sns.gemspec +26 -0
- data/lib/fluent/plugin/amazon_sns/version.rb +7 -0
- data/lib/fluent/plugin/out_amazon_sns.rb +83 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1c556b4a548112878e94eb613e01f2325dbbfd27
|
4
|
+
data.tar.gz: 54ddf45b21f14c071f00572d5600881006b48bd6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 470248acf2f49fe062316e3571b98112a6dde8d6b798f11494e44c76b425d843a2a3c73bf6c2954f713fcca7fb5bdd665ae4cbe561a586a639b4255eb82866d0
|
7
|
+
data.tar.gz: 581d69289b4fe15119855a1cb8ac669ac2a888de4efaf4de1511a45d3966ede25642614baff0f3383ba59277b9bf2e53f0f5cb2545d8e31cb62dbd4eaefc9e86
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/HISTORY.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Tatsuhiko Miyagawa
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Fluent::Plugin::AmazonSns
|
2
|
+
|
3
|
+
Fluent output plugin to send messages to Amazon SNS.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
fluent-gem install fluent-plugin-amazon_sns
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```
|
12
|
+
<match sns.**>
|
13
|
+
type amazon_sns
|
14
|
+
|
15
|
+
flush_interval 1s
|
16
|
+
|
17
|
+
# Optional if you have AWS_* environment variables set up (via IAM Role etc.)
|
18
|
+
aws_access_key_id AWS_ACCESS_KEY_ID
|
19
|
+
aws_secret_access_key AWS_SECRET_ACCESS_KEY
|
20
|
+
aws_region AWS_REGION # (e.g. ap-northeast-1)
|
21
|
+
|
22
|
+
# One of the following options must be enabled to map topics
|
23
|
+
|
24
|
+
## 1) Fixed string
|
25
|
+
topic_name MyTopic
|
26
|
+
|
27
|
+
## 2) Map fluent tags
|
28
|
+
## sns.App.MyTopic -> 'App-MyTopic'
|
29
|
+
topic_map_tag true
|
30
|
+
remove_tag_prefix 'sns'
|
31
|
+
|
32
|
+
## 3) Map fluent message key
|
33
|
+
## maps 'topic' key in the message
|
34
|
+
topic_map_key topic
|
35
|
+
|
36
|
+
# SNS Message Subject, either fixed string or map message key
|
37
|
+
subject SUBJECT_STRING
|
38
|
+
subject_key SUBJECT_KEY
|
39
|
+
|
40
|
+
</match>
|
41
|
+
```
|
42
|
+
|
43
|
+
## Difference with fluent-plugin-sns
|
44
|
+
|
45
|
+
* Topic names are dynamically configurable, rather than static
|
46
|
+
* Buffered output
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it ( http://github.com/<my-github-username>/fluent-plugin-amazon_sns/fork )
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
55
|
+
|
56
|
+
## Author
|
57
|
+
|
58
|
+
Tatsuhiko Miyagawa
|
59
|
+
|
60
|
+
The code is heavily inspired by: [ixixi/fluent-plugin-sns](https://github.com/ixixi/fluent-plugin-sns) and [norikra/fluent-plugin-norikra](https://github.com/norikra/fluent-plugin-norikra).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fluent/plugin/amazon_sns/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluent-plugin-amazon_sns"
|
8
|
+
spec.version = Fluent::Plugin::AmazonSns::VERSION
|
9
|
+
spec.authors = ["Tatsuhiko Miyagawa"]
|
10
|
+
spec.email = ["miyagawa@bulknews.net"]
|
11
|
+
spec.summary = %q{Fluent output plugin to send to Amazon SNS}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "fluentd", "~> 0.10.0"
|
22
|
+
spec.add_dependency "aws-sdk", "~> 1.12"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require "aws-sdk"
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
class AmazonSNSOutput < BufferedOutput
|
5
|
+
Fluent::Plugin.register_output('amazon_sns', self)
|
6
|
+
|
7
|
+
include SetTagKeyMixin
|
8
|
+
config_set_default :include_tag_key, false
|
9
|
+
|
10
|
+
include SetTimeKeyMixin
|
11
|
+
config_set_default :include_time_key, true
|
12
|
+
|
13
|
+
config_param :aws_access_key_id, :string, default: nil
|
14
|
+
config_param :aws_secret_access_key, :string, default: nil
|
15
|
+
config_param :aws_region, :string, default: nil
|
16
|
+
config_param :aws_proxy_uri, :string, default: ENV['HTTP_PROXY']
|
17
|
+
|
18
|
+
config_param :subject_key, :string, default: nil
|
19
|
+
config_param :subject, :string, default: nil
|
20
|
+
|
21
|
+
config_param :topic_name, :string, default: nil
|
22
|
+
config_param :topic_map_tag, :bool, default: false
|
23
|
+
config_param :remove_tag_prefix, :string, default: nil
|
24
|
+
config_param :topic_map_key, :string, default: nil
|
25
|
+
|
26
|
+
def configure(conf)
|
27
|
+
super
|
28
|
+
|
29
|
+
@topic_generator = case
|
30
|
+
when @topic_name
|
31
|
+
->(tag, record){ @topic_name }
|
32
|
+
when @topic_map_key
|
33
|
+
->(tag, record){ record[@topic_map_key] }
|
34
|
+
when @topic_map_tag
|
35
|
+
->(tag, record){ tag.gsub(/^#{@remove_tag_prefix}(\.)?/, '') }
|
36
|
+
else
|
37
|
+
raise Fluent::ConfigError, "no one way specified to decide target"
|
38
|
+
end
|
39
|
+
|
40
|
+
options = {}
|
41
|
+
[:access_key_id, :secret_access_key, :region, :proxy_uri].each do |key|
|
42
|
+
options[key] = instance_variable_get "@aws_#{key}"
|
43
|
+
end
|
44
|
+
|
45
|
+
AWS.config(options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def start
|
49
|
+
super
|
50
|
+
@sns = AWS::SNS.new
|
51
|
+
@topics = get_topics
|
52
|
+
end
|
53
|
+
|
54
|
+
def shutdown
|
55
|
+
super
|
56
|
+
end
|
57
|
+
|
58
|
+
def format(tag, time, record)
|
59
|
+
[tag, time, record].to_msgpack
|
60
|
+
end
|
61
|
+
|
62
|
+
def write(chunk)
|
63
|
+
chunk.msgpack_each do |tag, time, record|
|
64
|
+
record["time"] = Time.at(time).localtime
|
65
|
+
subject = record.delete(@subject_key) || @subject || 'Fluent-Notification'
|
66
|
+
topic = @topic_generator.call(tag, record)
|
67
|
+
topic = topic.gsub(/\./, '-') if topic # SNS doesn't allow .
|
68
|
+
if @topics[topic]
|
69
|
+
@topics[topic].publish(record.to_json, subject: subject)
|
70
|
+
else
|
71
|
+
$log.error "Could not find topic '#{topic}' on SNS"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_topics()
|
77
|
+
@sns.topics.inject({}) do |product, topic|
|
78
|
+
product[topic.name] = topic
|
79
|
+
product
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-amazon_sns
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tatsuhiko Miyagawa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.10.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.10.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: ''
|
70
|
+
email:
|
71
|
+
- miyagawa@bulknews.net
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- HISTORY.md
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- examples/fluentd.conf
|
83
|
+
- fluent-plugin-amazon_sns.gemspec
|
84
|
+
- lib/fluent/plugin/amazon_sns/version.rb
|
85
|
+
- lib/fluent/plugin/out_amazon_sns.rb
|
86
|
+
homepage: ''
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Fluent output plugin to send to Amazon SNS
|
110
|
+
test_files: []
|