fluent-plugin-oci-logging-analytics 2.0.4 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b2c10b68eefbf373de236156362383500f9746a9
4
- data.tar.gz: 6ad63e3893634f360387c68b03248291d787d33f
2
+ SHA256:
3
+ metadata.gz: da1ab666ee3e8c8dd828f2c929290f652a9c6d8a2bda423970eb809c700639da
4
+ data.tar.gz: 14b8caa8d04efb8f3b38043b061dc82c28a4ace4f91661417d9c16a8ced51b37
5
5
  SHA512:
6
- metadata.gz: fcb93cdf4da13e23101127320bec26bb96ac3426e2fe34402591febfc1e0ab8494a253e8c089f0bcd13aafea35b740ea353ee164213d89d415fe93a07d8764e2
7
- data.tar.gz: 83115a796e9baf6311c3d3da4f9f137fdbd4cbb74bb52f10a3686cc8441f26315c38522bb32c1acc06652aaae92bd7a1adff643f555df91de11a4b1e84487355
6
+ metadata.gz: d07374a5e2556eaba00f47dd68b967a06b8c1449eb38496dc76e1fc87bf63e400078494f5559b4e52d628344bf730659c3cbdd621d58c88fa74c92a742753992
7
+ data.tar.gz: 47ba0f5b4d056c20c4ddc0c8938e3cbc718e65e108235ee41ec6d8d31b24f9d48db6da059840f18ecb01f309c62c2b4929c48002d70e6cd04cafb83d8107cfac
@@ -1,6 +1,7 @@
1
1
  class MetricsLabels
2
- attr_accessor :tag, :logGroupId, :logSourceName, :logSet, :invalid_reason, :records_valid, :records_per_tag, :latency
2
+ attr_accessor :worker_id, :tag, :logGroupId, :logSourceName, :logSet, :invalid_reason, :records_valid, :records_per_tag, :latency
3
3
  def initialize
4
+ @worker_id = nil
4
5
  @tag = nil
5
6
  @logGroupId = nil
6
7
  @logSourceName = nil
@@ -14,16 +14,15 @@ class PrometheusMetrics
14
14
  end
15
15
  def createMetrics
16
16
  gauge = Prometheus::Client::Gauge
17
- @records_received = gauge.new(:oci_la_fluentd_output_plugin_records_received, docstring: 'Number of records received by the OCI Logging Analytics Fluentd output plugin.', labels: [:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set])
18
- @records_valid = gauge.new(:oci_la_fluentd_output_plugin_records_valid, docstring: 'Number of valid records received by the OCI Logging Analytics Fluentd output plugin.', labels: [:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set])
19
- @records_invalid = gauge.new(:oci_la_fluentd_output_plugin_records_invalid, docstring: 'Number of invalid records received by the OCI Logging Analytics Fluentd output plugin.', labels: [:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set,:reason])
20
- @records_error = gauge.new(:oci_la_fluentd_output_plugin_records_post_error, docstring: 'Number of records failed posting to OCI Logging Analytics by the Fluentd output plugin.', labels: [:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set,:error_code, :reason])
21
- @records_posted = gauge.new(:oci_la_fluentd_output_plugin_records_post_success, docstring: 'Number of records posted by the OCI Logging Analytics Fluentd output plugin.', labels: [:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set])
22
- #@bytes_received = gauge.new(:oci_la_bytes_received, docstring: '...', labels: [:tag])
23
- #@bytes_posted = gauge.new(:oci_la_bytes_posted, docstring: '...', labels: [:oci_la_log_group_id])
17
+ @records_received = gauge.new(:oci_la_fluentd_output_plugin_records_received, docstring: 'Number of records received by the OCI Logging Analytics Fluentd output plugin.', labels: [:worker_id,:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set])
18
+ @records_valid = gauge.new(:oci_la_fluentd_output_plugin_records_valid, docstring: 'Number of valid records received by the OCI Logging Analytics Fluentd output plugin.', labels: [:worker_id,:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set])
19
+ @records_invalid = gauge.new(:oci_la_fluentd_output_plugin_records_invalid, docstring: 'Number of invalid records received by the OCI Logging Analytics Fluentd output plugin.', labels: [:worker_id,:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set,:reason])
20
+ @records_error = gauge.new(:oci_la_fluentd_output_plugin_records_post_error, docstring: 'Number of records failed posting to OCI Logging Analytics by the Fluentd output plugin.', labels: [:worker_id,:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set,:error_code, :reason])
21
+ @records_posted = gauge.new(:oci_la_fluentd_output_plugin_records_post_success, docstring: 'Number of records posted by the OCI Logging Analytics Fluentd output plugin.', labels: [:worker_id,:tag,:oci_la_log_group_id,:oci_la_log_source_name,:oci_la_log_set])
22
+
24
23
  histogram = Prometheus::Client::Histogram
25
- @chunk_time_to_receive = histogram.new(:oci_la_fluentd_output_plugin_chunk_time_to_receive, docstring: 'Average time taken by Fluentd to deliver the collected records from Input plugin to OCI Logging Analytics output plugin.', labels: [:tag])
26
- @chunk_time_to_upload = histogram.new(:oci_la_fluentd_output_plugin_chunk_time_to_post, docstring: 'Average time taken for posting the received records to OCI Logging Analytics by the Fluentd output plugin.', labels: [:oci_la_log_group_id])
24
+ @chunk_time_to_receive = histogram.new(:oci_la_fluentd_output_plugin_chunk_time_to_receive, docstring: 'Average time taken by Fluentd to deliver the collected records from Input plugin to OCI Logging Analytics output plugin.', labels: [:worker_id,:tag])
25
+ @chunk_time_to_upload = histogram.new(:oci_la_fluentd_output_plugin_chunk_time_to_post, docstring: 'Average time taken for posting the received records to OCI Logging Analytics by the Fluentd output plugin.', labels: [:worker_id,:oci_la_log_group_id])
27
26
  end
28
27
 
29
28
  def registerMetrics
@@ -33,8 +32,6 @@ class PrometheusMetrics
33
32
  registry.register(@records_invalid) unless registry.exist?('oci_la_fluentd_output_plugin_records_invalid')
34
33
  registry.register(@records_error) unless registry.exist?('oci_la_fluentd_output_plugin_records_post_error')
35
34
  registry.register(@records_posted) unless registry.exist?('oci_la_fluentd_output_plugin_records_post_success')
36
- #registry.register(@bytes_received) unless registry.exist?('oci_la_bytes_received')
37
- #registry.register(@bytes_posted) unless registry.exist?('oci_la_bytes_valid')
38
35
  registry.register(@chunk_time_to_receive) unless registry.exist?('oci_la_fluentd_output_plugin_chunk_time_to_receive')
39
36
  registry.register(@chunk_time_to_upload) unless registry.exist?('oci_la_fluentd_output_plugin_chunk_time_to_post')
40
37
  end
@@ -4,6 +4,8 @@
4
4
  require 'fluent/plugin/output'
5
5
  require "benchmark"
6
6
  require 'zip'
7
+ require 'yajl'
8
+ require 'yajl/json_gem'
7
9
 
8
10
  require 'logger'
9
11
  require_relative '../dto/logEventsJson'
@@ -75,6 +77,8 @@ module Fluent::Plugin
75
77
  @@loganalytics_client = nil
76
78
  @@prometheusMetrics = nil
77
79
  @@logger_config_errors = []
80
+ @@worker_id = '0'
81
+ @@encoded_messages_count = 0
78
82
 
79
83
 
80
84
  desc 'OCI Tenancy Namespace.'
@@ -92,7 +96,7 @@ module Fluent::Plugin
92
96
  desc 'Payload zip File Location.'
93
97
  config_param :zip_file_location, :string, :default => nil
94
98
  desc 'The kubernetes_metadata_keys_mapping.'
95
- config_param :kubernetes_metadata_keys_mapping, :hash, :default => {"container_name":"Kubernetes Container Name","namespace_name":"Kubernetes Namespace Name","pod_name":"Kubernetes Pod Name","container_image":"Kubernetes Container Image","host":"Kubernetes Node Name","master_url":"Kubernetes Master Url"}
99
+ config_param :kubernetes_metadata_keys_mapping, :hash, :default => {"container_name":"Container","namespace_name":"Namespace","pod_name":"Pod","container_image":"Container Image Name","host":"Node"}
96
100
 
97
101
 
98
102
  #****************************************************************
@@ -146,7 +150,7 @@ module Fluent::Plugin
146
150
  desc 'The number of threads of output plugins, which is used to write chunks in parallel.'
147
151
  config_set_default :flush_thread_count, 1
148
152
  desc 'The max size of each chunks: events will be written into chunks until the size of chunks become this size.'
149
- config_set_default :chunk_limit_size, 2 * 1024 * 1024 # 2MB
153
+ config_set_default :chunk_limit_size, 4 * 1024 * 1024 # 4MB
150
154
  desc 'The size limitation of this buffer plugin instance.'
151
155
  config_set_default :total_limit_size, 5 * (1024**3) # 5GB
152
156
  desc 'Flush interval'
@@ -170,67 +174,72 @@ module Fluent::Plugin
170
174
  end
171
175
 
172
176
  def initialize_logger()
173
- filename = nil
174
- is_default_log_location = false
175
- if is_valid(@plugin_log_location)
176
- filename = @plugin_log_location[-1] == '/' ? @plugin_log_location : @plugin_log_location +'/'
177
- else
178
- is_default_log_location = true
179
- end
180
- if !is_valid_log_level(@plugin_log_level)
181
- @plugin_log_level = @@default_log_level
182
- end
183
- oci_fluent_output_plugin_log = nil
184
- if is_default_log_location
185
- oci_fluent_output_plugin_log = 'oci-logging-analytics.log'
186
- else
187
- oci_fluent_output_plugin_log = filename+'oci-logging-analytics.log'
188
- end
189
-
190
- logger_config = nil
191
-
192
- if is_valid_number_of_logs(@plugin_log_file_count) && is_valid_log_size(@plugin_log_file_size)
193
- # When customer provided valid log_file_count and log_file_size.
194
- # logger will rotate with max log_file_count with each file having max log_file_size.
195
- # Older logs purged automatically.
196
- @@logger = Logger.new(oci_fluent_output_plugin_log, @plugin_log_file_count, @@validated_log_size)
197
- logger_config = 'USER_CONFIG'
198
- elsif is_valid_log_rotation(@plugin_log_rotation)
199
- # When customer provided only log_rotation.
200
- # logger will create a new log based on log_rotation (new file everyday if the rotation is daily).
201
- # This will create too many logs over a period of time as log purging is not done.
202
- @@logger = Logger.new(oci_fluent_output_plugin_log, @plugin_log_rotation)
203
- logger_config = 'FALLBACK_CONFIG'
204
- else
205
- # When customer provided invalid log config, default config is considered.
206
- # logger will rotate with max default log_file_count with each file having max default log_file_size.
207
- # Older logs purged automatically.
208
- @@logger = Logger.new(oci_fluent_output_plugin_log, @@default_number_of_logs, @@default_log_size)
209
- logger_config = 'DEFAULT_CONFIG'
210
- end
211
-
212
- logger_set_level(@plugin_log_level)
177
+ begin
178
+ filename = nil
179
+ is_default_log_location = false
180
+ if is_valid(@plugin_log_location)
181
+ filename = @plugin_log_location[-1] == '/' ? @plugin_log_location : @plugin_log_location +'/'
182
+ else
183
+ @@logger = log
184
+ return
185
+ end
186
+ if !is_valid_log_level(@plugin_log_level)
187
+ @plugin_log_level = @@default_log_level
188
+ end
189
+ oci_fluent_output_plugin_log = nil
190
+ if is_default_log_location
191
+ oci_fluent_output_plugin_log = 'oci-logging-analytics.log'
192
+ else
193
+ oci_fluent_output_plugin_log = filename+'oci-logging-analytics.log'
194
+ end
195
+ logger_config = nil
196
+
197
+ if is_valid_number_of_logs(@plugin_log_file_count) && is_valid_log_size(@plugin_log_file_size)
198
+ # When customer provided valid log_file_count and log_file_size.
199
+ # logger will rotate with max log_file_count with each file having max log_file_size.
200
+ # Older logs purged automatically.
201
+ @@logger = Logger.new(oci_fluent_output_plugin_log, @plugin_log_file_count, @@validated_log_size)
202
+ logger_config = 'USER_CONFIG'
203
+ elsif is_valid_log_rotation(@plugin_log_rotation)
204
+ # When customer provided only log_rotation.
205
+ # logger will create a new log based on log_rotation (new file everyday if the rotation is daily).
206
+ # This will create too many logs over a period of time as log purging is not done.
207
+ @@logger = Logger.new(oci_fluent_output_plugin_log, @plugin_log_rotation)
208
+ logger_config = 'FALLBACK_CONFIG'
209
+ else
210
+ # When customer provided invalid log config, default config is considered.
211
+ # logger will rotate with max default log_file_count with each file having max default log_file_size.
212
+ # Older logs purged automatically.
213
+ @@logger = Logger.new(oci_fluent_output_plugin_log, @@default_number_of_logs, @@default_log_size)
214
+ logger_config = 'DEFAULT_CONFIG'
215
+ end
213
216
 
214
- @@logger.info {"Initializing oci-logging-analytics plugin"}
215
- if is_default_log_location
216
- @@logger.info {"plugin_log_location is not specified. oci-logging-analytics.log will be generated under directory from where fluentd is executed."}
217
- end
217
+ logger_set_level(@plugin_log_level)
218
+ @@logger.info {"Initializing oci-logging-analytics plugin"}
219
+ if is_default_log_location
220
+ @@logger.info {"plugin_log_location is not specified. oci-logging-analytics.log will be generated under directory from where fluentd is executed."}
221
+ end
218
222
 
219
- case logger_config
220
- when 'USER_CONFIG'
221
- @@logger.info {"Logger for oci-logging-analytics.log is initialized with config values log size: #{@plugin_log_file_size}, number of logs: #{@plugin_log_file_count}"}
222
- when 'FALLBACK_CONFIG'
223
- @@logger.info {"Logger for oci-logging-analytics.log is initialized with log rotation: #{@plugin_log_rotation}"}
224
- when 'DEFAULT_CONFIG'
225
- @@logger.info {"Logger for oci-logging-analytics.log is initialized with default config values log size: #{@@default_log_size}, number of logs: #{@@default_number_of_logs}"}
226
- end
227
- if @@logger_config_errors.length > 0
228
- @@logger_config_errors. each {|logger_config_error|
229
- @@logger.warn {"#{logger_config_error}"}
230
- }
231
- end
232
- if is_valid_log_age(@plugin_log_age)
233
- @@logger.warn {"'plugin_log_age' field is deprecated. Use 'plugin_log_file_size' and 'plugin_log_file_count' instead."}
223
+ case logger_config
224
+ when 'USER_CONFIG'
225
+ @@logger.info {"Logger for oci-logging-analytics.log is initialized with config values log size: #{@plugin_log_file_size}, number of logs: #{@plugin_log_file_count}"}
226
+ when 'FALLBACK_CONFIG'
227
+ @@logger.info {"Logger for oci-logging-analytics.log is initialized with log rotation: #{@plugin_log_rotation}"}
228
+ when 'DEFAULT_CONFIG'
229
+ @@logger.info {"Logger for oci-logging-analytics.log is initialized with default config values log size: #{@@default_log_size}, number of logs: #{@@default_number_of_logs}"}
230
+ end
231
+ if @@logger_config_errors.length > 0
232
+ @@logger_config_errors. each {|logger_config_error|
233
+ @@logger.warn {"#{logger_config_error}"}
234
+ }
235
+ end
236
+ if is_valid_log_age(@plugin_log_age)
237
+ @@logger.warn {"'plugin_log_age' field is deprecated. Use 'plugin_log_file_size' and 'plugin_log_file_count' instead."}
238
+ end
239
+ rescue => ex
240
+ @@logger = log
241
+ @@logger.error {"Error while initializing logger:#{ex.inspect}"}
242
+ @@logger.info {"Redirecting oci logging analytics logs to STDOUT"}
234
243
  end
235
244
  end
236
245
 
@@ -241,11 +250,16 @@ module Fluent::Plugin
241
250
  case @auth_type
242
251
  when "InstancePrincipal"
243
252
  instance_principals_signer = OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new
244
- @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: OCI::Config.new, signer: instance_principals_signer)
253
+ if is_valid(@endpoint)
254
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: OCI::Config.new, endpoint: @endpoint, signer: instance_principals_signer)
255
+ @@logger.info {"loganalytics_client initialised with endpoint: #{@endpoint}"}
256
+ else
257
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: OCI::Config.new, signer: instance_principals_signer)
258
+ end
245
259
  when "ConfigFile"
246
260
  my_config = OCI::ConfigFileLoader.load_config(config_file_location: @config_file_location, profile_name: @profile_name)
247
- if is_valid(endpoint)
248
- @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config:my_config, endpoint:@endpoint)
261
+ if is_valid(@endpoint)
262
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: my_config, endpoint: @endpoint)
249
263
  @@logger.info {"loganalytics_client initialised with endpoint: #{@endpoint}"}
250
264
  else
251
265
  @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config:my_config)
@@ -275,8 +289,8 @@ module Fluent::Plugin
275
289
  initialize_logger
276
290
 
277
291
  initialize_loganalytics_client
278
- @@logger.error {"Error in config file : Buffer plugin must be of @type file."} unless buffer_config['@type'] == 'file'
279
- raise Fluent::ConfigError, "Error in config file : Buffer plugin must be of @type file." unless buffer_config['@type'] == 'file'
292
+ #@@logger.error {"Error in config file : Buffer plugin must be of @type file."} unless buffer_config['@type'] == 'file'
293
+ #raise Fluent::ConfigError, "Error in config file : Buffer plugin must be of @type file." unless buffer_config['@type'] == 'file'
280
294
 
281
295
  is_mandatory_fields_valid,invalid_field_name = mandatory_field_validator
282
296
  if !is_mandatory_fields_valid
@@ -288,8 +302,8 @@ module Fluent::Plugin
288
302
  unless conf.elements(name: 'buffer').empty?
289
303
  buffer_conf = conf.elements(name: 'buffer').first
290
304
  chunk_limit_size_from_conf = buffer_conf['chunk_limit_size']
291
- unless chunk_limit_size_from_conf.nil?
292
- log.debug "chunk limit size as per the configuration file is #{chunk_limit_size_from_conf}"
305
+ unless chunk_limit_size_from_conf.nil? && buffer_config['@type'] != 'file'
306
+ @@logger.debug "chunk limit size as per the configuration file is #{chunk_limit_size_from_conf}"
293
307
  case chunk_limit_size_from_conf.to_s
294
308
  when /([0-9]+)k/i
295
309
  chunk_limit_size_bytes = $~[1].to_i * 1024
@@ -299,13 +313,13 @@ module Fluent::Plugin
299
313
  chunk_limit_size_bytes = $~[1].to_i * (1024 ** 3)
300
314
  when /([0-9]+)t/i
301
315
  chunk_limit_size_bytes = $~[1].to_i * (1024 ** 4)
302
- else
303
- raise Fluent::ConfigError, "error parsing chunk_limit_size"
316
+ #else
317
+ #raise Fluent::ConfigError, "error parsing chunk_limit_size"
304
318
  end
305
319
 
306
- log.debug "chunk limit size in bytes as per the configuration file is #{chunk_limit_size_bytes}"
307
- if !chunk_limit_size_bytes.between?(1048576, 2097152)
308
- raise Fluent::ConfigError, "chunk_limit_size must be between 1MB and 2MB"
320
+ @@logger.debug "chunk limit size in bytes as per the configuration file is #{chunk_limit_size_bytes}"
321
+ if chunk_limit_size_bytes != nil && !chunk_limit_size_bytes.between?(1048576, 4194304)
322
+ raise Fluent::ConfigError, "chunk_limit_size must be between 1MB and 4MB"
309
323
  end
310
324
  end
311
325
  end
@@ -577,7 +591,7 @@ module Fluent::Plugin
577
591
  kubernetes_metadata.each do |key, value|
578
592
  if kubernetes_metadata_keys_mapping.has_key?(key)
579
593
  if !is_valid(oci_la_metadata[kubernetes_metadata_keys_mapping[key]])
580
- oci_la_metadata[kubernetes_metadata_keys_mapping[key]] = json_message_handler(value)
594
+ oci_la_metadata[kubernetes_metadata_keys_mapping[key]] = json_message_handler(key, value)
581
595
  end
582
596
  end
583
597
  end
@@ -588,14 +602,21 @@ module Fluent::Plugin
588
602
  return oci_la_metadata
589
603
  end
590
604
 
591
- def json_message_handler(message)
592
- if message.is_a?(Hash)
593
- return JSON.generate(message)
594
- else
595
- return message
596
- end
597
- rescue => ex
598
- return message
605
+ def json_message_handler(key, message)
606
+ begin
607
+ if !is_valid(message)
608
+ return nil
609
+ end
610
+ if message.is_a?(Hash)
611
+ return Yajl.dump(message) #JSON.generate(message)
612
+ end
613
+ return message
614
+ rescue => ex
615
+ @@logger.error {"Error occured while generating json for
616
+ field: #{key}
617
+ exception : #{ex}"}
618
+ return nil
619
+ end
599
620
  end
600
621
 
601
622
  def group_by_logGroupId(chunk)
@@ -624,6 +645,10 @@ module Fluent::Plugin
624
645
  if !record.nil?
625
646
  begin
626
647
  record_hash = record.keys.map {|x| [x,true]}.to_h
648
+ if record_hash.has_key?("worker_id") && is_valid(record["worker_id"])
649
+ metricsLabels.worker_id = record["worker_id"]||= '0'
650
+ @@worker_id = record["worker_id"]||= '0'
651
+ end
627
652
  is_tag_exists = false
628
653
  if record_hash.has_key?("tag") && is_valid(record["tag"])
629
654
  is_tag_exists = true
@@ -702,22 +727,23 @@ module Fluent::Plugin
702
727
  if record["oci_la_log_set"] != nil
703
728
  metricsLabels.logSet = record["oci_la_log_set"]
704
729
  end
730
+ record["message"] = json_message_handler("message", record["message"])
731
+
732
+
705
733
  #This will check for null or empty messages and only that record will be ignored.
706
734
  if !is_valid(record["message"])
707
735
  metricsLabels.invalid_reason = OutOracleOCILogAnalytics::METRICS_INVALID_REASON_MESSAGE
708
736
  if is_tag_exists
709
- @@logger.warn {"'message' field has empty value, Skipping records associated with tag : #{record["tag"]}."}
710
737
  if invalid_records_per_tag.has_key?(record["tag"])
711
738
  invalid_records_per_tag[record["tag"]] += 1
712
739
  else
713
740
  invalid_records_per_tag[record["tag"]] = 1
741
+ @@logger.warn {"'message' field is empty or encoded, Skipping records associated with tag : #{record["tag"]}."}
714
742
  end
715
743
  else
716
- @@logger.warn {"'message' field has empty value, Skipping record."}
744
+ @@logger.warn {"'message' field is empty or encoded, Skipping record."}
717
745
  end
718
746
  next
719
- else
720
- record["message"] = json_message_handler(record["message"])
721
747
  end
722
748
 
723
749
  if record_hash.has_key?("kubernetes")
@@ -773,7 +799,7 @@ module Fluent::Plugin
773
799
 
774
800
  tag_metrics_set.each do |tag,metricsLabels|
775
801
  latency_avg = (metricsLabels.latency / metricsLabels.records_per_tag).round(3)
776
- @@prometheusMetrics.chunk_time_to_receive.observe(latency_avg, labels: { tag: tag})
802
+ @@prometheusMetrics.chunk_time_to_receive.observe(latency_avg, labels: { worker_id: metricsLabels.worker_id, tag: tag})
777
803
  end
778
804
 
779
805
  lrpes_for_logGroupId = {}
@@ -827,17 +853,20 @@ module Fluent::Plugin
827
853
  logGroup_metrics_map[metricsLabels.logGroupId] = metricsLabels_array
828
854
  end
829
855
 
830
- @@prometheusMetrics.records_received.set(value.to_i, labels: { tag: key,
856
+ @@prometheusMetrics.records_received.set(value.to_i, labels: { worker_id: metricsLabels.worker_id,
857
+ tag: key,
831
858
  oci_la_log_group_id: metricsLabels.logGroupId,
832
859
  oci_la_log_source_name: metricsLabels.logSourceName,
833
860
  oci_la_log_set: metricsLabels.logSet})
834
861
 
835
- @@prometheusMetrics.records_invalid.set(dropped_messages, labels: { tag: key,
862
+ @@prometheusMetrics.records_invalid.set(dropped_messages, labels: { worker_id: metricsLabels.worker_id,
863
+ tag: key,
836
864
  oci_la_log_group_id: metricsLabels.logGroupId,
837
865
  oci_la_log_source_name: metricsLabels.logSourceName,
838
866
  oci_la_log_set: metricsLabels.logSet,
839
867
  reason: metricsLabels.invalid_reason})
840
- @@prometheusMetrics.records_valid.set(valid_messages, labels: { tag: key,
868
+ @@prometheusMetrics.records_valid.set(valid_messages, labels: { worker_id: metricsLabels.worker_id,
869
+ tag: key,
841
870
  oci_la_log_group_id: metricsLabels.logGroupId,
842
871
  oci_la_log_source_name: metricsLabels.logSourceName,
843
872
  oci_la_log_set: metricsLabels.logSet})
@@ -875,7 +904,7 @@ module Fluent::Plugin
875
904
  end
876
905
  end
877
906
  }.real.round(3)
878
- @@prometheusMetrics.chunk_time_to_upload.observe(chunk_upload_time_taken, labels: { oci_la_log_group_id: oci_la_log_group_id})
907
+ @@prometheusMetrics.chunk_time_to_upload.observe(chunk_upload_time_taken, labels: { worker_id: @@worker_id, oci_la_log_group_id: oci_la_log_group_id})
879
908
 
880
909
  end
881
910
  ensure
@@ -956,7 +985,7 @@ module Fluent::Plugin
956
985
  @@logger.debug {"Added entry #{nextEntry} for oci_la_log_set #{oci_la_log_set} into the zip."}
957
986
  zos.put_next_entry(nextEntry)
958
987
  logEventsJsonFinal = LogEventsJson.new(oci_la_global_metadata,lrpes_for_logEvents)
959
- zos.write logEventsJsonFinal.to_hash.to_json
988
+ zos.write Yajl.dump(logEventsJsonFinal.to_hash)
960
989
  end
961
990
  }
962
991
  zippedstream.rewind
@@ -1002,13 +1031,15 @@ module Fluent::Plugin
1002
1031
  opts)
1003
1032
  if !response.nil? && response.status == 200 then
1004
1033
  headers = response.headers
1005
-
1006
- metricsLabels_array.each { |metricsLabels|
1007
- @@prometheusMetrics.records_posted.set(metricsLabels.records_valid, labels: { tag: metricsLabels.tag,
1008
- oci_la_log_group_id: metricsLabels.logGroupId,
1009
- oci_la_log_source_name: metricsLabels.logSourceName,
1010
- oci_la_log_set: metricsLabels.logSet})
1011
- }
1034
+ if metricsLabels_array != nil
1035
+ metricsLabels_array.each { |metricsLabels|
1036
+ @@prometheusMetrics.records_posted.set(metricsLabels.records_valid, labels: { worker_id: metricsLabels.worker_id,
1037
+ tag: metricsLabels.tag,
1038
+ oci_la_log_group_id: metricsLabels.logGroupId,
1039
+ oci_la_log_source_name: metricsLabels.logSourceName,
1040
+ oci_la_log_set: metricsLabels.logSet})
1041
+ }
1042
+ end
1012
1043
 
1013
1044
  #zippedstream.rewind #reposition buffer pointer to the beginning
1014
1045
  #zipfile = zippedstream&.sysread&.dup
@@ -1087,9 +1118,10 @@ module Fluent::Plugin
1087
1118
  error_reason = ex
1088
1119
  @@logger.error {"oci upload exception : Error while uploading the payload. #{ex}"}
1089
1120
  ensure
1090
- if error_reason != nil
1121
+ if error_reason != nil && metricsLabels_array != nil
1091
1122
  metricsLabels_array.each { |metricsLabels|
1092
- @@prometheusMetrics.records_error.set(metricsLabels.records_valid, labels: { tag: metricsLabels.tag,
1123
+ @@prometheusMetrics.records_error.set(metricsLabels.records_valid, labels: {worker_id: metricsLabels.worker_id,
1124
+ tag: metricsLabels.tag,
1093
1125
  oci_la_log_group_id: metricsLabels.logGroupId,
1094
1126
  oci_la_log_source_name: metricsLabels.logSourceName,
1095
1127
  oci_la_log_set: metricsLabels.logSet,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-oci-logging-analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oracle
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-20 00:00:00.000000000 Z
12
+ date: 2024-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -93,14 +93,34 @@ dependencies:
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 4.0.0
96
+ version: '4.0'
97
97
  type: :runtime
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 4.0.0
103
+ version: '4.0'
104
+ - !ruby/object:Gem::Dependency
105
+ name: yajl-ruby
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.4'
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: 1.4.3
114
+ type: :runtime
115
+ prerelease: false
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '1.4'
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 1.4.3
104
124
  description: OCI Logging Analytics Fluentd output plugin for ingesting the collected
105
125
  log events to OCI Logging Analytics.
106
126
  email:
@@ -136,8 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
156
  - !ruby/object:Gem::Version
137
157
  version: '0'
138
158
  requirements: []
139
- rubyforge_project:
140
- rubygems_version: 2.6.13
159
+ rubygems_version: 3.0.3.1
141
160
  signing_key:
142
161
  specification_version: 4
143
162
  summary: Fluentd output plugin for OCI Logging Analytics.