logstash-filter-date 3.1.3 → 3.1.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 560d311715c0a4a9fd5dce66347ac0454e8a0f9b
|
4
|
+
data.tar.gz: 16c331c55c8ee5473e7bd15b61cf984e3e02c26f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e2309227ddbc2945a328c27bf26bb2f3c48b86fe96797442bc919761079e1749282936532661923c225746699f7458529b1d2cd768d18d9e93f86513423d733
|
7
|
+
data.tar.gz: 6c41b484930ee043e2b19bc5725f59312ae69c27a7b732ea2ebfeb5d38c1359fa87cbacaf6d9ddbff5e3af5947969e8f8333bacf7390551e3bf02388445afcd2
|
data/CHANGELOG.md
CHANGED
@@ -171,9 +171,15 @@ class LogStash::Filters::Date < LogStash::Filters::Base
|
|
171
171
|
|
172
172
|
source = @match.first
|
173
173
|
|
174
|
-
|
174
|
+
success_block = Proc.new do |event|
|
175
175
|
filter_matched(event)
|
176
|
+
metric.increment(:matches)
|
176
177
|
end
|
178
|
+
failure_block = Proc.new do |event|
|
179
|
+
metric.increment(:failures)
|
180
|
+
end
|
181
|
+
|
182
|
+
@datefilter = org.logstash.filters.DateFilter.new(source, @target, @tag_on_failure, success_block, failure_block)
|
177
183
|
|
178
184
|
@match[1..-1].map do |format|
|
179
185
|
@datefilter.accept_filter_config(format, @locale, @timezone)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-date'
|
4
|
-
s.version = '3.1.
|
4
|
+
s.version = '3.1.5'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "The date filter is used for parsing dates from fields, and then using that date or timestamp as the logstash timestamp for 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"
|
data/spec/filters/date_spec.rb
CHANGED
@@ -9,20 +9,11 @@ RUBY_ENGINE == "jruby" and describe LogStash::Filters::Date do
|
|
9
9
|
org.logstash.filters.parser.JodaParser.setDefaultClock(org.logstash.filters.parser.JodaParser.wallClock);
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
match => [ "mydate"]
|
17
|
-
locale => "en"
|
18
|
-
}
|
19
|
-
}
|
20
|
-
CONFIG
|
21
|
-
|
22
|
-
sample "not_really_important" do
|
23
|
-
insist {subject}.raises LogStash::ConfigurationError
|
12
|
+
context "when giving an invalid match config" do
|
13
|
+
let(:options) { { "match" => ["mydate"] } }
|
14
|
+
it "raises a configuration error" do
|
15
|
+
expect { described_class.new(options) }.to raise_error(LogStash::ConfigurationError)
|
24
16
|
end
|
25
|
-
|
26
17
|
end
|
27
18
|
|
28
19
|
describe "parsing with ISO8601" do
|
@@ -754,4 +745,78 @@ RUBY_ENGINE == "jruby" and describe LogStash::Filters::Date do
|
|
754
745
|
end
|
755
746
|
end
|
756
747
|
end
|
748
|
+
|
749
|
+
describe "metric counters" do
|
750
|
+
subject { described_class.new("match" => [ "message", "yyyy" ]) }
|
751
|
+
|
752
|
+
context "when date parses a date correctly" do
|
753
|
+
let(:event) { ::LogStash::Event.new("message" => "1999") }
|
754
|
+
it "increases the matches counter" do
|
755
|
+
expect(subject.metric).to receive(:increment).with(:matches)
|
756
|
+
subject.filter(event)
|
757
|
+
end
|
758
|
+
end
|
759
|
+
|
760
|
+
context "when date parses a date correctly" do
|
761
|
+
let(:event) { ::LogStash::Event.new("message" => "not really a year") }
|
762
|
+
it "increases the matches counter" do
|
763
|
+
expect(subject.metric).to receive(:increment).with(:failures)
|
764
|
+
subject.filter(event)
|
765
|
+
end
|
766
|
+
end
|
767
|
+
end
|
768
|
+
|
769
|
+
describe "cancelled events" do
|
770
|
+
subject { described_class.new("match" => [ "message", "yyyy" ]) }
|
771
|
+
|
772
|
+
context "single cancelled event" do
|
773
|
+
let(:event) do
|
774
|
+
e = ::LogStash::Event.new("message" => "1999")
|
775
|
+
e.cancel
|
776
|
+
e
|
777
|
+
end
|
778
|
+
|
779
|
+
it "ignores and return cancelled" do
|
780
|
+
expect{subject.filter(event)}.to_not change{event.timestamp}
|
781
|
+
result = subject.filter(event)
|
782
|
+
expect(result.cancelled?).to be_truthy
|
783
|
+
end
|
784
|
+
end
|
785
|
+
|
786
|
+
context "cancelled events list" do
|
787
|
+
let(:uncancelled_year) { 2001 }
|
788
|
+
|
789
|
+
let(:now_year) do
|
790
|
+
::LogStash::Event.new.timestamp.year
|
791
|
+
end
|
792
|
+
|
793
|
+
let(:events) do
|
794
|
+
list = []
|
795
|
+
e = ::LogStash::Event.new("message" => "1999")
|
796
|
+
e.cancel
|
797
|
+
list << e
|
798
|
+
|
799
|
+
e = ::LogStash::Event.new("message" => "2000")
|
800
|
+
e.cancel
|
801
|
+
list << e
|
802
|
+
|
803
|
+
e = ::LogStash::Event.new("message" => uncancelled_year.to_s)
|
804
|
+
list << e
|
805
|
+
|
806
|
+
list
|
807
|
+
end
|
808
|
+
|
809
|
+
it "ignores and return ignored cancelled" do
|
810
|
+
result = subject.multi_filter(events)
|
811
|
+
expect(result.size).to eq(3)
|
812
|
+
expect(result[0].cancelled?).to be_truthy
|
813
|
+
expect(result[1].cancelled?).to be_truthy
|
814
|
+
expect(result[2].cancelled?).to be_falsey
|
815
|
+
|
816
|
+
expect(result[0].timestamp.year).to eq(now_year)
|
817
|
+
expect(result[1].timestamp.year).to eq(now_year)
|
818
|
+
expect(result[2].timestamp.year).to eq(uncancelled_year)
|
819
|
+
end
|
820
|
+
end
|
821
|
+
end
|
757
822
|
end
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-date
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|