logstash-filter-ruby 3.0.1 → 3.0.2

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: 7d10fa6e20d7158adc2c37c887e3f57648a5c5b2
4
- data.tar.gz: e8994128a58e45a0745ec166d50b11aa950aa5ca
3
+ metadata.gz: d37b548007d87f94ac0e0d9d3826f08d861e70ee
4
+ data.tar.gz: 8fdf8080f42d9ac002cc2253496969ef5e6a8ae2
5
5
  SHA512:
6
- metadata.gz: 81e29423e65065579d911be67dcdabf2c633052e4693b85c5a566be587ca428c168faaaf6c71ee5762663369af9e13bd801e8db622e3310d65512bc0a18868f3
7
- data.tar.gz: 76ffc07f01c1d9cd3345c8006ef62dbf3675e5242bc75861ddb976b4558e5f47bac804578f7a1698eecc1dccacb7fdbced7616ed6fdcd127addd0075f2273ed3
6
+ metadata.gz: c5b474c54c025b3d43fb8cfe1b67f6ea83a82bc787b56d6d304dcc9f8bc43e0f712bd569a091b69e751c63f97aae7a256d2be9f6fa38aed943de3665daf98bc4
7
+ data.tar.gz: 160597360b990a703014ad66c5ee7c21b8be5b12ff32244678535bbe9919b0b48ed58e6c74061fcf1fdbfdcb6c4341491a625ed0756b62be5a85814fea5e6e9f
data/CHANGELOG.md CHANGED
@@ -1,16 +1,23 @@
1
+ ## 3.0.2
2
+ - Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
3
+
1
4
  ## 3.0.1
2
- - Republish all the gems under jruby.
5
+ - internal: Republish all the gems under jruby.
6
+
3
7
  ## 3.0.0
4
- - 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
5
- # 2.0.5
6
- - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
7
- # 2.0.4
8
- - New dependency requirements for logstash-core for the 5.0 release
8
+ - 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
9
+
10
+ ## 2.0.5
11
+ - internal,deps: Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
12
+
13
+ ## 2.0.4
14
+ - internal,deps: New dependency requirements for logstash-core for the 5.0 release
15
+
9
16
  ## 2.0.3
10
- - Code cleanup and fixed json order verification is specs
17
+ - internal,test,cleanup: Code cleanup and fixed json order verification is specs
11
18
 
12
19
  ## 2.0.0
13
- - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
20
+ - internal: Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
14
21
  instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
15
- - Dependency on logstash-core update to 2.0
22
+ - internal,deps: Dependency on logstash-core update to 2.0
16
23
 
@@ -13,6 +13,15 @@ require "logstash/namespace"
13
13
  # }
14
14
  # }
15
15
  #
16
+ # If you need to create additional events, it cannot be done as in other filters where you would use `yield`,
17
+ # you must use a specific syntax `new_event_block.call(event)` like in this example duplicating the input event
18
+ # [source,ruby]
19
+ # filter {
20
+ # ruby {
21
+ # code => "new_event_block.call(event.clone)"
22
+ # }
23
+ # }
24
+ #
16
25
  class LogStash::Filters::Ruby < LogStash::Filters::Base
17
26
  config_name "ruby"
18
27
 
@@ -26,12 +35,12 @@ class LogStash::Filters::Ruby < LogStash::Filters::Base
26
35
  def register
27
36
  # TODO(sissel): Compile the ruby code
28
37
  eval(@init, binding, "(ruby filter init)") if @init
29
- eval("@codeblock = lambda { |event| #{@code} }", binding, "(ruby filter code)")
30
- end
38
+ eval("@codeblock = lambda { |event, &new_event_block| #{@code} }", binding, "(ruby filter code)")
39
+ end # def register
31
40
 
32
- def filter(event)
41
+ def filter(event,&block)
33
42
  begin
34
- @codeblock.call(event)
43
+ @codeblock.call(event,&block)
35
44
  filter_matched(event)
36
45
  rescue Exception => e
37
46
  @logger.error("Ruby exception occurred: #{e}")
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-ruby'
4
- s.version = '3.0.1'
4
+ s.version = '3.0.2'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Filter for executing ruby code on the event"
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"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
23
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
24
24
  s.add_runtime_dependency 'logstash-filter-date'
25
25
  s.add_development_dependency 'logstash-devutils'
26
26
  end
@@ -85,5 +85,37 @@ describe LogStash::Filters::Ruby do
85
85
  end
86
86
  end
87
87
 
88
+ describe "allow to create new event inside the ruby filter" do
89
+ config <<-CONFIG
90
+ filter {
91
+ ruby {
92
+ code => "new_event_block.call(event.clone)"
93
+ }
94
+ }
95
+ CONFIG
96
+
97
+ sample("message" => "hello world", "mydate" => "2014-09-23T00:00:00-0800") do
98
+ expect(subject).to be_a Array
99
+ expect(subject[0]).not_to eq(subject[1])
100
+ expect(subject[0].to_hash).to eq(subject[1].to_hash)
101
+ end
102
+ end
103
+
104
+ describe "allow to replace event by another one" do
105
+ config <<-CONFIG
106
+ filter {
107
+ ruby {
108
+ code => "new_event_block.call(event.clone);
109
+ event.cancel;"
110
+ add_tag => ["ok"]
111
+ }
112
+ }
113
+ CONFIG
114
+
115
+ sample("message" => "hello world", "mydate" => "2014-09-23T00:00:00-0800") do
116
+ expect(subject.get("message")).to eq("hello world");
117
+ expect(subject.get("mydate")).to eq("2014-09-23T00:00:00-0800");
118
+ end
119
+ end
88
120
  end
89
121
 
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - "~>"
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '1.60'
19
+ - - "<="
17
20
  - !ruby/object:Gem::Version
18
- version: '2.0'
21
+ version: '2.99'
19
22
  name: logstash-core-plugin-api
20
23
  prerelease: false
21
24
  type: :runtime
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.60'
30
+ - - "<="
25
31
  - !ruby/object:Gem::Version
26
- version: '2.0'
32
+ version: '2.99'
27
33
  - !ruby/object:Gem::Dependency
28
34
  requirement: !ruby/object:Gem::Requirement
29
35
  requirements:
@@ -89,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
95
  version: '0'
90
96
  requirements: []
91
97
  rubyforge_project:
92
- rubygems_version: 2.4.8
98
+ rubygems_version: 2.6.3
93
99
  signing_key:
94
100
  specification_version: 4
95
101
  summary: Filter for executing ruby code on the event