logstash-filter-elapsed 4.0.5 → 4.1.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 +5 -0
- data/docs/index.asciidoc +12 -0
- data/lib/logstash/filters/elapsed.rb +7 -1
- data/logstash-filter-elapsed.gemspec +1 -1
- data/spec/filters/elapsed_spec.rb +28 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62eed374e0f0470f24f6e08cf60524fbfc4c3b49c5e9c069b9047af0fcd2baaf
|
4
|
+
data.tar.gz: fb928437d7978ff7ed34497c8c232e795f65052f139936f01e40be1c0dd2ade6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2d64f1c578518e76661be136367c05c840285d769f343152ce976a88731ccddc87958417f85bea93a03a190191f38c6107acda76fe392166a05d6a13ce4b242
|
7
|
+
data.tar.gz: 04dfa3a1d4248d6e7874f218030ab93adfcad256b5da4c153341c8581eed96229f0ca57f7bfbf46aa6252d91d66c61dadbb26809ab31b724adbb9a57d28d7e39
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 4.1.0
|
2
|
+
- Added option `keep_start_event` to manage what to do when several messages matched
|
3
|
+
as a start event were received before the end event for the specified ID.
|
4
|
+
[#35](https://github.com/logstash-plugins/logstash-filter-elapsed/pull/35)
|
5
|
+
|
1
6
|
## 4.0.5
|
2
7
|
- Fixed default to true for the periodic_flush option in order for the caching expiration to work [#36](https://github.com/logstash-plugins/logstash-filter-elapsed/pull/36)
|
3
8
|
|
data/docs/index.asciidoc
CHANGED
@@ -106,6 +106,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
106
106
|
| <<plugins-{type}s-{plugin}-start_tag>> |<<string,string>>|Yes
|
107
107
|
| <<plugins-{type}s-{plugin}-timeout>> |<<number,number>>|No
|
108
108
|
| <<plugins-{type}s-{plugin}-unique_id_field>> |<<string,string>>|Yes
|
109
|
+
| <<plugins-{type}s-{plugin}-keep_start_event>> |<<string,string>>|No
|
109
110
|
|=======================================================================
|
110
111
|
|
111
112
|
Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
|
@@ -162,6 +163,17 @@ The name of the field containing the task ID.
|
|
162
163
|
This value must uniquely identify the task in the system, otherwise
|
163
164
|
it's impossible to match the couple of events.
|
164
165
|
|
166
|
+
[id="plugins-{type}s-{plugin}-keep_start_event"]
|
167
|
+
===== `keep_start_event`
|
168
|
+
|
169
|
+
* Value type is <<string,string>>
|
170
|
+
* Default value is `first`
|
171
|
+
|
172
|
+
This property manages what to do when several events matched as a start one
|
173
|
+
were received before the end event for the specified ID. There are two
|
174
|
+
supported values: `first` or `last`. If it's set to `first` (default value),
|
175
|
+
the first event matched as a start will be used; if it's set to `last`,
|
176
|
+
the last one will be used.
|
165
177
|
|
166
178
|
|
167
179
|
[id="plugins-{type}s-{plugin}-common-options"]
|
@@ -109,6 +109,12 @@ class LogStash::Filters::Elapsed < LogStash::Filters::Base
|
|
109
109
|
# to the "end event"; if it's set to `true` a new "match event" is created.
|
110
110
|
config :new_event_on_match, :validate => :boolean, :required => false, :default => false
|
111
111
|
|
112
|
+
# This property manage what to do when several "start events" were received
|
113
|
+
# before an "end event" for a concrete ID. If it's set to `first` (default
|
114
|
+
# value), the first "start event" will be used; if it's set to `last`,
|
115
|
+
# the last "start event" will be used.
|
116
|
+
config :keep_start_event, :validate => ['first', 'last'], :required => false, :default => 'first'
|
117
|
+
|
112
118
|
# This filter must have its flush function called periodically to be able to purge
|
113
119
|
# expired stored start events.
|
114
120
|
config :periodic_flush, :validate => :boolean, :default => true
|
@@ -139,7 +145,7 @@ class LogStash::Filters::Elapsed < LogStash::Filters::Base
|
|
139
145
|
@logger.debug("Elapsed, 'start event' received", start_tag: @start_tag, unique_id_field: @unique_id_field)
|
140
146
|
|
141
147
|
@mutex.synchronize do
|
142
|
-
unless(@start_events.has_key?(unique_id))
|
148
|
+
unless(@keep_start_event == 'first' && @start_events.has_key?(unique_id))
|
143
149
|
@start_events[unique_id] = LogStash::Filters::Elapsed::Element.new(event)
|
144
150
|
end
|
145
151
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-elapsed'
|
4
|
-
s.version = '4.0
|
4
|
+
s.version = '4.1.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Calculates the elapsed time between a pair of events"
|
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"
|
@@ -74,16 +74,36 @@ describe LogStash::Filters::Elapsed do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "receiving two 'start events' for the same id field" do
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
context "if 'keep_start_event' is set to 'last'" do
|
78
|
+
before(:each) do
|
79
|
+
setup_filter("keep_start_event" => 'last')
|
80
|
+
end
|
81
81
|
|
82
|
-
|
83
|
-
|
82
|
+
it "keeps the second one and does not save the first one" do
|
83
|
+
args = {"tags" => [START_TAG], ID_FIELD => "id123"}
|
84
|
+
first_event = event(args)
|
85
|
+
second_event = event(args)
|
84
86
|
|
85
|
-
|
86
|
-
|
87
|
+
@filter.filter(first_event)
|
88
|
+
@filter.filter(second_event)
|
89
|
+
|
90
|
+
insist { @filter.start_events.size } == 1
|
91
|
+
insist { @filter.start_events["id123"].event } == second_event
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "if 'keep_start_event' is set to 'first'" do
|
96
|
+
it "keeps the first one and does not save the second one" do
|
97
|
+
args = {"tags" => [START_TAG], ID_FIELD => "id123"}
|
98
|
+
first_event = event(args)
|
99
|
+
second_event = event(args)
|
100
|
+
|
101
|
+
@filter.filter(first_event)
|
102
|
+
@filter.filter(second_event)
|
103
|
+
|
104
|
+
insist { @filter.start_events.size } == 1
|
105
|
+
insist { @filter.start_events["id123"].event } == first_event
|
106
|
+
end
|
87
107
|
end
|
88
108
|
end
|
89
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-elapsed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|