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 +4 -4
- data/.circleci/config.yml +18 -0
- data/.github/workflows/main.yml +13 -0
- data/Gemfile.lock +1 -1
- data/README.md +76 -19
- data/lib/fluent/plugin/filter_auto_typecast.rb +7 -4
- data/lib/fluent/plugin/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a797c907bfb0335e142e4e04a4836441b5499a6621ffaa3b2ab816f88644c528
|
4
|
+
data.tar.gz: 17969815535edceb9c46e14099bad3257b9c2fadaca764db3f502dce3ba85c0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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
|
-
|
3
|
+
This plug-in helps to automatically cast and retransmit structured log data flowing through the Fluent network.
|
4
4
|
|
5
|
-
|
5
|
+
## Tested dependencies
|
6
6
|
|
7
|
-
|
7
|
+
* fluentd v1.7.0
|
8
8
|
|
9
|
-
|
9
|
+
## Installation
|
10
10
|
|
11
|
-
```
|
12
|
-
gem
|
11
|
+
```sh
|
12
|
+
gem install fluent-plugin-auto-typecast-filter
|
13
13
|
```
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
$ bundle
|
15
|
+
or
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
24
|
+
Basic usage in fluentd.conf:
|
26
25
|
|
27
|
-
|
26
|
+
```
|
27
|
+
<filter any.tag.**>
|
28
|
+
@type auto_typecast
|
29
|
+
</filter>
|
30
|
+
```
|
28
31
|
|
29
|
-
|
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
|
-
|
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
|
-
##
|
89
|
+
## Copyright
|
34
90
|
|
35
|
-
|
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
|
-
|
71
|
+
if (! (@ignore_key_regexp && @ignore_key_regexp.match("#{k}")))
|
72
|
+
y = String("#{v}")
|
71
73
|
|
72
|
-
|
74
|
+
x[k] = y.to_numeric! if y.numeric?
|
73
75
|
|
74
|
-
|
76
|
+
x[k] = y.to_boolean! if y.boolean?
|
75
77
|
|
76
|
-
|
78
|
+
x[k] = y.to_nil! if y.nil?
|
79
|
+
end
|
77
80
|
|
78
81
|
auto_typecast(v, d.next)
|
79
82
|
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.
|
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
|