fluent-plugin-coralogix 1.0.1 → 1.0.6

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: 9c2679f633f12acacc7a6df89e6ee390174f3c0218e8a0257a4f6ce04becc303
4
- data.tar.gz: a8eb5b2d6c736b3e262a5d2bbfb41b2625d29414b64d7e92f139a4a76af7b018
3
+ metadata.gz: ade24fd56923cdeef1a0f2c67326b96845c70a1c30a6a31b1c9d1cc8b8324a63
4
+ data.tar.gz: d74252467309c8a9ed77de3e002b9dec8345c61e6e452bc929a24d048e5d8934
5
5
  SHA512:
6
- metadata.gz: 4f3d283bc07e3519fa00ca98b2172090ff9f5c9545a729d1cd116ec3917a1205ad23a5ec00de8e088fa1a486504ab7cdc5c46d04df099e610a556deb27f03187
7
- data.tar.gz: a4eb11b58b4f0022c46a7cf985437eb25b52a215f37f0be49cc350566101d51e1ff4d7dcde4b31f61a674e239facf3e6abecf04f9c34ecaacc7b20915e8b8cbd
6
+ metadata.gz: a986b00fceeb1981307e1cea165abc39a36419e6bd6ec2f109ad8baea702e8925dc334e38aebc60e10d28ac8b58c9da077668bb48b324947b8ed36a62627b6c7
7
+ data.tar.gz: dd481eae2b188d5b591c07dbde93232247a928fc2225f3ce88c4b298c583e937281947aa8d423841f68d2bf7cbbe12135ab08a3de260001627098a71c9d45853
@@ -13,37 +13,61 @@ 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 :log_key_name, :string, :default => nil
16
+ config_param :config, :hash, :default => {}, deprecated: "This parameter is deprecated"
17
17
  config_param :privatekey, :string, :default => nil
18
- config_param :appname, :string
19
- config_param :subsystemname, :string
20
- config_param :is_json, :bool, :default => false
18
+ config_param :appname, :string, :default => ""
19
+ config_param :subsystemname, :string, :default => ""
20
+ config_param :log_key_name, :string, :default => nil
21
21
  config_param :timestamp_key_name, :default => nil
22
+ config_param :is_json, :bool, :default => false
22
23
  config_param :force_compression, :bool, :default => false
23
24
  config_param :debug, :bool, :default => false
24
- @configured = false
25
-
25
+ config_param :number_of_workers, :integer, :default => 1
26
+ config_section :proxy, :param_name => "proxy", required: false, multi: false do
27
+ config_param :host, :string
28
+ config_param :port, :integer
29
+ config_param :user, :string, :default => nil
30
+ config_param :password, :string, :default => nil, secret: true
31
+ end
26
32
 
27
33
  # This method is called before starting.
28
34
  def configure(conf)
29
35
  super
30
36
  begin
31
- @loggers = {}
32
- #If config parameters doesn't start with $ then we can configure Coralogix logger now.
33
- if !appname.start_with?("$") && !subsystemname.start_with?("$")
34
- @logger = CoralogixLogger.new privatekey, appname, subsystemname, debug, "FluentD (#{version?})", force_compression
35
- @configured = true
37
+ @currentWorker = 0;
38
+ @workers = {}
39
+ @app_name_from_config = DEFAULT_appname;
40
+ @sub_name_from_config = DEFAULT_subsystemname;
41
+ i = 0
42
+ $log.info "configure #{number_of_workers} workers"
43
+ until i == number_of_workers do
44
+ @workers[i.to_s] = {}
45
+ $log.info "init worker ##{i}"
46
+ private_key = get_private_key
47
+ if !appname.start_with?("$") && !subsystemname.start_with?("$")
48
+ @app_name_from_config = config.fetch("APP_NAME", appname)
49
+ @sub_name_from_config = config.fetch("SUB_SYSTEM", subsystemname)
50
+ @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
51
+ else
52
+ @workers[i.to_s] = {}
53
+ end
54
+ i+=1
36
55
  end
56
+
37
57
  rescue Exception => e
38
58
  $log.error "Failed to configure: #{e}"
39
59
  end
40
60
  end
41
61
 
62
+ def get_private_key
63
+ return config.fetch("PRIVATE_KEY", privatekey)
64
+ end
65
+
42
66
  def version?
43
67
  begin
44
- Gem.loaded_specs['fluent-plugin-coralogix'].version.to_s
45
- rescue Exception => e
46
- return '0.0.0'
68
+ Gem.loaded_specs['fluent-plugin-coralogix'].version.to_s
69
+ rescue Exception => e
70
+ return '0.0.0'
47
71
  end
48
72
  end
49
73
 
@@ -52,7 +76,7 @@ module Fluent
52
76
  res = record
53
77
  return key unless key.start_with?("$")
54
78
  key[1..-1].split(".").each do |k|
55
- res = res.fetch(k,nil)
79
+ res = res.fetch(k, nil)
56
80
  return default if res == nil
57
81
  end
58
82
  return res
@@ -70,16 +94,26 @@ module Fluent
70
94
  end
71
95
 
72
96
  def get_logger(record)
73
-
74
- return @logger if @configured
75
-
76
- app_name, sub_name = get_app_sub_name(record)
97
+ private_key = get_private_key
98
+ if !appname.start_with?("$") && !subsystemname.start_with?("$")
99
+ app_name = @app_name_from_config
100
+ sub_name = @sub_name_from_config
101
+ else
102
+ app_name, sub_name = get_app_sub_name(record)
103
+ end
77
104
 
78
- if !@loggers.key?("#{app_name}.#{sub_name}")
79
- @loggers["#{app_name}.#{sub_name}"] = CoralogixLogger.new privatekey, app_name, sub_name
105
+ # YK@2020-11-26T10:56 - We had encountered a case in which this value reached above 7K and the value of worker became null
106
+ if @currentWorker >= number_of_workers
107
+ @currentWorker = 0
108
+ end
109
+ worker = @workers[@currentWorker.to_s]
110
+ @currentWorker+=1;
111
+ if !worker.key?("#{app_name}.#{sub_name}")
112
+ 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
80
113
  end
81
114
 
82
- return @loggers["#{app_name}.#{sub_name}"]
115
+ return worker["#{app_name}.#{sub_name}"]
116
+
83
117
  end
84
118
 
85
119
 
@@ -102,7 +136,7 @@ module Fluent
102
136
  # NOTE! This method is called by Fluentd's main thread so you should not write slow routine here. It causes Fluentd's performance degression.
103
137
  def emit(tag, es, chain)
104
138
  chain.next
105
- es.each {|time,record|
139
+ es.each { |time, record|
106
140
  logger = get_logger(record)
107
141
 
108
142
  log_record = log_key_name != nil ? record.fetch(log_key_name, record) : record
@@ -110,17 +144,17 @@ module Fluent
110
144
  log_record = log_record.to_s.empty? ? record : log_record
111
145
 
112
146
  timestamp = record.fetch(timestamp_key_name, nil)
113
- if(timestamp.nil?)
147
+ if (timestamp.nil?)
114
148
  logger.debug log_record
115
149
  else
116
150
  begin
117
151
  float_timestamp = DateTime.parse(timestamp.to_s).to_time.to_f * 1000
118
- logger.debug log_record, nil, timestamp:float_timestamp
119
- rescue Exception => e
152
+ logger.debug log_record, nil, timestamp: float_timestamp
153
+ rescue Exception => e
120
154
  logger.debug log_record
121
- end
155
+ end
122
156
  end
123
157
  }
124
158
  end
125
159
  end
126
- end
160
+ 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.1
4
+ version: 1.0.6
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: 2020-11-26 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: []