logstash-output-datadog_logs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 41edad8cf6f6a34e93cadf9e90e1eb8cf0020f0347e176150fb09a426caa1d4d
4
+ data.tar.gz: 94ad289246e50f5f94fb7af41ed5d294411f2c354dfa0dafa75c6cff34eff783
5
+ SHA512:
6
+ metadata.gz: ec8edb4de17a8bb841465f8a7be66ac722874ae813bd81df5f99c51ce29d5f6c8189a4a1226f6a9647e5f213f54241b29ec685887ddda6c020b5397ef0ae4e70
7
+ data.tar.gz: aa3688b188dfe9c6a95f5aec1b0b6c0cf7ec4623e281ce840dd9ab94c22b65d87d8ea4062275d9bfbce67d12265bcb84f23812ea3f93cf3da3249160abe78a3f
@@ -0,0 +1,2 @@
1
+ ## 0.1.0
2
+ - Adapted Logmatic output plugin for Datadog needs
@@ -0,0 +1,10 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Alexandre Jacquemot - alexandre.jacquemot@datadoghq.com
6
+
7
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
8
+ Logstash, and you aren't on the list above and want to be, please let us know
9
+ and we'll make sure you're here. Contributions from folks like you are what make
10
+ open source awesome.
@@ -0,0 +1,28 @@
1
+ # logstash-output-datadog_logs
2
+ *Link to the [Datadog documentation](https://docs.datadoghq.com/logs)*
3
+
4
+ DatadogLogs lets you send logs to Datadog based on LogStash events.
5
+
6
+ ## How to install it?
7
+
8
+ ```bash
9
+ logstash-plugin install logstash-output-datadog_logs
10
+ ```
11
+
12
+
13
+ ## How to use it?
14
+
15
+ Configure `datadog_logs` plugin with your Datadog API key:
16
+
17
+ ```
18
+ output {
19
+ datadog_logs {
20
+ api_key => "<your_datadog_api_key>"
21
+ }
22
+ }
23
+
24
+ ```
25
+
26
+ ## Need Help?
27
+
28
+ If you need any support please contact us at support@datadoghq.com.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
@@ -0,0 +1,86 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
+
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
+
7
+ ## Documentation
8
+
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
10
+
11
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
+
14
+ ## Need Help?
15
+
16
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
+
18
+ ## Developing
19
+
20
+ ### 1. Plugin Developement and Testing
21
+
22
+ #### Code
23
+ - To get started, you'll need JRuby with the Bundler gem installed.
24
+
25
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ - Update your dependencies
35
+
36
+ ```sh
37
+ bundle install
38
+ ```
39
+
40
+ - Run tests
41
+
42
+ ```sh
43
+ bundle exec rspec
44
+ ```
45
+
46
+ ### 2. Running your unpublished Plugin in Logstash
47
+
48
+ #### 2.1 Run in a local Logstash clone
49
+
50
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
51
+ ```ruby
52
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
53
+ ```
54
+ - Install plugin
55
+ ```sh
56
+ bin/logstash-plugin install --no-verify
57
+ ```
58
+ - Run Logstash with your plugin
59
+ ```sh
60
+ bin/logstash -e 'filter {awesome {}}'
61
+ ```
62
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
63
+
64
+ #### 2.2 Run in an installed Logstash
65
+
66
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
67
+
68
+ - Build your plugin gem
69
+ ```sh
70
+ gem build logstash-filter-awesome.gemspec
71
+ ```
72
+ - Install the plugin from the Logstash home
73
+ ```sh
74
+ bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
75
+ ```
76
+ - Start Logstash and proceed to test the plugin
77
+
78
+ ## Contributing
79
+
80
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
81
+
82
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
83
+
84
+ It is more important to the community that you are able to contribute.
85
+
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,74 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed
2
+ # under the Apache License Version 2.0.
3
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ # Copyright 2017 Datadog, Inc.
5
+
6
+ # encoding: utf-8
7
+ require "logstash/outputs/base"
8
+ require "logstash/namespace"
9
+
10
+ # DatadogLogs lets you send logs to Datadog
11
+ # based on LogStash events.
12
+ class LogStash::Outputs::DatadogLogs < LogStash::Outputs::Base
13
+
14
+ config_name "datadog_logs"
15
+
16
+ default :codec, "json"
17
+
18
+ # Your Datadog API key
19
+ config :api_key, :validate => :string, :required => true
20
+
21
+ public
22
+ def register
23
+ require "socket"
24
+ @host = "intake.logs.datadoghq.com"
25
+ @port = 10516
26
+
27
+ client_socket = nil
28
+ @codec.on_event do |event, payload|
29
+ # open a connection if needed and send JSON payload
30
+ 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
36
+ message = "#{@api_key} #{payload}\n"
37
+ client_socket.syswrite(message)
38
+ @logger.debug("Sent", :payload => payload)
39
+ end # w.any?
40
+ rescue => e
41
+ # 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 1
46
+ retry
47
+ end # begin
48
+ end # @codec.on_event
49
+ end # def register
50
+
51
+ public
52
+ def receive(event)
53
+ # handle new event
54
+ @codec.encode(event)
55
+ end # def receive
56
+
57
+ private
58
+ def new_client_socket
59
+ # open a secure connection with Datadog
60
+ begin
61
+ socket = TCPSocket.new @host, @port
62
+ sslSocket = OpenSSL::SSL::SSLSocket.new socket
63
+ sslSocket.connect
64
+ @logger.debug("Started SSL connection", :host => @host)
65
+ return sslSocket
66
+ rescue => e
67
+ # always retry when the connection failed
68
+ @logger.warn("SSL exception", :exception => e, :backtrace => e.backtrace)
69
+ sleep 1
70
+ retry
71
+ end # begin
72
+ end # def new_client_socket
73
+
74
+ end # class LogStash::Outputs::DatadogLogs
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-datadog_logs'
3
+ s.version = '0.1.0'
4
+ s.licenses = ['Apache-2.0']
5
+ s.summary = 'DatadogLogs lets you send logs to Datadog based on LogStash events.'
6
+ s.homepage = 'https://www.datadoghq.com/'
7
+ s.authors = ['Datadog', 'Alexandre Jacquemot']
8
+ s.email = 'support@datadoghq.com'
9
+ s.require_paths = ['lib']
10
+
11
+ # Files
12
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
13
+ # Tests
14
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
+
16
+ # Special flag to let us know this is actually a logstash plugin
17
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
18
+
19
+ # Gem dependencies
20
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
21
+ s.add_development_dependency 'logstash-devutils'
22
+ end
@@ -0,0 +1,6 @@
1
+ # Unless explicitly stated otherwise all files in this repository are licensed
2
+ # under the Apache License Version 2.0.
3
+ # This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ # Copyright 2017 Datadog, Inc.
5
+
6
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-datadog_logs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Datadog
8
+ - Alexandre Jacquemot
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2017-12-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ name: logstash-core-plugin-api
21
+ prerelease: false
22
+ type: :runtime
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2.0'
28
+ - !ruby/object:Gem::Dependency
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ name: logstash-devutils
35
+ prerelease: false
36
+ type: :development
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description:
43
+ email: support@datadoghq.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - CHANGELOG.md
49
+ - CONTRIBUTORS
50
+ - DEVELOPER.md
51
+ - Gemfile
52
+ - LICENSE
53
+ - NOTICE.TXT
54
+ - README.md
55
+ - lib/logstash/outputs/datadog_logs.rb
56
+ - logstash-output-datadog_logs.gemspec
57
+ - spec/datadog_logs.rb
58
+ homepage: https://www.datadoghq.com/
59
+ licenses:
60
+ - Apache-2.0
61
+ metadata:
62
+ logstash_plugin: 'true'
63
+ logstash_group: output
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.6.13
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: DatadogLogs lets you send logs to Datadog based on LogStash events.
84
+ test_files:
85
+ - spec/datadog_logs.rb