logstash-input-gelf 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -6
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.md +11 -1
- data/lib/logstash/inputs/gelf.rb +14 -10
- data/logstash-input-gelf.gemspec +3 -3
- data/spec/inputs/gelf_spec.rb +11 -10
- metadata +41 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dadd960344e3445d70df63413aa82c8975d42c28
|
4
|
+
data.tar.gz: ff642ce5d0c7ef904c857be8acaad1bab17a9c2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b180ffd916f3ebb7472866b14dd294754f6d7a022fe54b416e60c442e7d260f3994be91014e60fb5b82e20a9085469b5a271484161afe064be833d6de07c76bc
|
7
|
+
data.tar.gz: 4691a2d35448c0c8d3fb03ffad34ccf66a72a2590698c0dc41c3aebd127083493364cfaeb80f7d29a946d7420313706ba2e884c3885582c459a3f2e77627ca3f
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
-
|
1
|
+
## 2.0.8
|
2
|
+
- Make the `Event.from_json` return a single element instead of an array and make this plugin works under 5.0
|
3
|
+
## 2.0.7
|
2
4
|
- Fix failing test caused by reverting Java Event back to Ruby Event
|
3
|
-
|
5
|
+
## 2.0.6
|
4
6
|
- Fix plugin crash when Logstash::Json fails to parse a message, https://github.com/logstash-plugins/logstash-input-gelf/pull/27
|
5
|
-
|
7
|
+
## 2.0.5
|
6
8
|
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
|
7
|
-
|
9
|
+
## 2.0.4
|
8
10
|
- New dependency requirements for logstash-core for the 5.0 release
|
9
|
-
|
11
|
+
## 2.0.3
|
10
12
|
- Fix Timestamp coercion to preserve upto microsecond precision, https://github.com/logstash-plugins/logstash-input-gelf/pull/35
|
11
|
-
|
13
|
+
## 2.0.0
|
12
14
|
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
13
15
|
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
14
16
|
- Dependency on logstash-core update to 2.0
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -55,7 +55,12 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
|
55
55
|
```
|
56
56
|
- Install plugin
|
57
57
|
```sh
|
58
|
+
# Logstash 2.3 and higher
|
59
|
+
bin/logstash-plugin install --no-verify
|
60
|
+
|
61
|
+
# Prior to Logstash 2.3
|
58
62
|
bin/plugin install --no-verify
|
63
|
+
|
59
64
|
```
|
60
65
|
- Run Logstash with your plugin
|
61
66
|
```sh
|
@@ -73,7 +78,12 @@ gem build logstash-filter-awesome.gemspec
|
|
73
78
|
```
|
74
79
|
- Install the plugin from the Logstash home
|
75
80
|
```sh
|
76
|
-
|
81
|
+
# Logstash 2.3 and higher
|
82
|
+
bin/logstash-plugin install --no-verify
|
83
|
+
|
84
|
+
# Prior to Logstash 2.3
|
85
|
+
bin/plugin install --no-verify
|
86
|
+
|
77
87
|
```
|
78
88
|
- Start Logstash and proceed to test the plugin
|
79
89
|
|
data/lib/logstash/inputs/gelf.rb
CHANGED
@@ -111,6 +111,7 @@ class LogStash::Inputs::Gelf < LogStash::Inputs::Base
|
|
111
111
|
next if data.nil?
|
112
112
|
|
113
113
|
event = self.class.new_event(data, client[3])
|
114
|
+
next if event.nil?
|
114
115
|
|
115
116
|
remap_gelf(event) if @remap
|
116
117
|
strip_leading_underscore(event) if @strip_leading_underscore
|
@@ -126,10 +127,11 @@ class LogStash::Inputs::Gelf < LogStash::Inputs::Base
|
|
126
127
|
# @return [LogStash::Event] new event with parsed json gelf, assigned source host and coerced timestamp
|
127
128
|
def self.new_event(json_gelf, host)
|
128
129
|
event = parse(json_gelf)
|
130
|
+
return if event.nil?
|
129
131
|
|
130
|
-
event
|
132
|
+
event.set(SOURCE_HOST_FIELD, host)
|
131
133
|
|
132
|
-
if (gelf_timestamp = event
|
134
|
+
if (gelf_timestamp = event.get(TIMESTAMP_GELF_FIELD)).is_a?(Numeric)
|
133
135
|
event.timestamp = self.coerce_timestamp(gelf_timestamp)
|
134
136
|
event.remove(TIMESTAMP_GELF_FIELD)
|
135
137
|
end
|
@@ -148,7 +150,9 @@ class LogStash::Inputs::Gelf < LogStash::Inputs::Base
|
|
148
150
|
|
149
151
|
# from_json_parse uses the Event#from_json method to deserialize and directly produce events
|
150
152
|
def self.from_json_parse(json)
|
151
|
-
|
153
|
+
# from_json will always return an array of item.
|
154
|
+
# in the context of gelf, the payload should be an array of 1
|
155
|
+
LogStash::Event.from_json(json).first
|
152
156
|
rescue LogStash::Json::ParserError => e
|
153
157
|
logger.error(PARSE_FAILURE_LOG_MESSAGE, :error => e, :data => json)
|
154
158
|
LogStash::Event.new(MESSAGE_FIELD => json, TAGS_FIELD => [PARSE_FAILURE_TAG, '_fromjsonparser'])
|
@@ -157,7 +161,7 @@ class LogStash::Inputs::Gelf < LogStash::Inputs::Base
|
|
157
161
|
# legacy_parse uses the LogStash::Json class to deserialize json
|
158
162
|
def self.legacy_parse(json)
|
159
163
|
o = LogStash::Json.load(json)
|
160
|
-
LogStash::Event.new(o)
|
164
|
+
LogStash::Event.new(o)
|
161
165
|
rescue LogStash::Json::ParserError => e
|
162
166
|
logger.error(PARSE_FAILURE_LOG_MESSAGE, :error => e, :data => json)
|
163
167
|
LogStash::Event.new(MESSAGE_FIELD => json, TAGS_FIELD => [PARSE_FAILURE_TAG, '_legacyjsonparser'])
|
@@ -171,14 +175,14 @@ class LogStash::Inputs::Gelf < LogStash::Inputs::Base
|
|
171
175
|
|
172
176
|
private
|
173
177
|
def remap_gelf(event)
|
174
|
-
if event
|
175
|
-
event
|
178
|
+
if event.get("full_message") && !event.get("full_message").empty?
|
179
|
+
event.set("message", event.get("full_message").dup)
|
176
180
|
event.remove("full_message")
|
177
|
-
if event
|
181
|
+
if event.get("short_message") == event.get("message")
|
178
182
|
event.remove("short_message")
|
179
183
|
end
|
180
|
-
elsif event
|
181
|
-
event
|
184
|
+
elsif event.get("short_message") && !event.get("short_message").empty?
|
185
|
+
event.set("message", event.get("short_message").dup)
|
182
186
|
event.remove("short_message")
|
183
187
|
end
|
184
188
|
end # def remap_gelf
|
@@ -188,7 +192,7 @@ class LogStash::Inputs::Gelf < LogStash::Inputs::Base
|
|
188
192
|
# Map all '_foo' fields to simply 'foo'
|
189
193
|
event.to_hash.keys.each do |key|
|
190
194
|
next unless key[0,1] == "_"
|
191
|
-
event
|
195
|
+
event.set(key[1..-1], event.get(key))
|
192
196
|
event.remove(key)
|
193
197
|
end
|
194
198
|
end # deef removing_leading_underscores
|
data/logstash-input-gelf.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-gelf'
|
4
|
-
s.version = '2.0.
|
4
|
+
s.version = '2.0.8'
|
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
|
-
s.description = "This gem is a
|
7
|
+
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
8
8
|
s.authors = ["Elastic"]
|
9
9
|
s.email = 'info@elastic.co'
|
10
10
|
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
@@ -20,7 +20,7 @@ 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-plugin-api", "~>
|
23
|
+
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
24
24
|
|
25
25
|
s.add_runtime_dependency "gelfd", ["0.2.0"] #(Apache 2.0 license)
|
26
26
|
s.add_runtime_dependency 'logstash-codec-plain'
|
data/spec/inputs/gelf_spec.rb
CHANGED
@@ -53,7 +53,7 @@ describe LogStash::Inputs::Gelf do
|
|
53
53
|
gelfclient.notify!("short_message" => "start")
|
54
54
|
|
55
55
|
e = queue.pop
|
56
|
-
while (e
|
56
|
+
while (e.get("message") != "start")
|
57
57
|
e = queue.pop
|
58
58
|
end
|
59
59
|
|
@@ -65,8 +65,8 @@ describe LogStash::Inputs::Gelf do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
events.each_with_index do |e, i|
|
68
|
-
insist { e
|
69
|
-
insist { e
|
68
|
+
insist { e.get("message") } == messages[i]
|
69
|
+
insist { e.get("host") } == Socket.gethostname
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -150,20 +150,21 @@ describe LogStash::Inputs::Gelf do
|
|
150
150
|
context "when an invalid JSON is fed to the listener" do
|
151
151
|
subject { LogStash::Inputs::Gelf.new_event(message, "host") }
|
152
152
|
let(:message) { "Invalid JSON message" }
|
153
|
-
|
153
|
+
|
154
|
+
if LogStash::Event.respond_to?(:from_json)
|
154
155
|
context "default :from_json parser output" do
|
155
156
|
it { should be_a(LogStash::Event) }
|
156
157
|
|
157
158
|
it "falls back to plain-text" do
|
158
|
-
expect(subject
|
159
|
+
expect(subject.get("message")).to eq(message)
|
159
160
|
end
|
160
161
|
|
161
162
|
it "tags message with _jsonparsefailure" do
|
162
|
-
expect(subject
|
163
|
+
expect(subject.get("tags")).to include("_jsonparsefailure")
|
163
164
|
end
|
164
165
|
|
165
166
|
it "tags message with _fromjsonparser" do
|
166
|
-
expect(subject
|
167
|
+
expect(subject.get("tags")).to include("_fromjsonparser")
|
167
168
|
end
|
168
169
|
end
|
169
170
|
else
|
@@ -171,15 +172,15 @@ describe LogStash::Inputs::Gelf do
|
|
171
172
|
it { should be_a(LogStash::Event) }
|
172
173
|
|
173
174
|
it "falls back to plain-text" do
|
174
|
-
expect(subject
|
175
|
+
expect(subject.get("message")).to eq(message)
|
175
176
|
end
|
176
177
|
|
177
178
|
it "tags message with _jsonparsefailure" do
|
178
|
-
expect(subject
|
179
|
+
expect(subject.get("tags")).to include("_jsonparsefailure")
|
179
180
|
end
|
180
181
|
|
181
182
|
it "tags message with _legacyjsonparser" do
|
182
|
-
expect(subject
|
183
|
+
expect(subject.get("tags")).to include("_legacyjsonparser")
|
183
184
|
end
|
184
185
|
end
|
185
186
|
end
|
metadata
CHANGED
@@ -1,114 +1,114 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-gelf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: logstash-core-plugin-api
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
14
|
requirement: !ruby/object:Gem::Requirement
|
21
15
|
requirements:
|
22
|
-
- - ~>
|
16
|
+
- - "~>"
|
23
17
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
18
|
+
version: '2.0'
|
19
|
+
name: logstash-core-plugin-api
|
25
20
|
prerelease: false
|
26
21
|
type: :runtime
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: gelfd
|
29
22
|
version_requirements: !ruby/object:Gem::Requirement
|
30
23
|
requirements:
|
31
|
-
- -
|
24
|
+
- - "~>"
|
32
25
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
35
29
|
requirements:
|
36
30
|
- - '='
|
37
31
|
- !ruby/object:Gem::Version
|
38
32
|
version: 0.2.0
|
33
|
+
name: gelfd
|
39
34
|
prerelease: false
|
40
35
|
type: :runtime
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: logstash-codec-plain
|
43
36
|
version_requirements: !ruby/object:Gem::Requirement
|
44
37
|
requirements:
|
45
|
-
- - '
|
38
|
+
- - '='
|
46
39
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
40
|
+
version: 0.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
48
42
|
requirement: !ruby/object:Gem::Requirement
|
49
43
|
requirements:
|
50
|
-
- -
|
44
|
+
- - ">="
|
51
45
|
- !ruby/object:Gem::Version
|
52
46
|
version: '0'
|
47
|
+
name: logstash-codec-plain
|
53
48
|
prerelease: false
|
54
49
|
type: :runtime
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: stud
|
57
50
|
version_requirements: !ruby/object:Gem::Requirement
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
62
56
|
requirement: !ruby/object:Gem::Requirement
|
63
57
|
requirements:
|
64
|
-
- - ~>
|
58
|
+
- - "~>"
|
65
59
|
- !ruby/object:Gem::Version
|
66
60
|
version: 0.0.22
|
61
|
+
name: stud
|
67
62
|
prerelease: false
|
68
63
|
type: :runtime
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: logstash-devutils
|
71
64
|
version_requirements: !ruby/object:Gem::Requirement
|
72
65
|
requirements:
|
73
|
-
- -
|
66
|
+
- - "~>"
|
74
67
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
68
|
+
version: 0.0.22
|
69
|
+
- !ruby/object:Gem::Dependency
|
76
70
|
requirement: !ruby/object:Gem::Requirement
|
77
71
|
requirements:
|
78
|
-
- -
|
72
|
+
- - ">="
|
79
73
|
- !ruby/object:Gem::Version
|
80
74
|
version: '0'
|
75
|
+
name: logstash-devutils
|
81
76
|
prerelease: false
|
82
77
|
type: :development
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: gelf
|
85
78
|
version_requirements: !ruby/object:Gem::Requirement
|
86
79
|
requirements:
|
87
|
-
- -
|
80
|
+
- - ">="
|
88
81
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
90
84
|
requirement: !ruby/object:Gem::Requirement
|
91
85
|
requirements:
|
92
86
|
- - '='
|
93
87
|
- !ruby/object:Gem::Version
|
94
88
|
version: 1.3.2
|
89
|
+
name: gelf
|
95
90
|
prerelease: false
|
96
91
|
type: :development
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: flores
|
99
92
|
version_requirements: !ruby/object:Gem::Requirement
|
100
93
|
requirements:
|
101
|
-
- - '
|
94
|
+
- - '='
|
102
95
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
96
|
+
version: 1.3.2
|
97
|
+
- !ruby/object:Gem::Dependency
|
104
98
|
requirement: !ruby/object:Gem::Requirement
|
105
99
|
requirements:
|
106
|
-
- -
|
100
|
+
- - ">="
|
107
101
|
- !ruby/object:Gem::Version
|
108
102
|
version: '0'
|
103
|
+
name: flores
|
109
104
|
prerelease: false
|
110
105
|
type: :development
|
111
|
-
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
|
112
112
|
email: info@elastic.co
|
113
113
|
executables: []
|
114
114
|
extensions: []
|
@@ -136,12 +136,12 @@ require_paths:
|
|
136
136
|
- lib
|
137
137
|
required_ruby_version: !ruby/object:Gem::Requirement
|
138
138
|
requirements:
|
139
|
-
- -
|
139
|
+
- - ">="
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- -
|
144
|
+
- - ">="
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|