logstash-output-thetapoint 0.3.0 → 2.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
2
  SHA256:
3
- metadata.gz: 20cbc4ec8b453142d66b1d01b492c27f22cf71b6645a6d56a11f61f6bd942292
4
- data.tar.gz: 89260c472479ffe2ba243d02084e2772aec5e338a8a775f28de1314697c8317a
3
+ metadata.gz: b8150caebfcaf3b54efe3d9a0ac2b38426bc1cfcfbef73c04a28d323c7303425
4
+ data.tar.gz: ec97d7e8c72b3fb768529861ba5ef40638827098717a26d7904fa0538b4c013d
5
5
  SHA512:
6
- metadata.gz: 4ca3d48d1dfcf8674aa657b7f0e041f9cee1f8de6fd1fcc5d91b82d825652ed25266ff25c1af2ffd59dde6bc0f11af666212e45131e4009b0d667bfecbc70d2b
7
- data.tar.gz: 55c4788405fbbd3d2da4e7ee0815b1a00d9dc2d38b3501a6417e7ee832c35e2e0dc09f3f7c7da957ad89ec5cbcb7e980720989b9e8764717dd133890af335c73
6
+ metadata.gz: 4100f2bb99b79a7b9b2c5a63c9f4689577dfef9814b0e8d8426dca65c9317fd0f87527c4e7c70c878c64f290131793ff9f7770dddbe940533fdddef9b7cbcd64
7
+ data.tar.gz: 3e200576da9997dadf4caa867f5a0dfa76b6e3daedef4a4ac123cf40b390b282560bffd3c816fbafe76ca99d83458ea65cec8d053b605ff20f50d414e4441123
data/CHANGELOG.md CHANGED
@@ -1,2 +0,0 @@
1
- ## 0.1.0
2
- - Plugin created with the logstash plugin generator
data/CONTRIBUTORS CHANGED
@@ -2,7 +2,8 @@ The following is a list of people who have contributed ideas, code, bug
2
2
  reports, or in general have helped logstash along its way.
3
3
 
4
4
  Contributors:
5
- * -
5
+ * Aaron Mildenstein (untergeek)
6
+ * Pier-Hugues Pellerin (ph)
6
7
 
7
8
  Note: If you've sent us patches, bug reports, or otherwise contributed to
8
9
  Logstash, and you aren't on the list above and want to be, please let us know
data/DEVELOPER.md CHANGED
@@ -1,2 +1,2 @@
1
- # logstash-output-thetapoint
1
+ # logstash-output-example
2
2
  Example output plugin. This should help bootstrap your effort to write your own output plugin!
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
-
3
+ # gem "logstash", :github => "elastic/logstash", :branch => "7.0"
data/LICENSE CHANGED
@@ -1,3 +1,5 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
2
+
1
3
  Licensed under the Apache License, Version 2.0 (the "License");
2
4
  you may not use this file except in compliance with the License.
3
5
  You may obtain a copy of the License at
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Logstash Plugin
2
2
 
3
- This is a plugin for [Logstash](https://github.com/elastic/logstash).
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
4
4
 
5
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
6
 
7
7
  ## Documentation
8
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/).
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.elasticsearch.org/guide/en/logstash/current/).
10
10
 
11
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
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
13
13
 
14
14
  ## Need Help?
15
15
 
@@ -53,7 +53,7 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
53
53
  ```
54
54
  - Install plugin
55
55
  ```sh
56
- bin/logstash-plugin install --no-verify
56
+ bin/plugin install --no-verify
57
57
  ```
58
58
  - Run Logstash with your plugin
59
59
  ```sh
@@ -71,7 +71,7 @@ gem build logstash-filter-awesome.gemspec
71
71
  ```
72
72
  - Install the plugin from the Logstash home
73
73
  ```sh
74
- bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
74
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
75
75
  ```
76
76
  - Start Logstash and proceed to test the plugin
77
77
 
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
83
83
 
84
84
  It is more important to the community that you are able to contribute.
85
85
 
86
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
@@ -1,10 +1,8 @@
1
- # encoding: utf-8
2
- require "logstash/outputs/base"
1
+ # encoding: utf-8 require "logstash/outputs/base"
3
2
  require "logstash/namespace"
4
3
  require "uri"
5
4
  require "net/http"
6
5
  require "net/https"
7
- require "stud/buffer"
8
6
  require "zlib"
9
7
  require 'time'
10
8
  require 'json'
@@ -12,13 +10,7 @@ require 'json'
12
10
  #
13
11
  # This is most useful so you can use logstash to parse and structure
14
12
  # your logs and ship structured, json events to ThetaPoint.
15
- #
16
- # To use this, you'll need to use a ThetaPoint input with type 'http'
17
- # and 'json logging' enabled.
18
13
  class LogStash::Outputs::ThetaPoint < LogStash::Outputs::Base
19
-
20
- include Stud::Buffer
21
-
22
14
  config_name "thetapoint"
23
15
 
24
16
  # The hostname to send logs to.
@@ -30,10 +22,6 @@ class LogStash::Outputs::ThetaPoint < LogStash::Outputs::Base
30
22
  # https://thetapoint03.theta-point.com/inputs/abcdef12-3456-7890-abcd-ef0123456789
31
23
  # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32
24
  # \----------> key <-------------/
33
- #
34
- # You can use %{foo} field lookups here if you need to pull the api key from
35
- # the event. This is mainly aimed at multitenant hosting providers who want
36
- # to offer shipping a customer's logs to that customer's loggly account.
37
25
  config :key, :validate => :string, :required => true
38
26
 
39
27
  # Should the log action be sent over https instead of plain http
@@ -53,104 +41,75 @@ class LogStash::Outputs::ThetaPoint < LogStash::Outputs::Base
53
41
 
54
42
  # If true, we send an HTTP POST request every "batch_events" events or
55
43
  # "batch_timeout" seconds (whichever comes first).
56
- config :batch, :validate => :boolean, :default => false
57
- config :batch_events, :validate => :number, :default => 100
58
- config :batch_timeout, :validate => :number, :default => 5
44
+ config :batch, :validate => :boolean, :default => false, :deprecated => true
45
+ config :batch_events, :validate => :number, :default => 100, :deprecated => true
46
+ config :batch_timeout, :validate => :number, :default => 5, :deprecated => true
59
47
 
60
- config :compress, :validate => :boolean, :default => false
48
+ config :compress, :validate => :boolean, :default => true
61
49
 
62
50
  public
63
51
  def register
64
- if @batch
65
- buffer_initialize(
66
- :max_items => @batch_events,
67
- :max_interval => @batch_timeout,
68
- :logger => @logger
69
- )
70
- end
71
-
52
+ @logger.debug "Initializing ThetaPoint Output", @config
72
53
  end
73
54
 
74
55
  public
75
56
  def receive(event)
76
- return unless output?(event)
57
+ @logger.debug("receive(#{event})")
77
58
 
78
- @logger.info("receive: #{event}")
59
+ send_data(event.to_json)
60
+ end # def receive
79
61
 
80
- if @batch
81
- # Stud::Buffer
82
- @logger.info("receive: Buffer Event")
83
- buffer_receive(event, event.sprintf(@key))
84
- return
85
- end
62
+ def multi_receive(events)
63
+ @logger.debug("multi_receive(#{events.length})")
86
64
 
87
- @logger.info("receive: Send Single Event")
88
- send_data(event.to_json, event.sprintf(@key))
65
+ send_data(events.to_json)
66
+ end # def multi_receive
89
67
 
90
- end # def receive
91
68
 
92
- def send_data(data, key)
69
+ def send_data(data)
70
+ @logger.debug("send_data(#{data.length})")
71
+
72
+ uri = "#{@proto}://#{@host}"
73
+ post_data = data
93
74
 
94
75
  # Comress data
95
76
  if @compress
96
- @logger.info("Deflate start", :now => Time.now.rfc2822, :length => data.length)
97
77
  post_data = Zlib::Deflate.deflate(data, Zlib::BEST_COMPRESSION)
98
- @logger.info("Deflate end", :now => Time.now.rfc2822, :length => post_data.length, :ratio => post_data.length/data.length)
99
- @path = "zbulk"
78
+ uri << "/zbulk/#{@key}"
100
79
  else
101
- post_data = data
80
+ uri << "/#{@key}"
102
81
  end
103
82
 
104
- # Send the data
105
- @logger.info("ThetaPoint Connect: ",
106
- :host => @host,
107
- :port => @port,
108
- :proxy_host => @proxy_host,
109
- :proxy_port => @proxy_port,
110
- :proxy_user => @proxy_user,
111
- :proxy_password => @proxy_password ? @proxy_password.value : nil)
112
- @http = Net::HTTP.new(@host, @port, @proxy_host, @proxy_port, @proxy_user, @proxy_password.value)
113
- @logger.info("http", :http => @http)
114
- if @proto == 'https'
115
- @http.use_ssl = true
116
- @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
83
+ @logger.debug("URI: #{uri}")
84
+ url = URI.parse(uri)
85
+
86
+ http = Net::HTTP::Proxy(@proxy_host,
87
+ @proxy_port,
88
+ @proxy_user,
89
+ @proxy_password.value).new(url.host, url.port)
90
+
91
+ if url.scheme == 'https'
92
+ http.use_ssl = true
93
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
117
94
  end
118
95
 
96
+ request = Net::HTTP::Post.new(url.path)
97
+ request.body = post_data
98
+
119
99
  begin
120
- @logger.info("Submit start", :now => Time.now.rfc2822)
121
- uri = "/#{@path}/#{key}"
122
- response = @http.request_post(uri, post_data)
123
- @logger.info("Submit end", :now => Time.now.rfc2822)
124
- @logger.info("response", :response => response)
100
+ response = http.request(request)
101
+ @logger.debug "Response: #{response}"
102
+
125
103
  if response.is_a?(Net::HTTPSuccess)
126
- @logger.info("Event send to ThetaPoint OK!")
104
+ @logger.debug("Event send to ThetaPoint OK!")
127
105
  else
128
106
  @logger.warn("HTTP error", :error => response.error!)
129
107
  end
130
- rescue Exception => e
131
- @logger.error("ThetaPoint Unhandled exception", :pd_error => e.backtrace)
132
- end
133
108
 
134
- end # def send_data
109
+ rescue StandardError => e
110
+ @logger.error("An unexpected error occurred", :exception => e.class.name, :error => e.to_s, :backtrace => e.backtrace)
111
+ end # rescue
135
112
 
136
- # called from Stud::Buffer#buffer_flush when there are events to flush
137
- def flush(events, key, teardown=false)
138
- @logger.info("Flush #{events.length} events")
139
- send_data(events.to_json, key)
140
- end # def flush
141
-
142
- # called from Stud::Buffer#buffer_flush when an error occurs
143
- def on_flush_error(e)
144
- @logger.warn("Failed to send backlog of events to ThetaPoint",
145
- :exception => e,
146
- :backtrace => e.backtrace
147
- )
148
- end # def on_flush_error
149
-
150
- def teardown
151
- if @batch
152
- buffer_flush(:final => true)
153
- end
154
- end # def teardown
113
+ end # def send_data
155
114
 
156
115
  end # class LogStash::Outputs::ThetaPoint
@@ -1,24 +1,24 @@
1
1
  Gem::Specification.new do |s|
2
- s.name = 'logstash-output-thetapoint'
3
- s.version = '0.3.0'
4
- s.licenses = ['Apache-2.0']
5
- s.summary = 'Send data to ThetaPoint'
6
- s.description = 'Send data to ThetaPoint using HTTPS to submit plain or compressed messages'
7
- s.homepage = 'https://github.com/harryrh/logstash-output-thetapoint'
8
- s.authors = ['Harry Halladay']
9
- s.email = 'harry@theta-point.com'
10
- s.require_paths = ['lib']
2
+ s.name = 'logstash-output-thetapoint'
3
+ s.version = "2.0"
4
+ s.licenses = ["Apache License (2.0)"]
5
+ s.summary = "If you don't know, you don't need this"
6
+ s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
7
+ s.authors = ["ThetaPoint"]
8
+ s.email = "info@theta-point.com"
9
+ s.homepage = "http://www.theta-point.com"
10
+ s.require_paths = ["lib"]
11
11
 
12
12
  # Files
13
13
  s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
- # Tests
14
+
15
+ # Tests
15
16
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
17
 
17
18
  # Special flag to let us know this is actually a logstash plugin
18
19
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
19
20
 
20
21
  # Gem dependencies
21
- s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
22
- s.add_runtime_dependency "logstash-codec-plain"
22
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
23
23
  s.add_development_dependency "logstash-devutils"
24
24
  end
@@ -1,22 +1,30 @@
1
- # encoding: utf-8
2
1
  require "logstash/devutils/rspec/spec_helper"
3
2
  require "logstash/outputs/thetapoint"
4
- require "logstash/codecs/plain"
5
- require "logstash/event"
6
3
 
7
- describe LogStash::Outputs::Thetapoint do
8
- let(:sample_event) { LogStash::Event.new }
9
- let(:output) { LogStash::Outputs::Thetapoint.new }
10
-
11
- before do
12
- output.register
4
+ describe LogStash::Outputs::ThetaPoint do
5
+ let(:config) { { 'key' => 'lksjdflskdjflskdjflskdj' } }
6
+ let(:event) do
7
+ LogStash::Outputs::ThetaPoint.new(
8
+ 'message' => 'example message',
9
+ 'type' => 'event',
10
+ '@timestamp' => Logstash::Timestamp.now)
13
11
  end
14
12
 
15
- describe "receive message" do
16
- subject { output.receive(sample_event) }
13
+ context 'when initializing' do
14
+ subject { LogStash::Outputs::ThetaPoint.new(config) }
15
+
16
+ it 'should register' do
17
+ expect { subject.register }.to_not raise_error
18
+ end
17
19
 
18
- it "returns a string" do
19
- expect(subject).to eq("Event received")
20
+ it 'should have default config values' do
21
+ insist { subject.host } == 'api.theta-point.com'
22
+ insist { subject.port } == 443
23
+ insist { subject.proto } == 'https'
20
24
  end
25
+
21
26
  end
27
+
22
28
  end
29
+
30
+ # vim: ts=2:sw=2:
metadata CHANGED
@@ -1,43 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-thetapoint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: '2.0'
5
5
  platform: ruby
6
6
  authors:
7
- - Harry Halladay
7
+ - ThetaPoint
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-27 00:00:00.000000000 Z
11
+ date: 2019-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - "~>"
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '1.60'
19
+ - - "<="
17
20
  - !ruby/object:Gem::Version
18
- version: '2.0'
21
+ version: '2.99'
19
22
  name: logstash-core-plugin-api
20
23
  prerelease: false
21
24
  type: :runtime
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.0'
27
- - !ruby/object:Gem::Dependency
28
- requirement: !ruby/object:Gem::Requirement
29
26
  requirements:
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
- version: '0'
33
- name: logstash-codec-plain
34
- prerelease: false
35
- type: :runtime
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
29
+ version: '1.60'
30
+ - - "<="
39
31
  - !ruby/object:Gem::Version
40
- version: '0'
32
+ version: '2.99'
41
33
  - !ruby/object:Gem::Dependency
42
34
  requirement: !ruby/object:Gem::Requirement
43
35
  requirements:
@@ -52,8 +44,10 @@ dependencies:
52
44
  - - ">="
53
45
  - !ruby/object:Gem::Version
54
46
  version: '0'
55
- description: Send data to ThetaPoint using HTTPS to submit plain or compressed messages
56
- email: harry@theta-point.com
47
+ description: This gem is a logstash plugin required to be installed on top of the
48
+ Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
49
+ a stand-alone program
50
+ email: info@theta-point.com
57
51
  executables: []
58
52
  extensions: []
59
53
  extra_rdoc_files: []
@@ -65,12 +59,11 @@ files:
65
59
  - LICENSE
66
60
  - README.md
67
61
  - lib/logstash/outputs/thetapoint.rb
68
- - lib/logstash/outputs/thetapoint.rb.org
69
62
  - logstash-output-thetapoint.gemspec
70
63
  - spec/outputs/thetapoint_spec.rb
71
- homepage: https://github.com/harryrh/logstash-output-thetapoint
64
+ homepage: http://www.theta-point.com
72
65
  licenses:
73
- - Apache-2.0
66
+ - Apache License (2.0)
74
67
  metadata:
75
68
  logstash_plugin: 'true'
76
69
  logstash_group: output
@@ -93,6 +86,6 @@ rubyforge_project:
93
86
  rubygems_version: 2.7.6
94
87
  signing_key:
95
88
  specification_version: 4
96
- summary: Send data to ThetaPoint
89
+ summary: If you don't know, you don't need this
97
90
  test_files:
98
91
  - spec/outputs/thetapoint_spec.rb
@@ -1,17 +0,0 @@
1
- # encoding: utf-8
2
- require "logstash/outputs/base"
3
- require "logstash/namespace"
4
-
5
- # An thetapoint output that does nothing.
6
- class LogStash::Outputs::Thetapoint < LogStash::Outputs::Base
7
- config_name "thetapoint"
8
-
9
- public
10
- def register
11
- end # def register
12
-
13
- public
14
- def receive(event)
15
- return "Event received"
16
- end # def event
17
- end # class LogStash::Outputs::Thetapoint