flexciton-logstash-output-opsgenie 1.0.0 → 1.0.1
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 +4 -4
- data/README.md +18 -8
- data/lib/logstash/outputs/opsgenie.rb +4 -4
- 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: 51221cc7c51172f6767f4e452a6b44f6a254aa2f496705d7a556c6f8ccfeb92b
|
4
|
+
data.tar.gz: fe02f65c8a1c9d763b9d2fa88d726fba01856fa156cf59eedc0a99e59fab5189
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab3bc1b5c0a2a1b4754d1e8704ed50562a6475cd1ff321cfdbb7609921a2f9e38f7f62489f1f1756cf4f42c998439de9c22542028feb8c764fdbd9c440271a07
|
7
|
+
data.tar.gz: b5653029c750dcc3e71641c3c7d097be87964c38400abb6a44668968cdc0920668d73dd8fc61e6663eceafb2ee9fb9ccaa95d1b6daa92a8fe692a46ea6ce5202
|
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
|
```
|
@@ -231,7 +231,7 @@ class LogStash::Outputs::OpsGenie < LogStash::Outputs::Base
|
|
231
231
|
def receive(event)
|
232
232
|
return unless output?(event)
|
233
233
|
|
234
|
-
@logger.info("processing #{event}")
|
234
|
+
@logger.info("processing event: #{event}")
|
235
235
|
opsGenieAction = event.get(@actionAttribute) if event.get(@actionAttribute)
|
236
236
|
if opsGenieAction then
|
237
237
|
params = {}
|
@@ -286,9 +286,9 @@ class LogStash::Outputs::OpsGenie < LogStash::Outputs::Base
|
|
286
286
|
|
287
287
|
private
|
288
288
|
def exponentialBackoff(retryCount)
|
289
|
-
|
290
|
-
@logger.info("sleeping for #{'%.2f' %
|
291
|
-
sleep
|
289
|
+
seconds_to_sleep = (2**retryCount - 1) / 2
|
290
|
+
@logger.info("sleeping for #{'%.2f' % seconds_to_sleep} seconds")
|
291
|
+
sleep seconds_to_sleep
|
292
292
|
end
|
293
293
|
|
294
294
|
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 = '1.0.1'
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
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: 2022-11-
|
11
|
+
date: 2022-11-03 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
|