logstash-filter-collect 1.0.0 → 1.0.1
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/CHANGELOG.md +5 -1
- data/CONTRIBUTORS +2 -2
- data/README.md +16 -0
- data/lib/logstash/filters/collect.rb +13 -4
- data/logstash-filter-collect.gemspec +1 -1
- data/spec/filters/collect_spec.rb +10 -2
- metadata +2 -3
- data/DEVELOPER.md +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88703e3545ad1d6c54c43b6b4d2678dc52053050
|
4
|
+
data.tar.gz: 7f3c702db26d2f36210b51c369d9441a1a694e0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeb41820242af03d20ed68c6631010bdbb37a5ec1a3c7a558d05b103f607e7bc45801cbd7d7ef3858da043261db11027979910e57adf00bf549c91a0a6d31fc6
|
7
|
+
data.tar.gz: b87498bf8c785116c25c0fabf3d211c88174ff84348f12022c5f9c338f71ca16ac1e5a6e3b73282612fa54407bfd3b2d9b2704178875d3bc873d0cc40b20a2f7
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTORS
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
The following is a list of people who have contributed ideas, code, bug
|
2
|
-
reports, or in general have helped
|
2
|
+
reports, or in general have helped.
|
3
3
|
|
4
4
|
Contributors:
|
5
|
-
* Mike Baranski - mike.baranski@gmail.com
|
5
|
+
* Mike Baranski - mike.baranski@gmail.com (http://mikeski.net)
|
6
6
|
|
7
7
|
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
8
8
|
Logstash, and you aren't on the list above and want to be, please let us know
|
data/README.md
CHANGED
@@ -6,6 +6,9 @@ It is fully free and fully open source. The license is Apache 2.0, meaning you a
|
|
6
6
|
|
7
7
|
Author: Mike Baranski (mike.baranski@gmail.com). Contributions are welcome.
|
8
8
|
|
9
|
+
[](https://badge.fury.io/rb/logstash-filter-collect)
|
10
|
+
[](https://travis-ci.org/mikebski/logstash-filter-datepart)
|
11
|
+
|
9
12
|
## License ##
|
10
13
|
|
11
14
|
Copyright (c) 2014–2017 Mike Baranski <http://www.mikeski.net>
|
@@ -24,6 +27,19 @@ limitations under the License.
|
|
24
27
|
|
25
28
|
## Installation
|
26
29
|
|
30
|
+
To install from rubygems.org:
|
31
|
+
|
32
|
+
bin/logstash-plugin install logstash-filter-collect
|
33
|
+
|
34
|
+
If you'd like to build locally, you should clone the repo and run:
|
35
|
+
|
36
|
+
bundle install
|
37
|
+
gem build logstash-filter-collect.gemspec
|
38
|
+
bin/logstash-plugin install --local ./logstash-filter-collect-1.0.0.gem
|
39
|
+
|
40
|
+
Make sure that the argument is the correct filename
|
41
|
+
(the gem that `gem build` creates) since the version might be different
|
42
|
+
|
27
43
|
## Usage
|
28
44
|
|
29
45
|
This plugin takes a list of objects in your event and turns it into a
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require 'json'
|
3
|
+
require 'logstash/filters/base'
|
4
|
+
require 'logstash/namespace'
|
4
5
|
|
5
6
|
# This filter will replace the contents of the default
|
6
7
|
# message field with whatever you specify in the configuration.
|
@@ -51,8 +52,16 @@ class LogStash::Filters::Collect < LogStash::Filters::Base
|
|
51
52
|
def filter(event)
|
52
53
|
object_array = event.get(@field)
|
53
54
|
if not object_array.class == Array
|
54
|
-
|
55
|
-
|
55
|
+
begin
|
56
|
+
object_array = JSON.parse(object_array)
|
57
|
+
rescue
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
if not object_array.class == Array
|
62
|
+
plugin_error("Error, #{@field} is not an array or parseable JSON", event)
|
63
|
+
return
|
64
|
+
end
|
56
65
|
end
|
57
66
|
|
58
67
|
new_collection = []
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require_relative '../spec_helper'
|
3
|
-
require
|
3
|
+
require 'json'
|
4
|
+
require 'logstash/filters/collect'
|
4
5
|
|
5
6
|
describe LogStash::Filters::Collect do
|
6
7
|
#config.expect_with(:rspec) { |c| c.syntax = :should }
|
@@ -13,7 +14,7 @@ describe LogStash::Filters::Collect do
|
|
13
14
|
end
|
14
15
|
|
15
16
|
it 'Test get_event method' do
|
16
|
-
e = get_event({'field1'
|
17
|
+
e = get_event({'field1' => 'val1'})
|
17
18
|
e.set('test', 1234)
|
18
19
|
e.to_hash
|
19
20
|
end
|
@@ -66,6 +67,13 @@ describe LogStash::Filters::Collect do
|
|
66
67
|
expect(e.get('names').class).to be(Array)
|
67
68
|
expect(e.get('names').include?('Mike')).to be(true)
|
68
69
|
expect(e.get('names').include?('Sam')).to be(true)
|
70
|
+
|
71
|
+
|
72
|
+
e = get_event({'people' => JSON.generate(ppl)})
|
73
|
+
f.filter(e)
|
74
|
+
expect(e.get('names').class).to be(Array)
|
75
|
+
expect(e.get('names').include?('Mike')).to be(true)
|
76
|
+
expect(e.get('names').include?('Sam')).to be(true)
|
69
77
|
end
|
70
78
|
|
71
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-collect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Baranski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,7 +46,6 @@ extra_rdoc_files: []
|
|
46
46
|
files:
|
47
47
|
- CHANGELOG.md
|
48
48
|
- CONTRIBUTORS
|
49
|
-
- DEVELOPER.md
|
50
49
|
- Gemfile
|
51
50
|
- LICENSE
|
52
51
|
- README.md
|
data/DEVELOPER.md
DELETED