logstash-output-datadog_logs 0.2.1 → 0.3.0

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
- SHA1:
3
- metadata.gz: c708a309549e6084b60795dfc4ff3be4329d0e8f
4
- data.tar.gz: c5b93168d3a46b54accb8e5aa9790550301b0318
2
+ SHA256:
3
+ metadata.gz: '08332207f354cf7e2c4a6d323fd7d9641622b1a0f3d458117d229506011ce719'
4
+ data.tar.gz: 108516196622ab56ef6b9c86c891bb68ebd80947897ed2dc1d8e8c23893fb50c
5
5
  SHA512:
6
- metadata.gz: 4fb5d1b94aa280e44b746fdcd7f5834e866a22d674c981542e7510f2dd3028a5fa3520e9ed6b03c27c58f7967548f430d00affd7f41a01d8f48326eb698cc14a
7
- data.tar.gz: fe129eff08cb0c34099134fa1165236e9c9b6738a087f134e6b0171dd5274405d55a30d47605db20d762c07d9ca748e9452c014d7f612eb1ce4ff426b6c4f4d0
6
+ metadata.gz: 9ace4d38fa8fdda5b0d0722a3536bc39964366e41ac51fdedf9ddd2588fed2bbdc15bb9eea6ebdec1b33394faf3e3f15c72a2750f320d886782a6dd53b7f09bf
7
+ data.tar.gz: 36c241db3336f385aff44926ac495ad1f2c4599b756490c4195418244054589aac6b30c87411dbd3873c6cd7ce6f20ba48bd733d890c538b8a43a0c7a0969887
data/README.md CHANGED
@@ -17,7 +17,7 @@ Configure `datadog_logs` plugin with your Datadog API key:
17
17
  ```
18
18
  output {
19
19
  datadog_logs {
20
- api_key => "<your_datadog_api_key>"
20
+ api_key => "<DATADOG_API_KEY>"
21
21
  }
22
22
  }
23
23
 
@@ -15,60 +15,63 @@ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
15
15
 
16
16
  default :codec, "json"
17
17
 
18
- # Your Datadog API key
19
- config :api_key, :validate => :string, :required => true
18
+ # Datadog configuration parameters
19
+ config :api_key, :validate => :string, :required => true
20
+ config :host, :validate => :string, :required => true, :default => 'intake.logs.datadoghq.com'
21
+ config :port, :validate => :number, :required => true, :default => 10516
22
+ config :use_ssl, :validate => :boolean, :required => true, :default => true
23
+ config :max_backoff, :validate => :number, :required => true, :default => 30
24
+ config :max_retries, :validate => :number, :required => true, :default => 5
20
25
 
21
26
  public
22
27
  def register
23
28
  require "socket"
24
- @host = "intake.logs.datadoghq.com"
25
- @port = 10516
26
-
27
- client_socket = nil
29
+ client = nil
28
30
  @codec.on_event do |event, payload|
29
- # open a connection if needed and send JSON payload
31
+ retries = 0
30
32
  begin
31
- client_socket = new_client_socket unless client_socket
32
- r,w,e = IO.select([client_socket], [client_socket], [client_socket], nil)
33
- client_socket.sysread(16384) if r.any?
34
- if w.any?
35
- # send message to Datadog
33
+ if retries < max_retries
34
+ if retries > 0
35
+ backoff = 2 ** retries
36
+ backoff = max_backoff unless backoff < max_backoff
37
+ sleep backoff
38
+ end
39
+ client ||= new_client
36
40
  message = "#{@api_key} #{payload}\n"
37
- client_socket.puts(message)
38
- @logger.debug("Sent", :payload => payload)
39
- end # w.any?
41
+ client.write(message)
42
+ else
43
+ @logger.warn("Max number of retries reached, dropping the payload", :payload => payload)
44
+ end
40
45
  rescue => e
41
46
  # close connection and always retry
42
- @logger.warn("TCP exception", :exception => e, :backtrace => e.backtrace)
43
- client_socket.close rescue nil
44
- client_socket = nil
45
- sleep 5
47
+ @logger.warn("Could not send message, retrying", :exception => e, :backtrace => e.backtrace)
48
+ client.close rescue nil
49
+ client = nil
50
+ retries += 1
46
51
  retry
47
- end # begin
48
- end # @codec.on_event
49
- end # def register
52
+ end
53
+ end
54
+ end
50
55
 
51
56
  public
52
57
  def receive(event)
53
58
  # handle new event
54
59
  @codec.encode(event)
55
- end # def receive
60
+ end
56
61
 
57
62
  private
58
- def new_client_socket
63
+ def new_client
59
64
  # open a secure connection with Datadog
60
- begin
65
+ if @use_ssl
66
+ @logger.info("Starting SSL connection", :host => @host, :port => @port)
61
67
  socket = TCPSocket.new @host, @port
62
68
  sslSocket = OpenSSL::SSL::SSLSocket.new socket
63
69
  sslSocket.connect
64
- @logger.debug("Started SSL connection", :host => @host)
65
70
  return sslSocket
66
- rescue => e
67
- # always retry when the connection failed
68
- @logger.warn("SSL exception", :exception => e, :backtrace => e.backtrace)
69
- sleep 5
70
- retry
71
- end # begin
72
- end # def new_client_socket
71
+ else
72
+ @logger.info("Starting plaintext connection", :host => @host, :port => @port)
73
+ return TCPSocket.new @host, @port
74
+ end
75
+ end
73
76
 
74
- end # class LogStash::Outputs::DatadogLogs
77
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-datadog_logs'
3
- s.version = '0.2.1'
3
+ s.version = '0.3.0'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = 'DatadogLogs lets you send logs to Datadog based on LogStash events.'
6
6
  s.homepage = 'https://www.datadoghq.com/'
metadata CHANGED
@@ -1,45 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-datadog_logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Datadog
8
8
  - Alexandre Jacquemot
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-22 00:00:00.000000000 Z
12
+ date: 2019-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: logstash-core-plugin-api
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
19
  version: '2.0'
21
- type: :runtime
20
+ name: logstash-core-plugin-api
22
21
  prerelease: false
22
+ type: :runtime
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2.0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: logstash-devutils
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
31
  - - ">="
33
32
  - !ruby/object:Gem::Version
34
33
  version: '0'
35
- type: :development
34
+ name: logstash-devutils
36
35
  prerelease: false
36
+ type: :development
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
- description:
42
+ description:
43
43
  email: support@datadoghq.com
44
44
  executables: []
45
45
  extensions: []
@@ -60,7 +60,7 @@ licenses:
60
60
  metadata:
61
61
  logstash_plugin: 'true'
62
62
  logstash_group: output
63
- post_install_message:
63
+ post_install_message:
64
64
  rdoc_options: []
65
65
  require_paths:
66
66
  - lib
@@ -75,9 +75,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubyforge_project:
79
- rubygems_version: 2.5.2
80
- signing_key:
78
+ rubyforge_project:
79
+ rubygems_version: 2.6.13
80
+ signing_key:
81
81
  specification_version: 4
82
82
  summary: DatadogLogs lets you send logs to Datadog based on LogStash events.
83
83
  test_files: