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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bba7ec257f540842aa9d9f509d52ad982401ae6
4
- data.tar.gz: a14a1f5b055e437c0d769123cfe586159485c542
3
+ metadata.gz: 88703e3545ad1d6c54c43b6b4d2678dc52053050
4
+ data.tar.gz: 7f3c702db26d2f36210b51c369d9441a1a694e0d
5
5
  SHA512:
6
- metadata.gz: c9181a4cfa77a6dc954e9b90e0b05e12e39ff4d636b249c487a4a341cd420fd3eb80c40a450b56e9513e4fc7e101f50307cecb0ec90e797ae2abb81ddeefd9e2
7
- data.tar.gz: 61ceb2a840cba9c529f24136197143ac88f2889cda9156fcc736d36ce8b31445db2ffc73a89c52406c016237aa8419104f1cd63233a1eba4b555230b42ccc3ea
6
+ metadata.gz: eeb41820242af03d20ed68c6631010bdbb37a5ec1a3c7a558d05b103f607e7bc45801cbd7d7ef3858da043261db11027979910e57adf00bf549c91a0a6d31fc6
7
+ data.tar.gz: b87498bf8c785116c25c0fabf3d211c88174ff84348f12022c5f9c338f71ca16ac1e5a6e3b73282612fa54407bfd3b2d9b2704178875d3bc873d0cc40b20a2f7
@@ -1,2 +1,6 @@
1
- ## 0.1.0
1
+ ## 1.0.1
2
+ - Try to parse field if it is not an array
3
+ ## 1.0.0
2
4
  - Plugin created with the logstash plugin generator
5
+ - Initial coding and testing
6
+
@@ -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 logstash along its way.
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
+ [![Gem Version](https://badge.fury.io/rb/logstash-filter-collect.svg?reload=1)](https://badge.fury.io/rb/logstash-filter-collect)
10
+ [![Build Status](https://travis-ci.org/mikebski/logstash-filter-datepart.svg?branch=master)](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 "logstash/filters/base"
3
- require "logstash/namespace"
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
- plugin_error("Error, #{@field} is not an array", event)
55
- return
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,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-collect'
3
- s.version = '1.0.0'
3
+ s.version = '1.0.1'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = 'Collect list of properties from list of objects'
6
6
  s.homepage = 'http://mikeski.net'
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require_relative '../spec_helper'
3
- require "logstash/filters/collect"
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': 'val1'})
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.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-09 00:00:00.000000000 Z
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
@@ -1,2 +0,0 @@
1
- # logstash-filter-collect
2
- Example filter plugin. This should help bootstrap your effort to write your own filter plugin!