logstash-output-logmatic 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0b87d20d8589bd5bd02e2ffd533e21555db26bbe
4
+ data.tar.gz: e18fbc95f1e283052bca1a7f73141eb41f589489
5
+ SHA512:
6
+ metadata.gz: 4213878f8e592aca8884e23d6f9358251cb6f96d9bf50cc6b59fd76264f645d4f98be46a1be38e39c0ca7328af7a850d60088e477705d8a7fe9c0d4c3fb77b03
7
+ data.tar.gz: ddeca254ef9835b9280138d43aaa30a5b24fa2eaf8071fd567e4e431bf28c0190408d9261f0c78bf6128e8d896605bc01107712620191a0fd097781979a78c31
data/CHANGELOG.md ADDED
File without changes
data/CONTRIBUTORS ADDED
@@ -0,0 +1,11 @@
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
+ * Aaron Mildenstein (untergeek)
6
+ * Pier-Hugues Pellerin (ph)
7
+
8
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
9
+ Logstash, and you aren't on the list above and want to be, please let us know
10
+ and we'll make sure you're here. Contributions from folks like you are what make
11
+ open source awesome.
data/DEVELOPER.md ADDED
@@ -0,0 +1,2 @@
1
+ # logstash-output-example
2
+ Example output plugin. This should help bootstrap your effort to write your own output plugin!
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/NOTICE.TXT ADDED
@@ -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/).
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Logstash Logmatic.io's Output Plugin
2
+
3
+ TThis project is an output plugin to send logs to Logmatic.io from Logstash >v1.5.0.
4
+
5
+ ## How to install it?
6
+
7
+ The gem should be published in the main repository.
8
+ To install it in your Logstash install:
9
+
10
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
11
+
12
+ ```
13
+ gem "logstash-output-logmatic"
14
+ ```
15
+
16
+ - Then install plugin:
17
+
18
+ ```
19
+ bin/plugin install --no-verify
20
+ ```
21
+
22
+ ## How to use it?
23
+
24
+ Then you just need to configure the output as follow:
25
+
26
+ ```
27
+ output {
28
+ logmatic {
29
+ key => "<your_api_key>"
30
+ # In order to limit the amount of resources the output uses buffering
31
+ # You can configure its behavior with:
32
+ # The number of elements queued before flushing
33
+ # queue_size => 10
34
+ # The timeframe in seconds for buffering before flushing
35
+ # timeframe => 10
36
+ }
37
+ }
38
+
39
+ ```
40
+ Don’t forget to change `<your_api_key>` to your provided api key.
41
+ Once you are happy with your configuration you have to restart Logstash to take it account.
42
+
43
+ ## Need Help?
44
+
45
+ If you need any support please contact us Logmatic.io's support team.
46
+
47
+ ## Developing
48
+
49
+ #### 1. Run in a local Logstash clone
50
+
51
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
52
+ ```ruby
53
+ gem "logstash-output-logmatic", :path => "/your/local/logstash-output-logmatic"
54
+ ```
55
+ - Install plugin
56
+ ```sh
57
+ bin/plugin install --no-verify
58
+ ```
59
+ - Run Logstash with your plugin
60
+ ```sh
61
+ bin/logstash -e 'output {logmatic {...}}'
62
+ ```
63
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
64
+
65
+ #### 2. Run in an installed Logstash
66
+
67
+ You can use the same **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:
68
+
69
+ - Build your plugin gem
70
+ ```sh
71
+ gem build logstash-output-logmatic.gemspec
72
+ ```
73
+ - Install the plugin from the Logstash home
74
+ ```sh
75
+ bin/plugin install /your/local/plugin/logstash-output-logmatic.gem
76
+ ```
77
+ - Start Logstash and proceed to test the plugin
@@ -0,0 +1,63 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+ require "stud/buffer"
5
+
6
+ # Ship log from logstash straight to Logmatic
7
+ #
8
+ # To use this you will need a valid Logmatic API Key
9
+ class LogStash::Outputs::LogmaticBatch < LogStash::Outputs::Base
10
+ include Stud::Buffer
11
+
12
+ config_name "logmatic"
13
+ milestone 2
14
+
15
+ # The Logmatic api key
16
+ # You can find it in the 'Account' section in the Logmatic interface.
17
+ config :key, :validate => :string, :required => true
18
+
19
+ # How many events to queue before flushing to Logmatic
20
+ # prior to schedule set in @timeframe
21
+ config :queue_size, :validate => :number, :default => 10
22
+
23
+ # How often (in seconds) to flush queued events to Logmatic
24
+ config :timeframe, :validate => :number, :default => 10
25
+
26
+ public
27
+ def register
28
+ require "net/https"
29
+ require "uri"
30
+ @url = "https://api.logmatic.io/v1/input/#{@key}"
31
+ @uri = URI.parse(@url)
32
+ @client = Net::HTTP.new(@uri.host, @uri.port)
33
+ @client.use_ssl = true
34
+ @client.verify_mode = OpenSSL::SSL::VERIFY_NONE
35
+ @logger.debug("Logmatic URL", :url => @url)
36
+
37
+ buffer_initialize(
38
+ :max_items => @queue_size,
39
+ :max_interval => @timeframe,
40
+ :logger => @logger
41
+ )
42
+ end
43
+
44
+ public
45
+ def receive(event)
46
+ return unless output?(event)
47
+ buffer_receive(event)
48
+ end
49
+
50
+ public
51
+ def flush(events, final=false)
52
+ # Send the event over http.
53
+ request = Net::HTTP::Post.new(@uri.path)
54
+ request.body = events.to_json
55
+ request.add_field("Content-Type", 'application/json')
56
+ response = @client.request(request)
57
+ if response.is_a?(Net::HTTPSuccess)
58
+ @logger.debug("Event sent to Logmatic OK!")
59
+ else
60
+ @logger.warn("HTTP error", :error => response.error!)
61
+ end
62
+ end # def receive
63
+ end # class LogStash::Outputs::LogmaticBatch
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-logmatic'
3
+ s.version = "0.1.0"
4
+ s.licenses = ["GNU 2.0"]
5
+ s.summary = "Logmatic Output"
6
+ s.description = "Logmatic output for Logstash"
7
+ s.authors = ["Giovanni CLEMENT","Renaud Boutet"]
8
+ s.homepage = ""
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", "~> 1.5.3"
21
+ s.add_runtime_dependency "logstash-codec-plain"
22
+ s.add_development_dependency "logstash-devutils"
23
+ end
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-logmatic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Giovanni CLEMENT
8
+ - Renaud Boutet
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-10-07 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: 1.5.3
20
+ name: logstash-core
21
+ prerelease: false
22
+ type: :runtime
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: 1.5.3
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-codec-plain
35
+ prerelease: false
36
+ type: :runtime
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ name: logstash-devutils
49
+ prerelease: false
50
+ type: :development
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: Logmatic output for Logstash
57
+ email:
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CHANGELOG.md
63
+ - CONTRIBUTORS
64
+ - DEVELOPER.md
65
+ - Gemfile
66
+ - LICENSE
67
+ - NOTICE.TXT
68
+ - README.md
69
+ - lib/logstash/outputs/logmatic.rb
70
+ - logstash-output-logmatic.gemspec
71
+ - spec/outputs/logmatic.rb
72
+ homepage: ''
73
+ licenses:
74
+ - GNU 2.0
75
+ metadata:
76
+ logstash_plugin: 'true'
77
+ logstash_group: output
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.4.5
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Logmatic Output
98
+ test_files:
99
+ - spec/outputs/logmatic.rb