logstash-filter-alter 2.0.5 → 3.0.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 +2 -0
- data/CONTRIBUTORS +1 -0
- data/LICENSE +1 -1
- data/README.md +12 -3
- data/lib/logstash/filters/alter.rb +13 -12
- data/logstash-filter-alter.gemspec +3 -4
- data/spec/filters/alter_spec.rb +13 -13
- data/spec/spec_helper.rb +2 -0
- metadata +15 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eb8e237797006fe3fa7b4471f2be7e671361e21
|
4
|
+
data.tar.gz: 75613dcbc2d967bc9e8c7c4d36d4721a06e81904
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e18ab1c0d2f31a260ea08899832c4863d6cd988f0ca6f785311740294a7e5a863fb12624d3e7ecb319c6674153fad0d325cf73adf026557f799de487a6dc14f2
|
7
|
+
data.tar.gz: dcb87d9b3b498df7a113610911e8f2e85ba4eb14fd9e68a92cdad1bd9ce3822d4fa084a56ef1144276cb4e505e369ce758de9856cf83c08361034b819a3af56d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# 3.0.0
|
2
|
+
- bumped up logstash-core-plugin-api dependency, changed direct field references to event get and set methods
|
1
3
|
# 2.0.5
|
2
4
|
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
|
3
5
|
# 2.0.4
|
data/CONTRIBUTORS
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
[![Build
|
4
|
-
Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Filters/job/logstash-plugin-filter-alter-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Filters/job/logstash-plugin-filter-alter-unit/)
|
3
|
+
[![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-alter.svg)](https://travis-ci.org/logstash-plugins/logstash-filter-alter)
|
5
4
|
|
6
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
7
6
|
|
@@ -56,7 +55,12 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
|
56
55
|
```
|
57
56
|
- Install plugin
|
58
57
|
```sh
|
58
|
+
# Logstash 2.3 and higher
|
59
|
+
bin/logstash-plugin install --no-verify
|
60
|
+
|
61
|
+
# Prior to Logstash 2.3
|
59
62
|
bin/plugin install --no-verify
|
63
|
+
|
60
64
|
```
|
61
65
|
- Run Logstash with your plugin
|
62
66
|
```sh
|
@@ -74,7 +78,12 @@ gem build logstash-filter-awesome.gemspec
|
|
74
78
|
```
|
75
79
|
- Install the plugin from the Logstash home
|
76
80
|
```sh
|
77
|
-
|
81
|
+
# Logstash 2.3 and higher
|
82
|
+
bin/logstash-plugin install --no-verify
|
83
|
+
|
84
|
+
# Prior to Logstash 2.3
|
85
|
+
bin/plugin install --no-verify
|
86
|
+
|
78
87
|
```
|
79
88
|
- Start Logstash and proceed to test the plugin
|
80
89
|
|
@@ -21,7 +21,7 @@ class LogStash::Filters::Alter < LogStash::Filters::Base
|
|
21
21
|
# alter {
|
22
22
|
# condrewrite => [
|
23
23
|
# "field_name", "expected_value", "new_value",
|
24
|
-
# "field_name2", "expected_value2, "new_value2",
|
24
|
+
# "field_name2", "expected_value2", "new_value2",
|
25
25
|
# ....
|
26
26
|
# ]
|
27
27
|
# }
|
@@ -37,7 +37,7 @@ class LogStash::Filters::Alter < LogStash::Filters::Base
|
|
37
37
|
# alter {
|
38
38
|
# condrewriteother => [
|
39
39
|
# "field_name", "expected_value", "field_name_to_change", "value",
|
40
|
-
# "field_name2", "expected_value2, "field_name_to_change2", "value2",
|
40
|
+
# "field_name2", "expected_value2", "field_name_to_change2", "value2",
|
41
41
|
# ....
|
42
42
|
# ]
|
43
43
|
# }
|
@@ -117,20 +117,21 @@ class LogStash::Filters::Alter < LogStash::Filters::Base
|
|
117
117
|
field = config[:field]
|
118
118
|
expected = config[:expected]
|
119
119
|
replacement = config[:replacement]
|
120
|
-
if event
|
121
|
-
|
120
|
+
if event.get(field).is_a?(Array)
|
121
|
+
new_array = event.get(field).map do |v|
|
122
122
|
if v == event.sprintf(expected)
|
123
123
|
v = event.sprintf(replacement)
|
124
124
|
else
|
125
125
|
v
|
126
126
|
end
|
127
127
|
end
|
128
|
+
event.set(field, new_array)
|
128
129
|
else
|
129
|
-
if event
|
130
|
+
if event.get(field) == event.sprintf(expected)
|
130
131
|
# The usage of encode(UTF-8) is a workarround here until the new
|
131
132
|
# version of logstash-core is released and include the fix for this
|
132
133
|
# after that, this should be removed.
|
133
|
-
event
|
134
|
+
event.set(field, event.sprintf(replacement).encode(Encoding::UTF_8))
|
134
135
|
end
|
135
136
|
end
|
136
137
|
end # @condrewrite_parsed.each
|
@@ -144,15 +145,15 @@ class LogStash::Filters::Alter < LogStash::Filters::Base
|
|
144
145
|
replacement_field = config[:replacement_field]
|
145
146
|
replacement_value = config[:replacement_value]
|
146
147
|
|
147
|
-
if event
|
148
|
-
event
|
148
|
+
if event.get(field).is_a?(Array)
|
149
|
+
event.get(field).each do |v|
|
149
150
|
if v == event.sprintf(expected)
|
150
|
-
event
|
151
|
+
event.set(replacement_field, event.sprintf(replacement_value))
|
151
152
|
end
|
152
153
|
end
|
153
154
|
else
|
154
|
-
if event
|
155
|
-
event
|
155
|
+
if event.get(field) == event.sprintf(expected)
|
156
|
+
event.set(replacement_field, event.sprintf(replacement_value))
|
156
157
|
end
|
157
158
|
end
|
158
159
|
end # @condrewriteother_parsed.each
|
@@ -167,7 +168,7 @@ class LogStash::Filters::Alter < LogStash::Filters::Base
|
|
167
168
|
substitution_parsed = subst_array.map { |x| event.sprintf(x) }
|
168
169
|
not_nul_index = substitution_parsed.find_index { |x| not x.nil? and not x.eql?("nil") and not (not x.index("%").nil? && x.match(/%\{[^}]\}/).nil?) }
|
169
170
|
if not not_nul_index.nil?
|
170
|
-
event
|
171
|
+
event.set(field, substitution_parsed[not_nul_index])
|
171
172
|
end
|
172
173
|
end # @coalesce_parsed.each
|
173
174
|
end # def coalesce
|
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-alter'
|
4
|
-
s.version = '
|
4
|
+
s.version = '3.0.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "The alter filter allows you to do general alterations to fields that are not included in the normal mutate filter"
|
7
|
-
s.description = "This gem is a
|
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"
|
8
8
|
s.authors = ["Elastic"]
|
9
9
|
s.email = 'info@elastic.co'
|
10
10
|
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
@@ -20,8 +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", "
|
23
|
+
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
24
24
|
|
25
25
|
s.add_development_dependency 'logstash-devutils'
|
26
26
|
end
|
27
|
-
|
data/spec/filters/alter_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../spec_helper'
|
4
4
|
require "logstash/filters/alter"
|
5
5
|
|
6
6
|
describe LogStash::Filters::Alter do
|
@@ -15,11 +15,11 @@ describe LogStash::Filters::Alter do
|
|
15
15
|
CONFIG
|
16
16
|
|
17
17
|
sample("rewrite-me" => "hello") do
|
18
|
-
insist { subject
|
18
|
+
insist { subject.get("rewrite-me") } == "goodbye"
|
19
19
|
end
|
20
20
|
|
21
21
|
sample("rewrite-me" => "greetings") do
|
22
|
-
insist { subject
|
22
|
+
insist { subject.get("rewrite-me") } == "greetings"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -34,23 +34,23 @@ describe LogStash::Filters::Alter do
|
|
34
34
|
|
35
35
|
sample("rewrite-me" => "hello", "test" => "hello",
|
36
36
|
"rewrite-value" => "goodbye") do
|
37
|
-
insist { subject
|
37
|
+
insist { subject.get("rewrite-me") } == "goodbye"
|
38
38
|
end
|
39
39
|
|
40
40
|
sample("rewrite-me" => "hello") do
|
41
|
-
insist { subject
|
41
|
+
insist { subject.get("rewrite-me") } == "hello"
|
42
42
|
end
|
43
43
|
|
44
44
|
sample("rewrite-me" => "%{test}") do
|
45
|
-
insist { subject
|
45
|
+
insist { subject.get("rewrite-me") } == "%{rewrite-value}"
|
46
46
|
end
|
47
47
|
|
48
48
|
sample("rewrite-me" => "hello", "test" => "hello") do
|
49
|
-
insist { subject
|
49
|
+
insist { subject.get("rewrite-me") } == "%{rewrite-value}"
|
50
50
|
end
|
51
51
|
|
52
52
|
sample("rewrite-me" => "greetings", "test" => "hello") do
|
53
|
-
insist { subject
|
53
|
+
insist { subject.get("rewrite-me") } == "greetings"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -64,20 +64,20 @@ describe LogStash::Filters::Alter do
|
|
64
64
|
CONFIG
|
65
65
|
|
66
66
|
sample("test-me" => "hello") do
|
67
|
-
insist { subject
|
67
|
+
insist { subject.get("rewrite-me") } == "goodbye"
|
68
68
|
end
|
69
69
|
|
70
70
|
sample("test-me" => "hello", "rewrite-me" => "hello2") do
|
71
|
-
insist { subject
|
71
|
+
insist { subject.get("rewrite-me") } == "goodbye"
|
72
72
|
end
|
73
73
|
|
74
74
|
sample("test-me" => "greetings") do
|
75
|
-
insist { subject
|
75
|
+
insist { subject.get("rewrite-me") }.nil?
|
76
76
|
end
|
77
77
|
|
78
78
|
sample("test-me" => "greetings",
|
79
79
|
"rewrite-me" => "hello2") do
|
80
|
-
insist { subject
|
80
|
+
insist { subject.get("rewrite-me") } == "hello2"
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -91,7 +91,7 @@ describe LogStash::Filters::Alter do
|
|
91
91
|
CONFIG
|
92
92
|
|
93
93
|
sample("coalesce-me" => "Hello") do
|
94
|
-
insist { subject
|
94
|
+
insist { subject.get("coalesce-me") } == "mydefault"
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-alter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-16 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: '
|
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: '
|
32
|
+
version: '2.99'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
requirement: !ruby/object:Gem::Requirement
|
29
35
|
requirements:
|
@@ -38,7 +44,7 @@ dependencies:
|
|
38
44
|
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
46
|
version: '0'
|
41
|
-
description: This gem is a
|
47
|
+
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
|
42
48
|
email: info@elastic.co
|
43
49
|
executables: []
|
44
50
|
extensions: []
|
@@ -53,6 +59,7 @@ files:
|
|
53
59
|
- lib/logstash/filters/alter.rb
|
54
60
|
- logstash-filter-alter.gemspec
|
55
61
|
- spec/filters/alter_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
56
63
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
57
64
|
licenses:
|
58
65
|
- Apache License (2.0)
|
@@ -81,3 +88,4 @@ specification_version: 4
|
|
81
88
|
summary: The alter filter allows you to do general alterations to fields that are not included in the normal mutate filter
|
82
89
|
test_files:
|
83
90
|
- spec/filters/alter_spec.rb
|
91
|
+
- spec/spec_helper.rb
|