logstash-output-logentries 0.1.2 → 1.0.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 +4 -4
- data/Gemfile +3 -1
- data/README.md +12 -4
- data/lib/logstash/outputs/logentries.rb +81 -67
- data/logstash-output-logentries.gemspec +1 -2
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 435b907a2cf1a2a84b6c7144cde39dfc80834f89
|
4
|
+
data.tar.gz: 789d602830227fa6c89678e9606961f68b0fc8ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f5836961c3ea81444f43f058a65cd05e995fc44b50c5d63168f8e0821a2a0b9f8268d60028435842c854056e47dfd7c73427f4350fd65fda83793d90d95c1c7
|
7
|
+
data.tar.gz: 49281deaf12cbaa0ac5402819081cdd58cbc93c394ab39dbd08a676136a8a1fa8395f878c45d65dbb580037a94e9f22ed8cfd6bb6c71f5139cfa63fa5bf167ea
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,13 +5,21 @@ This is a plugin for [Logentries](https://www.logentries.com) and Logstash.
|
|
5
5
|
# Send logs using token
|
6
6
|
You can forward logs from Logstash to Logentries using unique token. To do this you have to configure the output sectin of your .conf file in your logstash main folder.
|
7
7
|
|
8
|
-
|
8
|
+
```
|
9
|
+
output{
|
9
10
|
logentries{
|
10
11
|
token => "LOGENTRIES_TOKEN"
|
11
|
-
|
12
|
-
|
12
|
+
reconnect_interval => 10
|
13
|
+
ssl_enable => true
|
14
|
+
host => "data.logentries.com"
|
15
|
+
port => 443
|
16
|
+
}
|
17
|
+
}
|
18
|
+
```
|
13
19
|
|
14
|
-
|
20
|
+
Only `token => "LOGENTRIES_TOKEN"` is a required variable, the rest are optional. If you set `ssl_enable` to `false`, you must set the port to `80` or `514`
|
21
|
+
|
22
|
+
Please refer to Logstash documentation for more information and instruction on how to set up your .config file.
|
15
23
|
|
16
24
|
# Logentries Token
|
17
25
|
|
@@ -1,74 +1,88 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require "logstash/outputs/base"
|
2
3
|
require "logstash/namespace"
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "net/https"
|
6
|
-
|
4
|
+
require "logstash/codecs/plain"
|
5
|
+
require "socket"
|
7
6
|
|
7
|
+
# www.logentries.com
|
8
|
+
#
|
9
|
+
# Write events over TCP socket. Each event json is separated by a newline.
|
10
|
+
#
|
11
|
+
# You will read this token from your config file. Just put the following lines to your .config file:
|
12
|
+
#
|
13
|
+
# output{
|
14
|
+
# logentries{
|
15
|
+
# token => "LOGENTRIES_TOKEN"
|
16
|
+
# reconnect_interval => 10
|
17
|
+
# ssl_enable => true
|
18
|
+
# host => "data.logentries.com"
|
19
|
+
# port => 443
|
20
|
+
# }
|
21
|
+
# }
|
8
22
|
|
9
23
|
class LogStash::Outputs::Logentries < LogStash::Outputs::Base
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
config_name "logentries"
|
25
|
+
|
26
|
+
config :token, :validate => :string, :required => true
|
27
|
+
|
28
|
+
config :reconnect_interval, :validate => :number, :default => 10
|
29
|
+
config :ssl_enable, :validate => :boolean, :default => true
|
30
|
+
|
31
|
+
config :host, :validate => :string, :default => "data.logentries.com"
|
32
|
+
config :port, :validate => :number, :default => 443
|
33
|
+
|
34
|
+
def register
|
35
|
+
@client_socket = nil
|
36
|
+
|
37
|
+
if ssl?
|
38
|
+
@ssl_context = setup_ssl
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def receive(event)
|
43
|
+
message = event.to_json
|
44
|
+
|
45
|
+
begin
|
46
|
+
@client_socket ||= connect
|
47
|
+
@client_socket.puts("#{@token}" + message)
|
48
|
+
rescue => e
|
49
|
+
@logger.warn("Socket output exception: closing and resending event", :host => @host, :port => @port, :exception => e, :backtrace => e.backtrace, :event => event)
|
50
|
+
@client_socket.close rescue nil
|
51
|
+
@client_socket = nil
|
52
|
+
sleep(@reconnect_interval)
|
53
|
+
retry
|
27
54
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
@logger.warn("HTTP error", :error => response.error!)
|
62
|
-
end
|
63
|
-
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
64
|
-
@logger.warn("Error", e)
|
65
|
-
end
|
66
|
-
|
67
|
-
if response.is_a?(Net::HTTPSuccess)
|
68
|
-
@logger.info("Event Sent!")
|
69
|
-
else
|
70
|
-
@logger.warn("HTTP error", :error => response.error!)
|
71
|
-
end
|
72
|
-
|
73
|
-
end # receive
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def ssl?
|
60
|
+
@ssl_enable == true
|
61
|
+
end
|
62
|
+
|
63
|
+
def connect
|
64
|
+
socket = nil
|
65
|
+
socket = TCPSocket.new(@host, @port)
|
66
|
+
if ssl?
|
67
|
+
socket = OpenSSL::SSL::SSLSocket.new(socket, @ssl_context)
|
68
|
+
begin
|
69
|
+
socket.connect
|
70
|
+
rescue OpenSSL::SSL::SSLError => ssle
|
71
|
+
@logger.error("SSL Error", :exception => ssle, :backtrace => ssle.backtrace)
|
72
|
+
sleep(5)
|
73
|
+
raise
|
74
|
+
end
|
75
|
+
end
|
76
|
+
socket
|
77
|
+
end
|
78
|
+
|
79
|
+
def setup_ssl
|
80
|
+
require "openssl"
|
81
|
+
cert_store = OpenSSL::X509::Store.new
|
82
|
+
cert_store.set_default_paths
|
83
|
+
ssl_context = OpenSSL::SSL::SSLContext.new()
|
84
|
+
ssl_context.cert_store = cert_store
|
85
|
+
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
86
|
+
ssl_context
|
87
|
+
end
|
74
88
|
end #LogStash::Outputs::Logentries
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-logentries'
|
4
|
-
s.version = '0.
|
4
|
+
s.version = '1.0.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "You can forward logs from Logstash to Logentries using unique token."
|
7
7
|
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"
|
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
21
21
|
|
22
22
|
# Gem dependencies
|
23
|
-
s.add_runtime_dependency "logstash-core"
|
24
23
|
|
25
24
|
s.add_development_dependency 'logstash-devutils'
|
26
25
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-logentries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Logentries - Bart Siniarski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: logstash-core
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: logstash-devutils
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
64
|
version: '0'
|
79
65
|
requirements: []
|
80
66
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
67
|
+
rubygems_version: 2.5.1
|
82
68
|
signing_key:
|
83
69
|
specification_version: 4
|
84
70
|
summary: You can forward logs from Logstash to Logentries using unique token.
|