logstash-output-email 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -4
- data/lib/logstash/outputs/email.rb +6 -1
- data/logstash-output-email.gemspec +1 -1
- data/spec/outputs/email_spec.rb +79 -63
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9113b32924f9aa3aaf948a2def10f4de02e304a6
|
4
|
+
data.tar.gz: 685b26596c503699d5ab855720619cff6cb26075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e29a2e50322bd6b9eef87bc9f786834b0f4f58ff4f1a2746c14282915e8635fc2ce948bb48f03b188d07d014f5cc3a238503f6b3616f05460c59f00d4c901dad
|
7
|
+
data.tar.gz: c9ac9d5fe22bbf02b1a57e2348b5d26b19fd6eb5709d7509ffb61fdc5958a314c74405784f136f17c623ba5103b39fd3461e343f0cd3eb77e57a36cc1ea61bf5
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,5 @@
|
|
1
|
+
# 1.1.0
|
2
|
+
- Make the delivery method more reliable to failure by catching and
|
3
|
+
logging exceptions when happen, like this LS is not going to break
|
4
|
+
if something wrong happen, but is going to log it. Fixes #26 and #7
|
5
|
+
- Randomize port in specs so they can run in parallel.
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
This is a plugin for [Logstash](https://github.com/
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
4
|
|
5
5
|
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.
|
6
6
|
|
7
7
|
## Documentation
|
8
8
|
|
9
|
-
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.
|
9
|
+
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/).
|
10
10
|
|
11
11
|
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
12
|
-
- For more asciidoc formatting tips, see the excellent reference here https://github.com/
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
13
13
|
|
14
14
|
## Need Help?
|
15
15
|
|
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
|
|
83
83
|
|
84
84
|
It is more important to the community that you are able to contribute.
|
85
85
|
|
86
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -247,7 +247,12 @@ class LogStash::Outputs::Email < LogStash::Outputs::Base
|
|
247
247
|
mail.add_file(fileLocation)
|
248
248
|
end # end @attachments.each
|
249
249
|
@logger.debug? and @logger.debug("Sending mail with these values : ", :from => mail.from, :to => mail.to, :cc => mail.cc, :subject => mail.subject)
|
250
|
-
|
250
|
+
begin
|
251
|
+
mail.deliver!
|
252
|
+
rescue StandardError => e
|
253
|
+
@logger.error("Something happen while delivering an email", :exception => e)
|
254
|
+
@logger.debug? && @logger.debug("Processed event: ", :event => event)
|
255
|
+
end
|
251
256
|
end # end if successful
|
252
257
|
end # def receive
|
253
258
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-email'
|
4
|
-
s.version = '1.
|
4
|
+
s.version = '1.1.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Send email when an output is received."
|
7
7
|
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"
|
data/spec/outputs/email_spec.rb
CHANGED
@@ -5,10 +5,10 @@ require "message_observers"
|
|
5
5
|
|
6
6
|
describe "outputs/email" do
|
7
7
|
|
8
|
-
port
|
9
|
-
let (:rumbster)
|
8
|
+
let (:port) { rand(1024..65535) }
|
9
|
+
let (:rumbster) { Rumbster.new(port) }
|
10
10
|
let (:message_observer) { MailMessageObserver.new }
|
11
|
-
plugin
|
11
|
+
let(:plugin) { LogStash::Plugin.lookup("output", "email") }
|
12
12
|
|
13
13
|
|
14
14
|
before :each do
|
@@ -21,75 +21,91 @@ describe "outputs/email" do
|
|
21
21
|
sleep 0.01 until rumbster.stopped?
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
24
|
+
describe "send email" do
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
context "use a list of email as mail.to (LOGSTASH-827)" do
|
27
|
+
|
28
|
+
it "supports list of emails in to field" do
|
29
|
+
subject = plugin.new("to" => ["email1@host, email2@host"],
|
30
|
+
"match" => ["mymatch", "dummy_match,ok"],
|
31
|
+
"options" => ["port", port])
|
32
|
+
subject.register
|
33
|
+
subject.receive(LogStash::Event.new("message" => "hello", "dummy_match" => "ok"))
|
34
|
+
expect(message_observer.messages.size).to eq(1)
|
35
|
+
expect(message_observer.messages[0].to).to eq(["email1@host", "email2@host"])
|
36
|
+
end
|
37
|
+
|
38
|
+
it "multiple *to* addresses in a field" do
|
39
|
+
subject = plugin.new("to" => "%{to_addr}",
|
40
|
+
"match" => ["mymatch", "dummy_match,ok"],
|
41
|
+
"options" => ["port", port])
|
42
|
+
subject.register
|
43
|
+
subject.receive(LogStash::Event.new("message" => "hello",
|
44
|
+
"dummy_match" => "ok",
|
45
|
+
"to_addr" => ["email1@host", "email2@host"]))
|
46
|
+
expect(message_observer.messages.size).to eq(1)
|
47
|
+
expect(message_observer.messages[0].to).to eq(["email1@host", "email2@host"])
|
48
|
+
end
|
34
49
|
end
|
35
50
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
51
|
+
context "multi-lined text body (LOGSTASH-841)" do
|
52
|
+
it "handles multiline messages" do
|
53
|
+
subject = plugin.new("to" => "me@host",
|
54
|
+
"subject" => "Hello World",
|
55
|
+
"body" => "Line1\\nLine2\\nLine3",
|
56
|
+
"match" => ["mymatch", "dummy_match,*"],
|
57
|
+
"options" => ["port", port])
|
58
|
+
subject.register
|
59
|
+
subject.receive(LogStash::Event.new("message" => "hello", "dummy_match" => "ok"))
|
60
|
+
expect(message_observer.messages.size).to eq(1)
|
61
|
+
expect(message_observer.messages[0].subject).to eq("Hello World")
|
62
|
+
expect(message_observer.messages[0].body.raw_source).to eq("Line1\r\nLine2\r\nLine3\r\n")
|
63
|
+
end
|
46
64
|
end
|
47
|
-
end
|
48
65
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
66
|
+
context "use nil authenticationType (LOGSTASH-559)" do
|
67
|
+
it "reads messages correctly" do
|
68
|
+
subject = plugin.new("to" => "me@host",
|
69
|
+
"subject" => "Hello World",
|
70
|
+
"body" => "Line1\\nLine2\\nLine3",
|
71
|
+
"match" => ["mymatch", "dummy_match,*"],
|
72
|
+
"options" => ["port", port, "authenticationType", "nil"])
|
73
|
+
subject.register
|
74
|
+
subject.receive(LogStash::Event.new("message" => "hello", "dummy_match" => "ok"))
|
75
|
+
expect(message_observer.messages.size).to eq(1)
|
76
|
+
expect(message_observer.messages[0].subject).to eq("Hello World")
|
77
|
+
expect(message_observer.messages[0].body.raw_source).to eq("Line1\r\nLine2\r\nLine3\r\n")
|
78
|
+
end
|
61
79
|
end
|
62
|
-
end
|
63
80
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
81
|
+
context "match on source and message (LOGSTASH-826)" do
|
82
|
+
it "reads messages correctly" do
|
83
|
+
subject = plugin.new("to" => "me@host",
|
84
|
+
"subject" => "Hello World",
|
85
|
+
"body" => "Mail body",
|
86
|
+
"match" => [ "messageAndSourceMatch", "message,*hello,,and,type,*generator"],
|
87
|
+
"options" => ["port", port, "authenticationType", "nil"])
|
88
|
+
subject.register
|
89
|
+
subject.receive(LogStash::Event.new("message" => "hello world", "type" => "generator"))
|
90
|
+
expect(message_observer.messages.size).to eq(1)
|
91
|
+
expect(message_observer.messages[0].subject).to eq("Hello World")
|
92
|
+
expect(message_observer.messages[0].body.raw_source).to eq("Mail body\r\n")
|
93
|
+
end
|
76
94
|
end
|
77
|
-
end
|
78
95
|
|
79
|
-
|
80
|
-
|
81
|
-
subject
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
96
|
+
context "having no connection to the email server" do
|
97
|
+
|
98
|
+
subject { plugin.new("to" => "me@host") }
|
99
|
+
let(:event) { LogStash::Event.new("message" => "hello world") }
|
100
|
+
|
101
|
+
before(:each) do
|
102
|
+
subject.register
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should send without throwing an error" do
|
106
|
+
expect { subject.receive(event) }.not_to raise_error
|
107
|
+
end
|
91
108
|
end
|
109
|
+
|
92
110
|
end
|
93
111
|
end
|
94
|
-
|
95
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-email
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.4.6
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Send email when an output is received.
|