fluent-plugin-jq 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/Gemfile.lock +24 -5
- data/Makefile +2 -1
- data/README.md +81 -13
- data/example/fluent.conf +7 -2
- data/fluent-plugin-jq.gemspec +6 -3
- data/lib/fluent/plugin/filter_jq_transformer.rb +51 -0
- data/lib/fluent/plugin/formatter_jq.rb +16 -10
- data/test/helper.rb +3 -1
- data/test/plugin/test_filter_jq_transformer.rb +70 -0
- data/test/plugin/test_formatter_jq.rb +10 -9
- metadata +38 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24f79462819d358078a156e8ea375770075384849193ceff156938a397c9ef34
|
4
|
+
data.tar.gz: acdb2479ecd7c5a5d2d8baededdb5c11895454628ff1eb2bd2febf5363d64505
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 454db6f7ed58a47f1c4b6fa280793b06b4b8d6e898e3905aba79fb6fa184787f40f9bd475284e9e7d8ee26cf8cf1c13da2d96dc11465327f732cd6f35207f090
|
7
|
+
data.tar.gz: 7b6d295570fe9f509e0534e2ac2bc57c3cedf6e81b86fffc1960cf814f1e16e27c3d66d3418c7924f7c3c71af5eeba6e67b87f7587956ea82f059a4bac9b1ff1
|
data/CHANGES.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-jq (0.
|
4
|
+
fluent-plugin-jq (0.2.0)
|
5
5
|
fluentd (>= 0.14.10, < 2)
|
6
|
+
multi_json (~> 1.13)
|
6
7
|
ruby-jq (~> 0.1)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
10
11
|
specs:
|
11
12
|
cool.io (1.5.3)
|
13
|
+
coveralls (0.8.21)
|
14
|
+
json (>= 1.8, < 3)
|
15
|
+
simplecov (~> 0.14.1)
|
16
|
+
term-ansicolor (~> 1.3)
|
17
|
+
thor (~> 0.19.4)
|
18
|
+
tins (~> 1.6)
|
12
19
|
dig_rb (1.0.1)
|
20
|
+
docile (1.1.5)
|
13
21
|
fluentd (1.1.0)
|
14
22
|
cool.io (>= 1.4.5, < 2.0.0)
|
15
23
|
dig_rb (~> 1.0.0)
|
@@ -22,7 +30,8 @@ GEM
|
|
22
30
|
tzinfo-data (~> 1.0)
|
23
31
|
yajl-ruby (~> 1.0)
|
24
32
|
http_parser.rb (0.6.0)
|
25
|
-
|
33
|
+
json (2.1.0)
|
34
|
+
msgpack (1.2.4)
|
26
35
|
multi_json (1.13.1)
|
27
36
|
power_assert (1.1.1)
|
28
37
|
rake (12.3.0)
|
@@ -31,13 +40,22 @@ GEM
|
|
31
40
|
serverengine (2.0.6)
|
32
41
|
sigdump (~> 0.2.2)
|
33
42
|
sigdump (0.2.4)
|
43
|
+
simplecov (0.14.1)
|
44
|
+
docile (~> 1.1.0)
|
45
|
+
json (>= 1.8, < 3)
|
46
|
+
simplecov-html (~> 0.10.0)
|
47
|
+
simplecov-html (0.10.2)
|
34
48
|
strptime (0.2.3)
|
49
|
+
term-ansicolor (1.6.0)
|
50
|
+
tins (~> 1.0)
|
35
51
|
test-unit (3.2.7)
|
36
52
|
power_assert
|
53
|
+
thor (0.19.4)
|
37
54
|
thread_safe (0.3.6)
|
38
|
-
|
55
|
+
tins (1.16.3)
|
56
|
+
tzinfo (1.2.5)
|
39
57
|
thread_safe (~> 0.1)
|
40
|
-
tzinfo-data (1.
|
58
|
+
tzinfo-data (1.2018.3)
|
41
59
|
tzinfo (>= 1.0.0)
|
42
60
|
yajl-ruby (1.3.1)
|
43
61
|
|
@@ -46,9 +64,10 @@ PLATFORMS
|
|
46
64
|
|
47
65
|
DEPENDENCIES
|
48
66
|
bundler (~> 1.14)
|
67
|
+
coveralls (~> 0.8)
|
49
68
|
fluent-plugin-jq!
|
50
69
|
rake (~> 12.0)
|
51
70
|
test-unit (~> 3.0)
|
52
71
|
|
53
72
|
BUNDLED WITH
|
54
|
-
1.16.
|
73
|
+
1.16.1
|
data/Makefile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,18 @@
|
|
1
|
-
# fluent-plugin-jq
|
1
|
+
# fluent-plugin-jq
|
2
2
|
|
3
|
-
[
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/fluent-plugin-jq.svg)](https://badge.fury.io/rb/fluent-plugin-jq)
|
4
|
+
[![Build Status](https://travis-ci.org/Gimi/fluent-plugin-jq.svg?branch=master)](https://travis-ci.org/Gimi/fluent-plugin-jq)
|
5
|
+
|
6
|
+
A collection of [Fluentd](https://fluentd.org/) plugins use [jq](https://stedolan.github.io/jq/). It now contains two plugins:
|
7
|
+
* `jq` formatter - a formatter plugin formats inputs using jq filters.
|
8
|
+
* `jq_transformer` - a filter plugin transform inputs.
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
12
|
+
See also: [Plugin Management](https://docs.fluentd.org/v1.0/articles/plugin-management).
|
13
|
+
|
14
|
+
Before you install this plugin, please make sure that `libjq` has been installed on your machine. For example, it's called `jq-dev` on alpine linux; while on debian, and ubuntu, you will find it as the `libjq-dev` package.
|
15
|
+
|
7
16
|
### RubyGems
|
8
17
|
|
9
18
|
```
|
@@ -26,11 +35,45 @@ $ bundle
|
|
26
35
|
|
27
36
|
## Configuration
|
28
37
|
|
29
|
-
|
38
|
+
See also: [Output Plugin Overview](https://docs.fluentd.org/v1.0/articles/output-plugin-overview).
|
39
|
+
|
40
|
+
### `jq` Formatter
|
41
|
+
|
42
|
+
#### Example
|
43
|
+
|
44
|
+
```
|
45
|
+
<match **>
|
46
|
+
@type stdout
|
47
|
+
<format>
|
48
|
+
@type jq
|
49
|
+
jq '"\(.time | todate) [\(.logLevel | ascii_upcase)] \(.log)"'
|
50
|
+
</format>
|
51
|
+
</match>
|
52
|
+
```
|
53
|
+
|
54
|
+
In the example above, it will format the input with the jq filter specified in the `jq` parameter before sendint it to stdout. For example, given an input like
|
55
|
+
|
56
|
+
```javascript
|
57
|
+
{"time": 1520030594, "logLevel": "info", "log": "this is an example."}
|
58
|
+
```
|
59
|
+
|
60
|
+
What will be printed in stdout is
|
61
|
+
|
62
|
+
```
|
63
|
+
2018-03-02T22:43:14Z [INFO] this is an example.
|
64
|
+
```
|
65
|
+
|
66
|
+
#### Parameters
|
30
67
|
|
31
|
-
|
68
|
+
##### @type (string) (required)
|
32
69
|
|
33
|
-
|
70
|
+
This must be `jq`.
|
71
|
+
|
72
|
+
##### jq (string) (required)
|
73
|
+
|
74
|
+
The jq filter for formatting income events. The result of the program should only return one item of any kind (a string, an array, an object, etc.). If it returns multiple items, only the first will be used.
|
75
|
+
|
76
|
+
##### on_error (enum) (optional)
|
34
77
|
|
35
78
|
Defines the behavior on error happens when formatting an event. "skip" will skip the event; "ignore" will ignore the error and return the JSON representation of the original event; "raise_error" will raise a RuntimeError.
|
36
79
|
|
@@ -38,24 +81,49 @@ Available values: skip, ignore, raise_error
|
|
38
81
|
|
39
82
|
Default value: `ignore`.
|
40
83
|
|
41
|
-
###
|
84
|
+
### `jq_transformer` Filter
|
85
|
+
|
86
|
+
#### Example
|
87
|
+
|
88
|
+
```
|
89
|
+
<filter **>
|
90
|
+
@type jq_transformer
|
91
|
+
jq .record + {time, tag}
|
92
|
+
</filter>
|
93
|
+
```
|
94
|
+
|
95
|
+
The above example will transform the input event (the record) by adding two more fields: `time` (the event time from fluentd) and `tag` (the event tag), to it. For example, given an input event like:
|
42
96
|
|
97
|
+
```javascript
|
98
|
+
{"logLevel": "info", "log": "this is an example."}
|
43
99
|
```
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
100
|
+
|
101
|
+
with tag = `"some.tag"` and time = `1520030594`. Then the new event will like
|
102
|
+
|
103
|
+
```javascript
|
104
|
+
{"logLevel": "info", "log": "this is an example.", "time": 1520030594, "tag": "some.tag"}
|
49
105
|
```
|
50
106
|
|
51
|
-
|
107
|
+
#### Parameters
|
108
|
+
|
109
|
+
##### @type (string) (required)
|
110
|
+
|
111
|
+
This must be `jq_transformer`.
|
112
|
+
|
113
|
+
##### jq (string) (required)
|
114
|
+
|
115
|
+
The jq filter used to transform the input. The result of the filter should return an object. If after applying the transforming the new event is not an object (a hash), the event will be dropped.
|
116
|
+
|
117
|
+
### Built-in Example
|
118
|
+
|
119
|
+
Once you clone the project from github, you can run the following commands to see a real example for the plugins.
|
52
120
|
|
53
121
|
```
|
54
122
|
$ rake build_example
|
55
123
|
$ rake run_example
|
56
124
|
```
|
57
125
|
|
58
|
-
|
126
|
+
The above commands will build the example to a docker image, and run it. You can run `$ rake rm_example` to delete the image afterward.
|
59
127
|
|
60
128
|
## Copyright
|
61
129
|
|
data/example/fluent.conf
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
<source>
|
2
2
|
@type dummy
|
3
3
|
tag dummy
|
4
|
-
dummy {"
|
4
|
+
dummy {"log": "everything goes well", "stream": "stdout"}
|
5
5
|
</source>
|
6
6
|
|
7
|
+
<filter dummy>
|
8
|
+
@type jq_transformer
|
9
|
+
jq .record + {tag, time}
|
10
|
+
</filter>
|
11
|
+
|
7
12
|
<match dummy>
|
8
13
|
@type stdout
|
9
14
|
<format>
|
10
15
|
@type jq
|
11
|
-
|
16
|
+
jq '"\(.time | todate) [\(.tag)] \(.stream) => \(.log)"'
|
12
17
|
</format>
|
13
18
|
</match>
|
data/fluent-plugin-jq.gemspec
CHANGED
@@ -3,12 +3,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-jq"
|
6
|
-
spec.version = "0.
|
6
|
+
spec.version = "0.2.0"
|
7
7
|
spec.authors = ["Zhimin (Gimi) Liang"]
|
8
8
|
spec.email = ["liang.gimi@gmail.com"]
|
9
9
|
|
10
|
-
spec.summary = %q{Fluentd
|
11
|
-
spec.description = %q{
|
10
|
+
spec.summary = %q{Fluentd plugins uses the jq engine.}
|
11
|
+
spec.description = %q{fluent-plungin-jq is a collection of fluentd plugins which uses the jq engine to transform or format fluentd events.}
|
12
12
|
spec.homepage = "https://github.com/Gimi/fluent-plugin-jq"
|
13
13
|
spec.license = "Apache-2.0"
|
14
14
|
|
@@ -21,6 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.14"
|
22
22
|
spec.add_development_dependency "rake", "~> 12.0"
|
23
23
|
spec.add_development_dependency "test-unit", "~> 3.0"
|
24
|
+
spec.add_development_dependency "coveralls", "~> 0.8"
|
25
|
+
|
24
26
|
spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
|
25
27
|
spec.add_runtime_dependency "ruby-jq", "~> 0.1"
|
28
|
+
spec.add_runtime_dependency "multi_json", "~> 1.13"
|
26
29
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2018- Zhimin (Gimi) Liang (https://github.com/Gimi)
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "fluent/plugin/filter"
|
18
|
+
|
19
|
+
module Fluent
|
20
|
+
module Plugin
|
21
|
+
class JqTransformerFilter < Fluent::Plugin::Filter
|
22
|
+
Fluent::Plugin.register_filter("jq_transformer", self)
|
23
|
+
|
24
|
+
desc 'The jq filter used to transform the input. The result of the filter should return an object.'
|
25
|
+
config_param :jq, :string
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
super
|
29
|
+
require "jq"
|
30
|
+
end
|
31
|
+
|
32
|
+
def configure(conf)
|
33
|
+
super
|
34
|
+
JQ::Core.new @jq
|
35
|
+
rescue JQ::Error
|
36
|
+
raise Fluent::ConfigError, "Could not parse jq filter: #{@jq}, error: #{$!.message}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def filter(tag, time, record)
|
40
|
+
new_record = JQ(MultiJson.dump(tag: tag, time: time, record: record)).search(@jq).first
|
41
|
+
return new_record if new_record.is_a?(Hash)
|
42
|
+
|
43
|
+
log.error "jq filter #{@jq} did not return a hash, skip this record."
|
44
|
+
nil
|
45
|
+
rescue JQ::Error
|
46
|
+
log.error "Failed to transform #{MultiJson.dump record} with #{@jq}, error: #{$!.message}"
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
# Copyright 2018- Zhimin (Gimi) Liang (https://github.com/Gimi)
|
3
4
|
#
|
4
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -18,12 +19,13 @@ require "fluent/plugin/formatter"
|
|
18
19
|
module Fluent
|
19
20
|
module Plugin
|
20
21
|
class JqFormatter < Fluent::Plugin::Formatter
|
21
|
-
EMPTY_STRING = ''.freeze
|
22
|
-
|
23
22
|
Fluent::Plugin.register_formatter("jq", self)
|
24
23
|
|
25
24
|
desc 'The jq program used to format income events. The result of the program should only return one item of any kind (a string, an array, an object, etc.). If it returns multiple items, only the first will be used.'
|
26
|
-
config_param :
|
25
|
+
config_param :jq, :string, default: nil
|
26
|
+
|
27
|
+
desc 'The jq program used to format income events. The result of the program should only return one item of any kind (a string, an array, an object, etc.). If it returns multiple items, only the first will be used. DEPRECATED.'
|
28
|
+
config_param :jq_program, :string, deprecated: 'use jq instead.', default: nil
|
27
29
|
|
28
30
|
desc 'Defines the behavior on error happens when formatting an event. "skip" will skip the event; "ignore" will ignore the error and return the JSON representation of the original event; "raise_error" will raise a RuntimeError.'
|
29
31
|
config_param :on_error, :enum, list: [:skip, :ignore, :raise_error], default: :ignore
|
@@ -35,21 +37,25 @@ module Fluent
|
|
35
37
|
|
36
38
|
def configure(conf)
|
37
39
|
super
|
38
|
-
|
40
|
+
|
41
|
+
@jq = @jq_program unless @jq
|
42
|
+
raise Fluent::ConfigError, "jq is required." unless @jq
|
43
|
+
|
44
|
+
JQ::Core.new @jq
|
39
45
|
rescue JQ::Error
|
40
|
-
raise Fluent::ConfigError, "Could not parse
|
46
|
+
raise Fluent::ConfigError, "Could not parse jq filter #{@jq}, error: #{$!.message}"
|
41
47
|
end
|
42
48
|
|
43
49
|
def format(tag, time, record)
|
44
|
-
item = JQ(record
|
50
|
+
item = JQ(MultiJson.dump(record)).search(@jq).first
|
45
51
|
return item if item.instance_of?(String)
|
46
|
-
item
|
52
|
+
MultiJson.dump item
|
47
53
|
rescue JQ::Error
|
48
|
-
msg = "Failed to format #{record.to_json} with #{@
|
54
|
+
msg = "Failed to format #{record.to_json} with #{@jq}, error: #{$!.message}"
|
49
55
|
log.error msg
|
50
56
|
case @on_error
|
51
57
|
when :skip
|
52
|
-
return
|
58
|
+
return ''
|
53
59
|
when :ignore
|
54
60
|
return record.to_json
|
55
61
|
when :raise_error
|
data/test/helper.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
|
2
2
|
require "test-unit"
|
3
3
|
require "fluent/test"
|
4
|
-
require "fluent/test/driver/formatter"
|
5
4
|
require "fluent/test/helpers"
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
Coveralls.wear!
|
6
8
|
|
7
9
|
Test::Unit::TestCase.include(Fluent::Test::Helpers)
|
8
10
|
Test::Unit::TestCase.extend(Fluent::Test::Helpers)
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "helper"
|
4
|
+
require "fluent/test/driver/filter"
|
5
|
+
require "fluent/plugin/filter_jq_transformer"
|
6
|
+
|
7
|
+
class JqTransformerFilterTest < Test::Unit::TestCase
|
8
|
+
setup do
|
9
|
+
Fluent::Test.setup
|
10
|
+
end
|
11
|
+
|
12
|
+
test "it should require jq" do
|
13
|
+
assert_raise(Fluent::ConfigError) { create_driver '' }
|
14
|
+
end
|
15
|
+
|
16
|
+
test "it should raise error on invalid jq program" do
|
17
|
+
e = assert_raise(Fluent::ConfigError) { create_driver 'jq blah' }
|
18
|
+
assert_match(/compile error/, e.message)
|
19
|
+
end
|
20
|
+
|
21
|
+
test "it should work on tag" do
|
22
|
+
d = create_driver 'jq "{tag}"'
|
23
|
+
record = {"log" => "this is a log", "source" => "stdout"}
|
24
|
+
record = d.instance.filter("some.tag", event_time, record)
|
25
|
+
assert_equal record["tag"], "some.tag"
|
26
|
+
end
|
27
|
+
|
28
|
+
test "it should work on time" do
|
29
|
+
d = create_driver 'jq "{time: .time | gmtime }"'
|
30
|
+
now = event_time
|
31
|
+
record = {"log" => "this is a log", "source" => "stdout"}
|
32
|
+
record = d.instance.filter("some.tag", now, record)
|
33
|
+
assert_equal record["time"][0..5],
|
34
|
+
Time.at(now).utc.to_a[0..5].reverse.tap { |a| a[1] = a[1] - 1 }
|
35
|
+
end
|
36
|
+
|
37
|
+
test "it should work on record" do
|
38
|
+
d = create_driver 'jq "{message: .record.log, stream: .record.source}"'
|
39
|
+
record = {"log" => "this is a log", "source" => "stdout"}
|
40
|
+
record = d.instance.filter("some.tag", event_time, record)
|
41
|
+
assert_equal record["message"], "this is a log"
|
42
|
+
assert_equal record["stream"], "stdout"
|
43
|
+
end
|
44
|
+
|
45
|
+
test "it should skip if it does not return a hash" do
|
46
|
+
record = {"log" => "this is a log", "source" => "stdout"}
|
47
|
+
|
48
|
+
d = create_driver 'jq ".tag"'
|
49
|
+
assert_nil d.instance.filter("some.tag", event_time, record)
|
50
|
+
|
51
|
+
d = create_driver 'jq ".time"'
|
52
|
+
assert_nil d.instance.filter("some.tag", event_time, record)
|
53
|
+
|
54
|
+
d = create_driver 'jq "[.time]"'
|
55
|
+
assert_nil d.instance.filter("some.tag", event_time, record)
|
56
|
+
end
|
57
|
+
|
58
|
+
test "it should only return one object" do
|
59
|
+
d = create_driver 'jq ".record, {tag, time}"'
|
60
|
+
event = {"log" => "this is a log", "source" => "stdout"}
|
61
|
+
record = d.instance.filter("some.tag", event_time, event)
|
62
|
+
assert_equal event, record
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def create_driver(conf)
|
68
|
+
Fluent::Test::Driver::Filter.new(Fluent::Plugin::JqTransformerFilter).configure(conf)
|
69
|
+
end
|
70
|
+
end
|
@@ -1,43 +1,44 @@
|
|
1
1
|
require "helper"
|
2
|
-
require "fluent/
|
2
|
+
require "fluent/test/driver/formatter"
|
3
|
+
require "fluent/plugin/formatter_jq"
|
3
4
|
|
4
5
|
class JqFormatterTest < Test::Unit::TestCase
|
5
6
|
setup do
|
6
7
|
Fluent::Test.setup
|
7
8
|
end
|
8
9
|
|
9
|
-
test "it should require
|
10
|
+
test "it should require jq parameter" do
|
10
11
|
assert_raise(Fluent::ConfigError) { create_driver '' }
|
11
12
|
end
|
12
13
|
|
13
|
-
test "it should raise error on invalid jq
|
14
|
-
e = assert_raise(Fluent::ConfigError) { create_driver '
|
15
|
-
assert_match
|
14
|
+
test "it should raise error on invalid jq parameter" do
|
15
|
+
e = assert_raise(Fluent::ConfigError) { create_driver 'jq blah' }
|
16
|
+
assert_match(/compile error/, e.message)
|
16
17
|
end
|
17
18
|
|
18
19
|
test "it should work" do
|
19
|
-
d = create_driver '
|
20
|
+
d = create_driver 'jq .log'
|
20
21
|
record = {"log" => "this is a log", "source" => "stdout"}
|
21
22
|
text = d.instance.format("some.tag", event_time, record)
|
22
23
|
assert_equal record["log"], text
|
23
24
|
end
|
24
25
|
|
25
26
|
test "it should ignore error by default" do
|
26
|
-
d = create_driver '
|
27
|
+
d = create_driver 'jq .[1]'
|
27
28
|
record = {"log" => "some message"}
|
28
29
|
text = d.instance.format "some.tag", event_time, record
|
29
30
|
assert_equal record.to_json, text
|
30
31
|
end
|
31
32
|
|
32
33
|
test "it can skip on error" do
|
33
|
-
d = create_driver "
|
34
|
+
d = create_driver "jq .[1]\non_error skip"
|
34
35
|
record = {"log" => "some message"}
|
35
36
|
text = d.instance.format "some.tag", event_time, record
|
36
37
|
assert_equal '', text
|
37
38
|
end
|
38
39
|
|
39
40
|
test "it can raise error on error" do
|
40
|
-
d = create_driver "
|
41
|
+
d = create_driver "jq .[1]\non_error raise_error"
|
41
42
|
record = {"log" => "some message"}
|
42
43
|
assert_raise(RuntimeError) {
|
43
44
|
d.instance.format "some.tag", event_time, record
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-jq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zhimin (Gimi) Liang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: fluentd
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,13 +100,29 @@ dependencies:
|
|
86
100
|
- - "~>"
|
87
101
|
- !ruby/object:Gem::Version
|
88
102
|
version: '0.1'
|
89
|
-
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: multi_json
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.13'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '1.13'
|
117
|
+
description: fluent-plungin-jq is a collection of fluentd plugins which uses the jq
|
118
|
+
engine to transform or format fluentd events.
|
90
119
|
email:
|
91
120
|
- liang.gimi@gmail.com
|
92
121
|
executables: []
|
93
122
|
extensions: []
|
94
123
|
extra_rdoc_files: []
|
95
124
|
files:
|
125
|
+
- CHANGES.md
|
96
126
|
- Gemfile
|
97
127
|
- Gemfile.lock
|
98
128
|
- LICENSE
|
@@ -102,9 +132,11 @@ files:
|
|
102
132
|
- example/Dockerfile
|
103
133
|
- example/fluent.conf
|
104
134
|
- fluent-plugin-jq.gemspec
|
135
|
+
- lib/fluent/plugin/filter_jq_transformer.rb
|
105
136
|
- lib/fluent/plugin/formatter_jq.rb
|
106
137
|
- run_ci.sh
|
107
138
|
- test/helper.rb
|
139
|
+
- test/plugin/test_filter_jq_transformer.rb
|
108
140
|
- test/plugin/test_formatter_jq.rb
|
109
141
|
homepage: https://github.com/Gimi/fluent-plugin-jq
|
110
142
|
licenses:
|
@@ -126,10 +158,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
158
|
version: '0'
|
127
159
|
requirements: []
|
128
160
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.7.
|
161
|
+
rubygems_version: 2.7.6
|
130
162
|
signing_key:
|
131
163
|
specification_version: 4
|
132
|
-
summary: Fluentd
|
164
|
+
summary: Fluentd plugins uses the jq engine.
|
133
165
|
test_files:
|
134
166
|
- test/helper.rb
|
167
|
+
- test/plugin/test_filter_jq_transformer.rb
|
135
168
|
- test/plugin/test_formatter_jq.rb
|