logstash-output-datadog_logs 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 635ef3d038ba35b57528f006e81455e20b7cd27217a8fe6188f65d5229e13fe3
4
- data.tar.gz: 6b4325a4cf44791c40aa18360ba7fd9c92a451fb94b182c5a0803de711e3d462
3
+ metadata.gz: bbfe2fc6bf43df61e35e421486e1f7143e4acce4725386decdc05f946249009d
4
+ data.tar.gz: 36bdf364a1d4ae4d522712914cca7eff722b7f115bf553c6cfeee3d4869a7744
5
5
  SHA512:
6
- metadata.gz: e555d642d57cd65971b9e05c2cd6d76c8919ec7413d1dab24eb9fe6eb8d9be3ce51dcfd0dc4751d77f052d87f49ea032fb6ce488c6b99350ae31b41f93908d2e
7
- data.tar.gz: 2b89082813230155ebc747da6e5073aaa7f74d0ad2b1c922e8c577f670af6a2306447a0384229a0382f2c499de1741b20d11b03bc89f32f314939fee269e17c3
6
+ metadata.gz: 44eb1829c931dda34c65c962084d4be14ae5ef510000b32dec93e5b465a2e12dcc4ac27b7a53cb603f9c4d1e8a36c6c1262279f3c86317fef76d9448fcb0c125
7
+ data.tar.gz: ee06691a2c65deb5bf743f47072e35cf9615a238dd2a8f40f4db4459ff4e3fed3025908993f4ddf8f4814cd81117961919037c891d53e76b448058f838d77834
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.5.1
2
+ - Support using HTTP proxies, adding the `http_proxy` parameter.
3
+
1
4
  ## 0.5.0
2
5
  - Support Datadog v2 endpoints #28
3
6
 
data/Gemfile CHANGED
@@ -1,2 +1,11 @@
1
1
  source 'https://rubygems.org'
2
+
2
3
  gemspec
4
+
5
+ logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
6
+ use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
7
+
8
+ if Dir.exist?(logstash_path) && use_logstash_source
9
+ gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
+ gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
+ end
data/README.md CHANGED
@@ -58,8 +58,8 @@ output {
58
58
  | Property | Description | Default value |
59
59
  |-------------|--------------------------------------------------------------------------|----------------|
60
60
  | **api_key** | The API key of your Datadog platform | nil |
61
- | **host** | Proxy endpoint when logs are not directly forwarded to Datadog | intake.logs.datadoghq.com |
62
- | **port** | Proxy port when logs are not directly forwarded to Datadog | 443 |
61
+ | **host** | Endpoint when logs are not directly forwarded to Datadog | intake.logs.datadoghq.com |
62
+ | **port** | Port when logs are not directly forwarded to Datadog | 443 |
63
63
  | **use_ssl** | If true, the agent initializes a secure connection to Datadog. Ensure to update the port if you disable it. | true |
64
64
  | **max_retries** | The number of retries before the output plugin stops | 5 |
65
65
  | **max_backoff** | The maximum time waited between each retry in seconds | 30 |
@@ -67,6 +67,7 @@ output {
67
67
  | **use_compression** | Enable log compression for HTTP | true |
68
68
  | **compression_level** | Set the log compression level for HTTP (1 to 9, 9 being the best ratio) | 6 |
69
69
  | **no_ssl_validation** | Disable SSL validation (useful for proxy forwarding) | false |
70
+ | **http_proxy** | Proxy address for http proxies | none |
70
71
 
71
72
 
72
73
 
@@ -35,11 +35,12 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
35
35
  config :compression_level, :validate => :number, :required => false, :default => 6
36
36
  config :no_ssl_validation, :validate => :boolean, :required => false, :default => false
37
37
  config :force_v1_routes, :validate => :boolean, :required => false, :default => false # force using deprecated v1 routes
38
+ config :http_proxy, :validate => :string, :required => false, :default => ""
38
39
 
39
40
  # Register the plugin to logstash
40
41
  public
41
42
  def register
42
- @client = new_client(@logger, @api_key, @use_http, @use_ssl, @no_ssl_validation, @host, @port, @use_compression, @force_v1_routes)
43
+ @client = new_client(@logger, @api_key, @use_http, @use_ssl, @no_ssl_validation, @host, @port, @use_compression, @force_v1_routes, @http_proxy)
43
44
  end
44
45
 
45
46
  # Logstash shutdown hook
@@ -145,9 +146,9 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
145
146
  end
146
147
 
147
148
  # Build a new transport client
148
- def new_client(logger, api_key, use_http, use_ssl, no_ssl_validation, host, port, use_compression, force_v1_routes)
149
+ def new_client(logger, api_key, use_http, use_ssl, no_ssl_validation, host, port, use_compression, force_v1_routes, http_proxy)
149
150
  if use_http
150
- DatadogHTTPClient.new logger, use_ssl, no_ssl_validation, host, port, use_compression, api_key, force_v1_routes
151
+ DatadogHTTPClient.new logger, use_ssl, no_ssl_validation, host, port, use_compression, api_key, force_v1_routes, http_proxy
151
152
  else
152
153
  DatadogTCPClient.new logger, use_ssl, no_ssl_validation, host, port
153
154
  end
@@ -170,6 +171,7 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
170
171
  retries += 1
171
172
  retry
172
173
  end
174
+ @logger.error("Max number of retries reached, dropping message. Last exception: #{ex.message}")
173
175
  rescue => ex
174
176
  @logger.error("Unmanaged exception while sending log to datadog #{ex.message}")
175
177
  end
@@ -194,7 +196,7 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
194
196
  ::Manticore::ResolutionFailure
195
197
  ]
196
198
 
197
- def initialize(logger, use_ssl, no_ssl_validation, host, port, use_compression, api_key, force_v1_routes)
199
+ def initialize(logger, use_ssl, no_ssl_validation, host, port, use_compression, api_key, force_v1_routes, http_proxy)
198
200
  @logger = logger
199
201
  protocol = use_ssl ? "https" : "http"
200
202
 
@@ -216,6 +218,9 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
216
218
 
217
219
  config = {}
218
220
  config[:ssl][:verify] = :disable if no_ssl_validation
221
+ if http_proxy != ""
222
+ config[:proxy] = http_proxy
223
+ end
219
224
  @client = Manticore::Client.new(config)
220
225
  end
221
226
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatadogLogStashPlugin
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.1'
5
5
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.require_paths = ['lib']
16
16
 
17
17
  # Files
18
- s.files = Dir['lib/**/*', 'spec/**/*', 'vendor/**/*', '*.gemspec', '*.md', 'CONTRIBUTORS', 'Gemfile', 'LICENSE', 'NOTICE.TXT']
18
+ s.files = Dir['lib/**/*', 'spec/**/*', 'vendor/**/*', "vendor/jar-dependencies/**/*.jar", "vendor/jar-dependencies/**/*.rb", '*.gemspec', '*.md', 'CONTRIBUTORS', 'Gemfile', 'LICENSE', 'NOTICE.TXT']
19
19
  # Tests
20
20
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
21
21
 
@@ -23,10 +23,10 @@ Gem::Specification.new do |s|
23
23
  s.metadata = {"logstash_plugin" => "true", "logstash_group" => "output"}
24
24
 
25
25
  # Gem dependencies
26
- s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
26
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
27
27
  s.add_runtime_dependency 'manticore', '>= 0.5.2', '< 1.0.0'
28
28
  s.add_runtime_dependency 'logstash-codec-json'
29
29
 
30
- s.add_development_dependency 'logstash-devutils', "= 1.3.6"
30
+ s.add_development_dependency 'logstash-devutils'
31
31
  s.add_development_dependency 'webmock'
32
32
  end
@@ -2,7 +2,7 @@
2
2
  # under the Apache License Version 2.0.
3
3
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  # Copyright 2017 Datadog, Inc.
5
-
5
+ # encoding: utf-8
6
6
  require "logstash/devutils/rspec/spec_helper"
7
7
  require "logstash/outputs/datadog_logs"
8
8
  require 'webmock/rspec'
@@ -90,12 +90,13 @@ describe LogStash::Outputs::DatadogLogs do
90
90
  end
91
91
 
92
92
  context "when facing HTTP connection issues" do
93
+ http_proxy = ""
93
94
  [true, false].each do |force_v1_routes|
94
95
  it "should retry when server is returning 5XX " + (force_v1_routes ? "using v1 routes" : "using v2 routes") do
95
96
  api_key = 'XXX'
96
97
  stub_dd_request_with_return_code(api_key, 500, force_v1_routes)
97
98
  payload = '{}'
98
- client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes
99
+ client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes, http_proxy
99
100
  expect { client.send(payload) }.to raise_error(LogStash::Outputs::DatadogLogs::RetryableError)
100
101
  end
101
102
 
@@ -103,7 +104,7 @@ describe LogStash::Outputs::DatadogLogs do
103
104
  api_key = 'XXX'
104
105
  stub_dd_request_with_return_code(api_key, 400, force_v1_routes)
105
106
  payload = '{}'
106
- client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes
107
+ client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes, http_proxy
107
108
  expect { client.send(payload) }.to_not raise_error
108
109
  end
109
110
 
@@ -111,7 +112,7 @@ describe LogStash::Outputs::DatadogLogs do
111
112
  api_key = 'XXX'
112
113
  stub_dd_request_with_return_code(api_key, 429, force_v1_routes)
113
114
  payload = '{}'
114
- client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes
115
+ client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes, http_proxy
115
116
  expect { client.send(payload) }.to raise_error(LogStash::Outputs::DatadogLogs::RetryableError)
116
117
  end
117
118
 
@@ -119,7 +120,7 @@ describe LogStash::Outputs::DatadogLogs do
119
120
  api_key = 'XXX'
120
121
  stub_dd_request_with_error(api_key, Manticore::Timeout, force_v1_routes)
121
122
  payload = '{}'
122
- client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes
123
+ client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes, http_proxy
123
124
  expect { client.send(payload) }.to raise_error(LogStash::Outputs::DatadogLogs::RetryableError)
124
125
  end
125
126
 
@@ -127,7 +128,7 @@ describe LogStash::Outputs::DatadogLogs do
127
128
  api_key = 'XXX'
128
129
  stub_dd_request_with_error(api_key, Manticore::SocketException, force_v1_routes)
129
130
  payload = '{}'
130
- client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes
131
+ client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes, http_proxy
131
132
  expect { client.send(payload) }.to raise_error(LogStash::Outputs::DatadogLogs::RetryableError)
132
133
  end
133
134
 
@@ -135,7 +136,7 @@ describe LogStash::Outputs::DatadogLogs do
135
136
  api_key = 'XXX'
136
137
  stub_dd_request_with_error(api_key, Manticore::ClientProtocolException, force_v1_routes)
137
138
  payload = '{}'
138
- client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes
139
+ client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes, http_proxy
139
140
  expect { client.send(payload) }.to raise_error(LogStash::Outputs::DatadogLogs::RetryableError)
140
141
  end
141
142
 
@@ -143,7 +144,7 @@ describe LogStash::Outputs::DatadogLogs do
143
144
  api_key = 'XXX'
144
145
  stub_dd_request_with_error(api_key, Manticore::ResolutionFailure, force_v1_routes)
145
146
  payload = '{}'
146
- client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes
147
+ client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes, http_proxy
147
148
  expect { client.send(payload) }.to raise_error(LogStash::Outputs::DatadogLogs::RetryableError)
148
149
  end
149
150
 
@@ -151,7 +152,7 @@ describe LogStash::Outputs::DatadogLogs do
151
152
  api_key = 'XXX'
152
153
  stub_dd_request_with_error(api_key, Manticore::SocketTimeout, force_v1_routes)
153
154
  payload = '{}'
154
- client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes
155
+ client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes, http_proxy
155
156
  expect { client.send(payload) }.to raise_error(LogStash::Outputs::DatadogLogs::RetryableError)
156
157
  end
157
158
 
@@ -159,7 +160,7 @@ describe LogStash::Outputs::DatadogLogs do
159
160
  api_key = 'XXX'
160
161
  stub_dd_request_with_error(api_key, StandardError, force_v1_routes)
161
162
  payload = '{}'
162
- client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes
163
+ client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes, http_proxy
163
164
  expect { client.send(payload) }.to raise_error(StandardError)
164
165
  end
165
166
 
@@ -167,7 +168,7 @@ describe LogStash::Outputs::DatadogLogs do
167
168
  api_key = 'XXX'
168
169
  stub_dd_request_with_error(api_key, StandardError, force_v1_routes)
169
170
  payload = '{}'
170
- client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes
171
+ client = LogStash::Outputs::DatadogLogs::DatadogHTTPClient.new Logger.new(STDOUT), false, false, "datadog.com", 80, false, api_key, force_v1_routes, http_proxy
171
172
  expect { client.send_retries(payload, 2, 2) }.to_not raise_error
172
173
  end
173
174
  end
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.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog
@@ -9,22 +9,28 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-25 00:00:00.000000000 Z
12
+ date: 2023-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.60'
20
+ - - "<="
18
21
  - !ruby/object:Gem::Version
19
- version: '2.0'
22
+ version: '2.99'
20
23
  name: logstash-core-plugin-api
21
- prerelease: false
22
24
  type: :runtime
25
+ prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">="
26
29
  - !ruby/object:Gem::Version
27
- version: '2.0'
30
+ version: '1.60'
31
+ - - "<="
32
+ - !ruby/object:Gem::Version
33
+ version: '2.99'
28
34
  - !ruby/object:Gem::Dependency
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
@@ -35,8 +41,8 @@ dependencies:
35
41
  - !ruby/object:Gem::Version
36
42
  version: 1.0.0
37
43
  name: manticore
38
- prerelease: false
39
44
  type: :runtime
45
+ prerelease: false
40
46
  version_requirements: !ruby/object:Gem::Requirement
41
47
  requirements:
42
48
  - - ">="
@@ -52,8 +58,8 @@ dependencies:
52
58
  - !ruby/object:Gem::Version
53
59
  version: '0'
54
60
  name: logstash-codec-json
55
- prerelease: false
56
61
  type: :runtime
62
+ prerelease: false
57
63
  version_requirements: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - ">="
@@ -62,17 +68,17 @@ dependencies:
62
68
  - !ruby/object:Gem::Dependency
63
69
  requirement: !ruby/object:Gem::Requirement
64
70
  requirements:
65
- - - '='
71
+ - - ">="
66
72
  - !ruby/object:Gem::Version
67
- version: 1.3.6
73
+ version: '0'
68
74
  name: logstash-devutils
69
- prerelease: false
70
75
  type: :development
76
+ prerelease: false
71
77
  version_requirements: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - '='
79
+ - - ">="
74
80
  - !ruby/object:Gem::Version
75
- version: 1.3.6
81
+ version: '0'
76
82
  - !ruby/object:Gem::Dependency
77
83
  requirement: !ruby/object:Gem::Requirement
78
84
  requirements:
@@ -80,8 +86,8 @@ dependencies:
80
86
  - !ruby/object:Gem::Version
81
87
  version: '0'
82
88
  name: webmock
83
- prerelease: false
84
89
  type: :development
90
+ prerelease: false
85
91
  version_requirements: !ruby/object:Gem::Requirement
86
92
  requirements:
87
93
  - - ">="
@@ -124,8 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
130
  - !ruby/object:Gem::Version
125
131
  version: '0'
126
132
  requirements: []
127
- rubyforge_project:
128
- rubygems_version: 2.7.6
133
+ rubygems_version: 3.2.29
129
134
  signing_key:
130
135
  specification_version: 4
131
136
  summary: DatadogLogs lets you send logs to Datadog based on LogStash events.