logstash-output-slack 0.1.3-java
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 +8 -0
- data/.travis.yml +22 -0
- data/Gemfile +2 -0
- data/README.md +79 -0
- data/Rakefile +7 -0
- data/lib/logstash/outputs/slack.rb +92 -0
- data/logstash-output-slack.gemspec +40 -0
- data/spec/outputs/slack_spec.rb +296 -0
- data/spec/spec_helper.rb +3 -0
- metadata +191 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd3c670f33b5ba013a83424124e67d81d900f25e
|
4
|
+
data.tar.gz: a3f3f12a1e8f3eb72fadb2453e2dbbaa65125ae2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 024147cb302af44aca271029fabdb370b8ea5da971480d18343c9bd9920765bc2733309f431557669cb5e917a8ecc0c182cd5aaafa065ec9e48895fa619d195b
|
7
|
+
data.tar.gz: 5f25d2476832654a7e115a9bd64bd7d58473223699d81dfda9a712c85d98f432471f120759afae6958c0df3c34a23825d8194b94b15df9896eed309b13aef9e7
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
rvm:
|
4
|
+
- jruby 1.7.21
|
5
|
+
- jruby-head
|
6
|
+
|
7
|
+
jdk:
|
8
|
+
- openjdk6
|
9
|
+
- openjdk7
|
10
|
+
- oraclejdk7
|
11
|
+
- oraclejdk8
|
12
|
+
|
13
|
+
script: bundle exec rspec spec
|
14
|
+
|
15
|
+
notifications:
|
16
|
+
email: false
|
17
|
+
|
18
|
+
matrix:
|
19
|
+
fast_finish: true
|
20
|
+
exclude:
|
21
|
+
- rvm: jruby-head
|
22
|
+
jdk: openjdk6
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
[](https://travis-ci.org/cyli/logstash-output-slack)
|
2
|
+
|
3
|
+
Reviews of the code/contributions are very welcome (particularly with testing!), since I don't really know Ruby.
|
4
|
+
|
5
|
+
## Logstash Slack Output Plugin
|
6
|
+
|
7
|
+
Uses Slack [incoming webhooks API](https://api.slack.com/incoming-webhooks) to send log events to Slack.
|
8
|
+
|
9
|
+
Usage:
|
10
|
+
|
11
|
+
```
|
12
|
+
input {
|
13
|
+
...
|
14
|
+
}
|
15
|
+
|
16
|
+
filters {
|
17
|
+
...
|
18
|
+
}
|
19
|
+
|
20
|
+
output {
|
21
|
+
...
|
22
|
+
slack {
|
23
|
+
url => <YOUR SLACK WEBHOOK URL HERE>
|
24
|
+
channel => [channel-name - optional]
|
25
|
+
username => [slack username - optional]
|
26
|
+
icon_emoji => [emoji, something like ":simple_smile:" - optional]
|
27
|
+
icon_url => [icon url, would be overriden by icon_emoji - optional]
|
28
|
+
format => [default is "%{message}", but used to format the text - optional]
|
29
|
+
attachments => [an array of attachment maps as specified by the slack API - optional; if there is an "attachments" field in the event map and it is valid, it will override what is configured here, even if it's empty]
|
30
|
+
}
|
31
|
+
}
|
32
|
+
```
|
33
|
+
|
34
|
+
### Changelog:
|
35
|
+
- [v0.1.2](https://github.com/cyli/logstash-output-slack/releases/tag/v0.1.2):
|
36
|
+
- Added support for attachments
|
37
|
+
- [v0.1.1](https://github.com/cyli/logstash-output-slack/releases/tag/v0.1.1):
|
38
|
+
- Added variable expansion to usernames and channel names ([#6](https://github.com/cyli/logstash-output-slack/pull/6))
|
39
|
+
- Fixed bug when reporting malformed requests ([#3](https://github.com/cyli/logstash-output-slack/pull/3))
|
40
|
+
- Test fixes since newer versions of logstash-core expects the values in
|
41
|
+
the `add_field` hash to not be integers.
|
42
|
+
- [v0.1.0](https://github.com/cyli/logstash-output-slack/releases/tag/v0.1.0):
|
43
|
+
- initial version containing basic slack functionality
|
44
|
+
|
45
|
+
### Installation on Logstash >= 1.5
|
46
|
+
|
47
|
+
In the logstash directory, run: `bin/plugin install logstash-output-slack`, which will download and install the public gem.
|
48
|
+
|
49
|
+
#### To build your own gem and install:
|
50
|
+
|
51
|
+
1. `git clone <thisrepo>`
|
52
|
+
1. `bundle install`
|
53
|
+
1. `gem build logstash-output-slack.gemspec`
|
54
|
+
1. `cd <path to logstash>`
|
55
|
+
1. `logstash>1.5.0`: `bin/plugin install <path-to-your-built-gem>`
|
56
|
+
|
57
|
+
On `logstash==1.5.0`, due to [this bug](https://github.com/elastic/logstash/issues/2674), installing from a local gem doesn't work. You will need to:
|
58
|
+
|
59
|
+
1. Make sure that the `logstash-core` gem you've installed matches the exact beta 1.5 logstash version you are running.
|
60
|
+
1. modify the logstash Gemfile to include the line `gem "logstash-output-slack", :path => <path_to_the_directory_your_gem_is_in>`
|
61
|
+
1. `bin/plugin install --no-verify`
|
62
|
+
|
63
|
+
#### Verify that the plugin installed correctly
|
64
|
+
`bin/plugin list | grep logstash-output-slack`
|
65
|
+
|
66
|
+
#### Test that it works:
|
67
|
+
```
|
68
|
+
bin/logstash -e '
|
69
|
+
input { stdin {} }
|
70
|
+
output { slack { <your slack config here> }}'
|
71
|
+
```
|
72
|
+
|
73
|
+
And type some text in. The same text should appear in the channel it's configured to go in.
|
74
|
+
|
75
|
+
### Installation on Logstash < 1.5
|
76
|
+
|
77
|
+
Gem-installing this plugin would only work on Logstash 1.5. For Logstash < 1.5, you could just rename `lib` in this repo to `logstash`, and then run Logstash with `--pluginpath <path_to_this_repo>.
|
78
|
+
|
79
|
+
See the [flags](http://logstash.net/docs/1.4.2/flags) documentation for Logstash 1.4.
|
data/Rakefile
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/outputs/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
|
5
|
+
class LogStash::Outputs::Slack < LogStash::Outputs::Base
|
6
|
+
config_name "slack"
|
7
|
+
milestone 1
|
8
|
+
|
9
|
+
# The incoming webhook URI needed to post a message
|
10
|
+
config :url, :validate => :string, :required => true
|
11
|
+
|
12
|
+
# The text to post in slack
|
13
|
+
config :format, :validate => :string, :default => "%{message}"
|
14
|
+
|
15
|
+
# The channel to post to
|
16
|
+
config :channel, :validate => :string
|
17
|
+
|
18
|
+
# The username to use for posting
|
19
|
+
config :username, :validate => :string
|
20
|
+
|
21
|
+
# Emoji icon to use
|
22
|
+
config :icon_emoji, :validate => :string
|
23
|
+
|
24
|
+
# Icon URL to use
|
25
|
+
config :icon_url, :validate => :string
|
26
|
+
|
27
|
+
# Attachments array as described https://api.slack.com/docs/attachments
|
28
|
+
config :attachments, :validate => :array
|
29
|
+
|
30
|
+
public
|
31
|
+
def register
|
32
|
+
require 'rest-client'
|
33
|
+
require 'cgi'
|
34
|
+
require 'json'
|
35
|
+
|
36
|
+
@content_type = "application/x-www-form-urlencoded"
|
37
|
+
end # def register
|
38
|
+
|
39
|
+
public
|
40
|
+
def receive(event)
|
41
|
+
return unless output?(event)
|
42
|
+
|
43
|
+
payload_json = Hash.new
|
44
|
+
payload_json['text'] = event.sprintf(@format)
|
45
|
+
|
46
|
+
if not @channel.nil?
|
47
|
+
payload_json['channel'] = event.sprintf(@channel)
|
48
|
+
end
|
49
|
+
|
50
|
+
if not @username.nil?
|
51
|
+
payload_json['username'] = event.sprintf(@username)
|
52
|
+
end
|
53
|
+
|
54
|
+
if not @icon_emoji.nil?
|
55
|
+
payload_json['icon_emoji'] = @icon_emoji
|
56
|
+
end
|
57
|
+
|
58
|
+
if not @icon_url.nil?
|
59
|
+
payload_json['icon_url'] = @icon_url
|
60
|
+
end
|
61
|
+
|
62
|
+
if @attachments and @attachments.any?
|
63
|
+
payload_json['attachments'] = @attachments
|
64
|
+
end
|
65
|
+
if event.include?('attachments') and event['attachments'].is_a?(Array)
|
66
|
+
if event['attachments'].any?
|
67
|
+
# need to convert possibly from Java objects to Ruby Array, because
|
68
|
+
# JSON dumps does not work well with Java ArrayLists, etc.
|
69
|
+
rubified = JSON.parse(event.to_json())
|
70
|
+
payload_json['attachments'] = rubified['attachments']
|
71
|
+
else
|
72
|
+
payload_json.delete('attachments')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
begin
|
77
|
+
RestClient.post(
|
78
|
+
@url,
|
79
|
+
"payload=#{CGI.escape(JSON.dump(payload_json))}",
|
80
|
+
:accept => "application/json",
|
81
|
+
:'User-Agent' => "logstash-output-slack",
|
82
|
+
:content_type => @content_type) { |response, request, result, &block|
|
83
|
+
if response.code != 200
|
84
|
+
@logger.warn("Got a #{response.code} response: #{response}")
|
85
|
+
end
|
86
|
+
}
|
87
|
+
rescue Exception => e
|
88
|
+
@logger.warn("Unhandled exception", :exception => e,
|
89
|
+
:stacktrace => e.backtrace)
|
90
|
+
end
|
91
|
+
end # def receive
|
92
|
+
end # class LogStash::Outputs::Slack
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-output-slack'
|
3
|
+
s.version = '0.1.3'
|
4
|
+
s.licenses = ['MIT','Apache License (2.0)']
|
5
|
+
s.summary = "Write events to Slack"
|
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 = ["Ying Li"]
|
8
|
+
s.email = 'cyli@ying.com'
|
9
|
+
s.homepage = "https://github.com/cyli/logstash-output-slack"
|
10
|
+
s.require_paths = ["lib"]
|
11
|
+
|
12
|
+
# Files
|
13
|
+
s.files = `git ls-files`.split($\)
|
14
|
+
|
15
|
+
# Tests
|
16
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
+
|
18
|
+
# Special flag to let us know this is actually a logstash plugin
|
19
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
20
|
+
|
21
|
+
# Gem dependencies
|
22
|
+
|
23
|
+
# logstash-core > 2.0.0.snapshot3 requires jrjackson ~> 0.3.5, which requires
|
24
|
+
# JDK7.
|
25
|
+
core_upper_bound = "~> 2.0.0.snapshot3"
|
26
|
+
if RUBY_PLATFORM == 'java'
|
27
|
+
s.platform = RUBY_PLATFORM
|
28
|
+
if java.lang.System.get_property('java.version') < "1.7" # JDK6
|
29
|
+
core_upper_bound = "<= 2.0.0.snapshot3"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
s.add_runtime_dependency "logstash-core", core_upper_bound, ">= 1.4.0"
|
34
|
+
s.add_runtime_dependency "logstash-codec-plain", "~> 2.0.0", ">= 1.0.0"
|
35
|
+
s.add_runtime_dependency "rest-client", '~> 1.8', ">= 1.8.0"
|
36
|
+
s.add_development_dependency "logstash-devutils", "~> 0.0.16"
|
37
|
+
s.add_development_dependency "logstash-filter-json", "~> 2.0.1", ">= 1.0.1"
|
38
|
+
s.add_development_dependency "logstash-input-generator", "~> 2.0.1", ">= 1.0.0"
|
39
|
+
s.add_development_dependency "webmock", "~> 1.22", ">= 1.21.0"
|
40
|
+
end
|
@@ -0,0 +1,296 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
|
3
|
+
describe LogStash::Outputs::Slack do
|
4
|
+
|
5
|
+
# Actually do most of the boiler plate by stubbing out the request, running
|
6
|
+
# the logstash pipeline, and asserting that a request was made with the
|
7
|
+
# expected JSON.
|
8
|
+
def test_one_event(logstash_config, expected_json)
|
9
|
+
stub_request(:post, "requestb.in").
|
10
|
+
to_return(:body => "", :status => 200,
|
11
|
+
:headers => { 'Content-Length' => 0 })
|
12
|
+
|
13
|
+
LogStash::Pipeline.new(logstash_config).run
|
14
|
+
|
15
|
+
expect(a_request(:post, "http://requestb.in/r9lkbzr9").
|
16
|
+
with(:body => "payload=#{CGI.escape(JSON.dump(expected_json))}",
|
17
|
+
:headers => {
|
18
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
19
|
+
'Accept'=> 'application/json',
|
20
|
+
'User-Agent' => 'logstash-output-slack'
|
21
|
+
})).
|
22
|
+
to have_been_made.once
|
23
|
+
end
|
24
|
+
|
25
|
+
before do
|
26
|
+
WebMock.disable_net_connect!
|
27
|
+
end
|
28
|
+
|
29
|
+
after do
|
30
|
+
WebMock.reset!
|
31
|
+
WebMock.allow_net_connect!
|
32
|
+
end
|
33
|
+
|
34
|
+
context "passes the right payload to slack and" do
|
35
|
+
it "uses all default values" do
|
36
|
+
expected_json = {
|
37
|
+
:text => "This message should show in slack"
|
38
|
+
}
|
39
|
+
logstash_config = <<-CONFIG
|
40
|
+
input {
|
41
|
+
generator {
|
42
|
+
message => "This message should show in slack"
|
43
|
+
count => 1
|
44
|
+
}
|
45
|
+
}
|
46
|
+
output {
|
47
|
+
slack {
|
48
|
+
url => "http://requestb.in/r9lkbzr9"
|
49
|
+
}
|
50
|
+
}
|
51
|
+
CONFIG
|
52
|
+
|
53
|
+
test_one_event(logstash_config, expected_json)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "uses and formats all provided values" do
|
57
|
+
expected_json = {
|
58
|
+
:text => "This message should show in slack 3",
|
59
|
+
:channel => "mychannel",
|
60
|
+
:username => "slackbot",
|
61
|
+
:icon_emoji => ":chart_with_upwards_trend:",
|
62
|
+
:icon_url => "http://lorempixel.com/48/48"
|
63
|
+
}
|
64
|
+
|
65
|
+
logstash_config = <<-CONFIG
|
66
|
+
input {
|
67
|
+
generator {
|
68
|
+
message => "This message should show in slack"
|
69
|
+
add_field => {"x" => "3"
|
70
|
+
"channelname" => "mychannel"
|
71
|
+
"username" => "slackbot"}
|
72
|
+
count => 1
|
73
|
+
}
|
74
|
+
}
|
75
|
+
output {
|
76
|
+
slack {
|
77
|
+
url => "http://requestb.in/r9lkbzr9"
|
78
|
+
format => "%{message} %{x}"
|
79
|
+
channel => "%{channelname}"
|
80
|
+
username => "%{username}"
|
81
|
+
icon_emoji => ":chart_with_upwards_trend:"
|
82
|
+
icon_url => "http://lorempixel.com/48/48"
|
83
|
+
}
|
84
|
+
}
|
85
|
+
CONFIG
|
86
|
+
|
87
|
+
test_one_event(logstash_config, expected_json)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "uses and formats all provided values" do
|
91
|
+
expected_json = {
|
92
|
+
:text => "Unformatted message",
|
93
|
+
:channel => "mychannel",
|
94
|
+
:username => "slackbot",
|
95
|
+
:icon_emoji => ":chart_with_upwards_trend:",
|
96
|
+
:icon_url => "http://lorempixel.com/48/48"
|
97
|
+
}
|
98
|
+
|
99
|
+
logstash_config = <<-CONFIG
|
100
|
+
input {
|
101
|
+
generator {
|
102
|
+
message => "This message should show in slack"
|
103
|
+
count => 1
|
104
|
+
}
|
105
|
+
}
|
106
|
+
output {
|
107
|
+
slack {
|
108
|
+
url => "http://requestb.in/r9lkbzr9"
|
109
|
+
format => "Unformatted message"
|
110
|
+
channel => "mychannel"
|
111
|
+
username => "slackbot"
|
112
|
+
icon_emoji => ":chart_with_upwards_trend:"
|
113
|
+
icon_url => "http://lorempixel.com/48/48"
|
114
|
+
}
|
115
|
+
}
|
116
|
+
CONFIG
|
117
|
+
|
118
|
+
test_one_event(logstash_config, expected_json)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "uses the default attachments if none are in the event" do
|
122
|
+
expected_json = {
|
123
|
+
:text => "This message should show in slack",
|
124
|
+
:attachments => [{:image_url => "http://example.com/image.png"}]
|
125
|
+
}
|
126
|
+
|
127
|
+
logstash_config = <<-CONFIG
|
128
|
+
input {
|
129
|
+
generator {
|
130
|
+
message => "This message should show in slack"
|
131
|
+
count => 1
|
132
|
+
}
|
133
|
+
}
|
134
|
+
output {
|
135
|
+
slack {
|
136
|
+
url => "http://requestb.in/r9lkbzr9"
|
137
|
+
attachments => [
|
138
|
+
{image_url => "http://example.com/image.png"}
|
139
|
+
]
|
140
|
+
}
|
141
|
+
}
|
142
|
+
CONFIG
|
143
|
+
|
144
|
+
test_one_event(logstash_config, expected_json)
|
145
|
+
end
|
146
|
+
|
147
|
+
it "supports multiple default attachments" do
|
148
|
+
expected_json = {
|
149
|
+
:text => "This message should show in slack",
|
150
|
+
:attachments => [{:image_url => "http://example.com/image1.png"},
|
151
|
+
{:image_url => "http://example.com/image2.png"}]
|
152
|
+
}
|
153
|
+
|
154
|
+
logstash_config = <<-CONFIG
|
155
|
+
input {
|
156
|
+
generator {
|
157
|
+
message => "This message should show in slack"
|
158
|
+
count => 1
|
159
|
+
}
|
160
|
+
}
|
161
|
+
output {
|
162
|
+
slack {
|
163
|
+
url => "http://requestb.in/r9lkbzr9"
|
164
|
+
attachments => [
|
165
|
+
{image_url => "http://example.com/image1.png"},
|
166
|
+
{image_url => "http://example.com/image2.png"}
|
167
|
+
]
|
168
|
+
}
|
169
|
+
}
|
170
|
+
CONFIG
|
171
|
+
|
172
|
+
test_one_event(logstash_config, expected_json)
|
173
|
+
end
|
174
|
+
|
175
|
+
it "ignores empty default attachments" do
|
176
|
+
expected_json = {
|
177
|
+
:text => "This message should show in slack"
|
178
|
+
}
|
179
|
+
|
180
|
+
logstash_config = <<-CONFIG
|
181
|
+
input {
|
182
|
+
generator {
|
183
|
+
message => "This message should show in slack"
|
184
|
+
count => 1
|
185
|
+
}
|
186
|
+
}
|
187
|
+
output {
|
188
|
+
slack {
|
189
|
+
url => "http://requestb.in/r9lkbzr9"
|
190
|
+
attachments => []
|
191
|
+
}
|
192
|
+
}
|
193
|
+
CONFIG
|
194
|
+
|
195
|
+
test_one_event(logstash_config, expected_json)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "uses event attachments over default attachments" do
|
199
|
+
expected_json = {
|
200
|
+
:text => "This message should show in slack",
|
201
|
+
:attachments => [{:thumb_url => "http://other.com/thumb.png"}]
|
202
|
+
}
|
203
|
+
|
204
|
+
# add_field only takes string values, so we'll have to mutate to JSON
|
205
|
+
logstash_config = <<-CONFIG
|
206
|
+
input {
|
207
|
+
generator {
|
208
|
+
message => "This message should show in slack"
|
209
|
+
count => 1
|
210
|
+
add_field => {
|
211
|
+
attachments => '[{"thumb_url": "http://other.com/thumb.png"}]'
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
filter {
|
216
|
+
json {
|
217
|
+
source => "attachments"
|
218
|
+
target => "attachments"
|
219
|
+
}
|
220
|
+
}
|
221
|
+
output {
|
222
|
+
slack {
|
223
|
+
url => "http://requestb.in/r9lkbzr9"
|
224
|
+
attachments => [
|
225
|
+
{image_url => "http://example.com/image1.png"},
|
226
|
+
{image_url => "http://example.com/image2.png"}
|
227
|
+
]
|
228
|
+
}
|
229
|
+
}
|
230
|
+
CONFIG
|
231
|
+
|
232
|
+
test_one_event(logstash_config, expected_json)
|
233
|
+
end
|
234
|
+
|
235
|
+
it "erases default attachments if event attachments empty" do
|
236
|
+
expected_json = {
|
237
|
+
:text => "This message should show in slack"
|
238
|
+
}
|
239
|
+
|
240
|
+
# add_field only takes string values, so we'll have to mutate to JSON
|
241
|
+
logstash_config = <<-CONFIG
|
242
|
+
input {
|
243
|
+
generator {
|
244
|
+
message => "This message should show in slack"
|
245
|
+
count => 1
|
246
|
+
add_field => {attachments => '[]'}
|
247
|
+
}
|
248
|
+
}
|
249
|
+
filter {
|
250
|
+
json {
|
251
|
+
source => "attachments"
|
252
|
+
target => "attachments"
|
253
|
+
}
|
254
|
+
}
|
255
|
+
output {
|
256
|
+
slack {
|
257
|
+
url => "http://requestb.in/r9lkbzr9"
|
258
|
+
attachments => [
|
259
|
+
{image_url => "http://example.com/image1.png"},
|
260
|
+
{image_url => "http://example.com/image2.png"}
|
261
|
+
]
|
262
|
+
}
|
263
|
+
}
|
264
|
+
CONFIG
|
265
|
+
|
266
|
+
test_one_event(logstash_config, expected_json)
|
267
|
+
end
|
268
|
+
|
269
|
+
it "ignores event attachment if not array" do
|
270
|
+
expected_json = {
|
271
|
+
:text => "This message should show in slack",
|
272
|
+
:attachments => [{:image_url => "http://example.com/image.png"}]
|
273
|
+
}
|
274
|
+
|
275
|
+
logstash_config = <<-CONFIG
|
276
|
+
input {
|
277
|
+
generator {
|
278
|
+
message => "This message should show in slack"
|
279
|
+
count => 1
|
280
|
+
add_field => {attachments => "baddata"}
|
281
|
+
}
|
282
|
+
}
|
283
|
+
output {
|
284
|
+
slack {
|
285
|
+
url => "http://requestb.in/r9lkbzr9"
|
286
|
+
attachments => [
|
287
|
+
{image_url => "http://example.com/image.png"}
|
288
|
+
]
|
289
|
+
}
|
290
|
+
}
|
291
|
+
CONFIG
|
292
|
+
|
293
|
+
test_one_event(logstash_config, expected_json)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-output-slack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Ying Li
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ~>
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 2.0.0.snapshot3
|
19
|
+
- - '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.4.0
|
22
|
+
name: logstash-core
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.0.0.snapshot3
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.4.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 2.0.0
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.0.0
|
42
|
+
name: logstash-codec-plain
|
43
|
+
prerelease: false
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.0.0
|
50
|
+
- - '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.0.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '1.8'
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.0
|
62
|
+
name: rest-client
|
63
|
+
prerelease: false
|
64
|
+
type: :runtime
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.8'
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.8.0
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ~>
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 0.0.16
|
79
|
+
name: logstash-devutils
|
80
|
+
prerelease: false
|
81
|
+
type: :development
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ~>
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.0.16
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 2.0.1
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 1.0.1
|
96
|
+
name: logstash-filter-json
|
97
|
+
prerelease: false
|
98
|
+
type: :development
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.0.1
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 1.0.1
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
requirement: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ~>
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.0.1
|
113
|
+
- - '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 1.0.0
|
116
|
+
name: logstash-input-generator
|
117
|
+
prerelease: false
|
118
|
+
type: :development
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ~>
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 2.0.1
|
124
|
+
- - '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 1.0.0
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ~>
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '1.22'
|
133
|
+
- - '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 1.21.0
|
136
|
+
name: webmock
|
137
|
+
prerelease: false
|
138
|
+
type: :development
|
139
|
+
version_requirements: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ~>
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '1.22'
|
144
|
+
- - '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 1.21.0
|
147
|
+
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
|
148
|
+
email: cyli@ying.com
|
149
|
+
executables: []
|
150
|
+
extensions: []
|
151
|
+
extra_rdoc_files: []
|
152
|
+
files:
|
153
|
+
- .gitignore
|
154
|
+
- .travis.yml
|
155
|
+
- Gemfile
|
156
|
+
- README.md
|
157
|
+
- Rakefile
|
158
|
+
- lib/logstash/outputs/slack.rb
|
159
|
+
- logstash-output-slack.gemspec
|
160
|
+
- spec/outputs/slack_spec.rb
|
161
|
+
- spec/spec_helper.rb
|
162
|
+
homepage: https://github.com/cyli/logstash-output-slack
|
163
|
+
licenses:
|
164
|
+
- MIT
|
165
|
+
- Apache License (2.0)
|
166
|
+
metadata:
|
167
|
+
logstash_plugin: 'true'
|
168
|
+
logstash_group: output
|
169
|
+
post_install_message:
|
170
|
+
rdoc_options: []
|
171
|
+
require_paths:
|
172
|
+
- lib
|
173
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - '>='
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - '>='
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
requirements: []
|
184
|
+
rubyforge_project:
|
185
|
+
rubygems_version: 2.4.8
|
186
|
+
signing_key:
|
187
|
+
specification_version: 4
|
188
|
+
summary: Write events to Slack
|
189
|
+
test_files:
|
190
|
+
- spec/outputs/slack_spec.rb
|
191
|
+
- spec/spec_helper.rb
|