fluent-plugin-ltsv-parser 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-ltsv-parser"
|
4
|
-
gem.version = "0.0.
|
4
|
+
gem.version = "0.0.6"
|
5
5
|
gem.authors = ["anarcher"]
|
6
6
|
gem.email = ["anarcher@gmail.com"]
|
7
7
|
gem.description = %q{fluentd plugin to ltsv parse single field, or to combine log structure into single field}
|
@@ -4,7 +4,7 @@ class Fluent::ParserOutput < Fluent::Output
|
|
4
4
|
config_param :tag, :string, :default => nil
|
5
5
|
config_param :reserve_data, :bool, :default => false
|
6
6
|
config_param :key_name, :string
|
7
|
-
config_param :
|
7
|
+
config_param :filter_in, :string , :default => ""
|
8
8
|
config_param :add_prefix, :string ,:default => nil
|
9
9
|
|
10
10
|
def initialize
|
@@ -22,7 +22,7 @@ class Fluent::ParserOutput < Fluent::Output
|
|
22
22
|
if @key_name[0] == ":"
|
23
23
|
@key_name = @key_name[1..-1].to_sym
|
24
24
|
end
|
25
|
-
@
|
25
|
+
@filter_in = @filter_in.split(",").map(&:strip).select{ |e| e != "" }
|
26
26
|
end
|
27
27
|
|
28
28
|
def emit(tag,es,chain)
|
@@ -46,9 +46,9 @@ class Fluent::ParserOutput < Fluent::Output
|
|
46
46
|
private
|
47
47
|
|
48
48
|
def filter(record)
|
49
|
-
if @
|
50
|
-
_record = record.select{ |x| @
|
51
|
-
if _record.keys.length == @
|
49
|
+
if @filter_in.length > 0 then
|
50
|
+
_record = record.select{ |x| @filter_in.include? x }
|
51
|
+
if _record.keys.length == @filter_in.length then
|
52
52
|
return _record
|
53
53
|
else
|
54
54
|
log.warn("#{record} has an missing fields")
|