fluent-plugin-coralogix 1.0.3 → 1.0.8
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/lib/fluent/plugin/out_coralogix.rb +61 -34
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dae7df93ce63ae60ba2beffe047731d826b2e016982a32c409bad5fdd50d57e
|
4
|
+
data.tar.gz: 3044ea4a5c4bd4062d9fa8bb5ba50a2cf41defbefab2f2ddfdd65b124fc33b15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d1c799e6636b76cf379f6cccb6eca910de452ed62c0853540cc270112536f1d74080601d963f6f6e2bc43aad22b70a2d45ac39c5c74e3666ad221dff58faf71
|
7
|
+
data.tar.gz: f04beb89599c9de420bff3d0d025c8667b57cc6dca65be6821c7d864c0ecc8561d62b7292f0457d0de3dcdc2af4d305dc5f61583690fa96b4b45860e7c8e8006
|
@@ -13,35 +13,53 @@ module Fluent
|
|
13
13
|
# First, register the plugin. NAME is the name of this plugin
|
14
14
|
# and identifies the plugin in the configuration file.
|
15
15
|
Fluent::Plugin.register_output('coralogix', self)
|
16
|
-
config_param :
|
17
|
-
config_param :log_key_name, :string, :default => nil
|
16
|
+
config_param :endpoint, :string, :default => nil
|
18
17
|
config_param :privatekey, :string, :default => nil
|
19
18
|
config_param :appname, :string, :default => ""
|
20
19
|
config_param :subsystemname, :string, :default => ""
|
21
|
-
config_param :
|
20
|
+
config_param :log_key_name, :string, :default => nil
|
22
21
|
config_param :timestamp_key_name, :default => nil
|
22
|
+
config_param :is_json, :bool, :default => false
|
23
23
|
config_param :force_compression, :bool, :default => false
|
24
|
-
config_param :
|
25
|
-
|
26
|
-
|
24
|
+
config_param :number_of_workers, :integer, :default => 1
|
25
|
+
config_section :proxy, :param_name => "proxy", required: false, multi: false do
|
26
|
+
config_param :host, :string
|
27
|
+
config_param :port, :integer
|
28
|
+
config_param :user, :string, :default => nil
|
29
|
+
config_param :password, :string, :default => nil, secret: true
|
30
|
+
end
|
27
31
|
|
28
32
|
# This method is called before starting.
|
29
33
|
def configure(conf)
|
30
34
|
super
|
31
35
|
begin
|
32
|
-
@
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
@currentWorker = 0;
|
37
|
+
@workers = {}
|
38
|
+
@app_name_from_config = DEFAULT_appname;
|
39
|
+
@sub_name_from_config = DEFAULT_subsystemname;
|
40
|
+
i = 0
|
41
|
+
log.info "configure #{number_of_workers} workers"
|
42
|
+
until i == number_of_workers do
|
43
|
+
@workers[i.to_s] = {}
|
44
|
+
log.info "init worker ##{i}"
|
38
45
|
private_key = get_private_key
|
39
|
-
|
40
|
-
|
41
|
-
|
46
|
+
if !appname.start_with?("$") && !subsystemname.start_with?("$")
|
47
|
+
@app_name_from_config = config.fetch("APP_NAME", appname)
|
48
|
+
@sub_name_from_config = config.fetch("SUB_SYSTEM", subsystemname)
|
49
|
+
@workers[i.to_s]["#{@app_name_from_config}.#{@sub_name_from_config}"] = CoralogixLogger.new private_key, @app_name_from_config, @sub_name_from_config, false, "FluentD (#{version?})", force_compression, proxy ? proxy.to_h.map { |k,v| [k.to_s,v] }.to_h : Hash.new, log
|
50
|
+
else
|
51
|
+
@workers[i.to_s] = {}
|
52
|
+
end
|
53
|
+
i+=1
|
54
|
+
end
|
55
|
+
|
56
|
+
unless endpoint.nil?
|
57
|
+
ENV["CORALOGIX_LOG_URL"] = "https://#{endpoint}/api/v1/logs"
|
58
|
+
ENV["CORALOGIX_TIME_DELTA_URL"] = "https://#{endpoint}/sdk/v1/time"
|
42
59
|
end
|
60
|
+
|
43
61
|
rescue Exception => e
|
44
|
-
|
62
|
+
log.error "Failed to configure: #{e}"
|
45
63
|
end
|
46
64
|
end
|
47
65
|
|
@@ -51,9 +69,9 @@ module Fluent
|
|
51
69
|
|
52
70
|
def version?
|
53
71
|
begin
|
54
|
-
|
55
|
-
rescue Exception => e
|
56
|
-
|
72
|
+
Gem.loaded_specs['fluent-plugin-coralogix'].version.to_s
|
73
|
+
rescue Exception => e
|
74
|
+
return '0.0.0'
|
57
75
|
end
|
58
76
|
end
|
59
77
|
|
@@ -62,12 +80,12 @@ module Fluent
|
|
62
80
|
res = record
|
63
81
|
return key unless key.start_with?("$")
|
64
82
|
key[1..-1].split(".").each do |k|
|
65
|
-
res = res.fetch(k,nil)
|
83
|
+
res = res.fetch(k, nil)
|
66
84
|
return default if res == nil
|
67
85
|
end
|
68
86
|
return res
|
69
87
|
rescue Exception => e
|
70
|
-
|
88
|
+
log.error "Failed to extract #{key}: #{e}"
|
71
89
|
return default
|
72
90
|
end
|
73
91
|
end
|
@@ -80,17 +98,26 @@ module Fluent
|
|
80
98
|
end
|
81
99
|
|
82
100
|
def get_logger(record)
|
83
|
-
|
84
|
-
return @logger if @configured
|
85
|
-
|
86
101
|
private_key = get_private_key
|
87
|
-
|
102
|
+
if !appname.start_with?("$") && !subsystemname.start_with?("$")
|
103
|
+
app_name = @app_name_from_config
|
104
|
+
sub_name = @sub_name_from_config
|
105
|
+
else
|
106
|
+
app_name, sub_name = get_app_sub_name(record)
|
107
|
+
end
|
88
108
|
|
89
|
-
|
90
|
-
|
109
|
+
# YK@2020-11-26T10:56 - We had encountered a case in which this value reached above 7K and the value of worker became null
|
110
|
+
if @currentWorker >= number_of_workers
|
111
|
+
@currentWorker = 0
|
112
|
+
end
|
113
|
+
worker = @workers[@currentWorker.to_s]
|
114
|
+
@currentWorker+=1;
|
115
|
+
if !worker.key?("#{app_name}.#{sub_name}")
|
116
|
+
worker["#{app_name}.#{sub_name}"] = CoralogixLogger.new private_key, app_name, sub_name, false, "FluentD (#{version?})", force_compression, proxy ? proxy.to_h.map { |k, v| [k.to_s, v] }.to_h : Hash.new, log
|
91
117
|
end
|
92
118
|
|
93
|
-
return
|
119
|
+
return worker["#{app_name}.#{sub_name}"]
|
120
|
+
|
94
121
|
end
|
95
122
|
|
96
123
|
|
@@ -113,7 +140,7 @@ module Fluent
|
|
113
140
|
# NOTE! This method is called by Fluentd's main thread so you should not write slow routine here. It causes Fluentd's performance degression.
|
114
141
|
def emit(tag, es, chain)
|
115
142
|
chain.next
|
116
|
-
es.each {|time,record|
|
143
|
+
es.each { |time, record|
|
117
144
|
logger = get_logger(record)
|
118
145
|
|
119
146
|
log_record = log_key_name != nil ? record.fetch(log_key_name, record) : record
|
@@ -121,17 +148,17 @@ module Fluent
|
|
121
148
|
log_record = log_record.to_s.empty? ? record : log_record
|
122
149
|
|
123
150
|
timestamp = record.fetch(timestamp_key_name, nil)
|
124
|
-
if(timestamp.nil?)
|
151
|
+
if (timestamp.nil?)
|
125
152
|
logger.debug log_record
|
126
153
|
else
|
127
154
|
begin
|
128
155
|
float_timestamp = DateTime.parse(timestamp.to_s).to_time.to_f * 1000
|
129
|
-
logger.debug log_record, nil, timestamp:float_timestamp
|
130
|
-
rescue Exception => e
|
156
|
+
logger.debug log_record, nil, timestamp: float_timestamp
|
157
|
+
rescue Exception => e
|
131
158
|
logger.debug log_record
|
132
|
-
end
|
159
|
+
end
|
133
160
|
end
|
134
161
|
}
|
135
162
|
end
|
136
163
|
end
|
137
|
-
end
|
164
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-coralogix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Royee Goldberg
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: centralized_ruby_logger
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.
|
19
|
+
version: 0.0.16
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.
|
26
|
+
version: 0.0.16
|
27
27
|
description: Coralogix Fluentd plugin to send logs to Coralogix server.
|
28
28
|
email: royee@coralogix.com
|
29
29
|
executables: []
|
@@ -35,7 +35,7 @@ homepage: http://www.coralogix.com
|
|
35
35
|
licenses:
|
36
36
|
- MIT
|
37
37
|
metadata: {}
|
38
|
-
post_install_message:
|
38
|
+
post_install_message:
|
39
39
|
rdoc_options: []
|
40
40
|
require_paths:
|
41
41
|
- lib
|
@@ -50,9 +50,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '0'
|
52
52
|
requirements: []
|
53
|
-
rubyforge_project:
|
53
|
+
rubyforge_project:
|
54
54
|
rubygems_version: 2.7.3
|
55
|
-
signing_key:
|
55
|
+
signing_key:
|
56
56
|
specification_version: 4
|
57
57
|
summary: Coralogix Fluentd out plugin
|
58
58
|
test_files: []
|