logstash-output-datadog_logs 0.5.1 → 0.5.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 +7 -0
- data/README.md +3 -3
- data/lib/logstash/outputs/datadog_logs.rb +55 -15
- data/lib/logstash/outputs/version.rb +2 -2
- data/logstash-output-datadog_logs.gemspec +11 -2
- metadata +27 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35f5ce024bffbeaea8a434b00d7aa2e5c1bb2ce2a439bb69dd6f73dd7b92e269
|
4
|
+
data.tar.gz: f5565d500266000af583f7b647e3d33255e64dc8260a7c3d11ce7cb7ed3c2a5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e3503a6f977e30d581f964825f78348278533007084cbf584c05f8be6f8806c02dd43e5b32b8f7fc1cb9ba4ba47a66f884a95521e46d363e13495c4358e556f
|
7
|
+
data.tar.gz: 27f9fb1522429578e3bcb05575feddb90cf21343de8329d5fe151e25311d0bd91f8a85cac1bae3e4a7cb23429a10dbf735dd3d15321d9ff04bc943311ae98fca
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@ DatadogLogs lets you send logs to Datadog based on LogStash events.
|
|
5
5
|
|
6
6
|
## Requirements
|
7
7
|
|
8
|
-
The plugin relies upon the `zlib` library for compressing data.
|
8
|
+
The plugin relies upon the `zlib` library for compressing data. Successfully tested with Logstash 6.x, 7.x and 8.x.
|
9
9
|
|
10
10
|
## How to install it?
|
11
11
|
|
@@ -35,8 +35,8 @@ To enable TCP forwarding, configure your forwarder with:
|
|
35
35
|
output {
|
36
36
|
datadog_logs {
|
37
37
|
api_key => "<DATADOG_API_KEY>"
|
38
|
-
host => "
|
39
|
-
port =>
|
38
|
+
host => "intake.logs.datadoghq.com"
|
39
|
+
port => 443
|
40
40
|
use_http => false
|
41
41
|
}
|
42
42
|
}
|
@@ -14,13 +14,15 @@ require_relative "version"
|
|
14
14
|
# based on LogStash events.
|
15
15
|
class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
|
16
16
|
|
17
|
-
# Respect limit documented at https://docs.datadoghq.com/api
|
18
|
-
DD_MAX_BATCH_LENGTH =
|
17
|
+
# Respect limit documented at https://docs.datadoghq.com/api/latest/logs/#send-logs
|
18
|
+
DD_MAX_BATCH_LENGTH = 1000
|
19
19
|
DD_MAX_BATCH_SIZE = 5000000
|
20
20
|
DD_TRUNCATION_SUFFIX = "...TRUNCATED..."
|
21
21
|
|
22
22
|
config_name "datadog_logs"
|
23
23
|
|
24
|
+
concurrency :shared
|
25
|
+
|
24
26
|
default :codec, "json"
|
25
27
|
|
26
28
|
# Datadog configuration parameters
|
@@ -65,7 +67,11 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
|
|
65
67
|
end
|
66
68
|
end
|
67
69
|
rescue => e
|
68
|
-
|
70
|
+
if e.is_a?(InterruptedError)
|
71
|
+
raise e
|
72
|
+
else
|
73
|
+
@logger.error("Uncaught processing exception in datadog forwarder #{e.message}")
|
74
|
+
end
|
69
75
|
end
|
70
76
|
end
|
71
77
|
|
@@ -148,7 +154,7 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
|
|
148
154
|
# Build a new transport client
|
149
155
|
def new_client(logger, api_key, use_http, use_ssl, no_ssl_validation, host, port, use_compression, force_v1_routes, http_proxy)
|
150
156
|
if use_http
|
151
|
-
DatadogHTTPClient.new logger, use_ssl, no_ssl_validation, host, port, use_compression, api_key, force_v1_routes, http_proxy
|
157
|
+
DatadogHTTPClient.new logger, use_ssl, no_ssl_validation, host, port, use_compression, api_key, force_v1_routes, http_proxy, -> { defined?(pipeline_shutdown_requested?) ? pipeline_shutdown_requested? : false }
|
152
158
|
else
|
153
159
|
DatadogTCPClient.new logger, use_ssl, no_ssl_validation, host, port
|
154
160
|
end
|
@@ -157,6 +163,9 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
|
|
157
163
|
class RetryableError < StandardError;
|
158
164
|
end
|
159
165
|
|
166
|
+
class InterruptedError < StandardError;
|
167
|
+
end
|
168
|
+
|
160
169
|
class DatadogClient
|
161
170
|
def send_retries(payload, max_retries, max_backoff)
|
162
171
|
backoff = 1
|
@@ -166,17 +175,36 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
|
|
166
175
|
rescue RetryableError => e
|
167
176
|
if retries < max_retries || max_retries < 0
|
168
177
|
@logger.warn("Retrying send due to: #{e.message}")
|
169
|
-
|
178
|
+
interruptableSleep(backoff)
|
170
179
|
backoff = 2 * backoff unless backoff > max_backoff
|
171
180
|
retries += 1
|
172
181
|
retry
|
173
182
|
end
|
174
|
-
@logger.error("Max number of retries reached, dropping message. Last exception: #{
|
183
|
+
@logger.error("Max number of retries reached, dropping message. Last exception: #{e.message}")
|
175
184
|
rescue => ex
|
176
|
-
|
185
|
+
if ex.is_a?(InterruptedError)
|
186
|
+
raise ex
|
187
|
+
else
|
188
|
+
@logger.error("Unmanaged exception while sending log to datadog #{ex.message}")
|
189
|
+
end
|
177
190
|
end
|
178
191
|
end
|
179
192
|
|
193
|
+
def interruptableSleep(duration)
|
194
|
+
amountSlept = 0
|
195
|
+
while amountSlept < duration
|
196
|
+
sleep 1
|
197
|
+
amountSlept += 1
|
198
|
+
if interrupted?
|
199
|
+
raise InterruptedError.new "Interrupted while backing off"
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def interrupted?
|
205
|
+
false
|
206
|
+
end
|
207
|
+
|
180
208
|
def send(payload)
|
181
209
|
raise NotImplementedError, "Datadog transport client should implement the send method"
|
182
210
|
end
|
@@ -196,7 +224,8 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
|
|
196
224
|
::Manticore::ResolutionFailure
|
197
225
|
]
|
198
226
|
|
199
|
-
def initialize(logger, use_ssl, no_ssl_validation, host, port, use_compression, api_key, force_v1_routes, http_proxy)
|
227
|
+
def initialize(logger, use_ssl, no_ssl_validation, host, port, use_compression, api_key, force_v1_routes, http_proxy, interruptedLambda = nil)
|
228
|
+
@interruptedLambda = interruptedLambda
|
200
229
|
@logger = logger
|
201
230
|
protocol = use_ssl ? "https" : "http"
|
202
231
|
|
@@ -224,6 +253,14 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
|
|
224
253
|
@client = Manticore::Client.new(config)
|
225
254
|
end
|
226
255
|
|
256
|
+
def interrupted?
|
257
|
+
if @interruptedLambda
|
258
|
+
return @interruptedLambda.call
|
259
|
+
end
|
260
|
+
|
261
|
+
false
|
262
|
+
end
|
263
|
+
|
227
264
|
def send(payload)
|
228
265
|
begin
|
229
266
|
response = @client.post(@url, :body => payload, :headers => @headers).call
|
@@ -263,6 +300,7 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
|
|
263
300
|
@no_ssl_validation = no_ssl_validation
|
264
301
|
@host = host
|
265
302
|
@port = port
|
303
|
+
@send_mutex = Mutex.new
|
266
304
|
end
|
267
305
|
|
268
306
|
def connect
|
@@ -283,13 +321,15 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
|
|
283
321
|
end
|
284
322
|
|
285
323
|
def send(payload)
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
324
|
+
@send_mutex.synchronize do
|
325
|
+
begin
|
326
|
+
@socket ||= connect
|
327
|
+
@socket.puts(payload)
|
328
|
+
rescue => e
|
329
|
+
@socket.close rescue nil
|
330
|
+
@socket = nil
|
331
|
+
raise RetryableError.new "Unable to send payload: #{e.message}."
|
332
|
+
end
|
293
333
|
end
|
294
334
|
end
|
295
335
|
|
@@ -19,13 +19,22 @@ Gem::Specification.new do |s|
|
|
19
19
|
# Tests
|
20
20
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
s.metadata = {
|
23
|
+
'bug_tracker_uri' => 'https://github.com/DataDog/logstash-output-datadog_logs/issues',
|
24
|
+
'changelog_uri' => 'https://github.com/DataDog/logstash-output-datadog_logs/blob/master/CHANGELOG.md',
|
25
|
+
'documentation_uri' => 'https://github.com/DataDog/logstash-output-datadog_logs/blob/master/README.md',
|
26
|
+
'source_code_uri' => 'https://github.com/DataDog/logstash-output-datadog_logs',
|
27
|
+
|
28
|
+
# Special flag to let us know this is actually a logstash plugin
|
29
|
+
"logstash_plugin" => "true",
|
30
|
+
"logstash_group" => "output",
|
31
|
+
}
|
24
32
|
|
25
33
|
# Gem dependencies
|
26
34
|
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
27
35
|
s.add_runtime_dependency 'manticore', '>= 0.5.2', '< 1.0.0'
|
28
36
|
s.add_runtime_dependency 'logstash-codec-json'
|
37
|
+
s.add_runtime_dependency 'jar-dependencies', '>= 0.3.12', '< 0.5.0'
|
29
38
|
|
30
39
|
s.add_development_dependency 'logstash-devutils'
|
31
40
|
s.add_development_dependency 'webmock'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-datadog_logs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Datadog
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,6 +65,26 @@ dependencies:
|
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 0.3.12
|
74
|
+
- - "<"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.5.0
|
77
|
+
name: jar-dependencies
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.3.12
|
85
|
+
- - "<"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 0.5.0
|
68
88
|
- !ruby/object:Gem::Dependency
|
69
89
|
requirement: !ruby/object:Gem::Requirement
|
70
90
|
requirements:
|
@@ -113,6 +133,10 @@ homepage: https://www.datadoghq.com/
|
|
113
133
|
licenses:
|
114
134
|
- Apache-2.0
|
115
135
|
metadata:
|
136
|
+
bug_tracker_uri: https://github.com/DataDog/logstash-output-datadog_logs/issues
|
137
|
+
changelog_uri: https://github.com/DataDog/logstash-output-datadog_logs/blob/master/CHANGELOG.md
|
138
|
+
documentation_uri: https://github.com/DataDog/logstash-output-datadog_logs/blob/master/README.md
|
139
|
+
source_code_uri: https://github.com/DataDog/logstash-output-datadog_logs
|
116
140
|
logstash_plugin: 'true'
|
117
141
|
logstash_group: output
|
118
142
|
post_install_message:
|
@@ -130,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
154
|
- !ruby/object:Gem::Version
|
131
155
|
version: '0'
|
132
156
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
157
|
+
rubygems_version: 3.3.26
|
134
158
|
signing_key:
|
135
159
|
specification_version: 4
|
136
160
|
summary: DatadogLogs lets you send logs to Datadog based on LogStash events.
|