logstash-filter-qs 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6bf15e83cccf2d96dbd5d0c05b1b72e49fd046e2
4
+ data.tar.gz: 1431b822ef7daed2d7dc6039056831f3b93aa506
5
+ SHA512:
6
+ metadata.gz: 37f49bebdad4a8c0f92f72285594f3151770d2f049c3e41e7374dba6f31f96f47deb966f48213f55083f3aaf1ada1fadf695cd6a63425bce4e4c0a6d2d0f836e
7
+ data.tar.gz: 658116c236c3bc877e8418edf7136ffa6676fda8708f70aaf3778b3bba5c00e33b988d6369f5d96927f0415d31a15bf1ddd96fd61b9130b466227e76f8df0385
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Zentrick nv
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,24 @@
1
+ # logstash-filter-qs
2
+
3
+ Parses a query string into a hash.
4
+
5
+ ## Config
6
+
7
+ ```
8
+ filter {
9
+ qs {
10
+ source => "source_key" # Key for query string. Required.
11
+ destination => "destination_key" # Key for output. Default: "query".
12
+ match => "^(foo|ba[rz])$" # Regexp to filter keys. Optional.
13
+ multi => true # Values as arrays. Default: false.
14
+ }
15
+ }
16
+ ```
17
+
18
+ ## Maintainer
19
+
20
+ - [Tim De Pauw](https://github.com/timdp)
21
+
22
+ ## License
23
+
24
+ MIT
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+ require "cgi"
5
+
6
+ class LogStash::Filters::Qs < LogStash::Filters::Base
7
+ config_name "qs"
8
+
9
+ config :source, :validate => :string, :required => true
10
+
11
+ config :destination, :validate => :string, :default => "query"
12
+
13
+ config :multi, :validate => :boolean, :default => false
14
+
15
+ config :match, :validate => :string
16
+
17
+ public
18
+ def register
19
+ unless @match.nil?
20
+ @re_match = Regexp.new @match
21
+ end
22
+ end
23
+
24
+ public
25
+ def filter(event)
26
+ value = event[@source]
27
+
28
+ begin
29
+ query = CGI::parse(value)
30
+ rescue Exception => msg
31
+ query = { }
32
+ end
33
+
34
+ unless @multi
35
+ query.each { |key, value| query[key] = value[0] }
36
+ end
37
+
38
+ unless @re_match.nil?
39
+ query.keep_if { |key, value| @re_match.match(key) }
40
+ end
41
+
42
+ event[@destination] = query
43
+
44
+ filter_matched(event)
45
+ end
46
+ end
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-filter-qs'
3
+ s.version = '0.1.0'
4
+ s.licenses = ['MIT']
5
+ s.summary = "Parses a query string into a hash."
6
+ 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"
7
+ s.authors = ["Zentrick nv"]
8
+ s.email = 'hello@zentrick.com'
9
+ s.homepage = "https://www.zentrick.com/"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','Gemfile','LICENSE']
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
22
+ s.add_development_dependency 'logstash-devutils'
23
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+ require "logstash/filters/qs"
3
+
4
+ describe LogStash::Filters::Qs do
5
+ end
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-qs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Zentrick nv
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 2.0.0.beta2
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ name: logstash-core
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0.beta2
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ name: logstash-devutils
40
+ prerelease: false
41
+ type: :development
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ 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
48
+ email: hello@zentrick.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - Gemfile
54
+ - LICENSE
55
+ - README.md
56
+ - lib/logstash/filters/qs.rb
57
+ - logstash-filter-qs.gemspec
58
+ - spec/filters/qs_spec.rb
59
+ - spec/spec_helper.rb
60
+ homepage: https://www.zentrick.com/
61
+ licenses:
62
+ - MIT
63
+ metadata:
64
+ logstash_plugin: 'true'
65
+ logstash_group: filter
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.8
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Parses a query string into a hash.
86
+ test_files:
87
+ - spec/filters/qs_spec.rb
88
+ - spec/spec_helper.rb