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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0464583b2b032b742f4f575419787d97d9517cad54969ba205445c587fcb9f84'
4
- data.tar.gz: 1a3ecf5ce8ce9da3d4198093c9799c9fd42c824d2c54dade646479229bcdee48
3
+ metadata.gz: 3dae7df93ce63ae60ba2beffe047731d826b2e016982a32c409bad5fdd50d57e
4
+ data.tar.gz: 3044ea4a5c4bd4062d9fa8bb5ba50a2cf41defbefab2f2ddfdd65b124fc33b15
5
5
  SHA512:
6
- metadata.gz: abfd5e328bc35e658b351ac878faed181b4a3e8c1de71d657b8c3d131a00569db9b2a43eb77201875d7d0c238b1f92af7ad997c0da21e068fbc8cdd60851f2b5
7
- data.tar.gz: d8bed1800f225ae9cb04a34ada5321f25baf37d8c397216bcab10fad5bd79aa7d5427b91ce7308eafad484e235f780995f315b66ccc963a6afc6b993e9e49c0a
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 :config, :hash, :default => {}
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 :is_json, :bool, :default => false
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 :debug, :bool, :default => false
25
- @configured = false
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
- @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)
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
- @logger = CoralogixLogger.new private_key, app_name, sub_name, debug, "FluentD (#{version?})", force_compression
41
- @configured = true
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
- $log.error "Failed to configure: #{e}"
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
- Gem.loaded_specs['fluent-plugin-coralogix'].version.to_s
55
- rescue Exception => e
56
- return '0.0.0'
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
- $log.error "Failed to extract #{key}: #{e}"
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
- app_name, sub_name = get_app_sub_name(record)
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
- if !@loggers.key?("#{app_name}.#{sub_name}")
90
- @loggers["#{app_name}.#{sub_name}"] = CoralogixLogger.new private_key, app_name, sub_name
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 @loggers["#{app_name}.#{sub_name}"]
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.3
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: 2019-05-22 00:00:00.000000000 Z
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.15
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.15
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: []