fluent-plugin-gelf-best 1.4.1 → 1.5.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 +4 -4
- data/README.md +33 -5
- data/lib/fluent/plugin/formatter_gelf.rb +21 -32
- data/lib/fluent/plugin/gelf_plugin_util.rb +11 -7
- data/lib/fluent/plugin/out_gelf.rb +4 -6
- metadata +11 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f9741e4441ef5a4215766b19e56e248eaf3ed9cb5607b9972aaefee1a1c9ac0a
|
|
4
|
+
data.tar.gz: 1682a0cd4f716e8d693051c16256ecb6b68573ecf5ec5e718898f53a4cf3a63c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84aea4e3127272dfdcc7350160c244dee9a5eac9ecf8b500ae128dd6949373bb11b11fdc4dced1f3cc1497d26e5f8481867fd02eaaef50da344bdcd9d3dfca62
|
|
7
|
+
data.tar.gz: 1e489983a1df878009a64e2e07ef2b1163e5a3f45d57a340ebd3987977fb53800a32a5c9ea9a7248fe0fc396cffbdabd68faa93c0f40de184322b7c64a708322
|
data/README.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
# Fluentd GELF output and formatter plugins
|
|
2
|
+
|
|
3
|
+
[](https://github.com/bmichalkiewicz/fluent-plugin-gelf-best/actions/workflows/ci.yml)
|
|
4
|
+
|
|
2
5
|
This is a fork of the fluent-plugin-gelf-hs (https://github.com/hotschedules/fluent-plugin-gelf-hs), which is no longer maintained.
|
|
3
6
|
|
|
4
7
|
## Overview
|
|
@@ -23,12 +26,12 @@ For more info, review [Fluentd's official documentation](https://docs.fluentd.or
|
|
|
23
26
|
## Output plugin configuration
|
|
24
27
|
```
|
|
25
28
|
<match **>
|
|
26
|
-
type gelf
|
|
29
|
+
@type gelf
|
|
27
30
|
host <remote GELF host>
|
|
28
31
|
port <remote GELF port>
|
|
29
32
|
protocol <tcp or udp (default)>
|
|
30
|
-
udp_transport_type <LAN or WAN(default)>
|
|
31
|
-
max_bytes <maximum
|
|
33
|
+
udp_transport_type <LAN or WAN (default)>
|
|
34
|
+
max_bytes <maximum field size in bytes (32000 default)>
|
|
32
35
|
tls <true or false (default)>
|
|
33
36
|
tls_options <{} (default)> for options see https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12
|
|
34
37
|
[ fluent buffered output plugin configuration ]
|
|
@@ -38,12 +41,37 @@ For more info, review [Fluentd's official documentation](https://docs.fluentd.or
|
|
|
38
41
|
## Formatter plugin configuration
|
|
39
42
|
```
|
|
40
43
|
<match **>
|
|
41
|
-
type file (any type that
|
|
42
|
-
format
|
|
44
|
+
@type file (any type that takes a format section)
|
|
45
|
+
<format>
|
|
46
|
+
@type gelf
|
|
47
|
+
</format>
|
|
43
48
|
[ fluent file output plugin configuration ]
|
|
44
49
|
</match>
|
|
45
50
|
```
|
|
46
51
|
|
|
52
|
+
## Development
|
|
53
|
+
|
|
54
|
+
Install [Task](https://taskfile.dev) and run:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
task deps # install dependencies
|
|
58
|
+
task test # run the test suite
|
|
59
|
+
task build # build the gem
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Release
|
|
63
|
+
|
|
64
|
+
Bump the `VERSION` file, commit, then tag the release and push the tag:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
git tag v$(cat VERSION)
|
|
68
|
+
git push origin v$(cat VERSION)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The `Release` GitHub Actions workflow verifies the tag against `VERSION`, runs the tests,
|
|
72
|
+
builds the gem, pushes it to RubyGems (requires the `RUBYGEMS_API_KEY` repository secret)
|
|
73
|
+
and creates a GitHub release.
|
|
74
|
+
|
|
47
75
|
## License
|
|
48
76
|
|
|
49
77
|
fluent-plugin-gelf-best is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.
|
|
@@ -3,14 +3,11 @@ require "fluent/plugin/gelf_plugin_util"
|
|
|
3
3
|
require 'oj'
|
|
4
4
|
|
|
5
5
|
module Fluent
|
|
6
|
-
module
|
|
7
|
-
class GelfFormatter < Formatter
|
|
6
|
+
module Plugin
|
|
7
|
+
class GelfFormatter < Fluent::Plugin::Formatter
|
|
8
|
+
Fluent::Plugin.register_formatter('gelf', self)
|
|
8
9
|
|
|
9
|
-
unless method_defined?(:log)
|
|
10
|
-
define_method('log') { $log }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
Plugin.register_formatter("gelf", self)
|
|
10
|
+
define_method('log') { $log } unless method_defined?(:log)
|
|
14
11
|
|
|
15
12
|
include Fluent::GelfPluginUtil
|
|
16
13
|
|
|
@@ -18,32 +15,24 @@ module Fluent
|
|
|
18
15
|
config_param :add_msec_time, :bool, :default => false
|
|
19
16
|
config_param :max_bytes, :integer, :default => 32000
|
|
20
17
|
|
|
21
|
-
def configure(conf)
|
|
22
|
-
super(conf)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
18
|
def format(tag, time, record)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
record.to_s.force_encoding('UTF-8'),
|
|
44
|
-
e.message.to_s.force_encoding('UTF-8')
|
|
45
|
-
)
|
|
46
|
-
end
|
|
19
|
+
gelfentry = make_gelfentry(
|
|
20
|
+
tag, time, record,
|
|
21
|
+
{
|
|
22
|
+
:use_record_host => @use_record_host,
|
|
23
|
+
:add_msec_time => @add_msec_time,
|
|
24
|
+
:max_bytes => @max_bytes
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
Oj.dump(gelfentry, mode: :compat)
|
|
29
|
+
rescue StandardError => e
|
|
30
|
+
log.error sprintf(
|
|
31
|
+
'Error trying to serialize %s: %s',
|
|
32
|
+
record.to_s.force_encoding('UTF-8'),
|
|
33
|
+
e.message.to_s.force_encoding('UTF-8')
|
|
34
|
+
)
|
|
35
|
+
''
|
|
47
36
|
end
|
|
48
37
|
end
|
|
49
38
|
end
|
|
@@ -18,7 +18,7 @@ module Fluent
|
|
|
18
18
|
gelfentry = {'_fluentd_tag' => tag, 'timestamp' => time}
|
|
19
19
|
|
|
20
20
|
record.each_pair do |k, v|
|
|
21
|
-
gelfentry.merge!(process_record_entry(k, v,
|
|
21
|
+
gelfentry.merge!(process_record_entry(k, v, time, conf))
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
ensure_short_message(gelfentry)
|
|
@@ -27,19 +27,22 @@ module Fluent
|
|
|
27
27
|
|
|
28
28
|
private
|
|
29
29
|
|
|
30
|
-
def process_record_entry(k, v,
|
|
31
|
-
# Truncate values longer than max_bytes
|
|
32
|
-
|
|
30
|
+
def process_record_entry(k, v, time, conf)
|
|
31
|
+
# Truncate values longer than max_bytes; scrub so a multibyte
|
|
32
|
+
# character cut in half does not produce invalid UTF-8
|
|
33
|
+
if conf[:max_bytes] && v.respond_to?(:bytesize) && v.bytesize > conf[:max_bytes]
|
|
34
|
+
v = "#{v.byteslice(0, conf[:max_bytes] - 3).scrub('')}..."
|
|
35
|
+
end
|
|
33
36
|
|
|
34
37
|
case k
|
|
35
38
|
when 'host', 'hostname'
|
|
36
|
-
|
|
39
|
+
conf[:use_record_host] ? {'host' => v} : {'_host' => v}
|
|
37
40
|
when 'timestamp', 'time'
|
|
38
41
|
{ 'timestamp' => parse_timestamp(v) }
|
|
39
42
|
when 'level'
|
|
40
43
|
{'level' => LEVEL_MAP[v.to_s.downcase[0]] || (v.to_s.length >= 2 && v.to_s.downcase[1] != "r" ? GELF::UNKNOWN : v)}
|
|
41
44
|
when 'msec'
|
|
42
|
-
conf[:add_msec_time] ? {'timestamp' => "#{time.
|
|
45
|
+
conf[:add_msec_time] ? {'timestamp' => "#{time.to_i}.#{v}".to_f} : {'_msec' => v}
|
|
43
46
|
when 'short_message', 'version', 'full_message', 'facility', 'file', 'line'
|
|
44
47
|
{k => v}
|
|
45
48
|
else
|
|
@@ -69,7 +72,8 @@ module Fluent
|
|
|
69
72
|
end
|
|
70
73
|
end
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
# reached only when short_message is missing or blank and no fallback matched
|
|
76
|
+
gelfentry['short_message'] = '(no message)'
|
|
73
77
|
end
|
|
74
78
|
end
|
|
75
79
|
end
|
|
@@ -82,10 +82,6 @@ module Fluent
|
|
|
82
82
|
@conn.collect_file_and_line = false
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
def shutdown
|
|
86
|
-
super
|
|
87
|
-
end
|
|
88
|
-
|
|
89
85
|
def format(tag, time, record)
|
|
90
86
|
if defined? Fluent::EventTime and time.is_a? Fluent::EventTime then
|
|
91
87
|
timestamp = time.to_i + (time.nsec.to_f/1000000000).round(3)
|
|
@@ -102,12 +98,14 @@ module Fluent
|
|
|
102
98
|
:max_bytes => @max_bytes
|
|
103
99
|
}
|
|
104
100
|
).to_msgpack
|
|
105
|
-
rescue
|
|
101
|
+
rescue StandardError => e
|
|
106
102
|
log.error sprintf(
|
|
107
103
|
'Error trying to serialize %s: %s',
|
|
108
104
|
record.to_s.force_encoding('UTF-8'),
|
|
109
105
|
e.message.to_s.force_encoding('UTF-8')
|
|
110
106
|
)
|
|
107
|
+
# skip the record instead of corrupting the chunk with nil
|
|
108
|
+
''
|
|
111
109
|
end
|
|
112
110
|
end
|
|
113
111
|
|
|
@@ -115,7 +113,7 @@ module Fluent
|
|
|
115
113
|
chunk.msgpack_each do |data|
|
|
116
114
|
begin
|
|
117
115
|
@conn.notify!(data)
|
|
118
|
-
rescue
|
|
116
|
+
rescue StandardError => e
|
|
119
117
|
log.warn "failed to flush the buffer.", error_class: e.class.to_s, error: e.to_s, plugin_id: plugin_id
|
|
120
118
|
raise e
|
|
121
119
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-gelf-best
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Yamauchi
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-11-05 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: fluentd
|
|
@@ -82,7 +82,8 @@ dependencies:
|
|
|
82
82
|
- - ">="
|
|
83
83
|
- !ruby/object:Gem::Version
|
|
84
84
|
version: '0'
|
|
85
|
-
description:
|
|
85
|
+
description: Fluentd output and formatter plugins for sending events to Graylog2 using
|
|
86
|
+
the GELF protocol (UDP/TCP, optional TLS).
|
|
86
87
|
email:
|
|
87
88
|
- bartosz.michalkiewicz@outlook.com
|
|
88
89
|
executables: []
|
|
@@ -97,7 +98,10 @@ files:
|
|
|
97
98
|
homepage: https://github.com/bmichalkiewicz/fluent-plugin-gelf-best
|
|
98
99
|
licenses:
|
|
99
100
|
- Apache-2.0
|
|
100
|
-
metadata:
|
|
101
|
+
metadata:
|
|
102
|
+
homepage_uri: https://github.com/bmichalkiewicz/fluent-plugin-gelf-best
|
|
103
|
+
source_code_uri: https://github.com/bmichalkiewicz/fluent-plugin-gelf-best
|
|
104
|
+
bug_tracker_uri: https://github.com/bmichalkiewicz/fluent-plugin-gelf-best/issues
|
|
101
105
|
post_install_message:
|
|
102
106
|
rdoc_options: []
|
|
103
107
|
require_paths:
|
|
@@ -106,15 +110,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
106
110
|
requirements:
|
|
107
111
|
- - ">="
|
|
108
112
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '
|
|
113
|
+
version: '2.7'
|
|
110
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
115
|
requirements:
|
|
112
116
|
- - ">="
|
|
113
117
|
- !ruby/object:Gem::Version
|
|
114
118
|
version: '0'
|
|
115
119
|
requirements: []
|
|
116
|
-
rubygems_version: 3.
|
|
120
|
+
rubygems_version: 3.5.22
|
|
117
121
|
signing_key:
|
|
118
122
|
specification_version: 4
|
|
119
|
-
summary: Sends Fluentd events Graylog2 by GELF
|
|
123
|
+
summary: Sends Fluentd events to Graylog2 by GELF
|
|
120
124
|
test_files: []
|