fluent-plugin-gelf-best 1.3.2 → 1.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7327c66aa6fddfe60ed1448e76a59ecd906b458957758b748ee3162aefa85d0f
4
- data.tar.gz: 2f5b1820ab88ce8665288b2e218e8be53aa274d5047e32cde33faaa5dad967c6
3
+ metadata.gz: a52f6ee827886a2037e01355541bc387a6bc057a9f1970801fe29c259fa0ac7e
4
+ data.tar.gz: e7e605395d0d741227ecbb8baa94fdfc091374c1a7e8ad3329581b211b74939d
5
5
  SHA512:
6
- metadata.gz: 2735ce20d4dc4405d137405a30ec2c52dc83343fae9fdb7312f35e1b671546bd95ce0ab1c93648deaa1e0175fcedb79df739596aaedb27e767135695169a1ec5
7
- data.tar.gz: 4add4d31fc40b78c7ff70450b556749e755f0fa6072e62a24160c4afa8ae63f09f4a46c2e2a7d26e876bb9379b65264787da37a603aa807e5dd0489c092416af
6
+ metadata.gz: 5afa18f1abaac29f41fbf61989e91c9dc59411567793d8f7f61aa1e6e8fce55fa4345f980338fea9ef54c9d07b2d4b74b12c8441e936d4c8331ba3daa9fde4b5
7
+ data.tar.gz: 5b7737f5468e6dfe9c9704473af10848d57b993d4cbd7699e6bdd8692f59e877fc5b3d6edf4161531ab6b3e4bf8484a098cd8b3ae647e0c963f92f5abbd14ede
data/.gitignore CHANGED
@@ -1,4 +1,2 @@
1
- /certs/*key*
2
- /certs/*priv*
3
1
  **.gem
4
2
  **.gem.sha*
@@ -18,8 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_runtime_dependency "fluentd", ">=1.0.0"
21
- spec.add_runtime_dependency "gelf", ">= 2.0.0"
22
- spec.add_development_dependency "oj", "~> 3.3.10"
21
+ spec.add_runtime_dependency "gelf", ">= 3.1.0"
23
22
  spec.add_development_dependency "test-unit"
24
23
  spec.add_development_dependency "rake"
25
24
  end
@@ -16,6 +16,7 @@ module Fluent
16
16
 
17
17
  config_param :use_record_host, :bool, :default => true
18
18
  config_param :add_msec_time, :bool, :default => false
19
+ config_param :max_bytes, :integer, :default => 32000
19
20
 
20
21
  def configure(conf)
21
22
  super(conf)
@@ -29,7 +30,8 @@ module Fluent
29
30
  tag,time,record,
30
31
  {
31
32
  :use_record_host => @use_record_host,
32
- :add_msec_time => @add_msec_time
33
+ :add_msec_time => @add_msec_time,
34
+ :max_bytes => @max_bytes
33
35
  }
34
36
  )
35
37
 
@@ -1,26 +1,24 @@
1
- require 'oj'
2
- require 'date'
3
- require 'gelf'
4
-
5
1
  module Fluent
6
2
  module GelfPluginUtil
3
+ require "gelf"
4
+ require "date"
7
5
 
8
6
  LEVEL_MAP = {
9
- '0' => GELF::UNKNOWN, '1' => GELF::UNKNOWN, 'a' => GELF::UNKNOWN,
10
- '2' => GELF::FATAL, 'c' => GELF::FATAL,
11
- '3' => GELF::ERROR,
12
- '4' => GELF::WARN, 'w' => GELF::WARN,
13
- '5' => GELF::INFO, 'n' => GELF::INFO,
14
- '6' => GELF::INFO, 'i' => GELF::INFO,
15
- '7' => GELF::DEBUG, 'd' => GELF::DEBUG,
16
- 'e' => GELF::ERROR
7
+ "0" => GELF::UNKNOWN, "1" => GELF::UNKNOWN, "a" => GELF::UNKNOWN,
8
+ "2" => GELF::FATAL, "c" => GELF::FATAL,
9
+ "3" => GELF::ERROR,
10
+ "4" => GELF::WARN, "w" => GELF::WARN,
11
+ "5" => GELF::INFO, "n" => GELF::INFO,
12
+ "6" => GELF::INFO, "i" => GELF::INFO,
13
+ "7" => GELF::DEBUG, "d" => GELF::DEBUG,
14
+ "e" => GELF::ERROR # assuming 'e' stands typically for 'error'
17
15
  }.freeze
18
16
 
19
17
  def make_gelfentry(tag, time, record, conf = {})
20
- gelfentry = {"_fluentd_tag" => tag, "timestamp" => calculate_timestamp(time)}
18
+ gelfentry = {'_fluentd_tag' => tag, 'timestamp' => calculate_timestamp(time)}
21
19
 
22
- record.each do |k, v|
23
- process_record_entry(k, v, conf, gelfentry)
20
+ record.each_pair do |k, v|
21
+ gelfentry.merge!(process_record_entry(k, v, conf, gelfentry))
24
22
  end
25
23
 
26
24
  ensure_short_message(gelfentry)
@@ -38,31 +36,48 @@ module Fluent
38
36
  end
39
37
 
40
38
  def process_record_entry(k, v, conf, gelfentry)
39
+ # Truncate values longer than max_bytes
40
+ v = (v.respond_to?(:bytesize) && v.bytesize > conf[:max_bytes]) ? "#{v.byteslice(0, conf[:max_bytes] - 3)}..." : v
41
+
41
42
  case k
42
43
  when 'host', 'hostname'
43
- gelfentry['host'] = conf[:use_record_host] ? v : (gelfentry['_host'] = v)
44
+ return {'host' => (conf[:use_record_host] ? v : gelfentry['_host'] = v)}
44
45
  when 'timestamp', 'time'
45
- gelfentry['timestamp'] = parse_timestamp(v)
46
+ { 'timestamp' => parse_timestamp(v) }
46
47
  when 'level'
47
- gelfentry['level'] = LEVEL_MAP[v.to_s.downcase[0]] || GELF::UNKNOWN
48
+ {'level' => LEVEL_MAP[v.to_s.downcase[0]] || (v.to_s.length >= 2 && v.to_s.downcase[1] != "r" ? GELF::UNKNOWN : v)}
48
49
  when 'msec'
49
- gelfentry['timestamp'] = conf[:add_msec_time] ? "#{time.to_s}.#{v}".to_f : (gelfentry['_msec'] = v)
50
+ conf[:add_msec_time] ? {'timestamp' => "#{time.to_s}.#{v}".to_f} : {'_msec' => v}
50
51
  when 'short_message', 'version', 'full_message', 'facility', 'file', 'line'
51
- gelfentry[k] = v
52
+ {k => v}
52
53
  else
53
- gelfentry[k.start_with?('_') ? k : "_#{k}"] = v
54
+ {k.start_with?('_') ? k : "_#{k}" => v}
54
55
  end
55
56
  end
56
57
 
57
58
  def parse_timestamp(v)
58
- return v if v.is_a?(Integer) || v.is_a?(Float)
59
-
60
- DateTime.parse(v).strftime("%Q").to_f / 1_000 rescue v
59
+ if v.is_a?(Integer) || v.is_a?(Float)
60
+ v
61
+ else
62
+ begin
63
+ (DateTime.parse(v).strftime("%Q").to_f / 1_000).round(3)
64
+ rescue ArgumentError
65
+ v
66
+ end
67
+ end
61
68
  end
62
69
 
63
70
  def ensure_short_message(gelfentry)
64
- default_key = ['_message', '_msg', '_log', '_record'].find { |key| gelfentry[key]&.strip&.empty? == false }
65
- gelfentry['short_message'] = default_key ? gelfentry.delete(default_key) : '(no message)'
71
+ return if gelfentry['short_message'] && !gelfentry['short_message'].to_s.strip.empty?
72
+
73
+ ['_message', '_msg', '_log', '_record'].each do |key|
74
+ if gelfentry[key] && !gelfentry[key].to_s.strip.empty?
75
+ gelfentry['short_message'] = gelfentry.delete(key)
76
+ return
77
+ end
78
+ end
79
+
80
+ gelfentry['short_message'] = '(no message)' unless gelfentry['short_message']
66
81
  end
67
82
  end
68
83
  end
@@ -10,6 +10,7 @@ module Fluent
10
10
 
11
11
  config_param :use_record_host, :bool, :default => false
12
12
  config_param :add_msec_time, :bool, :default => false
13
+ config_param :max_bytes, :integer, :default => 32000
13
14
  config_param :host, :string, :default => nil
14
15
  config_param :port, :integer, :default => 12201
15
16
  config_param :protocol, :string, :default => 'udp'
@@ -87,7 +88,8 @@ module Fluent
87
88
  tag,timestamp,record,
88
89
  {
89
90
  :use_record_host => @use_record_host,
90
- :add_msec_time => @add_msec_time
91
+ :add_msec_time => @add_msec_time,
92
+ :max_bytes => @max_bytes
91
93
  }
92
94
  ).to_msgpack
93
95
  rescue Exception => e
@@ -1,3 +1,3 @@
1
1
  module FluentPluginGelfBest
2
- VERSION = "1.3.2"
2
+ VERSION = "1.3.4"
3
3
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-gelf-best
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Yamauchi
8
8
  - Eric Searcy
9
9
  - Bartosz Michaliewicz
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-04-18 00:00:00.000000000 Z
13
+ date: 2024-08-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluentd
@@ -32,28 +32,14 @@ dependencies:
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: 2.0.0
35
+ version: 3.1.0
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 2.0.0
43
- - !ruby/object:Gem::Dependency
44
- name: oj
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: 3.3.10
50
- type: :development
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - "~>"
55
- - !ruby/object:Gem::Version
56
- version: 3.3.10
42
+ version: 3.1.0
57
43
  - !ruby/object:Gem::Dependency
58
44
  name: test-unit
59
45
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +68,7 @@ dependencies:
82
68
  - - ">="
83
69
  - !ruby/object:Gem::Version
84
70
  version: '0'
85
- description:
71
+ description:
86
72
  email:
87
73
  - bartosz.michalkiewicz@outlook.com
88
74
  executables: []
@@ -94,7 +80,6 @@ files:
94
80
  - LICENSE
95
81
  - README.md
96
82
  - Rakefile
97
- - certs/oss@hotschedules.com.cert
98
83
  - fluent-plugin-gelf-best.gemspec
99
84
  - lib/fluent-plugin-gelf-best/version.rb
100
85
  - lib/fluent/plugin/formatter_gelf.rb
@@ -104,7 +89,7 @@ homepage: https://github.com/bmichalkiewicz/fluent-plugin-gelf-best
104
89
  licenses:
105
90
  - Apache-2.0
106
91
  metadata: {}
107
- post_install_message:
92
+ post_install_message:
108
93
  rdoc_options: []
109
94
  require_paths:
110
95
  - lib
@@ -119,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
104
  - !ruby/object:Gem::Version
120
105
  version: '0'
121
106
  requirements: []
122
- rubygems_version: 3.3.5
123
- signing_key:
107
+ rubygems_version: 3.4.20
108
+ signing_key:
124
109
  specification_version: 4
125
110
  summary: Sends Fluentd events Graylog2 by GELF
126
111
  test_files: []
@@ -1,25 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIELzCCAxGgAwIBAgIJAMOoRmNuvAZcMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYD
3
- VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5j
4
- aXNjbzEVMBMGA1UECgwMSG90c2NoZWR1bGVzMQ4wDAYDVQQLDAVJbmZyYTEfMB0G
5
- A1UEAwwWaW5mcmEuaG90c2NoZWR1bGVzLmNvbTEjMCEGCSqGSIb3DQEJARYUb3Nz
6
- QGhvdHNjaGVkdWxlcy5jb20wHhcNMTcwMjE4MDA1NDU4WhcNMjEwMjE4MDA1NDU4
7
- WjCBpzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcM
8
- DVNhbiBGcmFuY2lzY28xFTATBgNVBAoMDEhvdHNjaGVkdWxlczEOMAwGA1UECwwF
9
- SW5mcmExHzAdBgNVBAMMFmluZnJhLmhvdHNjaGVkdWxlcy5jb20xIzAhBgkqhkiG
10
- 9w0BCQEWFG9zc0Bob3RzY2hlZHVsZXMuY29tMIIBKDANBgkqhkiG9w0BAQEFAAOC
11
- ARUAMIIBEAKCAQcAutTytHjHFb5yK/29POqMS3DyxRSRRbKvBus/rEL3reeKDVlf
12
- eO9a/9U3oUcxHFHeISF9uOBSvL88svxhLqxkKLVA0vMbVgDFoGsOlh93nA5Lmw+H
13
- SEzG3+Z6JqH8YfAIqVyp1nZcdtC7u8xYpDD65ayjRALLuvOUXORGeqgedlgiwwLp
14
- 2tZ7A9tCzBZnDjcNenD8zXLCOdRjJiBPq/XQS9h4POWvpom0z+jyUkRj3ojqOoXW
15
- bKKdXzdZ3s5BSwgxlWJo+lK/50+xLpjJe4mEJwySkrluy8GOG/UR/j+Y4I1j1FbY
16
- RwT9SUSairjh0zgiDC0LTjAJBIenuxxuM9jhRyoiu+YYVwIDAQABo1AwTjAdBgNV
17
- HQ4EFgQUtlFsvLIJ59o2GyoRTXKEIPEgnn8wHwYDVR0jBBgwFoAUtlFsvLIJ59o2
18
- GyoRTXKEIPEgnn8wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQcAdELJ
19
- QdrR55Xak3q5IhLnIdOLJC6ZEdHI2173SSmytInyDX6fe9uZION4I9WCCm/hCp+t
20
- QILh4feu14iDWmBxzy6F6tiyuEjhaU5Ud9wZ/YDBQhP2AHquoPAufxXZAUFlA5er
21
- wIYVupToBrWavfbjgRqRHAZ6vwrLwoIiomh2/wv06HLrFmSzj5q6BVp7FFMKDail
22
- QWzJ4aQl786RMwPa776eVaKQTmQuTUUppvhVq9QdKyxwGPibAYGbYKZwmmtx+BV2
23
- GJevNV8BSuhh6m2AHCxEzMaD7WKNbewTTgGLUlvppaR9SE2V/yUZ7x1Vp8/mGeO6
24
- 2Zk648Ep9HVPKmwoVuB75+xEQw==
25
- -----END CERTIFICATE-----