fluent-plugin-auto-typecast-filter 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 +7 -0
- data/.gitignore +9 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +51 -0
- data/README.md +35 -0
- data/Rakefile +12 -0
- data/fluent-plugin-auto-typecast-filter.gemspec +42 -0
- data/lib/fluent/plugin/filter_auto_typecast.rb +95 -0
- data/lib/fluent/plugin/version.rb +5 -0
- data/td-agent.conf +35 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4dfeb23384ee55ada48e90e803c9d8c964f664fc8efcbd36c06dc160ebb22478
|
4
|
+
data.tar.gz: eba704cbc7525ed3c178381d02f3b96c94950d458d5e8cae4da11a926b11f4d6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b6cdab2b71b86350766b5eb0b76a6c65f2fb431c1bd9e6c6af7b4db479042e1e2fc3424df35dca202a4e3fd5bc1b6bd87e14535fc12c93a8bd340936376dd9c2
|
7
|
+
data.tar.gz: 2a69c393f279dc32f52b0fb17bfda2a0fcfd8584ef70682107eaaa09e825d7535420f5320d2300fc55c75223ef9ffda0045e30a16d3237a779f85ed23587042d
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fluent-plugin-auto-typecast-filter (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
concurrent-ruby (1.1.5)
|
10
|
+
cool.io (1.5.4)
|
11
|
+
dig_rb (1.0.1)
|
12
|
+
fluentd (1.7.0)
|
13
|
+
cool.io (>= 1.4.5, < 2.0.0)
|
14
|
+
dig_rb (~> 1.0.0)
|
15
|
+
http_parser.rb (>= 0.5.1, < 0.7.0)
|
16
|
+
msgpack (>= 0.7.0, < 2.0.0)
|
17
|
+
serverengine (>= 2.0.4, < 3.0.0)
|
18
|
+
sigdump (~> 0.2.2)
|
19
|
+
strptime (>= 0.2.2, < 1.0.0)
|
20
|
+
tzinfo (~> 2.0)
|
21
|
+
tzinfo-data (~> 1.0)
|
22
|
+
yajl-ruby (~> 1.0)
|
23
|
+
hoe (3.18.0)
|
24
|
+
rake (>= 0.8, < 13.0)
|
25
|
+
http_parser.rb (0.6.0)
|
26
|
+
msgpack (1.3.1)
|
27
|
+
rake (10.5.0)
|
28
|
+
serverengine (2.1.1)
|
29
|
+
sigdump (~> 0.2.2)
|
30
|
+
sigdump (0.2.4)
|
31
|
+
strptime (0.2.3)
|
32
|
+
test-unit (1.2.3)
|
33
|
+
hoe (>= 1.5.1)
|
34
|
+
tzinfo (2.0.0)
|
35
|
+
concurrent-ruby (~> 1.0)
|
36
|
+
tzinfo-data (1.2019.2)
|
37
|
+
tzinfo (>= 1.0.0)
|
38
|
+
yajl-ruby (1.4.1)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
bundler (~> 2.0.2)
|
45
|
+
fluent-plugin-auto-typecast-filter!
|
46
|
+
fluentd (~> 1.7.0)
|
47
|
+
rake (~> 10.0)
|
48
|
+
test-unit (~> 1.2.3)
|
49
|
+
|
50
|
+
BUNDLED WITH
|
51
|
+
2.0.2
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Fluent::Plugin::AutoTypecastFilter
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fluent/plugin/auto/typecast/filter`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'fluent-plugin-auto-typecast-filter'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install fluent-plugin-auto-typecast-filter
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/s5o-c/fluent-plugin-auto-typecast-filter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "fluent/plugin/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluent-plugin-auto-typecast-filter"
|
8
|
+
spec.version = Fluent::Plugin::VERSION
|
9
|
+
spec.authors = ["Shotaro Chiba"]
|
10
|
+
spec.email = ["s@pws.jp"]
|
11
|
+
|
12
|
+
spec.summary = %q{fluent-plugin-auto-typecast-filter}
|
13
|
+
spec.description = %q{fluent-plugin-auto-typecast-filter}
|
14
|
+
spec.homepage = "https://github.com/s5o-c/fluent-plugin-auto-typecast-filter"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["source_code_uri"] = "https://github.com/s5o-c/fluent-plugin-auto-typecast-filter"
|
23
|
+
spec.metadata["changelog_uri"] = "https://github.com/s5o-c/fluent-plugin-auto-typecast-filter"
|
24
|
+
else
|
25
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
+
"public gem pushes."
|
27
|
+
end
|
28
|
+
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
spec.bindir = "exe"
|
35
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
36
|
+
spec.require_paths = ["lib"]
|
37
|
+
|
38
|
+
spec.add_development_dependency "bundler", "~> 2.0.2"
|
39
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
40
|
+
spec.add_development_dependency "test-unit", "~> 1.2.3"
|
41
|
+
spec.add_development_dependency "fluentd", "~> 1.7.0"
|
42
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'fluent/plugin/filter'
|
2
|
+
|
3
|
+
class String
|
4
|
+
def numeric?
|
5
|
+
Float(self) != nil rescue false
|
6
|
+
end
|
7
|
+
|
8
|
+
def boolean?
|
9
|
+
return true if self =~ /^(?:true|false|TRUE|FALSE)$/
|
10
|
+
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
def nil?
|
15
|
+
return true if self =~ /^(?:null|nil|NULL|NIL)$/
|
16
|
+
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_numeric!
|
21
|
+
if self.numeric?
|
22
|
+
if self.index('.')
|
23
|
+
return self.to_f
|
24
|
+
else
|
25
|
+
return self.to_i
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
0
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_boolean!
|
33
|
+
return true if self =~ /^(?:true|TRUE)$/i
|
34
|
+
return false if self =~ /^(?:false|FALSE)$/i
|
35
|
+
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_nil!
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module Fluent::Plugin
|
45
|
+
class AutoTypecastFilter < Filter
|
46
|
+
Fluent::Plugin.register_filter('auto_typecast', self)
|
47
|
+
|
48
|
+
config_param :deep_dive, :bool, default: false
|
49
|
+
|
50
|
+
# def configure(conf)
|
51
|
+
# super
|
52
|
+
# # do the usual configuration here
|
53
|
+
# end
|
54
|
+
|
55
|
+
# def start
|
56
|
+
# super
|
57
|
+
# # Override this method if anything needed as startup.
|
58
|
+
# end
|
59
|
+
|
60
|
+
# def shutdown
|
61
|
+
# # Override this method to use it to free up resources, etc.
|
62
|
+
# super
|
63
|
+
# end
|
64
|
+
|
65
|
+
private def transform(x, k, v)
|
66
|
+
y = String("#{v}")
|
67
|
+
|
68
|
+
x[k] = y.to_numeric! if y.numeric?
|
69
|
+
|
70
|
+
x[k] = y.to_boolean! if y.boolean?
|
71
|
+
|
72
|
+
x[k] = y.to_nil! if y.nil?
|
73
|
+
|
74
|
+
auto_typecast(v) if @deep_dive
|
75
|
+
end
|
76
|
+
|
77
|
+
private def auto_typecast(x)
|
78
|
+
return x if ! x.kind_of?(Enumerable)
|
79
|
+
|
80
|
+
x.each do |k, v|
|
81
|
+
transform(x, k, v)
|
82
|
+
end if x.kind_of?(Hash)
|
83
|
+
|
84
|
+
x.each_with_index do |v, k|
|
85
|
+
transform(x, k, v)
|
86
|
+
end if x.kind_of?(Array)
|
87
|
+
end
|
88
|
+
|
89
|
+
def filter(tag, time, record)
|
90
|
+
auto_typecast(record)
|
91
|
+
|
92
|
+
record
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
data/td-agent.conf
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
<source>
|
2
|
+
@type dummy
|
3
|
+
@label @filter
|
4
|
+
tag dummy
|
5
|
+
dummy {
|
6
|
+
"_0": "NULL",
|
7
|
+
"_1": "0",
|
8
|
+
"_2": "10",
|
9
|
+
"_3": "0.0",
|
10
|
+
"_4": "10.0",
|
11
|
+
"_5": "1_000_000_000_000_000_000.0",
|
12
|
+
"_6": "true",
|
13
|
+
"_7": "FALSE",
|
14
|
+
"_8": "",
|
15
|
+
"_9": "string"
|
16
|
+
}
|
17
|
+
rate 1
|
18
|
+
</source>
|
19
|
+
|
20
|
+
<label @filter>
|
21
|
+
<filter **>
|
22
|
+
@type auto_typecast
|
23
|
+
</filter>
|
24
|
+
|
25
|
+
<match **>
|
26
|
+
@type relabel
|
27
|
+
@label @output
|
28
|
+
</match>
|
29
|
+
</label>
|
30
|
+
|
31
|
+
<label @output>
|
32
|
+
<match **>
|
33
|
+
@type stdout
|
34
|
+
</match>
|
35
|
+
</label>
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-auto-typecast-filter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shotaro Chiba
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-23 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.2
|
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.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.2.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.2.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fluentd
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.7.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.7.0
|
69
|
+
description: fluent-plugin-auto-typecast-filter
|
70
|
+
email:
|
71
|
+
- s@pws.jp
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- fluent-plugin-auto-typecast-filter.gemspec
|
82
|
+
- lib/fluent/plugin/filter_auto_typecast.rb
|
83
|
+
- lib/fluent/plugin/version.rb
|
84
|
+
- td-agent.conf
|
85
|
+
homepage: https://github.com/s5o-c/fluent-plugin-auto-typecast-filter
|
86
|
+
licenses: []
|
87
|
+
metadata:
|
88
|
+
homepage_uri: https://github.com/s5o-c/fluent-plugin-auto-typecast-filter
|
89
|
+
source_code_uri: https://github.com/s5o-c/fluent-plugin-auto-typecast-filter
|
90
|
+
changelog_uri: https://github.com/s5o-c/fluent-plugin-auto-typecast-filter
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubygems_version: 3.0.3
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: fluent-plugin-auto-typecast-filter
|
110
|
+
test_files: []
|