fluent-plugin-auto-typecast-filter 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6d7314f5466b3219331621cfccb3bdb34c4261b2dc7785ebf41ad7063e6fb93
4
- data.tar.gz: 83c23e1f56367963aaa9c5655ef2ef314386592e6fea913f2859b5cdf726758f
3
+ metadata.gz: a797c907bfb0335e142e4e04a4836441b5499a6621ffaa3b2ab816f88644c528
4
+ data.tar.gz: 17969815535edceb9c46e14099bad3257b9c2fadaca764db3f502dce3ba85c0d
5
5
  SHA512:
6
- metadata.gz: 418b2ce25db5cb35cc43c91c1bd099ad0b9d2029d888f1babef58cfa1f5e485562f25d42c4df0a0c931daf855dfde71ca72427164ed8a05896b8eadafb57d761
7
- data.tar.gz: e6f7614bce1469a9fc974abfedb48dd6bb90e3a85abb08ad7559aae4a1944edd5f35885bdf82fe6dd4a3eb92b0a0b3d7983fb17de4a4d24deef34e68c7a0710e
6
+ metadata.gz: 3e250bb54855c8702405215f80441a3a0b21bfa82322a47312c3d81b281d871b0560c008f6c5b06c169e883f3db372a03a5a4d19c9136d747fc258783db1eb8d
7
+ data.tar.gz: 551457d64e3431fb24fbb1f3560c86960e0b50bfcae1801132804eb417a4d004a8fc904c5391aa2bf0facd97ce98a74442d355df4e75b7dd657a2696f073c33c
@@ -0,0 +1,18 @@
1
+ version: 2.1
2
+ executors:
3
+ executor:
4
+ docker:
5
+ - image: circleci/ruby:2.6.3
6
+ jobs:
7
+ test:
8
+ executor: executor
9
+ steps:
10
+ - checkout
11
+ - run: gem install bundler -v 2.0.2
12
+ - run: bundle install --path vendor/bundle
13
+ - run: bundle exec rake test
14
+ workflows:
15
+ version: 2
16
+ continuous-integration:
17
+ jobs:
18
+ - test
@@ -0,0 +1,13 @@
1
+ name: continuous-integration
2
+ on: [push]
3
+ jobs:
4
+ build:
5
+ runs-on: ubuntu-latest
6
+ steps:
7
+ - uses: actions/checkout@v1
8
+ - uses: actions/setup-ruby@v1
9
+ with:
10
+ ruby-version: '2.6.3'
11
+ - run: gem install bundler -v 2.0.2
12
+ - run: bundle install --path vendor/
13
+ - run: bundle exec rake test
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-auto-typecast-filter (0.1.0)
4
+ fluent-plugin-auto-typecast-filter (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,35 +1,92 @@
1
- # Fluent::Plugin::AutoTypecastFilter
1
+ # Fluent::Plugin::AutoTypecastFilter [![CircleCI](https://circleci.com/gh/s5o-c/fluent-plugin-auto-typecast-filter/tree/master.svg?style=svg)](https://circleci.com/gh/s5o-c/fluent-plugin-auto-typecast-filter/tree/master) [![Gem Version](https://badge.fury.io/rb/fluent-plugin-auto-typecast-filter.svg)](https://badge.fury.io/rb/fluent-plugin-auto-typecast-filter)
2
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.
3
+ This plug-in helps to automatically cast and retransmit structured log data flowing through the Fluent network.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## Tested dependencies
6
6
 
7
- ## Installation
7
+ * fluentd v1.7.0
8
8
 
9
- Add this line to your application's Gemfile:
9
+ ## Installation
10
10
 
11
- ```ruby
12
- gem 'fluent-plugin-auto-typecast-filter'
11
+ ```sh
12
+ gem install fluent-plugin-auto-typecast-filter
13
13
  ```
14
14
 
15
- And then execute:
16
-
17
- $ bundle
15
+ or
18
16
 
19
- Or install it yourself as:
20
-
21
- $ gem install fluent-plugin-auto-typecast-filter
17
+ ```sh
18
+ # for `fluent-gem` users:
19
+ fluent-gem install fluent-plugin-auto-typecast-filter
20
+ ```
22
21
 
23
22
  ## Usage
24
23
 
25
- TODO: Write usage instructions here
24
+ Basic usage in fluentd.conf:
26
25
 
27
- ## Development
26
+ ```
27
+ <filter any.tag.**>
28
+ @type auto_typecast
29
+ </filter>
30
+ ```
28
31
 
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.
32
+ ## Parameters
33
+
34
+ | Parameter | Description | Type | Default |
35
+ ---|---|---|---
36
+ | `maxdepth` | Maximum level of nesting that is autocast. If **`0`** is specified, all nests are targeted. | Integer | `1` |
37
+ | `ignore_key_regexp` | Regular expression to determine keys that are not subject to processing. | RegExp | `nil` |
38
+
39
+ ## Examples
40
+
41
+ **Case 1:**
42
+
43
+ ```plain
44
+ # CONFIG:
45
+ maxdepth 0
46
+
47
+ # INPUT:
48
+ { 'k': { 'k': { 'k': [ { 'k': {
49
+ 'k0': 'string',
50
+ 'k1': '20',
51
+ 'k2': '1.0',
52
+ 'k3': 'NULL',
53
+ 'k4': 'true'
54
+ } } ] } } }
55
+
56
+ # FILTERED OUTPUT:
57
+ { 'k': { 'k': { 'k': [ { 'k': {
58
+ 'k0': 'string',
59
+ 'k1': 20,
60
+ 'k2': 1.0,
61
+ 'k3': null,
62
+ 'k4': true
63
+ } } ] } } }
64
+ ```
30
65
 
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).
66
+ **Case 2:**
67
+
68
+ ```plain
69
+ # CONFIG:
70
+ maxdepth 3
71
+
72
+ # INPUT:
73
+ { 'k' : {
74
+ 'k0': [ '10', '20', '30' ],
75
+ 'k1': {
76
+ 'k': [ '10', '20', '30' ]
77
+ }
78
+ }
79
+
80
+ # FILTERED OUTPUT:
81
+ { 'k' : {
82
+ 'k0': [ 10, 20, 30 ]
83
+ 'k1': {
84
+ 'k': [ '10', '20', '30' ]
85
+ }
86
+ }
87
+ ```
32
88
 
33
- ## Contributing
89
+ ## Copyright
34
90
 
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.
91
+ * Copyright (c) 2019- Shotaro Chiba
92
+ * Apache License, Version 2.0
@@ -50,6 +50,7 @@ module Fluent::Plugin
50
50
  Fluent::Plugin.register_filter('auto_typecast', self)
51
51
 
52
52
  config_param :maxdepth, :integer, default: DEFAULT_MAXDEPTH
53
+ config_param :ignore_key_regexp, :regexp, default: nil
53
54
 
54
55
  # def configure(conf)
55
56
  # super
@@ -67,13 +68,15 @@ module Fluent::Plugin
67
68
  # end
68
69
 
69
70
  private def transform(x, k, v, d)
70
- y = String("#{v}")
71
+ if (! (@ignore_key_regexp && @ignore_key_regexp.match("#{k}")))
72
+ y = String("#{v}")
71
73
 
72
- x[k] = y.to_numeric! if y.numeric?
74
+ x[k] = y.to_numeric! if y.numeric?
73
75
 
74
- x[k] = y.to_boolean! if y.boolean?
76
+ x[k] = y.to_boolean! if y.boolean?
75
77
 
76
- x[k] = y.to_nil! if y.nil?
78
+ x[k] = y.to_nil! if y.nil?
79
+ end
77
80
 
78
81
  auto_typecast(v, d.next)
79
82
  end
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
  module Plugin
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-auto-typecast-filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shotaro Chiba
@@ -73,6 +73,8 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".circleci/config.yml"
77
+ - ".github/workflows/main.yml"
76
78
  - ".gitignore"
77
79
  - Gemfile
78
80
  - Gemfile.lock