logstash-output-ses 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 389fab468a4e418d083e1c5ee92730c2f968055b
4
+ data.tar.gz: de3f79f40e378ca96d86307fc4684e6f584162b8
5
+ SHA512:
6
+ metadata.gz: c3487d614c02ac2f3ba30eb138451d55911b54178da57318787e0db3b9c8a0a3774e2267fe71fef06144f307b8f18473844d6a6299ae86f8d307beb4b72de642
7
+ data.tar.gz: aca071dc60deb6a36779b05946cb0ba5d4abfe8d023186e81ba8878b4f52215f89d8509cca2efe450bed113a6015f8eb0afc61e41c3f8bd60666c4c72a2e028c
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 2.0.1
2
+ - Add encoding: utf-8 to spec files. This can help prevent issues during testing.
3
+ ## 2.0.0
4
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
5
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
6
+ - Dependency on logstash-core update to 2.0
7
+
data/CONTRIBUTORS ADDED
@@ -0,0 +1,11 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Aaron Mildenstein (untergeek)
6
+ * Pier-Hugues Pellerin (ph)
7
+
8
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
9
+ Logstash, and you aren't on the list above and want to be, please let us know
10
+ and we'll make sure you're here. Contributions from folks like you are what make
11
+ open source awesome.
data/DEVELOPER.md ADDED
@@ -0,0 +1,2 @@
1
+ # logstash-output-example
2
+ Example output plugin. This should help bootstrap your effort to write your own output plugin!
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/NOTICE.TXT ADDED
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
data/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # Logstash Plugin
2
+
3
+ [![Build
4
+ Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-example-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-example-unit/)
5
+
6
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
7
+
8
+ It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
9
+
10
+ ## Documentation
11
+
12
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
13
+
14
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
15
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
16
+
17
+ ## Need Help?
18
+
19
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
20
+
21
+ ## Developing
22
+
23
+ ### 1. Plugin Developement and Testing
24
+
25
+ #### Code
26
+ - To get started, you'll need JRuby with the Bundler gem installed.
27
+
28
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
29
+
30
+ - Install dependencies
31
+ ```sh
32
+ bundle install
33
+ ```
34
+
35
+ #### Test
36
+
37
+ - Update your dependencies
38
+
39
+ ```sh
40
+ bundle install
41
+ ```
42
+
43
+ - Run tests
44
+
45
+ ```sh
46
+ bundle exec rspec
47
+ ```
48
+
49
+ ### 2. Running your unpublished Plugin in Logstash
50
+
51
+ #### 2.1 Run in a local Logstash clone
52
+
53
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
54
+ ```ruby
55
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
56
+ ```
57
+ - Install plugin
58
+ ```sh
59
+ bin/plugin install --no-verify
60
+ ```
61
+ - Run Logstash with your plugin
62
+ ```sh
63
+ bin/logstash -e 'filter {awesome {}}'
64
+ ```
65
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
66
+
67
+ #### 2.2 Run in an installed Logstash
68
+
69
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
70
+
71
+ - Build your plugin gem
72
+ ```sh
73
+ gem build logstash-filter-awesome.gemspec
74
+ ```
75
+ - Install the plugin from the Logstash home
76
+ ```sh
77
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
78
+ ```
79
+ - Start Logstash and proceed to test the plugin
80
+
81
+ ## Contributing
82
+
83
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
84
+
85
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
86
+
87
+ It is more important to the community that you are able to contribute.
88
+
89
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,102 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+
5
+
6
+ # An example output that does nothing.
7
+ class LogStash::Outputs::Ses < LogStash::Outputs::Base
8
+
9
+ config_name "ses"
10
+ #Amazon web service account key
11
+ config :aws_key_id, :validate => :string
12
+ #Amazon web service account secret key
13
+ config :aws_sec_key, :validate => :string
14
+ #Amazon web service targetted region where mail will be send
15
+ config :region_name, :validate => :string
16
+
17
+ #Verified AWS SES sender mail address , required
18
+ config :from,:validate => :string, :required => true
19
+ #Mail target users which seperated with comma
20
+ config :to, :validate => :string, :default => ""
21
+ #Mail cc users which seperated with comma
22
+ config :cc, :validate => :string, :default => ""
23
+ #Mail bcc users which seperated with comma
24
+ config :bcc, :validate => :string, :default => ""
25
+ #Mail subject
26
+ config :subject, :validate => :string, :default => ""
27
+ #Mail body which will be formatted with event values
28
+ config :body, :validate => :string, :default => ""
29
+ #Mail html body which will be formatted with event values
30
+ config :htmlbody, :validate => :string, :default => ""
31
+ #Mail reply address
32
+ config :reply_to_addresses,:validate => :string, :default => ""
33
+
34
+ public
35
+ def register
36
+ require "aws-sdk-resources"
37
+ options = {}
38
+ if @aws_key_id && @aws_sec_key
39
+ options[:access_key_id] = @aws_key_id
40
+ options[:secret_access_key] = @aws_sec_key
41
+ end
42
+
43
+ if @region_name
44
+ options[:region] = @region_name
45
+ end
46
+
47
+
48
+ @ses = Aws::SES::Client.new(options)
49
+
50
+ @to_addresses = @to.split ","
51
+ if @to_addresses.empty?
52
+ logger.error("To can not nil.",:to => @to)
53
+ raise "SES 'To' area can not nil."
54
+ end
55
+
56
+ @cc_addresses = @cc.split ","
57
+ @bcc_addresses = @bcc.split ","
58
+
59
+ @destination = {:to_addresses => @to_addresses }
60
+ unless @cc_addresses.empty?
61
+ @destination[:cc_addresses] = @cc_addresses
62
+ end
63
+ unless @bcc_addresses.empty?
64
+ @destination[:bcc_addresses] = @bcc_addresses
65
+ end
66
+
67
+ @logger.debug("Aws SES Registered!", :config => options)
68
+ end # def register
69
+
70
+ public
71
+ def receive(event)
72
+ @logger.debug? and @logger.debug("Creating AWS SES mail with these settings : ", :message => event,:options => @options, :from => @from, :to => @to_addresses, :cc => @cc_addresses, :subject => @subject,:innerTarget => event.sprintf("%{mailTo}"))
73
+
74
+ innerTarget = @destination.dup
75
+ if event.include?('mailTo')
76
+ innerTarget[:to_addresses] = event.sprintf("%{mailTo}").split ','
77
+ @logger.debug? and @logger.debug("new mailTo address found in event,overriding target addresses", :parsed => innerTarget[:to_addresses] )
78
+ end
79
+
80
+ subject = event.sprintf(@subject)
81
+ body = event.sprintf(@body)
82
+ htmlbody = event.sprintf(@htmlbody)
83
+ message = { :subject => {:data => subject},
84
+ :body => {
85
+ :html => {:data => htmlbody },
86
+ :text => {:data => body }
87
+ }
88
+ }
89
+
90
+ begin
91
+ @logger.debug? and @logger.debug("Sending mail with these values : ", :from => @from, :to => innerTarget, :subject => @subject, :body => @body)
92
+ @ses.send_email(
93
+ :source => @from,
94
+ :destination => innerTarget,
95
+ :message => message
96
+ )
97
+ rescue => e
98
+ logger.error("Something happen while delivering an SES email", :msg => e.message)
99
+ @logger.debug? && @logger.debug("Processed event: ", :event => event)
100
+ end
101
+ end # def event
102
+ end # class LogStash::Outputs::ses
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-ses'
3
+ s.version = "2.0.0"
4
+ s.licenses = ["Apache License (2.0)"]
5
+ s.summary = "Logstash amazon Simple Email Service (SES) Addon"
6
+ s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
7
+ s.authors = ["serdar ozau"]
8
+ s.email = "serdar.ozay@gmail.com"
9
+ s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
22
+ s.add_runtime_dependency 'logstash-mixin-aws', '>= 1.0.0'
23
+
24
+ s.add_development_dependency "logstash-devutils"
25
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/outputs/example"
4
+ require "logstash/codecs/plain"
5
+ require "logstash/event"
6
+
7
+ describe LogStash::Outputs::Ses do
8
+ let(:sample_event) { LogStash::Event.new }
9
+ let(:output) { LogStash::Outputs::Ses.new }
10
+
11
+ before do
12
+ output.register
13
+ end
14
+
15
+ describe "receive message" do
16
+ subject { output.receive(sample_event) }
17
+
18
+ it "returns a string" do
19
+ expect(subject).to eq("Event received")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ puts 'hello'
2
+ a = {:k => 1}
3
+ if a[:l] != nil
4
+ puts 'sad'
5
+ else
6
+ puts 'asd'
7
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-ses
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - serdar ozau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: logstash-mixin-aws
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: 1.0.0
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: logstash-devutils
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description: This gem is a logstash plugin required to be installed on top of the
62
+ Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
63
+ a stand-alone program
64
+ email: serdar.ozay@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - lib/logstash/outputs/ses.rb
70
+ - spec/outputs/ses_spec.rb
71
+ - spec/outputs/test.rb
72
+ - logstash-output-ses.gemspec
73
+ - README.md
74
+ - CHANGELOG.md
75
+ - DEVELOPER.md
76
+ - CONTRIBUTORS
77
+ - Gemfile
78
+ - LICENSE
79
+ - NOTICE.TXT
80
+ homepage: http://www.elastic.co/guide/en/logstash/current/index.html
81
+ licenses:
82
+ - Apache License (2.0)
83
+ metadata:
84
+ logstash_plugin: 'true'
85
+ logstash_group: output
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.0.14
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Logstash amazon Simple Email Service (SES) Addon
106
+ test_files:
107
+ - spec/outputs/ses_spec.rb
108
+ - spec/outputs/test.rb