logstash-filter-aggregate 2.9.2 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/docs/index.asciidoc +24 -1
- data/lib/logstash/filters/aggregate.rb +3 -3
- data/logstash-filter-aggregate.gemspec +3 -3
- data/spec/filters/aggregate_spec.rb +14 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e30c90c81bac3cd99cf2a01d8e66e010a89acf87
|
4
|
+
data.tar.gz: 5733c4b4a64b9a6b7032fd093f289ad0d2e84f2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 809dbbdba440d501fb460ab5d60cbaaabb397654a054cd668a2d38ed1de31b99876839896cbd0c16634572d702ba8e944f094616d95e916935009a3290de8d36
|
7
|
+
data.tar.gz: 6cb68ae7e22433d0bc0a49803a95e1836de98f8bb36c937812b2bbb6981d5624590df1ce27694ee34cb7fef53774ab18e9b823b0253b62c3687ea8f83895b82e
|
data/CHANGELOG.md
CHANGED
data/docs/index.asciidoc
CHANGED
@@ -402,7 +402,7 @@ The code to execute to update aggregated map, using current event.
|
|
402
402
|
|
403
403
|
Or on the contrary, the code to execute to update event, using aggregated map.
|
404
404
|
|
405
|
-
Available variables are
|
405
|
+
Available variables are:
|
406
406
|
|
407
407
|
`event`: current Logstash event
|
408
408
|
|
@@ -411,8 +411,11 @@ Available variables are :
|
|
411
411
|
`map_meta`: meta informations associated to aggregate map. It allows to set a custom `timeout` or `inactivity_timeout`.
|
412
412
|
It allows also to get `creation_timestamp`, `lastevent_timestamp` and `task_id`.
|
413
413
|
|
414
|
+
`new_event_block`: block used to emit new Logstash events. See the second example on how to use it.
|
415
|
+
|
414
416
|
When option push_map_as_event_on_timeout=true, if you set `map_meta.timeout=0` in `code` block, then aggregated map is immediately pushed as a new event.
|
415
417
|
|
418
|
+
|
416
419
|
Example:
|
417
420
|
[source,ruby]
|
418
421
|
filter {
|
@@ -421,6 +424,26 @@ Example:
|
|
421
424
|
}
|
422
425
|
}
|
423
426
|
|
427
|
+
|
428
|
+
To create additional events during the code execution, to be emitted immediately, you can use `new_event_block.call(event)` function, like in the following example:
|
429
|
+
|
430
|
+
[source,ruby]
|
431
|
+
filter {
|
432
|
+
aggregate {
|
433
|
+
code => "
|
434
|
+
data = {:my_sql_duration => map['sql_duration']}
|
435
|
+
generated_event = LogStash::Event.new(data)
|
436
|
+
generated_event.set('my_other_field', 34)
|
437
|
+
new_event_block.call(generated_event)
|
438
|
+
"
|
439
|
+
}
|
440
|
+
}
|
441
|
+
|
442
|
+
The parameter of the function `new_event_block.call` must be of type `LogStash::Event`.
|
443
|
+
To create such an object, the constructor of the same class can be used: `LogStash::Event.new()`.
|
444
|
+
`LogStash::Event.new()` can receive a parameter of type ruby http://ruby-doc.org/core-1.9.1/Hash.html[Hash] to initialize the new event fields.
|
445
|
+
|
446
|
+
|
424
447
|
[id="plugins-{type}s-{plugin}-end_of_task"]
|
425
448
|
===== `end_of_task`
|
426
449
|
|
@@ -83,7 +83,7 @@ class LogStash::Filters::Aggregate < LogStash::Filters::Base
|
|
83
83
|
end
|
84
84
|
|
85
85
|
# process lambda expression to call in each filter call
|
86
|
-
eval("@codeblock = lambda { |event, map, map_meta| #{@code} }", binding, "(aggregate filter code)")
|
86
|
+
eval("@codeblock = lambda { |event, map, map_meta, &new_event_block| #{@code} }", binding, "(aggregate filter code)")
|
87
87
|
|
88
88
|
# process lambda expression to call in the timeout case or previous event case
|
89
89
|
if @timeout_code
|
@@ -168,7 +168,7 @@ class LogStash::Filters::Aggregate < LogStash::Filters::Base
|
|
168
168
|
|
169
169
|
# This method is invoked each time an event matches the filter
|
170
170
|
public
|
171
|
-
def filter(event)
|
171
|
+
def filter(event, &new_event_block)
|
172
172
|
|
173
173
|
# define task id
|
174
174
|
task_id = event.sprintf(@task_id)
|
@@ -213,7 +213,7 @@ class LogStash::Filters::Aggregate < LogStash::Filters::Base
|
|
213
213
|
# execute the code to read/update map and event
|
214
214
|
map = aggregate_maps_element.map
|
215
215
|
begin
|
216
|
-
@codeblock.call(event, map, aggregate_maps_element)
|
216
|
+
@codeblock.call(event, map, aggregate_maps_element, &new_event_block)
|
217
217
|
@logger.debug("Aggregate successful filter code execution", :code => @code)
|
218
218
|
noError = true
|
219
219
|
rescue => exception
|
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-filter-aggregate'
|
3
|
-
s.version
|
4
|
-
s.licenses = ['Apache
|
5
|
-
s.summary =
|
3
|
+
s.version = '2.10.0'
|
4
|
+
s.licenses = ['Apache-2.0']
|
5
|
+
s.summary = 'Aggregates information from several events originating with a single task'
|
6
6
|
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'
|
7
7
|
s.authors = ['Elastic', 'Fabien Baligand']
|
8
8
|
s.email = 'info@elastic.co'
|
@@ -420,4 +420,17 @@ describe LogStash::Filters::Aggregate do
|
|
420
420
|
end
|
421
421
|
end
|
422
422
|
|
423
|
-
|
423
|
+
context "Custom event generation code is used" do
|
424
|
+
describe "when a new event is manually generated" do
|
425
|
+
it "should push a new event immediately" do
|
426
|
+
agg_filter = setup_filter({ "task_id" => "%{task_id}", "code" => "map['sql_duration'] = 2; new_event_block.call(LogStash::Event.new({:my_sql_duration => map['sql_duration']}))", "timeout" => 120 })
|
427
|
+
agg_filter.filter(event({"task_id" => "1"})) do |yield_event|
|
428
|
+
expect(yield_event).not_to be_nil
|
429
|
+
expect(yield_event.get("my_sql_duration")).to eq(2)
|
430
|
+
end
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
end
|
435
|
+
|
436
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-aggregate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,7 +45,9 @@ dependencies:
|
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
|
-
description: This gem is a Logstash plugin required to be installed on top of the
|
48
|
+
description: This gem is a Logstash plugin required to be installed on top of the
|
49
|
+
Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
|
50
|
+
gem is not a stand-alone program
|
49
51
|
email: info@elastic.co
|
50
52
|
executables: []
|
51
53
|
extensions: []
|
@@ -65,7 +67,7 @@ files:
|
|
65
67
|
- spec/filters/aggregate_spec_helper.rb
|
66
68
|
homepage: https://github.com/logstash-plugins/logstash-filter-aggregate
|
67
69
|
licenses:
|
68
|
-
- Apache
|
70
|
+
- Apache-2.0
|
69
71
|
metadata:
|
70
72
|
logstash_plugin: 'true'
|
71
73
|
logstash_group: filter
|
@@ -85,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
87
|
version: '0'
|
86
88
|
requirements: []
|
87
89
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
90
|
+
rubygems_version: 2.6.14.1
|
89
91
|
signing_key:
|
90
92
|
specification_version: 4
|
91
93
|
summary: Aggregates information from several events originating with a single task
|