logstash-output-slack 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -0
- data/README.md +18 -7
- data/lib/logstash/outputs/slack.rb +3 -3
- data/logstash-output-slack.gemspec +1 -1
- data/spec/outputs/slack_spec.rb +52 -5
- 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: db23f70996dcdbc3878464c3c944aa6cd8fc08ae
|
4
|
+
data.tar.gz: d724aa6471b1dbbd4ce760ce3af7436ceeda6030
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf5d70cacabf2a886b520398d96b98565258e0b71afa631e36135c9173e128eba8866486f793f7c0d2fbb9b51e4b3c40d5895f14a4c3fade1e921990705a9ac
|
7
|
+
data.tar.gz: 3d258583fbd011a8c3637cee468c01304f4f4ce19187656dfb55f59ff5d5e485a78e7d905c1860c4679c5e11d7ef3729abca91d631b927cd139f4edda50b234a
|
data/.travis.yml
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
rvm:
|
4
|
+
- jruby 1.7.21
|
4
5
|
- jruby-head
|
5
6
|
|
6
7
|
jdk:
|
8
|
+
- openjdk6
|
7
9
|
- openjdk7
|
8
10
|
- oraclejdk7
|
9
11
|
- oraclejdk8
|
@@ -12,3 +14,11 @@ script: bundle exec rspec spec
|
|
12
14
|
|
13
15
|
notifications:
|
14
16
|
email: false
|
17
|
+
|
18
|
+
matrix:
|
19
|
+
fast_finish: true
|
20
|
+
allow_failures:
|
21
|
+
- rvm: jruby-head
|
22
|
+
exclude:
|
23
|
+
- rvm: jruby-head
|
24
|
+
jdk: openjdk6
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/cyli/logstash-output-slack.svg?branch=master)](https://travis-ci.org/cyli/logstash-output-slack)
|
2
2
|
|
3
|
+
Reviews of the code/contributions are very welcome (particularly with testing!), since I don't really know Ruby.
|
4
|
+
|
3
5
|
## Logstash Slack Output Plugin
|
4
6
|
|
5
7
|
Uses Slack [incoming webhooks API](https://api.slack.com/incoming-webhooks) to send log events to Slack.
|
@@ -30,23 +32,32 @@ output {
|
|
30
32
|
|
31
33
|
Not supported yet: attachments
|
32
34
|
|
35
|
+
### Changelog:
|
36
|
+
- v 0.1.1:
|
37
|
+
- Added variable expansion to usernames and channel names ([#6](https://github.com/cyli/logstash-output-slack/pull/6))
|
38
|
+
- Fixed bug when reporting malformed requests ([#3](https://github.com/cyli/logstash-output-slack/pull/3))
|
39
|
+
- Test fixes since newer versions of logstash-core expects the values in
|
40
|
+
the `add_field` hash to not be integers.
|
41
|
+
- v 0.1.0:
|
42
|
+
- initial version containing basic slack functionality
|
43
|
+
|
33
44
|
### Installation on Logstash >= 1.5
|
34
45
|
|
35
|
-
In the logstash directory, run: `bin/plugin install logstash-output-slack
|
46
|
+
In the logstash directory, run: `bin/plugin install logstash-output-slack`, which will download and install the public gem.
|
36
47
|
|
37
48
|
#### To build your own gem and install:
|
38
49
|
|
39
50
|
1. `git clone <thisrepo>`
|
40
51
|
1. `bundle install`
|
41
52
|
1. `gem build logstash-output-slack.gemspec`
|
53
|
+
1. `cd <path to logstash>`
|
54
|
+
1. `logstash>1.5.0`: `bin/plugin install <path-to-your-built-gem>`
|
42
55
|
|
43
|
-
|
44
|
-
|
45
|
-
You need to:
|
56
|
+
On `logstash==1.5.0`, due to [this bug](https://github.com/elastic/logstash/issues/2674), installing from a local gem doesn't work right now. You will need to:
|
46
57
|
|
47
|
-
1. Make sure that the `logstash-core` gem you've installed matches the exact beta 1.5 logstash version you are running.
|
48
|
-
1. modify the logstash Gemfile to include the line `gem "logstash-output-slack", :path => <path_to_the_directory_your_gem_is_in>`
|
49
|
-
1. `bin/plugin install --no-verify`
|
58
|
+
1. Make sure that the `logstash-core` gem you've installed matches the exact beta 1.5 logstash version you are running.
|
59
|
+
1. modify the logstash Gemfile to include the line `gem "logstash-output-slack", :path => <path_to_the_directory_your_gem_is_in>`
|
60
|
+
1. `bin/plugin install --no-verify`
|
50
61
|
|
51
62
|
#### Verify that the plugin installed correctly
|
52
63
|
`bin/plugin list | grep logstash-output-slack`
|
@@ -42,11 +42,11 @@ class LogStash::Outputs::Slack < LogStash::Outputs::Base
|
|
42
42
|
payload_json['text'] = event.sprintf(@format)
|
43
43
|
|
44
44
|
if not @channel.nil?
|
45
|
-
payload_json['channel'] = @channel
|
45
|
+
payload_json['channel'] = event.sprintf(@channel)
|
46
46
|
end
|
47
47
|
|
48
48
|
if not @username.nil?
|
49
|
-
payload_json['username'] = @username
|
49
|
+
payload_json['username'] = event.sprintf(@username)
|
50
50
|
end
|
51
51
|
|
52
52
|
if not @icon_emoji.nil?
|
@@ -66,7 +66,7 @@ class LogStash::Outputs::Slack < LogStash::Outputs::Base
|
|
66
66
|
:'User-Agent' => "logstash-output-slack",
|
67
67
|
:content_type => @content_type) { |response, request, result, &block|
|
68
68
|
if response.code != 200
|
69
|
-
@logger.warn("Got a #{response.code}
|
69
|
+
@logger.warn("Got a #{response.code} response: #{response}")
|
70
70
|
end
|
71
71
|
}
|
72
72
|
rescue Exception => e
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-slack'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.1'
|
4
4
|
s.licenses = ['MIT','Apache License (2.0)']
|
5
5
|
s.summary = "Write events to Slack"
|
6
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"
|
data/spec/outputs/slack_spec.rb
CHANGED
@@ -18,11 +18,13 @@ describe LogStash::Outputs::Slack do
|
|
18
18
|
CONFIG
|
19
19
|
end
|
20
20
|
|
21
|
-
let(:
|
21
|
+
let(:long_formatted_config) do <<-CONFIG
|
22
22
|
input {
|
23
23
|
generator {
|
24
24
|
message => "This message should show in slack"
|
25
|
-
add_field => {"
|
25
|
+
add_field => {"x" => "3"
|
26
|
+
"channelname" => "mychannel"
|
27
|
+
"username" => "slackbot"}
|
26
28
|
count => 1
|
27
29
|
}
|
28
30
|
}
|
@@ -30,7 +32,28 @@ describe LogStash::Outputs::Slack do
|
|
30
32
|
output {
|
31
33
|
slack {
|
32
34
|
url => "http://requestb.in/r9lkbzr9"
|
33
|
-
format => "%{message} %{
|
35
|
+
format => "%{message} %{x}"
|
36
|
+
channel => "%{channelname}"
|
37
|
+
username => "%{username}"
|
38
|
+
icon_emoji => ":chart_with_upwards_trend:"
|
39
|
+
icon_url => "http://lorempixel.com/48/48"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
CONFIG
|
43
|
+
end
|
44
|
+
|
45
|
+
let(:long_unformatted_config) do <<-CONFIG
|
46
|
+
input {
|
47
|
+
generator {
|
48
|
+
message => "This message should not show in slack"
|
49
|
+
count => 1
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
output {
|
54
|
+
slack {
|
55
|
+
url => "http://requestb.in/r9lkbzr9"
|
56
|
+
format => "Unformatted message"
|
34
57
|
channel => "mychannel"
|
35
58
|
username => "slackbot"
|
36
59
|
icon_emoji => ":chart_with_upwards_trend:"
|
@@ -71,7 +94,7 @@ describe LogStash::Outputs::Slack do
|
|
71
94
|
to have_been_made.once
|
72
95
|
end
|
73
96
|
|
74
|
-
it "uses all provided values" do
|
97
|
+
it "uses and formats all provided values" do
|
75
98
|
stub_request(:post, "requestb.in").
|
76
99
|
to_return(:body => "", :status => 200,
|
77
100
|
:headers => { 'Content-Length' => 0 })
|
@@ -84,7 +107,7 @@ describe LogStash::Outputs::Slack do
|
|
84
107
|
:icon_url => "http://lorempixel.com/48/48"
|
85
108
|
}
|
86
109
|
|
87
|
-
LogStash::Pipeline.new(
|
110
|
+
LogStash::Pipeline.new(long_formatted_config).run
|
88
111
|
|
89
112
|
expect(a_request(:post, "http://requestb.in/r9lkbzr9").
|
90
113
|
with(:body => "payload=#{CGI.escape(JSON.dump(expected_json))}",
|
@@ -96,5 +119,29 @@ describe LogStash::Outputs::Slack do
|
|
96
119
|
to have_been_made.once
|
97
120
|
end
|
98
121
|
|
122
|
+
it "uses and formats all provided values" do
|
123
|
+
stub_request(:post, "requestb.in").
|
124
|
+
to_return(:body => "", :status => 200,
|
125
|
+
:headers => { 'Content-Length' => 0 })
|
126
|
+
|
127
|
+
expected_json = {
|
128
|
+
:text => "Unformatted message",
|
129
|
+
:channel => "mychannel",
|
130
|
+
:username => "slackbot",
|
131
|
+
:icon_emoji => ":chart_with_upwards_trend:",
|
132
|
+
:icon_url => "http://lorempixel.com/48/48"
|
133
|
+
}
|
134
|
+
|
135
|
+
LogStash::Pipeline.new(long_unformatted_config).run
|
136
|
+
|
137
|
+
expect(a_request(:post, "http://requestb.in/r9lkbzr9").
|
138
|
+
with(:body => "payload=#{CGI.escape(JSON.dump(expected_json))}",
|
139
|
+
:headers => {
|
140
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
141
|
+
'Accept'=> 'application/json',
|
142
|
+
'User-Agent' => 'logstash-output-slack'
|
143
|
+
})).
|
144
|
+
to have_been_made.once
|
145
|
+
end
|
99
146
|
end
|
100
147
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ying Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
requirements:
|
154
154
|
- jar 'org.elasticsearch:elasticsearch', '1.4.0'
|
155
155
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.4.8
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Write events to Slack
|