logstash-output-loggly 2.0.2 → 2.0.3
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/CHANGELOG.md +3 -0
- data/README.md +3 -0
- data/lib/logstash/outputs/loggly.rb +69 -10
- data/logstash-output-loggly.gemspec +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca11a79fa8a9b3f8d1d5d46e9acf8765208e70d3
|
4
|
+
data.tar.gz: 208aae37bf9ed33d6570d2468f1eac8f2f7dfd0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 688dbae1838330cb2e1829ef103d945fb2898ca13448fa348ee0cf0c5559586c26b6255e75b7832e77c366464f84f26dffc2c73f54d0dbe62bc1f554018f3e80
|
7
|
+
data.tar.gz: d9fa90bfec39c4223e7313b626818b26635661d76629b2c2fbb25e6340fc740eb576a3bd25b88f6356b6ee98d2399e1d5932f880ac2605422636ddc04523919a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 2.0.3
|
2
|
+
- Adding exception handling and retries
|
3
|
+
|
1
4
|
## 2.0.0
|
2
5
|
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
3
6
|
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
+
[](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-loggly-unit/)
|
5
|
+
|
3
6
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
7
|
|
5
8
|
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.
|
@@ -37,7 +37,7 @@ class LogStash::Outputs::Loggly < LogStash::Outputs::Base
|
|
37
37
|
# The loggly http input key to send to.
|
38
38
|
# This is usually visible in the Loggly 'Inputs' page as something like this:
|
39
39
|
# ....
|
40
|
-
# https://logs.
|
40
|
+
# https://logs-01.loggly.net/inputs/abcdef12-3456-7890-abcd-ef0123456789
|
41
41
|
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
42
42
|
# \----------> key <-------------/
|
43
43
|
# ....
|
@@ -59,6 +59,16 @@ class LogStash::Outputs::Loggly < LogStash::Outputs::Base
|
|
59
59
|
# https://www.loggly.com/docs/source-groups/
|
60
60
|
config :tag, :validate => :string, :default => "logstash"
|
61
61
|
|
62
|
+
# Retry count.
|
63
|
+
# It may be possible that the request may timeout due to slow Internet connection
|
64
|
+
# if such condition appears, retry_count helps in retrying request for multiple times
|
65
|
+
# It will try to submit request until retry_count and then halt
|
66
|
+
config :retry_count, :validate => :number, :default => 5
|
67
|
+
|
68
|
+
# Can Retry.
|
69
|
+
# Setting this value true helps user to send multiple retry attempts if the first request fails
|
70
|
+
config :can_retry, :validate => :boolean, :default => true
|
71
|
+
|
62
72
|
# Proxy Host
|
63
73
|
config :proxy_host, :validate => :string
|
64
74
|
|
@@ -72,7 +82,14 @@ class LogStash::Outputs::Loggly < LogStash::Outputs::Base
|
|
72
82
|
config :proxy_password, :validate => :password, :default => ""
|
73
83
|
|
74
84
|
|
75
|
-
|
85
|
+
# HTTP constants
|
86
|
+
HTTP_SUCCESS = "200"
|
87
|
+
HTTP_FORBIDDEN = "403"
|
88
|
+
HTTP_NOT_FOUND = "404"
|
89
|
+
HTTP_INTERNAL_SERVER_ERROR = "500"
|
90
|
+
HTTP_GATEWAY_TIMEOUT = "504"
|
91
|
+
|
92
|
+
public
|
76
93
|
def register
|
77
94
|
# nothing to do
|
78
95
|
end
|
@@ -117,17 +134,59 @@ class LogStash::Outputs::Loggly < LogStash::Outputs::Base
|
|
117
134
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
118
135
|
end
|
119
136
|
|
120
|
-
# post message
|
121
137
|
request = Net::HTTP::Post.new(url.path)
|
122
138
|
request.body = message
|
123
|
-
response = http.request(request)
|
124
139
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
140
|
+
# Variable for count total retries
|
141
|
+
totalRetries = 0
|
142
|
+
|
143
|
+
#try posting once when can_retry is false
|
144
|
+
if @can_retry == false
|
145
|
+
@retry_count = 1
|
129
146
|
end
|
147
|
+
|
148
|
+
|
149
|
+
@retry_count.times do
|
150
|
+
begin
|
151
|
+
response = http.request(request)
|
152
|
+
case response.code
|
153
|
+
|
154
|
+
# HTTP_SUCCESS :Code 2xx
|
155
|
+
when HTTP_SUCCESS
|
156
|
+
puts "Event send to Loggly"
|
157
|
+
|
158
|
+
# HTTP_FORBIDDEN :Code 403
|
159
|
+
when HTTP_FORBIDDEN
|
160
|
+
@logger.warn("User does not have privileges to execute the action.")
|
161
|
+
|
162
|
+
# HTTP_NOT_FOUND :Code 404
|
163
|
+
when HTTP_NOT_FOUND
|
164
|
+
@logger.warn("Invalid URL. Please check URL should be http://logs-01.loggly.com/inputs/CUSTOMER_TOKEN/tag/logstash")
|
165
|
+
|
166
|
+
# HTTP_INTERNAL_SERVER_ERROR :Code 500
|
167
|
+
when HTTP_INTERNAL_SERVER_ERROR
|
168
|
+
@logger.warn("Internal Server Error")
|
169
|
+
|
170
|
+
# HTTP_GATEWAY_TIMEOUT :Code 504
|
171
|
+
when HTTP_GATEWAY_TIMEOUT
|
172
|
+
@logger.warn("Gateway Time Out")
|
173
|
+
else
|
174
|
+
@logger.error("Unexpected response code", :code => response.code)
|
175
|
+
end # case
|
176
|
+
|
177
|
+
if [HTTP_SUCCESS,HTTP_FORBIDDEN,HTTP_NOT_FOUND].include?(response.code) # break the retries loop for the specified response code
|
178
|
+
break
|
179
|
+
end
|
180
|
+
rescue StandardError => e
|
181
|
+
@logger.error("An unexpected error occurred", :exception => e.class.name, :error => e.to_s, :backtrace => e.backtrace)
|
182
|
+
end # rescue
|
183
|
+
|
184
|
+
if totalRetries < @retry_count && totalRetries > 0
|
185
|
+
puts "Waiting for five seconds before retry..."
|
186
|
+
sleep(5)
|
187
|
+
end
|
188
|
+
|
189
|
+
totalRetries = totalRetries + 1
|
190
|
+
end #loop
|
130
191
|
end # def send_event
|
131
|
-
|
132
192
|
end # class LogStash::Outputs::Loggly
|
133
|
-
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-loggly'
|
4
|
-
s.version = '2.0.
|
4
|
+
s.version = '2.0.3'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Got a loggly account? Use logstash to ship logs to Loggly!"
|
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"
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-loggly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
14
|
+
name: logstash-core
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - '>='
|
17
18
|
- !ruby/object:Gem::Version
|
@@ -19,10 +20,7 @@ dependencies:
|
|
19
20
|
- - <
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 3.0.0
|
22
|
-
|
23
|
-
prerelease: false
|
24
|
-
type: :runtime
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
26
24
|
requirements:
|
27
25
|
- - '>='
|
28
26
|
- !ruby/object:Gem::Version
|
@@ -30,34 +28,36 @@ dependencies:
|
|
30
28
|
- - <
|
31
29
|
- !ruby/object:Gem::Version
|
32
30
|
version: 3.0.0
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
+
name: logstash-devutils
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
34
40
|
requirement: !ruby/object:Gem::Requirement
|
35
41
|
requirements:
|
36
42
|
- - '>='
|
37
43
|
- !ruby/object:Gem::Version
|
38
44
|
version: '0'
|
39
|
-
name: logstash-devutils
|
40
45
|
prerelease: false
|
41
46
|
type: :development
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: logstash-codec-plain
|
42
49
|
version_requirements: !ruby/object:Gem::Requirement
|
43
50
|
requirements:
|
44
51
|
- - '>='
|
45
52
|
- !ruby/object:Gem::Version
|
46
53
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
54
|
requirement: !ruby/object:Gem::Requirement
|
49
55
|
requirements:
|
50
56
|
- - '>='
|
51
57
|
- !ruby/object:Gem::Version
|
52
58
|
version: '0'
|
53
|
-
name: logstash-codec-plain
|
54
59
|
prerelease: false
|
55
60
|
type: :development
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - '>='
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
61
61
|
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
|
62
62
|
email: info@elastic.co
|
63
63
|
executables: []
|