fluent-plugin-k8s 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 86cefd88e849cbba4452dd248aa1d7c7e848530497a5258a07f97c574e928449
4
+ data.tar.gz: fdc8201ac184f4efa4385376106d903b53606fed303d91e11a3a0bf98b7671a6
5
+ SHA512:
6
+ metadata.gz: 7bf2ace23ec763b38f08adea5edbb70a8267c1b3df829e7331c16309ef153243c4a0ecbf3d66749270ed15fb93b43c80ce6ab293f04ee3aeb777e74ac8307fbd
7
+ data.tar.gz: c0eb40d8c6b9ca1ec72c1a04d9955125dedaca6607b8287960bb691f365dc7da013035748a6c6a12ee6a76aff2ef3fffd80247a98667c7af5dd4409e45fe85bf
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-myscrub.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 dengbo
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # fluent-plugin-myscrub [![Gem Version](https://badge.fury.io/rb/fluent-plugin-k8s.svg)](https://rubygems.org/gems/fluent-plugin-k8s)
2
+
3
+ Fluent plugin for get simple metadata of k8s
4
+
5
+
6
+ ## Installation
7
+
8
+
9
+ Install it yourself as:
10
+
11
+ $ gem install fluent-plugin-k8s
12
+
13
+ ## Configuration
14
+
15
+ ```
16
+ <filter **>
17
+ @type k8s
18
+ </filter>
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```
24
+ <source>
25
+ @type file
26
+ ...
27
+ tag raw.kubernetes.**
28
+ </source>
29
+
30
+ <filter raw.kubernetes.**>
31
+ @type k8s
32
+ </filter>
33
+
34
+ <match **>
35
+ @type stdout
36
+ </match>
37
+ ```
38
+
39
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "fluent-plugin-k8s"
5
+ spec.version = "0.0.1"
6
+ spec.authors = ["dengbo"]
7
+ spec.email = ["dengbo02@inspur.com"]
8
+
9
+ spec.summary = %q{Fluentd filter plugin.}
10
+ spec.description = %q{fluent plugin for get k8s simple metadata.}
11
+ spec.homepage = "https://github.com/xidiandb/fluent-plugin-k8s"
12
+ spec.license = "MIT"
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 2.0"
23
+ spec.add_development_dependency "rake", "~> 12.3.3"
24
+ spec.add_development_dependency "fluentd", [">= 0.14.0", "< 2"]
25
+ end
@@ -0,0 +1,24 @@
1
+ require 'fluent/plugin/filter'
2
+
3
+ module Fluent::Plugin
4
+ class K8sFilter < Filter
5
+ Fluent::Plugin.register_filter('k8s', self)
6
+ config_param :tag_regexp,
7
+ :string,
8
+ :default => 'var\.log\.containers\.(?<pod_name>[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<namespace>[^_]+)_(?<container_name>.+)-(?<docker_id>[a-z0-9]{64})\.log$'
9
+ def configure(conf)
10
+ super
11
+ @tag_compiled = Regexp.compile(@tag_regexp)
12
+ end
13
+
14
+ def filter(tag, time, record)
15
+ tag_match_data = tag.match(@tag_compiled)
16
+ if !!tag_match_data
17
+ record['namespace_name']=tag_match_data['namespace']
18
+ record['pod_name']=tag_match_data['pod_name']
19
+ record['container_name']=tag_match_data['container_name']
20
+ end
21
+ record
22
+ end
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-k8s
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - dengbo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-09-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
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: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 12.3.3
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 12.3.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: fluentd
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.14.0
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '2'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 0.14.0
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '2'
61
+ description: fluent plugin for get k8s simple metadata.
62
+ email:
63
+ - dengbo02@inspur.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".gitignore"
69
+ - Gemfile
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - fluent-plugin-k8s.gemspec
74
+ - lib/fluent/plugin/filter_k8s.rb
75
+ homepage: https://github.com/xidiandb/fluent-plugin-k8s
76
+ licenses:
77
+ - MIT
78
+ metadata:
79
+ homepage_uri: https://github.com/xidiandb/fluent-plugin-k8s
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.7.6.2
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Fluentd filter plugin.
100
+ test_files: []