logstash-input-syslog 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +95 -0
- data/lib/logstash/inputs/syslog.rb +99 -69
- data/logstash-input-syslog.gemspec +4 -1
- data/spec/inputs/syslog_spec.rb +110 -13
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b78d69100942cdae0c081913bf27f54faf8e395a
|
4
|
+
data.tar.gz: d4a62595577b76589e0362e5b87fd9ca394cf0c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ee9f00aaba2b9c4a77a2c03184812df896d796822d8540e56d6d44c9ef1cc6c4c4875ff0a6ddc768fe71eb213aaccdb8d0117092540b99468488c59c4629f4d
|
7
|
+
data.tar.gz: 4523dd8f04baa8fbfaafc1221c0792e383865b38df4975832bd49d6bb939031f40e3f4be8510e61aec3cf876e925241a3fdaa5aca73268cc9af8de5693714986
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2012-
|
1
|
+
Copyright (c) 2012-2015 Elasticsearch <http://www.elasticsearch.org>
|
2
2
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
you may not use this file except in compliance with the License.
|
data/README.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
|
4
|
+
|
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
|
+
|
7
|
+
## Documentation
|
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.elasticsearch.org/guide/en/logstash/current/).
|
10
|
+
|
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/elasticsearch/docs#asciidoc-guide
|
13
|
+
|
14
|
+
## Need Help?
|
15
|
+
|
16
|
+
Need help? Try #logstash on freenode IRC or the logstash-users@googlegroups.com mailing list.
|
17
|
+
|
18
|
+
## Developing
|
19
|
+
|
20
|
+
### 1. Plugin Developement and Testing
|
21
|
+
|
22
|
+
#### Code
|
23
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
24
|
+
|
25
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization.
|
26
|
+
|
27
|
+
- Install dependencies
|
28
|
+
```sh
|
29
|
+
bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
#### Test
|
33
|
+
|
34
|
+
```sh
|
35
|
+
bundle exec rspec
|
36
|
+
```
|
37
|
+
|
38
|
+
The Logstash code required to run the tests/specs is specified in the `Gemfile` by the line similar to:
|
39
|
+
```ruby
|
40
|
+
gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5"
|
41
|
+
```
|
42
|
+
To test against another version or a local Logstash, edit the `Gemfile` to specify an alternative location, for example:
|
43
|
+
```ruby
|
44
|
+
gem "logstash", :github => "elasticsearch/logstash", :ref => "master"
|
45
|
+
```
|
46
|
+
```ruby
|
47
|
+
gem "logstash", :path => "/your/local/logstash"
|
48
|
+
```
|
49
|
+
|
50
|
+
Then update your dependencies and run your tests:
|
51
|
+
|
52
|
+
```sh
|
53
|
+
bundle install
|
54
|
+
bundle exec rspec
|
55
|
+
```
|
56
|
+
|
57
|
+
### 2. Running your unpublished Plugin in Logstash
|
58
|
+
|
59
|
+
#### 2.1 Run in a local Logstash clone
|
60
|
+
|
61
|
+
- Edit Logstash `tools/Gemfile` and add the local plugin path, for example:
|
62
|
+
```ruby
|
63
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
64
|
+
```
|
65
|
+
- Update Logstash dependencies
|
66
|
+
```sh
|
67
|
+
rake vendor:gems
|
68
|
+
```
|
69
|
+
- Run Logstash with your plugin
|
70
|
+
```sh
|
71
|
+
bin/logstash -e 'filter {awesome {}}'
|
72
|
+
```
|
73
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
74
|
+
|
75
|
+
#### 2.2 Run in an installed Logstash
|
76
|
+
|
77
|
+
- Build your plugin gem
|
78
|
+
```sh
|
79
|
+
gem build logstash-filter-awesome.gemspec
|
80
|
+
```
|
81
|
+
- Install the plugin from the Logstash home
|
82
|
+
```sh
|
83
|
+
bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
|
84
|
+
```
|
85
|
+
- Start Logstash and proceed to test the plugin
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
90
|
+
|
91
|
+
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
92
|
+
|
93
|
+
It is more important to me that you are able to contribute.
|
94
|
+
|
95
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "date"
|
3
|
+
require "socket"
|
4
|
+
require "concurrent_ruby"
|
3
5
|
require "logstash/filters/grok"
|
4
6
|
require "logstash/filters/date"
|
5
7
|
require "logstash/inputs/base"
|
6
8
|
require "logstash/namespace"
|
7
|
-
require "socket"
|
8
9
|
|
9
10
|
# Read syslog messages as events over the network.
|
10
11
|
#
|
@@ -24,7 +25,6 @@ require "socket"
|
|
24
25
|
#
|
25
26
|
class LogStash::Inputs::Syslog < LogStash::Inputs::Base
|
26
27
|
config_name "syslog"
|
27
|
-
milestone 1
|
28
28
|
|
29
29
|
default :codec, "plain"
|
30
30
|
|
@@ -44,10 +44,28 @@ class LogStash::Inputs::Syslog < LogStash::Inputs::Base
|
|
44
44
|
# Labels for severity levels. These are defined in RFC3164.
|
45
45
|
config :severity_labels, :validate => :array, :default => [ "Emergency" , "Alert", "Critical", "Error", "Warning", "Notice", "Informational", "Debug" ]
|
46
46
|
|
47
|
+
# Specify a time zone canonical ID to be used for date parsing.
|
48
|
+
# The valid IDs are listed on the [Joda.org available time zones page](http://joda-time.sourceforge.net/timezones.html).
|
49
|
+
# This is useful in case the time zone cannot be extracted from the value,
|
50
|
+
# and is not the platform default.
|
51
|
+
# If this is not specified the platform default will be used.
|
52
|
+
# Canonical ID is good as it takes care of daylight saving time for you
|
53
|
+
# For example, `America/Los_Angeles` or `Europe/France` are valid IDs.
|
54
|
+
config :timezone, :validate => :string
|
55
|
+
|
56
|
+
# Specify a locale to be used for date parsing using either IETF-BCP47 or POSIX language tag.
|
57
|
+
# Simple examples are `en`,`en-US` for BCP47 or `en_US` for POSIX.
|
58
|
+
# If not specified, the platform default will be used.
|
59
|
+
#
|
60
|
+
# The locale is mostly necessary to be set for parsing month names (pattern with MMM) and
|
61
|
+
# weekday names (pattern with EEE).
|
62
|
+
#
|
63
|
+
config :locale, :validate => :string
|
64
|
+
|
47
65
|
public
|
48
66
|
def initialize(params)
|
49
67
|
super
|
50
|
-
@shutdown_requested = false
|
68
|
+
@shutdown_requested = Concurrent::AtomicBoolean.new(false)
|
51
69
|
BasicSocket.do_not_reverse_lookup = true
|
52
70
|
end # def initialize
|
53
71
|
|
@@ -61,44 +79,27 @@ class LogStash::Inputs::Syslog < LogStash::Inputs::Base
|
|
61
79
|
)
|
62
80
|
|
63
81
|
@date_filter = LogStash::Filters::Date.new(
|
64
|
-
"match" => [ "timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss", "ISO8601"]
|
82
|
+
"match" => [ "timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss", "ISO8601"],
|
83
|
+
"locale" => @locale,
|
84
|
+
"timezone" => @timezone,
|
65
85
|
)
|
66
86
|
|
67
87
|
@grok_filter.register
|
68
88
|
@date_filter.register
|
69
89
|
|
70
|
-
@
|
90
|
+
@tcp_sockets = ThreadSafe::Array.new
|
91
|
+
@tcp = @udp = nil
|
71
92
|
end # def register
|
72
93
|
|
73
94
|
public
|
74
95
|
def run(output_queue)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
:address => "#{@host}:#{@port}", :exception => e,
|
83
|
-
:backtrace => e.backtrace)
|
84
|
-
sleep(5)
|
85
|
-
retry
|
86
|
-
end # begin
|
87
|
-
end # Thread.new
|
88
|
-
|
89
|
-
# tcp server
|
90
|
-
tcp_thr = Thread.new do
|
91
|
-
begin
|
92
|
-
tcp_listener(output_queue)
|
93
|
-
rescue => e
|
94
|
-
break if @shutdown_requested
|
95
|
-
@logger.warn("syslog tcp listener died",
|
96
|
-
:address => "#{@host}:#{@port}", :exception => e,
|
97
|
-
:backtrace => e.backtrace)
|
98
|
-
sleep(5)
|
99
|
-
retry
|
100
|
-
end # begin
|
101
|
-
end # Thread.new
|
96
|
+
udp_thr = Thread.new(output_queue) do |output_queue|
|
97
|
+
server(:udp, output_queue)
|
98
|
+
end
|
99
|
+
|
100
|
+
tcp_thr = Thread.new(output_queue) do |output_queue|
|
101
|
+
server(:tcp, output_queue)
|
102
|
+
end
|
102
103
|
|
103
104
|
# If we exit and we're the only input, the agent will think no inputs
|
104
105
|
# are running and initiate a shutdown.
|
@@ -107,65 +108,94 @@ class LogStash::Inputs::Syslog < LogStash::Inputs::Base
|
|
107
108
|
end # def run
|
108
109
|
|
109
110
|
private
|
111
|
+
# server call the specified protocol listener and basically restarts on
|
112
|
+
# any listener uncatched exception
|
113
|
+
#
|
114
|
+
# @param protocol [Symbol] either :udp or :tcp
|
115
|
+
# @param output_queue [Queue] the pipeline input to filters queue
|
116
|
+
def server(protocol, output_queue)
|
117
|
+
self.send("#{protocol}_listener", output_queue)
|
118
|
+
rescue => e
|
119
|
+
if @shutdown_requested.false?
|
120
|
+
@logger.warn("syslog listener died", :protocol => protocol, :address => "#{@host}:#{@port}", :exception => e, :backtrace => e.backtrace)
|
121
|
+
sleep(5)
|
122
|
+
retry
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
# udp_listener creates the udp socket and continously read from it.
|
128
|
+
# upon exception the socket will be closed and the exception bubbled
|
129
|
+
# in the server which will restart the listener
|
110
130
|
def udp_listener(output_queue)
|
111
131
|
@logger.info("Starting syslog udp listener", :address => "#{@host}:#{@port}")
|
112
132
|
|
113
|
-
if @udp
|
114
|
-
@udp.close
|
115
|
-
end
|
116
|
-
|
133
|
+
@udp.close if @udp
|
117
134
|
@udp = UDPSocket.new(Socket::AF_INET)
|
118
135
|
@udp.bind(@host, @port)
|
119
136
|
|
120
|
-
|
137
|
+
while true
|
121
138
|
payload, client = @udp.recvfrom(9000)
|
122
|
-
|
123
|
-
@codec.decode(payload) do |event|
|
124
|
-
decorate(event)
|
125
|
-
event["host"] = client[3]
|
126
|
-
syslog_relay(event)
|
127
|
-
output_queue << event
|
128
|
-
end
|
139
|
+
decode(client[3], output_queue, payload)
|
129
140
|
end
|
130
141
|
ensure
|
131
142
|
close_udp
|
132
143
|
end # def udp_listener
|
133
144
|
|
134
145
|
private
|
146
|
+
# tcp_listener accepts tcp connections and creates a new tcp_receiver thread
|
147
|
+
# for each accepted socket.
|
148
|
+
# upon exception all tcp sockets will be closed and the exception bubbled
|
149
|
+
# in the server which will restart the listener.
|
135
150
|
def tcp_listener(output_queue)
|
136
151
|
@logger.info("Starting syslog tcp listener", :address => "#{@host}:#{@port}")
|
137
152
|
@tcp = TCPServer.new(@host, @port)
|
138
|
-
@tcp_clients = []
|
139
153
|
|
140
154
|
loop do
|
141
|
-
|
142
|
-
@
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
decorate(event)
|
151
|
-
event["host"] = ip
|
152
|
-
syslog_relay(event)
|
153
|
-
output_queue << event
|
154
|
-
end
|
155
|
-
end
|
156
|
-
rescue Errno::ECONNRESET
|
157
|
-
ensure
|
158
|
-
@tcp_clients.delete(client)
|
159
|
-
end
|
160
|
-
end # Thread.new
|
161
|
-
end # loop do
|
155
|
+
socket = @tcp.accept
|
156
|
+
@tcp_sockets << socket
|
157
|
+
|
158
|
+
break if @shutdown_requested.true?
|
159
|
+
|
160
|
+
Thread.new(output_queue, socket) do |output_queue, socket|
|
161
|
+
tcp_receiver(output_queue, socket)
|
162
|
+
end
|
163
|
+
end
|
162
164
|
ensure
|
163
165
|
close_tcp
|
164
166
|
end # def tcp_listener
|
165
167
|
|
168
|
+
# tcp_receiver is executed in a thread, any uncatched exception will be bubbled up to the
|
169
|
+
# tcp server thread and all tcp connections will be closed and the listener restarted.
|
170
|
+
def tcp_receiver(output_queue, socket)
|
171
|
+
ip, port = socket.peeraddr[3], socket.peeraddr[1]
|
172
|
+
@logger.info("new connection", :client => "#{ip}:#{port}")
|
173
|
+
LogStash::Util::set_thread_name("input|syslog|tcp|#{ip}:#{port}}")
|
174
|
+
|
175
|
+
socket.each { |line| decode(ip, output_queue, line) }
|
176
|
+
rescue Errno::ECONNRESET
|
177
|
+
# swallow connection reset exceptions to avoid bubling up the tcp_listener & server
|
178
|
+
ensure
|
179
|
+
@tcp_sockets.delete(socket)
|
180
|
+
socket.close rescue nil
|
181
|
+
end
|
182
|
+
|
183
|
+
private
|
184
|
+
def decode(host, output_queue, data)
|
185
|
+
@codec.decode(data) do |event|
|
186
|
+
decorate(event)
|
187
|
+
event["host"] = host
|
188
|
+
syslog_relay(event)
|
189
|
+
output_queue << event
|
190
|
+
end
|
191
|
+
rescue => e
|
192
|
+
# swallow and log all decoding exceptions, these will never be socket related
|
193
|
+
@logger.error("Error decoding data", :data => line.inspect, :exception => e, :backtrace => e.backtrace)
|
194
|
+
end
|
195
|
+
|
166
196
|
public
|
167
197
|
def teardown
|
168
|
-
@shutdown_requested
|
198
|
+
@shutdown_requested.make_true
|
169
199
|
close_udp
|
170
200
|
close_tcp
|
171
201
|
finished
|
@@ -183,8 +213,8 @@ class LogStash::Inputs::Syslog < LogStash::Inputs::Base
|
|
183
213
|
private
|
184
214
|
def close_tcp
|
185
215
|
# If we somehow have this left open, close it.
|
186
|
-
@
|
187
|
-
|
216
|
+
@tcp_sockets.each do |socket|
|
217
|
+
socket.close rescue nil
|
188
218
|
end
|
189
219
|
@tcp.close if @tcp rescue nil
|
190
220
|
@tcp = nil
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-syslog'
|
4
|
-
s.version = '0.1.
|
4
|
+
s.version = '0.1.2'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Read syslog messages as events over the network."
|
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"
|
@@ -22,6 +22,9 @@ Gem::Specification.new do |s|
|
|
22
22
|
# Gem dependencies
|
23
23
|
s.add_runtime_dependency 'logstash', '>= 1.4.0', '< 2.0.0'
|
24
24
|
|
25
|
+
s.add_runtime_dependency 'concurrent-ruby'
|
26
|
+
s.add_runtime_dependency 'thread_safe'
|
27
|
+
|
25
28
|
s.add_runtime_dependency 'logstash-codec-plain'
|
26
29
|
s.add_runtime_dependency 'logstash-filter-grok'
|
27
30
|
s.add_runtime_dependency 'logstash-filter-date'
|
data/spec/inputs/syslog_spec.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# encoding: utf-8
|
2
2
|
require "logstash/devutils/rspec/spec_helper"
|
3
|
-
require "socket"
|
4
3
|
require "logstash/inputs/syslog"
|
5
4
|
require "logstash/event"
|
5
|
+
require "stud/try"
|
6
|
+
require "socket"
|
6
7
|
|
7
8
|
describe "inputs/syslog" do
|
8
|
-
|
9
|
+
SYSLOG_LINE = "<164>Oct 26 15:19:25 1.2.3.4 %ASA-4-106023: Deny udp src DRAC:10.1.2.3/43434 dst outside:192.168.0.1/53 by access-group \"acl_drac\" [0x0, 0x0]"
|
9
10
|
|
10
|
-
|
11
|
+
describe "should properly handle priority, severity and facilities" do
|
11
12
|
port = 5511
|
12
13
|
event_count = 10
|
13
14
|
|
@@ -21,27 +22,33 @@ describe "inputs/syslog" do
|
|
21
22
|
CONFIG
|
22
23
|
|
23
24
|
input do |pipeline, queue|
|
24
|
-
Thread.new { pipeline.run }
|
25
|
+
t = Thread.new { pipeline.run }
|
25
26
|
sleep 0.1 while !pipeline.ready?
|
26
27
|
|
27
28
|
socket = Stud.try(5.times) { TCPSocket.new("127.0.0.1", port) }
|
28
29
|
event_count.times do |i|
|
29
|
-
socket.puts(
|
30
|
+
socket.puts(SYSLOG_LINE)
|
30
31
|
end
|
31
32
|
socket.close
|
32
33
|
|
33
34
|
events = event_count.times.collect { queue.pop }
|
34
35
|
|
36
|
+
# important to shutdown here before any assertion so that the pipeline + socket
|
37
|
+
# cleanups are correctly done before any potential spec error that would result
|
38
|
+
# in aborting execution and not doing the cleanup.
|
39
|
+
pipeline.shutdown
|
40
|
+
t.join
|
41
|
+
|
35
42
|
insist { events.length } == event_count
|
36
|
-
|
37
|
-
insist {
|
38
|
-
insist {
|
39
|
-
insist {
|
43
|
+
events.each do |event|
|
44
|
+
insist { event["priority"] } == 164
|
45
|
+
insist { event["severity"] } == 4
|
46
|
+
insist { event["facility"] } == 20
|
40
47
|
end
|
41
48
|
end
|
42
49
|
end
|
43
50
|
|
44
|
-
|
51
|
+
describe "should add unique tag when grok parsing fails with live syslog input" do
|
45
52
|
port = 5511
|
46
53
|
event_count = 10
|
47
54
|
|
@@ -55,7 +62,7 @@ describe "inputs/syslog" do
|
|
55
62
|
CONFIG
|
56
63
|
|
57
64
|
input do |pipeline, queue|
|
58
|
-
Thread.new { pipeline.run }
|
65
|
+
t = Thread.new { pipeline.run }
|
59
66
|
sleep 0.1 while !pipeline.ready?
|
60
67
|
|
61
68
|
socket = Stud.try(5.times) { TCPSocket.new("127.0.0.1", port) }
|
@@ -66,13 +73,103 @@ describe "inputs/syslog" do
|
|
66
73
|
|
67
74
|
events = event_count.times.collect { queue.pop }
|
68
75
|
|
76
|
+
# important to shutdown here before any assertion so that the pipeline + socket
|
77
|
+
# cleanups are correctly done before any potential spec error that would result
|
78
|
+
# in aborting execution and not doing the cleanup.
|
79
|
+
pipeline.shutdown
|
80
|
+
t.join
|
81
|
+
|
69
82
|
insist { events.length } == event_count
|
70
83
|
event_count.times do |i|
|
71
|
-
insist { events[i]["tags"] } == ["
|
84
|
+
insist { events[i]["tags"] } == ["_grokparsefailure_sysloginput"]
|
72
85
|
end
|
73
86
|
end
|
74
87
|
end
|
75
88
|
|
89
|
+
describe "should properly handle locale and timezone" do
|
90
|
+
port = 5511
|
91
|
+
event_count = 10
|
92
|
+
|
93
|
+
config <<-CONFIG
|
94
|
+
input {
|
95
|
+
syslog {
|
96
|
+
type => "blah"
|
97
|
+
port => #{port}
|
98
|
+
locale => "en"
|
99
|
+
timezone => "UTC"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
CONFIG
|
103
|
+
|
104
|
+
input do |pipeline, queue|
|
105
|
+
t = Thread.new { pipeline.run }
|
106
|
+
sleep 0.1 while !pipeline.ready?
|
107
|
+
|
108
|
+
socket = Stud.try(5.times) { TCPSocket.new("127.0.0.1", port) }
|
109
|
+
event_count.times do |i|
|
110
|
+
socket.puts(SYSLOG_LINE)
|
111
|
+
end
|
112
|
+
socket.close
|
113
|
+
|
114
|
+
events = event_count.times.collect { queue.pop }
|
115
|
+
|
116
|
+
# important to shutdown here before any assertion so that the pipeline + socket
|
117
|
+
# cleanups are correctly done before any potential spec error that would result
|
118
|
+
# in aborting execution and not doing the cleanup.
|
119
|
+
pipeline.shutdown
|
120
|
+
t.join
|
121
|
+
|
122
|
+
insist { events.length } == event_count
|
123
|
+
events.each do |event|
|
124
|
+
insist { event["@timestamp"].to_iso8601 } == "#{Time.now.year}-10-26T15:19:25.000Z"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "should properly handle no locale and no timezone" do
|
130
|
+
port = 5511
|
131
|
+
|
132
|
+
config <<-CONFIG
|
133
|
+
input {
|
134
|
+
syslog {
|
135
|
+
type => "blah"
|
136
|
+
port => #{port}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
CONFIG
|
140
|
+
|
141
|
+
input do |pipeline, queue|
|
142
|
+
t = Thread.new { pipeline.run }
|
143
|
+
sleep 0.1 while !pipeline.ready?
|
144
|
+
|
145
|
+
socket = Stud.try(5.times) { TCPSocket.new("127.0.0.1", port) }
|
146
|
+
socket.puts(SYSLOG_LINE)
|
147
|
+
socket.close
|
148
|
+
|
149
|
+
event = queue.pop
|
150
|
+
|
151
|
+
# important to shutdown here before any assertion so that the pipeline + socket
|
152
|
+
# cleanups are correctly done before any potential spec error that would result
|
153
|
+
# in aborting execution and not doing the cleanup.
|
154
|
+
pipeline.shutdown
|
155
|
+
t.join
|
156
|
+
|
157
|
+
# chances platform timezone is not UTC so ignore the hours
|
158
|
+
insist { event["@timestamp"].to_iso8601 } =~ /#{Time.now.year}-10-26T\d\d:19:25.000Z/
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should support non UTC timezone" do
|
163
|
+
input = LogStash::Inputs::Syslog.new({"timezone" => "-05:00"})
|
164
|
+
input.register
|
165
|
+
|
166
|
+
# event which is not syslog should have a new tag
|
167
|
+
|
168
|
+
syslog_event = LogStash::Event.new({ "message" => "<164>Oct 26 15:19:25 1.2.3.4 %ASA-4-106023: Deny udp src DRAC:10.1.2.3/43434" })
|
169
|
+
input.syslog_relay(syslog_event)
|
170
|
+
insist { syslog_event["@timestamp"].to_iso8601 } == "#{Time.now.year}-10-26T20:19:25.000Z"
|
171
|
+
end
|
172
|
+
|
76
173
|
it "should add unique tag when grok parsing fails" do
|
77
174
|
input = LogStash::Inputs::Syslog.new({})
|
78
175
|
input.register
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-syslog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elasticsearch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash
|
@@ -30,6 +30,34 @@ dependencies:
|
|
30
30
|
version: 2.0.0
|
31
31
|
prerelease: false
|
32
32
|
type: :runtime
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: concurrent-ruby
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
prerelease: false
|
46
|
+
type: :runtime
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: thread_safe
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
prerelease: false
|
60
|
+
type: :runtime
|
33
61
|
- !ruby/object:Gem::Dependency
|
34
62
|
name: logstash-codec-plain
|
35
63
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -95,6 +123,7 @@ files:
|
|
95
123
|
- .gitignore
|
96
124
|
- Gemfile
|
97
125
|
- LICENSE
|
126
|
+
- README.md
|
98
127
|
- Rakefile
|
99
128
|
- lib/logstash/inputs/syslog.rb
|
100
129
|
- logstash-input-syslog.gemspec
|
@@ -121,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
150
|
version: '0'
|
122
151
|
requirements: []
|
123
152
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
153
|
+
rubygems_version: 2.1.9
|
125
154
|
signing_key:
|
126
155
|
specification_version: 4
|
127
156
|
summary: Read syslog messages as events over the network.
|