fluent-plugin-coralogix 1.0.2 → 1.0.7

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: 0b3d6decaa08868b283f9b0ca1771bab137c45cc93a7863b5089a0a1d1e75662
4
- data.tar.gz: d4be68d3c32a83bfd9b243bcdcf3185bfd2242adec11a3751f502dd6683834ba
3
+ metadata.gz: 7c41a200602498024b0dfa869418e82a7997982f249f51d32630dd33c09ec037
4
+ data.tar.gz: a652ef47796968d984e94aa86e1c92b593f74c4cc7e90145909df8259e0d6f8f
5
5
  SHA512:
6
- metadata.gz: 5c86aa2d9a9e5620d4cfa35c9059900c7fc7fded593f42578efcb12ccd1c8c88cbf8d0f9284e525ccb7da38ad0c61262bdb3c680de0d67364f32dbcef3e83775
7
- data.tar.gz: '0384590b37a4e54c3fba35cc9d95513e7a88d9da200cf5d2bbad8d699c5a71a7cc997a3a653ffb0e45f8af56350e5e133e65b81b9fe3e57da417310d843148e3'
6
+ metadata.gz: a769ed473fbfd0035db47cddf4980746f866b1087ae217caa55aa7c44d19f1af90dc6b0959ac4e3324643fa87635509bc30e5fbbe2718aec8a0d92aaca2a8caa
7
+ data.tar.gz: 91c8fe7de64cf8ce1d3465fdaa5d32a9558dcef7594f9843ae66785dcdb3adc22723696e5c9a6aa14dd8f078eaec00422259d0ed6697ad5f1166075794ccd160
@@ -13,33 +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 :config, :hash, :default => {}
17
- config_param :log_key_name, :string, :default => nil
16
+ config_param :config, :hash, :default => {}, deprecated: "This parameter is deprecated"
17
+ config_param :endpoint, :string, :default => nil
18
18
  config_param :privatekey, :string, :default => nil
19
19
  config_param :appname, :string, :default => ""
20
20
  config_param :subsystemname, :string, :default => ""
21
- config_param :is_json, :bool, :default => false
21
+ config_param :log_key_name, :string, :default => nil
22
22
  config_param :timestamp_key_name, :default => nil
23
+ config_param :is_json, :bool, :default => false
23
24
  config_param :force_compression, :bool, :default => false
24
25
  config_param :debug, :bool, :default => false
25
- @configured = false
26
-
26
+ config_param :number_of_workers, :integer, :default => 1
27
+ config_section :proxy, :param_name => "proxy", required: false, multi: false do
28
+ config_param :host, :string
29
+ config_param :port, :integer
30
+ config_param :user, :string, :default => nil
31
+ config_param :password, :string, :default => nil, secret: true
32
+ end
27
33
 
28
34
  # This method is called before starting.
29
35
  def configure(conf)
30
36
  super
31
37
  begin
32
- @loggers = {}
33
-
34
- #If config parameters doesn't start with $ then we can configure Coralogix logger now.
35
- if !appname.start_with?("$") && !subsystemname.start_with?("$")
36
- app_name = config.fetch("APP_NAME", appname)
37
- sub_name = config.fetch("SUB_SYSTEM", subsystemname)
38
+ @currentWorker = 0;
39
+ @workers = {}
40
+ @app_name_from_config = DEFAULT_appname;
41
+ @sub_name_from_config = DEFAULT_subsystemname;
42
+ i = 0
43
+ $log.info "configure #{number_of_workers} workers"
44
+ until i == number_of_workers do
45
+ @workers[i.to_s] = {}
46
+ $log.info "init worker ##{i}"
38
47
  private_key = get_private_key
39
-
40
- @logger = CoralogixLogger.new private_key, app_name, sub_name, debug, "FluentD (#{version?})", force_compression
41
- @configured = true
48
+ if !appname.start_with?("$") && !subsystemname.start_with?("$")
49
+ @app_name_from_config = config.fetch("APP_NAME", appname)
50
+ @sub_name_from_config = config.fetch("SUB_SYSTEM", subsystemname)
51
+ @workers[i.to_s]["#{@app_name_from_config}.#{@sub_name_from_config}"] = CoralogixLogger.new private_key, @app_name_from_config, @sub_name_from_config, debug, "FluentD (#{version?})", force_compression, proxy ? proxy.to_h.map { |k,v| [k.to_s,v] }.to_h : Hash.new
52
+ else
53
+ @workers[i.to_s] = {}
54
+ end
55
+ i+=1
56
+ end
57
+
58
+ unless endpoint.nil?
59
+ ENV["CORALOGIX_LOG_URL"] = "https://#{endpoint}/api/v1/logs"
60
+ ENV["CORALOGIX_TIME_DELTA_URL"] = "https://#{endpoint}/sdk/v1/time"
42
61
  end
62
+
43
63
  rescue Exception => e
44
64
  $log.error "Failed to configure: #{e}"
45
65
  end
@@ -51,9 +71,9 @@ module Fluent
51
71
 
52
72
  def version?
53
73
  begin
54
- Gem.loaded_specs['fluent-plugin-coralogix'].version.to_s
55
- rescue Exception => e
56
- return '0.0.0'
74
+ Gem.loaded_specs['fluent-plugin-coralogix'].version.to_s
75
+ rescue Exception => e
76
+ return '0.0.0'
57
77
  end
58
78
  end
59
79
 
@@ -62,7 +82,7 @@ module Fluent
62
82
  res = record
63
83
  return key unless key.start_with?("$")
64
84
  key[1..-1].split(".").each do |k|
65
- res = res.fetch(k,nil)
85
+ res = res.fetch(k, nil)
66
86
  return default if res == nil
67
87
  end
68
88
  return res
@@ -80,17 +100,26 @@ module Fluent
80
100
  end
81
101
 
82
102
  def get_logger(record)
83
-
84
- return @logger if @configured
85
-
86
103
  private_key = get_private_key
87
- app_name, sub_name = get_app_sub_name(record)
104
+ if !appname.start_with?("$") && !subsystemname.start_with?("$")
105
+ app_name = @app_name_from_config
106
+ sub_name = @sub_name_from_config
107
+ else
108
+ app_name, sub_name = get_app_sub_name(record)
109
+ end
88
110
 
89
- if !@loggers.key?("#{app_name}.#{sub_name}")
90
- @loggers["#{app_name}.#{sub_name}"] = CoralogixLogger.new private_key, app_name, sub_name
111
+ # YK@2020-11-26T10:56 - We had encountered a case in which this value reached above 7K and the value of worker became null
112
+ if @currentWorker >= number_of_workers
113
+ @currentWorker = 0
114
+ end
115
+ worker = @workers[@currentWorker.to_s]
116
+ @currentWorker+=1;
117
+ if !worker.key?("#{app_name}.#{sub_name}")
118
+ worker["#{app_name}.#{sub_name}"] = CoralogixLogger.new private_key, app_name, sub_name, debug, "FluentD (#{version?})", force_compression, proxy ? proxy.to_h.map { |k, v| [k.to_s, v] }.to_h : Hash.new
91
119
  end
92
120
 
93
- return @loggers["#{app_name}.#{sub_name}"]
121
+ return worker["#{app_name}.#{sub_name}"]
122
+
94
123
  end
95
124
 
96
125
 
@@ -113,7 +142,7 @@ module Fluent
113
142
  # 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
143
  def emit(tag, es, chain)
115
144
  chain.next
116
- es.each {|time,record|
145
+ es.each { |time, record|
117
146
  logger = get_logger(record)
118
147
 
119
148
  log_record = log_key_name != nil ? record.fetch(log_key_name, record) : record
@@ -121,17 +150,17 @@ module Fluent
121
150
  log_record = log_record.to_s.empty? ? record : log_record
122
151
 
123
152
  timestamp = record.fetch(timestamp_key_name, nil)
124
- if(timestamp.nil?)
153
+ if (timestamp.nil?)
125
154
  logger.debug log_record
126
155
  else
127
156
  begin
128
157
  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
158
+ logger.debug log_record, nil, timestamp: float_timestamp
159
+ rescue Exception => e
131
160
  logger.debug log_record
132
- end
161
+ end
133
162
  end
134
163
  }
135
164
  end
136
165
  end
137
- end
166
+ 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.2
4
+ version: 1.0.7
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: 2018-10-16 00:00:00.000000000 Z
11
+ date: 2021-02-08 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.12
19
+ version: 0.0.15
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.12
26
+ version: 0.0.15
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:
54
- rubygems_version: 2.7.6
55
- signing_key:
53
+ rubyforge_project:
54
+ rubygems_version: 2.7.3
55
+ signing_key:
56
56
  specification_version: 4
57
57
  summary: Coralogix Fluentd out plugin
58
58
  test_files: []