flexciton-logstash-output-opsgenie 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -8
- data/lib/logstash/outputs/opsgenie.rb +11 -9
- data/logstash-output-opsgenie.gemspec +6 -7
- data/spec/outputs/opsgenie_spec.rb +72 -24
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34a1e3ca52554902ba67056b1359f82ae6d1a5e92bd0cf5dd5b2862b22822a1c
|
4
|
+
data.tar.gz: 175bd9c7866726b5c466cbaaee1bca001b3ebe5f3915e058f3ed5f5bdbb25c5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6157fb6cc89687064bd9dbce6ff6d88f5988f5fe889e9afe202542d78056574d4e430ed30dff22abbb86f41bd6d9be2774d4d6a15c8014af383eb956aae0e18
|
7
|
+
data.tar.gz: c11dd7a785043177b0eb95e2aa112fffcb81d2abbd9d925d33d7f64d2e2b8f2235c4138530dfd0d5ff65a61fe4446ac89ed8dd87fb6e3266de00605d1660e9e8
|
data/README.md
CHANGED
@@ -1,25 +1,32 @@
|
|
1
|
-
#
|
1
|
+
# Flexciton Logstash Output OpsGenie Plugin
|
2
2
|
|
3
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
|
+
This version is forked from: https://github.com/opsgenie/logstash-output-opsgenie
|
8
|
+
All kudos goes to the original authors.
|
8
9
|
|
9
|
-
|
10
|
+
`flexciton-logstash-output-opsgenie` improvements:
|
11
|
+
- Add error handling on network errors. Previously the pipeline in `Logstash` would simply crash and cause `Logstash` to go down or stop processing logs completely. Now it will retry certain errors or log a warning and silence the exception.
|
12
|
+
- Fix all tests. Tests were broken since 2017 changes to adjust to new Opsgenie API. Now they pass.
|
13
|
+
|
14
|
+
### Install and Run Flexciton Logstash Output OpsGenie in Logstash
|
15
|
+
|
16
|
+
Flexciton Logstash Output OpsGenie plugin is available in [RubyGems.org](https://rubygems.org/gems/flexciton-logstash-output-opsgenie)
|
10
17
|
|
11
18
|
- `Logstash 5.4+`
|
12
19
|
```sh
|
13
|
-
bin/logstash-plugin install logstash-output-opsgenie
|
20
|
+
bin/logstash-plugin install flexciton-logstash-output-opsgenie
|
14
21
|
```
|
15
22
|
- `Other Versions`
|
16
23
|
```sh
|
17
|
-
bin/plugin install logstash-output-opsgenie
|
24
|
+
bin/plugin install flexciton-logstash-output-opsgenie
|
18
25
|
```
|
19
26
|
|
20
27
|
- OpsGenie has an integration with Logstash. To use the plugin you need to add a [Logstash Integration](https://app.opsgenie.com/integration?add=Logstash) in OpsGenie and obtain the API Key.
|
21
28
|
|
22
|
-
- You may use plugins like [Mutate](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html) to populate the fields which will be used in [logstash-output-opsgenie](https://github.com/
|
29
|
+
- You may use plugins like [Mutate](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html) to populate the fields which will be used in [flexciton-logstash-output-opsgenie](https://github.com/flexciton/logstash-output-opsgenie).
|
23
30
|
```filter {
|
24
31
|
mutate{
|
25
32
|
add_field => {
|
@@ -43,11 +50,14 @@ bin/plugin install logstash-output-opsgenie
|
|
43
50
|
}
|
44
51
|
```
|
45
52
|
|
46
|
-
- Add the following configuration to your configuration file and populate
|
53
|
+
- Add the following configuration to your configuration file and populate `apiKey` field with your Logstash Integration API Key
|
54
|
+
|
55
|
+
NOTE: despite the integration document in Atlassian shows that api key should be wrapped in quotes (`"apiKey"`) - this is not the case. Use `apiKey` as shown below please.
|
56
|
+
|
47
57
|
```sh
|
48
58
|
output {
|
49
59
|
opsgenie {
|
50
|
-
|
60
|
+
apiKey => "logstash_integration_api_key"
|
51
61
|
}
|
52
62
|
}
|
53
63
|
```
|
@@ -7,10 +7,11 @@ require "net/http"
|
|
7
7
|
require "net/https"
|
8
8
|
|
9
9
|
|
10
|
-
|
10
|
+
CATCHABLE_EXCEPTIONS = [
|
11
11
|
Errno::EINVAL,
|
12
12
|
Net::HTTPBadResponse,
|
13
13
|
Net::HTTPHeaderSyntaxError,
|
14
|
+
JSON::ParserError,
|
14
15
|
]
|
15
16
|
|
16
17
|
RETRYABLE_HTTP_EXCEPTIONS = [
|
@@ -204,7 +205,11 @@ class LogStash::Outputs::OpsGenie < LogStash::Outputs::Base
|
|
204
205
|
)
|
205
206
|
request.body = params.to_json
|
206
207
|
response = http.request(request)
|
207
|
-
|
208
|
+
|
209
|
+
body = response.body
|
210
|
+
body = JSON.parse(body)
|
211
|
+
@logger.warn("Executed [#{uri}]. Response:[#{body}]")
|
212
|
+
rescue *CATCHABLE_EXCEPTIONS => e
|
208
213
|
@logger.warn("Silencing exception in logstash opsgenie outputs: [#{e.class}: #{e.message}]")
|
209
214
|
return
|
210
215
|
rescue *RETRYABLE_HTTP_EXCEPTIONS => e
|
@@ -221,9 +226,6 @@ class LogStash::Outputs::OpsGenie < LogStash::Outputs::Base
|
|
221
226
|
end
|
222
227
|
end
|
223
228
|
|
224
|
-
body = response.body
|
225
|
-
body = JSON.parse(body)
|
226
|
-
@logger.warn("Executed [#{uri}]. Response:[#{body}]")
|
227
229
|
end
|
228
230
|
end # def executePost
|
229
231
|
|
@@ -231,7 +233,7 @@ class LogStash::Outputs::OpsGenie < LogStash::Outputs::Base
|
|
231
233
|
def receive(event)
|
232
234
|
return unless output?(event)
|
233
235
|
|
234
|
-
@logger.info("processing #{event}")
|
236
|
+
@logger.info("processing event: #{event}")
|
235
237
|
opsGenieAction = event.get(@actionAttribute) if event.get(@actionAttribute)
|
236
238
|
if opsGenieAction then
|
237
239
|
params = {}
|
@@ -286,9 +288,9 @@ class LogStash::Outputs::OpsGenie < LogStash::Outputs::Base
|
|
286
288
|
|
287
289
|
private
|
288
290
|
def exponentialBackoff(retryCount)
|
289
|
-
|
290
|
-
@logger.info("sleeping for #{'%.2f' %
|
291
|
-
sleep
|
291
|
+
seconds_to_sleep = (2**retryCount - 1) / 2
|
292
|
+
@logger.info("sleeping for #{'%.2f' % seconds_to_sleep} seconds")
|
293
|
+
sleep seconds_to_sleep
|
292
294
|
end
|
293
295
|
|
294
296
|
end # class LogStash::Outputs::OpsGenie
|
@@ -1,12 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'flexciton-logstash-output-opsgenie'
|
3
|
-
s.version
|
4
|
-
s.licenses = ["Apache
|
5
|
-
s.summary = "
|
6
|
-
s.description = "
|
7
|
-
s.authors = ["
|
8
|
-
s.
|
9
|
-
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
3
|
+
s.version = '2.0.0'
|
4
|
+
s.licenses = ["Apache-2.0"]
|
5
|
+
s.summary = "Flexciton Logstash Output Opsgenie plugin allows creation, closing, acknowledging and adding notes to alerts in OpsGenie."
|
6
|
+
s.description = "Install this gem on your Logstash instance with: $LS_HOME/bin/logstash-plugin install flexciton-logstash-output-opsgenie. Includes retry and silencing mechanism for network errors."
|
7
|
+
s.authors = ["Flexciton Ltd, Tomasz Kluczkowski"]
|
8
|
+
s.homepage = "https://github.com/flexciton/logstash-output-opsgenie"
|
10
9
|
s.require_paths = ["lib"]
|
11
10
|
|
12
11
|
# Files
|
@@ -10,43 +10,91 @@ describe LogStash::Outputs::OpsGenie do
|
|
10
10
|
|
11
11
|
describe "receive message" do
|
12
12
|
|
13
|
-
it "when opsgenieAction is not specified" do
|
13
|
+
it "warns when opsgenieAction is not specified" do
|
14
14
|
expect(logger).to receive(:warn).with("No opsgenie action defined").once
|
15
|
-
|
15
|
+
|
16
|
+
event_data = {"message" => "test_alert","@version" => "1","@timestamp" => "2015-09-22T11:20:00.250Z"}
|
17
|
+
subject.receive(LogStash::Event.new(event_data))
|
16
18
|
end
|
17
19
|
|
18
|
-
it "when opsgenieAction is not valid" do
|
20
|
+
it "warns when opsgenieAction is not valid" do
|
19
21
|
action = "invalid"
|
20
22
|
expect(logger).to receive(:warn).with("Action #{action} does not match any available action, discarding..").once
|
21
|
-
|
23
|
+
|
24
|
+
event_data = {
|
25
|
+
"@timestamp" => "2015-09-22T11:20:00.250Z",
|
26
|
+
"message" => "test_alert",
|
27
|
+
"@version" => "1",
|
28
|
+
"opsgenieAction" => action
|
29
|
+
}
|
30
|
+
subject.receive(LogStash::Event.new(event_data))
|
22
31
|
end
|
23
32
|
|
24
|
-
it "when opsGenieAction is 'create'" do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
it "logs event when opsGenieAction is 'create'" do
|
34
|
+
event_data = {
|
35
|
+
"@timestamp" => "2015-09-22T11:20:00.250Z",
|
36
|
+
"host" => "my-mac",
|
37
|
+
"message" => "test_alert",
|
38
|
+
"@version" => "1",
|
39
|
+
"opsgenieAction" => "create"
|
40
|
+
}
|
41
|
+
expect(logger).to receive(:info).with(
|
42
|
+
"processing event: #{event_data['@timestamp']} #{event_data['host']} #{event_data['message']}"
|
43
|
+
).once
|
44
|
+
expect(logger).to receive(:info).with("Executing url #{subject.opsGenieBaseUrl}").once
|
45
|
+
|
46
|
+
subject.receive(LogStash::Event.new(event_data))
|
29
47
|
end
|
30
48
|
|
31
|
-
it "when opsGenieAction is 'close'" do
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
49
|
+
it "logs event when opsGenieAction is 'close'" do
|
50
|
+
event_data = {
|
51
|
+
"@timestamp" => "2015-09-22T11:20:00.250Z",
|
52
|
+
"host" => "my-mac",
|
53
|
+
"message" => "test_alert",
|
54
|
+
"@version" => "1",
|
55
|
+
"opsgenieAction" => "close"
|
56
|
+
}
|
57
|
+
expect(logger).to receive(:info).with(
|
58
|
+
"processing event: #{event_data['@timestamp']} #{event_data['host']} #{event_data['message']}"
|
59
|
+
).once
|
60
|
+
expect(logger).to receive(:info).with(
|
61
|
+
"Executing url #{subject.opsGenieBaseUrl}#{subject.closeActionPath}?identifierType=#{subject.identifierType}"
|
62
|
+
).once
|
63
|
+
subject.receive(LogStash::Event.new(event_data))
|
36
64
|
end
|
37
65
|
|
38
|
-
it "when opsGenieAction is 'acknowledge'" do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
66
|
+
it "logs event when opsGenieAction is 'acknowledge'" do
|
67
|
+
event_data = {
|
68
|
+
"@timestamp" => "2015-09-22T11:20:00.250Z",
|
69
|
+
"host" => "my-mac",
|
70
|
+
"message" => "test_alert",
|
71
|
+
"@version" => "1",
|
72
|
+
"opsgenieAction" => "acknowledge"
|
73
|
+
}
|
74
|
+
expect(logger).to receive(:info).with(
|
75
|
+
"processing event: #{event_data['@timestamp']} #{event_data['host']} #{event_data['message']}"
|
76
|
+
).once
|
77
|
+
expect(logger).to receive(:info).with(
|
78
|
+
"Executing url #{subject.opsGenieBaseUrl}#{subject.acknowledgeActionPath}?identifierType=#{subject.identifierType}"
|
79
|
+
).once
|
80
|
+
subject.receive(LogStash::Event.new(event_data))
|
43
81
|
end
|
44
82
|
|
45
|
-
it "when opsGenieAction is 'note'" do
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
83
|
+
it "logs event when opsGenieAction is 'note'" do
|
84
|
+
event_data = {
|
85
|
+
"@timestamp" => "2015-09-22T11:20:00.250Z",
|
86
|
+
"host" => "my-mac",
|
87
|
+
"message" => "test_alert",
|
88
|
+
"@version" => "1",
|
89
|
+
"opsgenieAction" => "note"
|
90
|
+
}
|
91
|
+
expect(logger).to receive(:info).with(
|
92
|
+
"processing event: #{event_data['@timestamp']} #{event_data['host']} #{event_data['message']}"
|
93
|
+
).once
|
94
|
+
expect(logger).to receive(:info).with(
|
95
|
+
"Executing url #{subject.opsGenieBaseUrl}#{subject.noteActionPath}?identifierType=#{subject.identifierType}"
|
96
|
+
).once
|
97
|
+
subject.receive(LogStash::Event.new(event_data))
|
50
98
|
end
|
51
99
|
end
|
52
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexciton-logstash-output-opsgenie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Flexciton Ltd, Tomasz Kluczkowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,10 +58,10 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
|
-
description:
|
62
|
-
|
63
|
-
|
64
|
-
email:
|
61
|
+
description: 'Install this gem on your Logstash instance with: $LS_HOME/bin/logstash-plugin
|
62
|
+
install flexciton-logstash-output-opsgenie. Includes retry and silencing mechanism
|
63
|
+
for network errors.'
|
64
|
+
email:
|
65
65
|
executables: []
|
66
66
|
extensions: []
|
67
67
|
extra_rdoc_files: []
|
@@ -74,9 +74,9 @@ files:
|
|
74
74
|
- lib/logstash/outputs/opsgenie.rb
|
75
75
|
- logstash-output-opsgenie.gemspec
|
76
76
|
- spec/outputs/opsgenie_spec.rb
|
77
|
-
homepage:
|
77
|
+
homepage: https://github.com/flexciton/logstash-output-opsgenie
|
78
78
|
licenses:
|
79
|
-
- Apache
|
79
|
+
- Apache-2.0
|
80
80
|
metadata:
|
81
81
|
logstash_plugin: 'true'
|
82
82
|
logstash_group: output
|
@@ -95,10 +95,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
|
-
rubygems_version: 3.
|
98
|
+
rubygems_version: 3.1.6
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
|
-
summary:
|
102
|
-
in OpsGenie.
|
101
|
+
summary: Flexciton Logstash Output Opsgenie plugin allows creation, closing, acknowledging
|
102
|
+
and adding notes to alerts in OpsGenie.
|
103
103
|
test_files:
|
104
104
|
- spec/outputs/opsgenie_spec.rb
|