diff --git a/fluent-plugin-enhance-k8s-metadata/Gemfile b/fluent-plugin-enhance-k8s-metadata/Gemfile new file mode 100644 index 0000000000..b4e2a20bb6 --- /dev/null +++ b/fluent-plugin-enhance-k8s-metadata/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gemspec diff --git a/fluent-plugin-enhance-k8s-metadata/README.md b/fluent-plugin-enhance-k8s-metadata/README.md new file mode 100644 index 0000000000..e951ee40a4 --- /dev/null +++ b/fluent-plugin-enhance-k8s-metadata/README.md @@ -0,0 +1,41 @@ +# fluent-plugin-enhance-k8s-metadata + +[Fluentd](https://fluentd.org/) output plugin to add extra Kubernetes metadata to the events. + +- Sample of Input + +```json +TBD +``` + +- Sample of Output + +```json +TBD +``` + +## Installation + +### RubyGems + +```sh +gem install fluent-plugin-enhance-k8s-metadata +``` + +### Bundler + +Add following line to your Gemfile: + +```ruby +gem "fluent-plugin-enhance-k8s-metadata" +``` + +And then execute: + +```sh +bundle +``` + +## Configuration + +TBD \ No newline at end of file diff --git a/fluent-plugin-enhance-k8s-metadata/Rakefile b/fluent-plugin-enhance-k8s-metadata/Rakefile new file mode 100644 index 0000000000..9756c6eeb6 --- /dev/null +++ b/fluent-plugin-enhance-k8s-metadata/Rakefile @@ -0,0 +1,13 @@ +require "bundler" +Bundler::GemHelper.install_tasks + +require "rake/testtask" + +Rake::TestTask.new(:test) do |t| + t.libs.push("lib", "test") + t.test_files = FileList["test/**/test_*.rb"] + t.verbose = true + t.warning = true +end + +task default: [:test] diff --git a/fluent-plugin-enhance-k8s-metadata/fluent-plugin-enhance-k8s-metadata.gemspec b/fluent-plugin-enhance-k8s-metadata/fluent-plugin-enhance-k8s-metadata.gemspec new file mode 100644 index 0000000000..ef4a37af89 --- /dev/null +++ b/fluent-plugin-enhance-k8s-metadata/fluent-plugin-enhance-k8s-metadata.gemspec @@ -0,0 +1,26 @@ +lib = File.expand_path("../lib", __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + +Gem::Specification.new do |spec| + spec.name = "fluent-plugin-enhance-k8s-metadata" + spec.version = "0.0.0" + spec.authors = ["Sumo Logic"] + spec.email = ["collection@sumologic.com"] + + spec.summary = "Fluentd plugin for appending extra metadata from Kubernetes." + spec.homepage = "https://github.com/SumoLogic/sumologic-kubernetes-collection" + spec.license = "Apache-2.0" + + test_files, files = `git ls-files -z`.split("\x0").partition do |f| + f.match(%r{^(test|spec|features)/}) + end + spec.files = files + spec.executables = files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.test_files = test_files + spec.require_paths = ["lib"] + + spec.add_development_dependency "bundler", "~> 2.0" + spec.add_development_dependency "rake", "~> 12.0" + spec.add_development_dependency "test-unit", "~> 3.0" + spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"] +end diff --git a/fluent-plugin-enhance-k8s-metadata/lib/fluent/plugin/filter_enhance_k8s_metadata.rb b/fluent-plugin-enhance-k8s-metadata/lib/fluent/plugin/filter_enhance_k8s_metadata.rb new file mode 100644 index 0000000000..4cf6ab37a1 --- /dev/null +++ b/fluent-plugin-enhance-k8s-metadata/lib/fluent/plugin/filter_enhance_k8s_metadata.rb @@ -0,0 +1,13 @@ +require 'fluent/plugin/filter' + +module Fluent + module Plugin + # fluentd filter plugin for appending Kubernetes metadata to events + class EnhanceK8sMetadataFilter < Fluent::Plugin::Filter + Fluent::Plugin.register_filter('enhance_k8s_metadata', self) + + def filter(tag, time, record) + end + end + end +end diff --git a/fluent-plugin-enhance-k8s-metadata/test/helper.rb b/fluent-plugin-enhance-k8s-metadata/test/helper.rb new file mode 100644 index 0000000000..46cfa10c95 --- /dev/null +++ b/fluent-plugin-enhance-k8s-metadata/test/helper.rb @@ -0,0 +1,8 @@ +$LOAD_PATH.unshift(File.expand_path("../../", __FILE__)) +require "test-unit" +require "fluent/test" +require "fluent/test/driver/filter" +require "fluent/test/helpers" + +Test::Unit::TestCase.include(Fluent::Test::Helpers) +Test::Unit::TestCase.extend(Fluent::Test::Helpers) diff --git a/fluent-plugin-enhance-k8s-metadata/test/plugin/test_filter_enhance_k8s_metadata.rb b/fluent-plugin-enhance-k8s-metadata/test/plugin/test_filter_enhance_k8s_metadata.rb new file mode 100644 index 0000000000..533daed366 --- /dev/null +++ b/fluent-plugin-enhance-k8s-metadata/test/plugin/test_filter_enhance_k8s_metadata.rb @@ -0,0 +1,14 @@ +require "helper" +require "fluent/plugin/filter_enhance_k8s_metadata.rb" + +class EnhanceK8sMetadataFilterTest < Test::Unit::TestCase + setup do + Fluent::Test.setup + end + + private + + def create_driver(conf) + Fluent::Test::Driver::Filter.new(Fluent::Plugin::EnhanceK8sMetadataFilter).configure(conf) + end +end