fluent-plugin-tkgi-metadata-parser 1.0.0

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4d9138b2b8ed47185ddcfb4c75f543c68693109c7b8e401dd5ed227061171edc
4
+ data.tar.gz: 59ee969a172811b858b8c1916ed83c82a01e8a5c31046c284502d1d76511e5d0
5
+ SHA512:
6
+ metadata.gz: 6b05ec91e09d2f97bfb4fcac3693b58ce58be6d3c0a5d8d83d2a4647e2a6601d06f3237ed01fa1689d7afc4242545b17ee872e78a6623c7ad2531c83ebb2982a
7
+ data.tar.gz: 900cc106dcdc93aa7b6e43c8652559b6c0e2b5cabe61e509cef28dd803624921e77af760dd56fc18b12b827334b4dba773b51317f37dac875c76d781fc2541ce
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fluent-plugin-tkgi-metadata-parser (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ fluent-plugin-tkgi-metadata-parser!
15
+
16
+ BUNDLED WITH
17
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 srbhklkrn
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.
@@ -0,0 +1 @@
1
+ # fluent-plugin-tkgi-metadata-parser
@@ -0,0 +1,16 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ Gem::Specification.new do |spec|
3
+ spec.name = 'fluent-plugin-tkgi-metadata-parser'
4
+ spec.version = '1.0.0'
5
+ spec.authors = ['Saurabh Kulkarni']
6
+ spec.email = ['saurabh.kl@outlook.com']
7
+ spec.summary = 'FluentD parser plugin to parse TKGI metadata'
8
+ spec.homepage = 'https://github.com/srbhklkrn/fluent-plugin-tkgi-metadata-parser'
9
+ spec.license = 'MIT'
10
+ spec.platform = Gem::Platform::RUBY
11
+ spec.files = `git ls-files`.split("\n").reject{|f| f.start_with?(".")}
12
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
14
+ spec.require_paths = ["lib"]
15
+ spec.required_ruby_version = '>= 2.5.0'
16
+ end
@@ -0,0 +1,47 @@
1
+ require "fluent/plugin/parser"
2
+
3
+ module Fluent::Plugin
4
+ class TKGIMetadataParser < Parser
5
+ # Register this parser as "tkgi_metadata"
6
+ Fluent::Plugin.register_parser("tkgi_metadata", self)
7
+
8
+ config_param :delimiter, :string, default: " " # delimiter is configurable with " " as default
9
+
10
+ config_param :es_mode, :bool, default: false
11
+
12
+ def configure(conf)
13
+ super
14
+
15
+ if @delimiter.length != 1
16
+ raise ConfigError, "delimiter must be a single character. #{@delimiter} is not."
17
+ end
18
+ end
19
+
20
+ def parse(text)
21
+ # Delete first and last square bracket
22
+ text.delete_prefix!("[")
23
+ text.delete_suffix!("]")
24
+
25
+ # Delete any double quotes
26
+ text.gsub!(/"/,'')
27
+
28
+ source, key_values = text.split(' ', 2)
29
+ source, id = source.split('@', 2)
30
+ record = {}
31
+
32
+ key_values.split(' ').each do |kv|
33
+ k, v = kv.split('=', 2)
34
+
35
+ if @es_mode
36
+ k.gsub!(/[\.]/, '_')
37
+ end
38
+
39
+ record[k] = v
40
+ end
41
+
42
+ record.merge!(source: source, source_id: id)
43
+
44
+ yield nil, record
45
+ end
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-tkgi-metadata-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Saurabh Kulkarni
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-12-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - saurabh.kl@outlook.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Gemfile
21
+ - Gemfile.lock
22
+ - LICENSE
23
+ - README.md
24
+ - fluent-plugin-tkgi-metadata-parser.gemspec
25
+ - lib/fluent/plugin/parser_tkgi_metadata.rb
26
+ homepage: https://github.com/srbhklkrn/fluent-plugin-tkgi-metadata-parser
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 2.5.0
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.1.2
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: FluentD parser plugin to parse TKGI metadata
49
+ test_files: []