logstash-input-gelf 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/logstash/inputs/gelf.rb +13 -22
- data/logstash-input-gelf.gemspec +6 -4
- data/spec/inputs/gelf_spec.rb +17 -1
- data/spec/support/helpers.rb +18 -0
- metadata +54 -32
- data/.gitignore +0 -5
- data/Rakefile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ff957b43e508399be6ac9cd6c40e43a514975c4
|
4
|
+
data.tar.gz: c99b33f98812dca86031883966c187d7537403dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3113b911955cf7452599d729c4d09cff402e8ad2c9e171a19110ba0da51e8a0bd3c8e4dc624f6cc485767979339f957a8eec5acf1abbe827af0394d88fa4b35
|
7
|
+
data.tar.gz: aacaf58b8fcaecf873126a00be4fddad9ef2499131de68c9d4858849c40ddf97873d1eca0b5c936c67df6ce5de91dd08098ce3146561d960bec5bfbec039fcc2
|
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
This is a plugin for [Logstash](https://github.com/
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/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.
|
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
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/
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
13
13
|
|
14
14
|
## Need Help?
|
15
15
|
|
@@ -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/
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
data/lib/logstash/inputs/gelf.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require "date"
|
3
2
|
require "logstash/inputs/base"
|
4
3
|
require "logstash/namespace"
|
5
4
|
require "logstash/json"
|
6
5
|
require "logstash/timestamp"
|
6
|
+
require "stud/interval"
|
7
|
+
require "date"
|
7
8
|
require "socket"
|
8
9
|
|
9
10
|
# This input will read GELF messages as events over the network,
|
@@ -42,12 +43,12 @@ class LogStash::Inputs::Gelf < LogStash::Inputs::Base
|
|
42
43
|
#
|
43
44
|
config :strip_leading_underscore, :validate => :boolean, :default => true
|
44
45
|
|
46
|
+
RECONNECT_BACKOFF_SLEEP = 5
|
47
|
+
|
45
48
|
public
|
46
49
|
def initialize(params)
|
47
50
|
super
|
48
51
|
BasicSocket.do_not_reverse_lookup = true
|
49
|
-
@shutdown_requested = false
|
50
|
-
@udp = nil
|
51
52
|
end # def initialize
|
52
53
|
|
53
54
|
public
|
@@ -60,42 +61,31 @@ class LogStash::Inputs::Gelf < LogStash::Inputs::Base
|
|
60
61
|
begin
|
61
62
|
# udp server
|
62
63
|
udp_listener(output_queue)
|
63
|
-
rescue LogStash::ShutdownSignal
|
64
|
-
@shutdown_requested = true
|
65
64
|
rescue => e
|
66
|
-
unless
|
65
|
+
unless stop?
|
67
66
|
@logger.warn("gelf listener died", :exception => e, :backtrace => e.backtrace)
|
68
|
-
|
69
|
-
retry
|
67
|
+
Stud.stoppable_sleep(RECONNECT_BACKOFF_SLEEP) { stop? }
|
68
|
+
retry unless stop?
|
70
69
|
end
|
71
70
|
end # begin
|
72
71
|
end # def run
|
73
72
|
|
74
73
|
public
|
75
|
-
def
|
76
|
-
@
|
77
|
-
|
78
|
-
@udp.close_read rescue nil
|
79
|
-
@udp.close_write rescue nil
|
80
|
-
@udp = nil
|
81
|
-
end
|
82
|
-
finished
|
74
|
+
def stop
|
75
|
+
@udp.close
|
76
|
+
rescue IOError # the plugin is currently shutting down, so its safe to ignore theses errors
|
83
77
|
end
|
84
78
|
|
85
79
|
private
|
86
80
|
def udp_listener(output_queue)
|
87
81
|
@logger.info("Starting gelf listener", :address => "#{@host}:#{@port}")
|
88
82
|
|
89
|
-
if @udp
|
90
|
-
@udp.close_read rescue nil
|
91
|
-
@udp.close_write rescue nil
|
92
|
-
end
|
93
|
-
|
94
83
|
@udp = UDPSocket.new(Socket::AF_INET)
|
95
84
|
@udp.bind(@host, @port)
|
96
85
|
|
97
|
-
while
|
86
|
+
while !stop?
|
98
87
|
line, client = @udp.recvfrom(8192)
|
88
|
+
|
99
89
|
begin
|
100
90
|
data = Gelfd::Parser.parse(line)
|
101
91
|
rescue => ex
|
@@ -113,6 +103,7 @@ class LogStash::Inputs::Gelf < LogStash::Inputs::Base
|
|
113
103
|
event.timestamp = LogStash::Timestamp.at(event["timestamp"])
|
114
104
|
event.remove("timestamp")
|
115
105
|
end
|
106
|
+
|
116
107
|
remap_gelf(event) if @remap
|
117
108
|
strip_leading_underscore(event) if @strip_leading_underscore
|
118
109
|
decorate(event)
|
data/logstash-input-gelf.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-gelf'
|
4
|
-
s.version = '
|
4
|
+
s.version = '2.0.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This input will read GELF messages as events over the network, making it a good choice if you already use Graylog2 today."
|
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"
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.require_paths = ["lib"]
|
12
12
|
|
13
13
|
# Files
|
14
|
-
s.files =
|
14
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
15
15
|
|
16
16
|
# Tests
|
17
17
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
@@ -20,12 +20,14 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
21
21
|
|
22
22
|
# Gem dependencies
|
23
|
-
s.add_runtime_dependency "logstash-core",
|
23
|
+
s.add_runtime_dependency "logstash-core", "~> 2.0.0.snapshot"
|
24
24
|
|
25
25
|
s.add_runtime_dependency "gelfd", ["0.2.0"] #(Apache 2.0 license)
|
26
|
-
s.add_runtime_dependency "gelf", ["1.3.2"] #(MIT license)
|
27
26
|
s.add_runtime_dependency 'logstash-codec-plain'
|
27
|
+
s.add_runtime_dependency "stud", "~> 0.0.22"
|
28
28
|
|
29
29
|
s.add_development_dependency 'logstash-devutils'
|
30
|
+
s.add_development_dependency "gelf", ["1.3.2"] #(MIT license)
|
31
|
+
s.add_development_dependency "flores"
|
30
32
|
end
|
31
33
|
|
data/spec/inputs/gelf_spec.rb
CHANGED
@@ -1,8 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require "logstash/devutils/rspec/spec_helper"
|
2
3
|
require "logstash/inputs/gelf"
|
4
|
+
require_relative "../support/helpers"
|
3
5
|
require "gelf"
|
6
|
+
require "flores/random"
|
4
7
|
|
5
|
-
describe
|
8
|
+
describe LogStash::Inputs::Gelf do
|
9
|
+
context "when interrupting the plugin" do
|
10
|
+
let(:port) { Flores::Random.integer(1024..65535) }
|
11
|
+
let(:host) { "127.0.0.1" }
|
12
|
+
let(:chunksize) { 1420 }
|
13
|
+
let(:producer) { InfiniteGelfProducer.new(host, port, chunksize) }
|
14
|
+
let(:config) { { "host" => host, "port" => port } }
|
15
|
+
|
16
|
+
before { producer.run }
|
17
|
+
after { producer.stop }
|
18
|
+
|
19
|
+
|
20
|
+
it_behaves_like "an interruptible input plugin"
|
21
|
+
end
|
6
22
|
|
7
23
|
it "reads chunked gelf messages " do
|
8
24
|
port = 12209
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
class InfiniteGelfProducer
|
3
|
+
def initialize(host, port, chunksize)
|
4
|
+
@client = GELF::Notifier.new(host, port, chunksize)
|
5
|
+
end
|
6
|
+
|
7
|
+
def run
|
8
|
+
@producer = Thread.new do
|
9
|
+
while true
|
10
|
+
@client.notify!("short_message" => "hello world")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def stop
|
16
|
+
@producer.kill
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,108 +1,129 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-gelf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: logstash-core
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.4.0
|
20
|
-
- - <
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 2.0.0
|
23
14
|
requirement: !ruby/object:Gem::Requirement
|
24
15
|
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 1.4.0
|
28
|
-
- - <
|
16
|
+
- - ~>
|
29
17
|
- !ruby/object:Gem::Version
|
30
|
-
version: 2.0.0
|
18
|
+
version: 2.0.0.snapshot
|
19
|
+
name: logstash-core
|
31
20
|
prerelease: false
|
32
21
|
type: :runtime
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: gelfd
|
35
22
|
version_requirements: !ruby/object:Gem::Requirement
|
36
23
|
requirements:
|
37
|
-
- -
|
24
|
+
- - ~>
|
38
25
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
26
|
+
version: 2.0.0.snapshot
|
27
|
+
- !ruby/object:Gem::Dependency
|
40
28
|
requirement: !ruby/object:Gem::Requirement
|
41
29
|
requirements:
|
42
30
|
- - '='
|
43
31
|
- !ruby/object:Gem::Version
|
44
32
|
version: 0.2.0
|
33
|
+
name: gelfd
|
45
34
|
prerelease: false
|
46
35
|
type: :runtime
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: gelf
|
49
36
|
version_requirements: !ruby/object:Gem::Requirement
|
50
37
|
requirements:
|
51
38
|
- - '='
|
52
39
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
40
|
+
version: 0.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
54
42
|
requirement: !ruby/object:Gem::Requirement
|
55
43
|
requirements:
|
56
|
-
- - '
|
44
|
+
- - '>='
|
57
45
|
- !ruby/object:Gem::Version
|
58
|
-
version:
|
46
|
+
version: '0'
|
47
|
+
name: logstash-codec-plain
|
59
48
|
prerelease: false
|
60
49
|
type: :runtime
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: logstash-codec-plain
|
63
50
|
version_requirements: !ruby/object:Gem::Requirement
|
64
51
|
requirements:
|
65
52
|
- - '>='
|
66
53
|
- !ruby/object:Gem::Version
|
67
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
68
56
|
requirement: !ruby/object:Gem::Requirement
|
69
57
|
requirements:
|
70
|
-
- -
|
58
|
+
- - ~>
|
71
59
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
60
|
+
version: 0.0.22
|
61
|
+
name: stud
|
73
62
|
prerelease: false
|
74
63
|
type: :runtime
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.0.22
|
75
69
|
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
76
75
|
name: logstash-devutils
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
77
78
|
version_requirements: !ruby/object:Gem::Requirement
|
78
79
|
requirements:
|
79
80
|
- - '>='
|
80
81
|
- !ruby/object:Gem::Version
|
81
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.3.2
|
89
|
+
name: gelf
|
90
|
+
prerelease: false
|
91
|
+
type: :development
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.2
|
97
|
+
- !ruby/object:Gem::Dependency
|
82
98
|
requirement: !ruby/object:Gem::Requirement
|
83
99
|
requirements:
|
84
100
|
- - '>='
|
85
101
|
- !ruby/object:Gem::Version
|
86
102
|
version: '0'
|
103
|
+
name: flores
|
87
104
|
prerelease: false
|
88
105
|
type: :development
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
89
111
|
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
|
90
112
|
email: info@elastic.co
|
91
113
|
executables: []
|
92
114
|
extensions: []
|
93
115
|
extra_rdoc_files: []
|
94
116
|
files:
|
95
|
-
- .gitignore
|
96
117
|
- CHANGELOG.md
|
97
118
|
- CONTRIBUTORS
|
98
119
|
- Gemfile
|
99
120
|
- LICENSE
|
100
121
|
- NOTICE.TXT
|
101
122
|
- README.md
|
102
|
-
- Rakefile
|
103
123
|
- lib/logstash/inputs/gelf.rb
|
104
124
|
- logstash-input-gelf.gemspec
|
105
125
|
- spec/inputs/gelf_spec.rb
|
126
|
+
- spec/support/helpers.rb
|
106
127
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
107
128
|
licenses:
|
108
129
|
- Apache License (2.0)
|
@@ -125,9 +146,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
146
|
version: '0'
|
126
147
|
requirements: []
|
127
148
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
149
|
+
rubygems_version: 2.4.8
|
129
150
|
signing_key:
|
130
151
|
specification_version: 4
|
131
152
|
summary: This input will read GELF messages as events over the network, making it a good choice if you already use Graylog2 today.
|
132
153
|
test_files:
|
133
154
|
- spec/inputs/gelf_spec.rb
|
155
|
+
- spec/support/helpers.rb
|
data/.gitignore
DELETED