logstash-filter-translate 2.1.3 → 2.1.4
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/CHANGELOG.md +5 -2
- data/LICENSE +1 -1
- data/README.md +12 -3
- data/lib/logstash/filters/translate.rb +44 -10
- data/logstash-filter-translate.gemspec +2 -2
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfc9d748a0e3154c355b43202c3583de6852f192
|
4
|
+
data.tar.gz: 505b2845b2a50e11f7fb6318fa36e4f82f7485d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 773183d1b34ab1b5ec10c925c85c77e4f43bc992b4a1a15d501449c52d62d8b2d3512b722cbe241ade0ed6d174c5a83e0e359bba0db3fb304415ae702f7482eb
|
7
|
+
data.tar.gz: 77c37788a42fd3e4d174e56600de8fb988d5a950c8f0022be6c903ba15641a40631f78236c64745dbccfab819e7ca1e1e91f9791e145835dd58ec128c25aed26
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
# 2.1.4
|
2
|
+
- Fix threadsafety issues by adding in a read/write lock
|
3
|
+
|
1
4
|
# 2.1.3
|
2
5
|
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
|
3
6
|
# 2.1.2
|
4
7
|
- New dependency requirements for logstash-core for the 5.0 release
|
5
8
|
## 2.1.1
|
6
9
|
- Add more descriptive message with the dictionary could not be loaded,
|
7
|
-
also include test for it.
|
10
|
+
also include test for it.
|
8
11
|
|
9
12
|
## 2.1.0
|
10
13
|
- Added other formats, a part from YAML, to be used when loading
|
@@ -12,7 +15,7 @@
|
|
12
15
|
YAML, JSON and CSV.
|
13
16
|
|
14
17
|
## 2.0.0
|
15
|
-
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
18
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
16
19
|
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
17
20
|
- Dependency on logstash-core update to 2.0
|
18
21
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
[](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Filters/job/logstash-plugin-filter-translate-unit/)
|
3
|
+
[](https://travis-ci.org/logstash-plugins/logstash-filter-translate)
|
5
4
|
|
6
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
7
6
|
|
@@ -56,7 +55,12 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
|
56
55
|
```
|
57
56
|
- Install plugin
|
58
57
|
```sh
|
58
|
+
# Logstash 2.3 and higher
|
59
|
+
bin/logstash-plugin install --no-verify
|
60
|
+
|
61
|
+
# Prior to Logstash 2.3
|
59
62
|
bin/plugin install --no-verify
|
63
|
+
|
60
64
|
```
|
61
65
|
- Run Logstash with your plugin
|
62
66
|
```sh
|
@@ -74,7 +78,12 @@ gem build logstash-filter-awesome.gemspec
|
|
74
78
|
```
|
75
79
|
- Install the plugin from the Logstash home
|
76
80
|
```sh
|
77
|
-
|
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
|
+
|
78
87
|
```
|
79
88
|
- Start Logstash and proceed to test the plugin
|
80
89
|
|
@@ -4,6 +4,9 @@ require "logstash/namespace"
|
|
4
4
|
require "json"
|
5
5
|
require "csv"
|
6
6
|
|
7
|
+
java_import 'java.util.concurrent.locks.ReentrantReadWriteLock'
|
8
|
+
|
9
|
+
|
7
10
|
# A general search and replace tool which uses a configured hash
|
8
11
|
# and/or a file to determine replacement values. Currently supported are
|
9
12
|
# YAML, JSON and CSV files.
|
@@ -121,10 +124,14 @@ class LogStash::Filters::Translate < LogStash::Filters::Base
|
|
121
124
|
config :fallback, :validate => :string
|
122
125
|
|
123
126
|
def register
|
127
|
+
rw_lock = java.util.concurrent.locks.ReentrantReadWriteLock.new
|
128
|
+
@read_lock = rw_lock.readLock
|
129
|
+
@write_lock = rw_lock.writeLock
|
130
|
+
|
124
131
|
if @dictionary_path
|
125
132
|
@next_refresh = Time.now + @refresh_interval
|
126
133
|
raise_exception = true
|
127
|
-
load_dictionary(raise_exception)
|
134
|
+
lock_for_write { load_dictionary(raise_exception) }
|
128
135
|
end
|
129
136
|
|
130
137
|
@logger.debug? and @logger.debug("#{self.class.name}: Dictionary - ", :dictionary => @dictionary)
|
@@ -135,12 +142,34 @@ class LogStash::Filters::Translate < LogStash::Filters::Base
|
|
135
142
|
end
|
136
143
|
end # def register
|
137
144
|
|
145
|
+
def lock_for_read
|
146
|
+
@read_lock.lock
|
147
|
+
begin
|
148
|
+
yield
|
149
|
+
ensure
|
150
|
+
@read_lock.unlock
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def lock_for_write
|
155
|
+
@write_lock.lock
|
156
|
+
begin
|
157
|
+
yield
|
158
|
+
ensure
|
159
|
+
@write_lock.unlock
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
138
163
|
def filter(event)
|
139
164
|
if @dictionary_path
|
140
|
-
if
|
141
|
-
|
142
|
-
|
143
|
-
|
165
|
+
if needs_refresh?
|
166
|
+
lock_for_write do
|
167
|
+
if needs_refresh?
|
168
|
+
load_dictionary
|
169
|
+
@next_refresh = Time.now + @refresh_interval
|
170
|
+
@logger.info("refreshing dictionary file")
|
171
|
+
end
|
172
|
+
end
|
144
173
|
end
|
145
174
|
end
|
146
175
|
|
@@ -155,15 +184,16 @@ class LogStash::Filters::Translate < LogStash::Filters::Base
|
|
155
184
|
if @regex
|
156
185
|
key = @dictionary.keys.detect{|k| source.match(Regexp.new(k))}
|
157
186
|
if key
|
158
|
-
event[@destination] = @dictionary[key]
|
187
|
+
event[@destination] = lock_for_read { @dictionary[key] }
|
159
188
|
matched = true
|
160
189
|
end
|
161
190
|
elsif @dictionary.include?(source)
|
162
|
-
event[@destination] = @dictionary[source]
|
191
|
+
event[@destination] = lock_for_read { @dictionary[source] }
|
163
192
|
matched = true
|
164
193
|
end
|
165
|
-
else
|
166
|
-
translation = source.gsub(Regexp.union(@dictionary.keys), @dictionary)
|
194
|
+
else
|
195
|
+
translation = lock_for_read { source.gsub(Regexp.union(@dictionary.keys), @dictionary) }
|
196
|
+
|
167
197
|
if source != translation
|
168
198
|
event[@destination] = translation.force_encoding(Encoding::UTF_8)
|
169
199
|
matched = true
|
@@ -225,7 +255,7 @@ class LogStash::Filters::Translate < LogStash::Filters::Base
|
|
225
255
|
end
|
226
256
|
|
227
257
|
def merge_dictionary!(data, raise_exception=false)
|
228
|
-
|
258
|
+
@dictionary.merge!(data)
|
229
259
|
end
|
230
260
|
|
231
261
|
def loading_exception(e, raise_exception=false)
|
@@ -236,4 +266,8 @@ class LogStash::Filters::Translate < LogStash::Filters::Base
|
|
236
266
|
@logger.warn("#{msg}, continuing with old dictionary", :dictionary_path => @dictionary_path)
|
237
267
|
end
|
238
268
|
end
|
269
|
+
|
270
|
+
def needs_refresh?
|
271
|
+
@next_refresh < Time.now
|
272
|
+
end
|
239
273
|
end # class LogStash::Filters::Translate
|
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-translate'
|
4
|
-
s.version = '2.1.
|
4
|
+
s.version = '2.1.4'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "A general search and replace tool which uses a configured hash and/or a YAML file to determine replacement values."
|
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"
|
metadata
CHANGED
@@ -1,44 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.4
|
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-06-02 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'
|
14
20
|
requirement: !ruby/object:Gem::Requirement
|
15
21
|
requirements:
|
16
|
-
- -
|
22
|
+
- - ~>
|
17
23
|
- !ruby/object:Gem::Version
|
18
24
|
version: '1.0'
|
19
|
-
name: logstash-core-plugin-api
|
20
25
|
prerelease: false
|
21
26
|
type: :runtime
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: logstash-devutils
|
22
29
|
version_requirements: !ruby/object:Gem::Requirement
|
23
30
|
requirements:
|
24
|
-
- -
|
31
|
+
- - '>='
|
25
32
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
33
|
+
version: '0'
|
28
34
|
requirement: !ruby/object:Gem::Requirement
|
29
35
|
requirements:
|
30
|
-
- -
|
36
|
+
- - '>='
|
31
37
|
- !ruby/object:Gem::Version
|
32
38
|
version: '0'
|
33
|
-
name: logstash-devutils
|
34
39
|
prerelease: false
|
35
40
|
type: :development
|
36
|
-
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
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
|
41
|
+
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
|
42
42
|
email: info@elastic.co
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
@@ -70,12 +70,12 @@ require_paths:
|
|
70
70
|
- lib
|
71
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - '>='
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|