logstash-filter-combine 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 74854f535d2cff3da5922968879b506cd422079b1a954847fa17d3de2e0c7e27
4
+ data.tar.gz: 060c9733adbd9976c04fe233b6ee392287a362cbc51e61fd56f1ce58d1a88076
5
+ SHA512:
6
+ metadata.gz: c9a7f8e010731c9b37f408df373364c0192d83e3f220945678e854a0099521d434630358bb686013eb06bd65967368011096bd0b42b31fc1454440b814bc5f2b
7
+ data.tar.gz: 83733bb0957c3d954437cb152cf1c8b74cb7055681465365631921634b48bd09159e7b414ea9f8613712442e1a8484a5c466bab156da727cdcdeac234e6a665b
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.1.0
2
+ - Init release
data/CONTRIBUTORS ADDED
@@ -0,0 +1,3 @@
1
+ Contributors:
2
+ * Julian Wecke (securitym0nkey)
3
+
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ logstash_path = ENV['LOGSTASH_PATH'] || '/usr/share/logstash'
5
+
6
+ if Dir.exist?(logstash_path)
7
+ gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
8
+ gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
9
+ end
10
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Julian Wecke
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # Logstash Combine Filter Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
+
5
+ It is fully free and fully open source. The license is [MIT](LICENSE).
6
+
7
+
8
+ ## Documentation
9
+ This filter plugin combines multiple source fields into one array.
10
+
11
+
12
+ ### Example config
13
+
14
+ To create an array of source1, source2 and source3 under combine_target
15
+
16
+ ```
17
+ filter {
18
+ combine {
19
+ target => "combine_target"
20
+ sources => ["source1","source2", "source3"]
21
+ }
22
+ }
23
+
24
+ ```
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+
4
+ # This combine filter will replace the contents of the default
5
+ # message field with whatever you specify in the configuration.
6
+ #
7
+ # It is only intended to be used as an combine.
8
+
9
+ class LogStash::Filters::Combine < LogStash::Filters::Base
10
+
11
+ # filter {
12
+ # combine {
13
+ # target => "targetfield"
14
+ # sources => ["sourcefield1","sourcefield2"]
15
+ # }
16
+ # }
17
+ #
18
+ config_name "combine"
19
+
20
+ #Replace the message with this value.
21
+ #config :message, :validate => :string, :default => "Hello World!"
22
+
23
+ config :sources, :validate => :array
24
+ config :target, :validate => :string
25
+ config :remove_sources, :validate => :boolean, :default => false
26
+
27
+ public
28
+ def register
29
+ # Add instance variables
30
+ end # def register
31
+
32
+ public
33
+ def filter(event)
34
+
35
+ arr = []
36
+
37
+ @sources.each do |field|
38
+ data = event.get(field)
39
+ if !data.nil?
40
+ arr << data
41
+ event.remove(field) if @remove_sources
42
+ end
43
+ end
44
+
45
+ if arr.length() > 0
46
+ event.set(@target, arr)
47
+ filter_matched(event)
48
+ end
49
+
50
+ end # def filter
51
+ end # class LogStash::Filters::Combine
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-filter-combine'
3
+ s.version = '0.1.0'
4
+ s.licenses = ['MIT']
5
+ s.summary = 'Logstash Filter Plugin to combine fields into an array'
6
+ s.description = 'A logstash filter for combining multiple source fields into a target array.'
7
+ s.homepage = 'https://github.com/securitym0nkey/logstash-filter-combine'
8
+ s.authors = ['Julian Wecke']
9
+ s.email = 'julian@wecke.me'
10
+ s.require_paths = ['lib']
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
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-plugin-api", "~> 2.0"
22
+ s.add_development_dependency 'logstash-devutils', '~> 0'
23
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ require_relative '../spec_helper'
3
+ require "logstash/filters/combine"
4
+
5
+ describe LogStash::Filters::Combine do
6
+ describe "Set to Hello World" do
7
+ let(:config) do <<-CONFIG
8
+ filter {
9
+ combine {
10
+ message => "Hello World"
11
+ }
12
+ }
13
+ CONFIG
14
+ end
15
+
16
+ sample("message" => "some text") do
17
+ expect(subject).to include("message")
18
+ expect(subject.get('message')).to eq('Hello World')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-combine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Julian Wecke
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-core-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: logstash-devutils
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A logstash filter for combining multiple source fields into a target
42
+ array.
43
+ email: julian@wecke.me
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - CHANGELOG.md
49
+ - CONTRIBUTORS
50
+ - Gemfile
51
+ - LICENSE
52
+ - README.md
53
+ - lib/logstash/filters/combine.rb
54
+ - logstash-filter-combine.gemspec
55
+ - spec/filters/combine_spec.rb
56
+ - spec/spec_helper.rb
57
+ homepage: https://github.com/securitym0nkey/logstash-filter-combine
58
+ licenses:
59
+ - MIT
60
+ metadata:
61
+ logstash_plugin: 'true'
62
+ logstash_group: filter
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubygems_version: 3.3.25
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Logstash Filter Plugin to combine fields into an array
82
+ test_files:
83
+ - spec/filters/combine_spec.rb
84
+ - spec/spec_helper.rb