logstash-filter-throttle 4.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29516e66e87030588ab5f56191b0ac346efbaaa7
4
- data.tar.gz: 74a3f0a23b80d19244eca960b00bd5f80898b253
3
+ metadata.gz: fad6d0a8d7a465d2f90cfc4ccb065804890444fe
4
+ data.tar.gz: 201cd6b667a0d2034116ef37a154aa8f3bd32dd1
5
5
  SHA512:
6
- metadata.gz: a992934db1063a273159ff44ab7f00bba78f51a8c144b508c5d84c287ca10f53c1a4fb77143dffee7c018737bea7e2865bb414f050ab64ee879cf1032434c218
7
- data.tar.gz: 035919b7fd35b9274c1e099946f4f36299a671d5cbc76559ec5efebd5aa4e225fbc6c0079c61b9dae855ecb3ed3c58d2775a84f2a05cce059b2b6d8832b78921
6
+ metadata.gz: 089baf8ba028077104a6bcde68d87eee9298825cb7bc7414ac0291eff7aa8a9e80533be00330dc15efb66acacc80dd6a6bc182aa26f998cc1d7f7b3d2a79f248
7
+ data.tar.gz: 4fe4d68746fe2119a753876dfe7e927abd13b4c8ca5dd46f291d4c8593dbc3c99f79a768aee67d1ef3830a733d49b836996b6103117e7314060c12682a2564ad
@@ -1,3 +1,6 @@
1
+ ## 4.0.1
2
+ - fix racing condition that causes logstash to crash under heavy load conditions
3
+
1
4
  ## 4.0.0
2
5
  - Full reimplementation of the plugin. The plugin is now thread-safe and properly tracks past events.
3
6
  - Updated tests and added runtime dependencies
@@ -6,15 +9,18 @@
6
9
  - Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
7
10
 
8
11
  ## 3.0.1
9
- - Republish all the gems under jruby.
12
+ - internal: Republish all the gems under jruby.
13
+
10
14
  ## 3.0.0
11
- - Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
12
- # 2.0.4
13
- - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
14
- # 2.0.3
15
- - New dependency requirements for logstash-core for the 5.0 release
15
+ - internal,deps: Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
16
+
17
+ ## 2.0.4
18
+ - internal,deps: Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
19
+
20
+ ## 2.0.3
21
+ - internal,deps: New dependency requirements for logstash-core for the 5.0 release
22
+
16
23
  ## 2.0.0
17
- - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
24
+ - internal: Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
18
25
  instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
19
- - Dependency on logstash-core update to 2.0
20
-
26
+ - internal,deps: Dependency on logstash-core update to 2.0
@@ -221,27 +221,38 @@ class LogStash::Filters::Throttle < LogStash::Filters::Base
221
221
  # filters the event
222
222
  public
223
223
  def filter(event)
224
- key = event.sprintf(@key) # substitute field
225
- period = event.sprintf(@period).to_i # substitute period
226
- period = 60 if period == 0 # fallback if unparsable
227
- epoch = event.timestamp.to_i # event epoch time
228
-
229
- @key_cache.compute_if_absent(key) do # initialise timeslot cache
230
- ThreadSafe::TimeslotCache.new(epoch) # and add to key cache
224
+ key = event.sprintf(@key) # substitute field
225
+ period = event.sprintf(@period).to_i # substitute period
226
+ period = 60 if period == 0 # fallback if unparsable
227
+ epoch = event.timestamp.to_i # event epoch time
228
+
229
+ while true
230
+ # initialise timeslot cache (if required)
231
+ @key_cache.compute_if_absent(key) { ThreadSafe::TimeslotCache.new(epoch) }
232
+ timeslot_cache = @key_cache[key] # try to get timeslot cache
233
+ break unless timeslot_cache.nil? # retry until succesful
234
+
235
+ @logger.warn? and @logger.warn(
236
+ "filters/#{self.class.name}: timeslot cache disappeared, increase max_counters to prevent this.")
231
237
  end
232
238
 
233
- timeslot_cache = @key_cache[key] # get timeslot cache
234
- timeslot_cache.latest = epoch # update to latest epoch
239
+ timeslot_cache.latest = epoch # update to latest epoch
235
240
 
236
241
  # find target timeslot
237
242
  timeslot_key = epoch - (epoch - timeslot_cache.created) % period
238
243
 
239
- # initialise timeslot and counter (if required)
240
- timeslot_cache.compute_if_absent(timeslot_key) { Atomic.new(0) }
244
+ while true
245
+ # initialise timeslot and counter (if required)
246
+ timeslot_cache.compute_if_absent(timeslot_key) { Atomic.new(0) }
247
+ timeslot = timeslot_cache[timeslot_key] # try to get timeslot
248
+ break unless timeslot.nil? # retry until succesful
241
249
 
242
- timeslot = timeslot_cache[timeslot_key] # get timeslot
243
- timeslot.update { |v| v + 1 } # increment counter
244
- count = timeslot.value # get latest counter value
250
+ @logger.warn? and @logger.warn(
251
+ "filters/#{self.class.name}: timeslot disappeared, increase max_age to prevent this.")
252
+ end
253
+
254
+ timeslot.update { |v| v + 1 } # increment counter
255
+ count = timeslot.value # get latest counter value
245
256
 
246
257
  @logger.debug? and @logger.debug(
247
258
  "filters/#{self.class.name}: counter incremented",
@@ -267,13 +278,13 @@ class LogStash::Filters::Throttle < LogStash::Filters::Base
267
278
 
268
279
  public
269
280
  def flush(options = {})
270
- max_latest = 0 # get maximum epoch
281
+ max_latest = 0 # get maximum epoch
271
282
  @key_cache.each_value { |tc| max_latest = tc.latest if tc.latest > max_latest }
272
283
 
273
284
  total_counters = 0
274
285
  @key_cache.each_pair do |key,timeslot_cache|
275
286
  if timeslot_cache.latest < max_latest - @max_age
276
- @key_cache.delete(key) # delete expired timeslot cache
287
+ @key_cache.delete(key) # delete expired timeslot cache
277
288
  else
278
289
  total_counters += timeslot_cache.size # get total number of counters
279
290
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-throttle'
4
- s.version = '4.0.0'
4
+ s.version = '4.0.1'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "The throttle filter is for throttling the number of events received."
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/logstash-plugin install gemname. This gem is not a stand-alone program"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-throttle
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-31 00:00:00.000000000 Z
11
+ date: 2016-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement