fluent-plugin-bunyan 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/CHANGELOG.md +41 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +46 -0
- data/LICENSE +21 -0
- data/README.md +44 -0
- data/Rakefile +13 -0
- data/azure-pipelines.yml +24 -0
- data/fluent-plugin-bunyan.gemspec +30 -0
- data/lib/fluent/plugin/parser_bunyan.rb +59 -0
- data/test/helper.rb +8 -0
- data/test/plugin/test_parser_bunyan.rb +110 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9c7ca077c27fc89eada5a3b8854ae9ac6b16a26503d73fa5690f4b8ed423d77c
|
4
|
+
data.tar.gz: 35fe59d48c1c8dabe0c22900ff203e46884fb0b21125e7a8799399b70f3a3fe8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4854c127c3a0903daa6b604f2b347c9bea23f9fe202fad1c10779b340efc177459cb34552f35a50c713f36241fd9e2204cd64bd7b55dcc75dd744cd5f876a86
|
7
|
+
data.tar.gz: 44b4796655c0985988e9683a71ce0a849c9cb4d45ad075267ff790f542bb7022c1c41b28690e47de42ac5c703a2a05b6dd6be69cb86102ee7e130c1d05bf4353
|
data/.gitignore
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
This file contains changes throughout the life of this project.
|
4
|
+
|
5
|
+
### Development
|
6
|
+
[Full Changelog](https://github.com/gildas/fluent-plugin-bunyan/compare/v0.0.4...dev)
|
7
|
+
|
8
|
+
New Features:
|
9
|
+
* None Yet
|
10
|
+
|
11
|
+
Bug Fixes:
|
12
|
+
* None Yet
|
13
|
+
|
14
|
+
### 0.0.4 / 2020-03-17
|
15
|
+
[Full Changelog](https://github.com/gildas/fluent-plugin-bunyan/compare/v0.0.3...v0.0.4)
|
16
|
+
|
17
|
+
Bug Fixes:
|
18
|
+
* JSON logs were not extracted properly when coming from Kubernetes
|
19
|
+
|
20
|
+
### 0.0.3 / 2020-03-15
|
21
|
+
[Full Changelog](https://github.com/gildas/fluent-plugin-bunyan/compare/v0.0.2...v0.0.3)
|
22
|
+
|
23
|
+
New Features:
|
24
|
+
* Not exactly a feature, but tests go through Azure Pipeline
|
25
|
+
|
26
|
+
Bug Fixes:
|
27
|
+
* Removed the requirement of rake version as per gem build warning
|
28
|
+
* The Fluent parser was not "required" properly besides tests passing
|
29
|
+
* License was still Apache on the README file
|
30
|
+
|
31
|
+
### 0.0.2 / 2020-03-10
|
32
|
+
[Full Changelog](https://github.com/gildas/fluent-plugin-bunyan/compare/v0.0.1...v0.0.2)
|
33
|
+
|
34
|
+
Bug Fixes:
|
35
|
+
* The GEM spec requires rake version 12.3.3 at least.
|
36
|
+
There is a vulnerability before rake 12.3.3: [CVE-2020-8130](https://github.com/advisories/GHSA-jppv-gw3r-w3q8).
|
37
|
+
We just should be on the safe side...
|
38
|
+
|
39
|
+
### 0.0.1 / 2020-03-10
|
40
|
+
|
41
|
+
Initial Release
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fluent-plugin-bunyan (0.0.4)
|
5
|
+
fluentd (>= 0.14.10, < 2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
concurrent-ruby (1.1.6)
|
11
|
+
cool.io (1.6.0)
|
12
|
+
fluentd (1.9.3)
|
13
|
+
cool.io (>= 1.4.5, < 2.0.0)
|
14
|
+
http_parser.rb (>= 0.5.1, < 0.7.0)
|
15
|
+
msgpack (>= 1.3.1, < 2.0.0)
|
16
|
+
serverengine (>= 2.0.4, < 3.0.0)
|
17
|
+
sigdump (~> 0.2.2)
|
18
|
+
strptime (>= 0.2.2, < 1.0.0)
|
19
|
+
tzinfo (>= 1.0, < 3.0)
|
20
|
+
tzinfo-data (~> 1.0)
|
21
|
+
yajl-ruby (~> 1.0)
|
22
|
+
http_parser.rb (0.6.0)
|
23
|
+
msgpack (1.3.3)
|
24
|
+
power_assert (0.2.7)
|
25
|
+
serverengine (2.2.1)
|
26
|
+
sigdump (~> 0.2.2)
|
27
|
+
sigdump (0.2.4)
|
28
|
+
strptime (0.2.3)
|
29
|
+
test-unit (3.2.5)
|
30
|
+
power_assert
|
31
|
+
tzinfo (2.0.1)
|
32
|
+
concurrent-ruby (~> 1.0)
|
33
|
+
tzinfo-data (1.2019.3)
|
34
|
+
tzinfo (>= 1.0.0)
|
35
|
+
yajl-ruby (1.4.1)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
bundler (~> 1.14)
|
42
|
+
fluent-plugin-bunyan!
|
43
|
+
test-unit (~> 3.0)
|
44
|
+
|
45
|
+
BUNDLED WITH
|
46
|
+
1.16.1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Gildas Cherruel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# fluent-plugin-bunyan
|
2
|
+
|
3
|
+
[Fluentd](https://fluentd.org/) parser plugin to process logs from applications that write [bunyan](https://github.com/gildas/go-logger/blob/master/trentm/node-bunyan) logs.
|
4
|
+
|
5
|
+
The plugin requires [Fluentd](https://fluentd.org/) 1.0 at least.
|
6
|
+
|
7
|
+
| | |
|
8
|
+
---|---|
|
9
|
+
master | [![Build Status](https://dev.azure.com/keltiek/gildas/_apis/build/status/gildas.fluent-plugin-bunyan?branchName=master)](https://dev.azure.com/keltiek/gildas/_build/latest?definitionId=4&branchName=master)
|
10
|
+
dev | [![Build Status](https://dev.azure.com/keltiek/gildas/_apis/build/status/gildas.fluent-plugin-bunyan?branchName=dev)](https://dev.azure.com/keltiek/gildas/_build/latest?definitionId=4&branchName=dev)
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Pretty straight forward:
|
15
|
+
```console
|
16
|
+
$ gem install fluent-plugin-bunyan
|
17
|
+
```
|
18
|
+
|
19
|
+
## Configuration
|
20
|
+
|
21
|
+
Simply add the parser to the [Fluentd](https://fluentd.org/) configuration file, for example:
|
22
|
+
|
23
|
+
```xml
|
24
|
+
<source>
|
25
|
+
@type tail # say the logs come from stdout
|
26
|
+
<parse>
|
27
|
+
@type bunyan
|
28
|
+
</parse>
|
29
|
+
</source>
|
30
|
+
```
|
31
|
+
|
32
|
+
## Testing
|
33
|
+
|
34
|
+
To run the unit tests, make sure you have the [Fluentd](https://fluentd.org/) gem installed and run:
|
35
|
+
|
36
|
+
```console
|
37
|
+
rake test
|
38
|
+
```
|
39
|
+
|
40
|
+
## Copyright
|
41
|
+
|
42
|
+
* Copyright(c) 2020- Gildas Cherruel
|
43
|
+
* License
|
44
|
+
* MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "bundler"
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs.push("lib", "test")
|
8
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
9
|
+
t.verbose = true
|
10
|
+
t.warning = true
|
11
|
+
end
|
12
|
+
|
13
|
+
task default: [:test]
|
data/azure-pipelines.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Ruby
|
2
|
+
# Package your Ruby project.
|
3
|
+
# Add steps that install rails, analyze code, save build artifacts, deploy, and more:
|
4
|
+
# https://docs.microsoft.com/azure/devops/pipelines/languages/ruby
|
5
|
+
|
6
|
+
trigger:
|
7
|
+
- master
|
8
|
+
- dev
|
9
|
+
|
10
|
+
pool:
|
11
|
+
vmImage: 'ubuntu-latest'
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- task: UseRubyVersion@0
|
15
|
+
inputs:
|
16
|
+
versionSpec: '>= 2.5'
|
17
|
+
|
18
|
+
- script: |
|
19
|
+
gem install bundler -v 1.16.1
|
20
|
+
bundle install --retry=3 --jobs=4
|
21
|
+
displayName: 'bundle install'
|
22
|
+
|
23
|
+
- script: rake test
|
24
|
+
displayName: 'run tests'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "fluent-plugin-bunyan"
|
6
|
+
spec.version = "0.0.4"
|
7
|
+
spec.authors = ["Gildas Cherruel"]
|
8
|
+
spec.email = ["gildas@breizh.org"]
|
9
|
+
|
10
|
+
spec.summary = %q{Fluentd Parser for applications that produce [Bunyan](https://github.com/trentm/node-bunyan) logs.}
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.homepage = "https://github.com/gildas/fluent-plugin-bunyan"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/gildas/fluent-plugin-bunyan/blob/master/CHANGELOG.md"
|
18
|
+
|
19
|
+
test_files, files = `git ls-files -z`.split("\x0").partition do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.files = files
|
23
|
+
spec.executables = files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
|
+
spec.test_files = test_files
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
28
|
+
spec.add_development_dependency "test-unit", "~> 3.0"
|
29
|
+
spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
|
30
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2020- Gildas Cherruel
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require "fluent/parser"
|
17
|
+
|
18
|
+
module Fluent
|
19
|
+
module Plugin
|
20
|
+
class BunyanParser < JSONParser
|
21
|
+
Fluent::Plugin.register_parser("bunyan", self)
|
22
|
+
|
23
|
+
def configure(conf)
|
24
|
+
conf["time_format"] = "%iso8601"
|
25
|
+
super(conf)
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse(text)
|
29
|
+
# Example of a log line we want to get stuff from:
|
30
|
+
# 2020-03-16T22:14:05.710251038+09:00 stdout F {"UserAgent":"kube-probe/1.17","hostname":"helloworld-go-helloworld-5649dfd7bd-k8954","level":30,"msg":"request start: GET /","name":"helloworld","pid":1,"remote":"10.1.10.1:60114","reqid":"e4745ed6-82d4-4013-aeda-1d02bef42331","scope":"/","tid":17,"time":"2020-03-16T13:14:05Z","topic":"route","v":0}
|
31
|
+
if text =~ /[^{]*({.*)/
|
32
|
+
super(text.sub(/[^{]*({.*)/, '\1')) do |time, record|
|
33
|
+
if record then
|
34
|
+
record["severity"] = severity(record["level"] || 0)
|
35
|
+
record["host"] = record.delete("hostname")
|
36
|
+
record["message"] = record.delete("msg")
|
37
|
+
|
38
|
+
record.delete("v")
|
39
|
+
end
|
40
|
+
yield time, record
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def severity(level)
|
46
|
+
return "fatal" if level >= 60
|
47
|
+
return "error" if level >= 50
|
48
|
+
return "warn" if level >= 40
|
49
|
+
return "info" if level >= 30
|
50
|
+
return "debug" if level >= 20
|
51
|
+
return "trace"
|
52
|
+
end
|
53
|
+
|
54
|
+
def version
|
55
|
+
return "0.0.4"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
|
2
|
+
require "test-unit"
|
3
|
+
require "fluent/test"
|
4
|
+
require "fluent/test/driver/parser"
|
5
|
+
require "fluent/test/helpers"
|
6
|
+
|
7
|
+
Test::Unit::TestCase.include(Fluent::Test::Helpers)
|
8
|
+
Test::Unit::TestCase.extend(Fluent::Test::Helpers)
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require "helper"
|
2
|
+
require "fluent/plugin/parser_bunyan.rb"
|
3
|
+
|
4
|
+
class BunyanParserTest < Test::Unit::TestCase
|
5
|
+
setup do
|
6
|
+
Fluent::Test.setup
|
7
|
+
end
|
8
|
+
|
9
|
+
CONFIG = %[
|
10
|
+
pattern apache
|
11
|
+
]
|
12
|
+
|
13
|
+
sub_test_case "parse" do
|
14
|
+
test "can parse simple entry" do
|
15
|
+
driver = create_driver(CONFIG)
|
16
|
+
text = '{"hostname":"helloworld-go-helloworld-5649dfd7bd-k8954","level":30,"msg":"The message","name":"helloworld","pid":1,"scope":"main","tid":1,"time":"2020-03-10T07:08:41Z","topic":"main","v":0}'
|
17
|
+
expected_time = Time.utc(2020, 3, 10, 7, 8, 41).to_i
|
18
|
+
expected_record = {
|
19
|
+
"host" => "helloworld-go-helloworld-5649dfd7bd-k8954",
|
20
|
+
"name" => "helloworld",
|
21
|
+
"severity" => "info",
|
22
|
+
"level" => 30,
|
23
|
+
"message" => "The message",
|
24
|
+
"topic" => "main",
|
25
|
+
"scope" => "main",
|
26
|
+
"pid" => 1,
|
27
|
+
"tid" => 1,
|
28
|
+
}
|
29
|
+
driver.instance.parse(text) do |time, record|
|
30
|
+
assert_equal(expected_record, record)
|
31
|
+
assert_equal(expected_time, time)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
test "can parse entry with custom properties" do
|
36
|
+
driver = create_driver(CONFIG)
|
37
|
+
text = '{"hostname":"helloworld-go-helloworld-5649dfd7bd-k8954","level":50,"msg":"Failed to be happy","name":"helloworld","pid":1,"reqid":"0ba850ff-1e1f-4bcf-8288-135927bb850f","scope":"start","tid":21,"time":"2020-03-10T15:04:19Z","topic":"server","v":0}'
|
38
|
+
expected_time = Time.utc(2020, 3, 10, 15, 4, 19).to_i
|
39
|
+
expected_record = {
|
40
|
+
"host" => "helloworld-go-helloworld-5649dfd7bd-k8954",
|
41
|
+
"name" => "helloworld",
|
42
|
+
"severity" => "error",
|
43
|
+
"level" => 50,
|
44
|
+
"message" => "Failed to be happy",
|
45
|
+
"topic" => "server",
|
46
|
+
"scope" => "start",
|
47
|
+
"pid" => 1,
|
48
|
+
"tid" => 21,
|
49
|
+
"reqid" => "0ba850ff-1e1f-4bcf-8288-135927bb850f",
|
50
|
+
}
|
51
|
+
driver.instance.parse(text) do |time, record|
|
52
|
+
assert_equal(expected_record, record)
|
53
|
+
assert_equal(expected_time, time)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
test "can parse entry with complex custom properties" do
|
58
|
+
driver = create_driver(CONFIG)
|
59
|
+
text = '{"hostname":"helloworld-go-helloworld-5649dfd7bd-k8954","level":50,"msg":"Failed to be happy","name":"helloworld","pid":1,"err":{"text": "aouch", "code": 404},"reqid":"0ba850ff-1e1f-4bcf-8288-135927bb850f","scope":"start","tid":21,"time":"2020-03-10T15:04:19Z","topic":"server","v":0}'
|
60
|
+
expected_time = Time.utc(2020, 3, 10, 15, 4, 19).to_i
|
61
|
+
expected_record = {
|
62
|
+
"host" => "helloworld-go-helloworld-5649dfd7bd-k8954",
|
63
|
+
"name" => "helloworld",
|
64
|
+
"severity" => "error",
|
65
|
+
"level" => 50,
|
66
|
+
"message" => "Failed to be happy",
|
67
|
+
"topic" => "server",
|
68
|
+
"scope" => "start",
|
69
|
+
"pid" => 1,
|
70
|
+
"tid" => 21,
|
71
|
+
"reqid" => "0ba850ff-1e1f-4bcf-8288-135927bb850f",
|
72
|
+
"err" => {
|
73
|
+
"code" => 404,
|
74
|
+
"text" => "aouch",
|
75
|
+
},
|
76
|
+
}
|
77
|
+
driver.instance.parse(text) do |time, record|
|
78
|
+
assert_equal(expected_record, record)
|
79
|
+
assert_equal(expected_time, time)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
test "can parse entry from Kubernetes" do
|
85
|
+
driver = create_driver(CONFIG)
|
86
|
+
text = '2020-03-10T07:08:41.710251038+09:00 stdout F {"hostname":"helloworld-go-helloworld-5649dfd7bd-k8954","level":30,"msg":"The message","name":"helloworld","pid":1,"scope":"main","tid":1,"time":"2020-03-10T07:08:41Z","topic":"main","v":0}'
|
87
|
+
expected_time = Time.utc(2020, 3, 10, 7, 8, 41).to_i
|
88
|
+
expected_record = {
|
89
|
+
"host" => "helloworld-go-helloworld-5649dfd7bd-k8954",
|
90
|
+
"name" => "helloworld",
|
91
|
+
"severity" => "info",
|
92
|
+
"level" => 30,
|
93
|
+
"message" => "The message",
|
94
|
+
"topic" => "main",
|
95
|
+
"scope" => "main",
|
96
|
+
"pid" => 1,
|
97
|
+
"tid" => 1,
|
98
|
+
}
|
99
|
+
driver.instance.parse(text) do |time, record|
|
100
|
+
assert_equal(expected_record, record)
|
101
|
+
assert_equal(expected_time, time)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def create_driver(conf = CONFIG)
|
108
|
+
Fluent::Test::Driver::Parser.new(Fluent::Plugin::BunyanParser).configure(conf)
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-bunyan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gildas Cherruel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-16 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: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fluentd
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.14.10
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '2'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 0.14.10
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2'
|
61
|
+
description: Fluentd Parser for applications that produce [Bunyan](https://github.com/trentm/node-bunyan)
|
62
|
+
logs.
|
63
|
+
email:
|
64
|
+
- gildas@breizh.org
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- ".gitignore"
|
70
|
+
- CHANGELOG.md
|
71
|
+
- Gemfile
|
72
|
+
- Gemfile.lock
|
73
|
+
- LICENSE
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- azure-pipelines.yml
|
77
|
+
- fluent-plugin-bunyan.gemspec
|
78
|
+
- lib/fluent/plugin/parser_bunyan.rb
|
79
|
+
- test/helper.rb
|
80
|
+
- test/plugin/test_parser_bunyan.rb
|
81
|
+
homepage: https://github.com/gildas/fluent-plugin-bunyan
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata:
|
85
|
+
homepage_uri: https://github.com/gildas/fluent-plugin-bunyan
|
86
|
+
source_code_uri: https://github.com/gildas/fluent-plugin-bunyan
|
87
|
+
changelog_uri: https://github.com/gildas/fluent-plugin-bunyan/blob/master/CHANGELOG.md
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.7.6
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Fluentd Parser for applications that produce [Bunyan](https://github.com/trentm/node-bunyan)
|
108
|
+
logs.
|
109
|
+
test_files:
|
110
|
+
- test/helper.rb
|
111
|
+
- test/plugin/test_parser_bunyan.rb
|