logstash-filter-translate 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/logstash-filter-translate.gemspec +2 -2
- data/spec/filters/translate_spec.rb +83 -63
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5522423e565a186cb510bff658b46dc95a6faafa
|
4
|
+
data.tar.gz: 6a56306cc43c2e35376372f0a48283f8217030cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db2cbcff7dad08c6b5f84fbf59f6400c734da6d723a6b453d36c7e5ca88814f55e26cb0100fe7989e7a7f4f29358bed8dcab4bc670982c993329a05e7566ee34
|
7
|
+
data.tar.gz: 962fb927bd78ef64b90f0de95cef9042bf06be1c489af1c0901fa9a2ab7eb517dd9aa11f642a79fb1235d0e625e7fcd024d873e88041c1d9f4f31cde1093027f
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-translate'
|
4
|
-
s.version = '2.0.
|
4
|
+
s.version = '2.0.2'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "A general search and replace tool which uses a configured hash and/or a YAML file to determine replacement values."
|
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/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", ">= 2.0.0.
|
23
|
+
s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
|
24
24
|
|
25
25
|
s.add_development_dependency 'logstash-devutils'
|
26
26
|
end
|
@@ -3,100 +3,120 @@ require "logstash/devutils/rspec/spec_helper"
|
|
3
3
|
require "logstash/filters/translate"
|
4
4
|
|
5
5
|
describe LogStash::Filters::Translate do
|
6
|
-
|
6
|
+
|
7
|
+
let(:config) { Hash.new }
|
8
|
+
subject { described_class.new(config) }
|
7
9
|
|
8
10
|
describe "exact translation" do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
|
12
|
+
let(:config) do
|
13
|
+
{
|
14
|
+
"field" => "status",
|
15
|
+
"destination" => "translation",
|
16
|
+
"dictionary" => [ "200", "OK",
|
15
17
|
"300", "Redirect",
|
16
18
|
"400", "Client Error",
|
17
|
-
"500", "Server Error" ]
|
18
|
-
|
19
|
-
|
20
|
-
}
|
19
|
+
"500", "Server Error" ],
|
20
|
+
"exact" => true,
|
21
|
+
"regex" => false
|
21
22
|
}
|
22
|
-
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:event) { LogStash::Event.new("status" => 200) }
|
23
26
|
|
24
|
-
|
25
|
-
|
27
|
+
it "return the exact translation" do
|
28
|
+
subject.register
|
29
|
+
subject.filter(event)
|
30
|
+
expect(event["translation"]).to eq("OK")
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
34
|
+
|
29
35
|
describe "multi translation" do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
|
37
|
+
let(:config) do
|
38
|
+
{
|
39
|
+
"field" => "status",
|
40
|
+
"destination" => "translation",
|
41
|
+
"dictionary" => [ "200", "OK",
|
36
42
|
"300", "Redirect",
|
37
43
|
"400", "Client Error",
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
}
|
44
|
+
"500", "Server Error" ],
|
45
|
+
"exact" => false,
|
46
|
+
"regex" => false
|
42
47
|
}
|
43
|
-
|
48
|
+
end
|
44
49
|
|
45
|
-
|
46
|
-
|
50
|
+
let(:event) { LogStash::Event.new("status" => "200 & 500") }
|
51
|
+
|
52
|
+
it "return the exact translation" do
|
53
|
+
subject.register
|
54
|
+
subject.filter(event)
|
55
|
+
expect(event["translation"]).to eq("OK & Server Error")
|
47
56
|
end
|
57
|
+
|
48
58
|
end
|
49
59
|
|
50
60
|
describe "regex translation" do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
61
|
+
|
62
|
+
let(:config) do
|
63
|
+
{
|
64
|
+
"field" => "status",
|
65
|
+
"destination" => "translation",
|
66
|
+
"dictionary" => [ "^2[0-9][0-9]$", "OK",
|
57
67
|
"^3[0-9][0-9]$", "Redirect",
|
58
68
|
"^4[0-9][0-9]$", "Client Error",
|
59
|
-
"^5[0-9][0-9]$", "Server Error" ]
|
60
|
-
|
61
|
-
|
62
|
-
}
|
69
|
+
"^5[0-9][0-9]$", "Server Error" ],
|
70
|
+
"exact" => true,
|
71
|
+
"regex" => true
|
63
72
|
}
|
64
|
-
|
73
|
+
end
|
65
74
|
|
66
|
-
|
67
|
-
|
75
|
+
let(:event) { LogStash::Event.new("status" => "200") }
|
76
|
+
|
77
|
+
it "return the exact translation" do
|
78
|
+
subject.register
|
79
|
+
subject.filter(event)
|
80
|
+
expect(event["translation"]).to eq("OK")
|
68
81
|
end
|
69
82
|
end
|
70
83
|
|
71
|
-
describe "fallback value
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
84
|
+
describe "fallback value" do
|
85
|
+
|
86
|
+
context "static configuration" do
|
87
|
+
let(:config) do
|
88
|
+
{
|
89
|
+
"field" => "status",
|
90
|
+
"destination" => "translation",
|
91
|
+
"fallback" => "no match"
|
78
92
|
}
|
79
|
-
|
80
|
-
|
93
|
+
end
|
94
|
+
|
95
|
+
let(:event) { LogStash::Event.new("status" => "200") }
|
81
96
|
|
82
|
-
|
83
|
-
|
97
|
+
it "return the exact translation" do
|
98
|
+
subject.register
|
99
|
+
subject.filter(event)
|
100
|
+
expect(event["translation"]).to eq("no match")
|
101
|
+
end
|
84
102
|
end
|
85
|
-
end
|
86
103
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
fallback => "%{missing_translation}"
|
104
|
+
context "allow sprintf" do
|
105
|
+
let(:config) do
|
106
|
+
{
|
107
|
+
"field" => "status",
|
108
|
+
"destination" => "translation",
|
109
|
+
"fallback" => "%{missing_translation}"
|
94
110
|
}
|
95
|
-
|
96
|
-
|
111
|
+
end
|
112
|
+
|
113
|
+
let(:event) { LogStash::Event.new("status" => "200", "missing_translation" => "missing no match") }
|
97
114
|
|
98
|
-
|
99
|
-
|
115
|
+
it "return the exact translation" do
|
116
|
+
subject.register
|
117
|
+
subject.filter(event)
|
118
|
+
expect(event["translation"]).to eq("missing no match")
|
119
|
+
end
|
100
120
|
end
|
101
121
|
end
|
102
122
|
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.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: 2015-10-
|
11
|
+
date: 2015-10-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
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 2.0.0.
|
18
|
+
version: 2.0.0.beta2
|
19
19
|
- - <
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 3.0.0
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.0.0.
|
29
|
+
version: 2.0.0.beta2
|
30
30
|
- - <
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.0.0
|