fluent-plugin-oci-logging-analytics 2.0.6 → 2.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: da1ab666ee3e8c8dd828f2c929290f652a9c6d8a2bda423970eb809c700639da
4
- data.tar.gz: 14b8caa8d04efb8f3b38043b061dc82c28a4ace4f91661417d9c16a8ced51b37
3
+ metadata.gz: e5a472e64d8b068a1d4ae4d9c8007c0cfcfae37290ec188ff6a1e7a97f9b3005
4
+ data.tar.gz: be3762be1e1e6794672bc9ff21871a96d6a5a82053743c6432bab4ca209e0d22
5
5
  SHA512:
6
- metadata.gz: d07374a5e2556eaba00f47dd68b967a06b8c1449eb38496dc76e1fc87bf63e400078494f5559b4e52d628344bf730659c3cbdd621d58c88fa74c92a742753992
7
- data.tar.gz: 47ba0f5b4d056c20c4ddc0c8938e3cbc718e65e108235ee41ec6d8d31b24f9d48db6da059840f18ecb01f309c62c2b4929c48002d70e6cd04cafb83d8107cfac
6
+ metadata.gz: ed1e0a0ee7201c4ad6a2b0cb632fddf155778569ff47762d12407f1bf76c431d8cffb32bdb391f84b484eaf4698d1b457c2ddfcfa4e46b61a02ff550d4c3a650
7
+ data.tar.gz: 685a2f9fe44d8fbe8b49c64880a2f2bafe065242e1a2700b8ac3e40cb14b66ff0aa3b3a3975a9da7d62bbec203f3fb59700f950a33fbee78ab1e1e45dc1738f6
@@ -1,10 +1,10 @@
1
- ## Copyright (c) 2021, 2022 Oracle and/or its affiliates.
1
+ ## Copyright (c) 2021, 2024 Oracle and/or its affiliates.
2
2
  ## The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
3
3
 
4
4
  class LogEvents
5
- attr_accessor :entityId, :entityType, :logSourceName, :logPath, :logRecords , :metadata
5
+ attr_accessor :entityId, :entityType, :logSourceName, :logPath, :logRecords , :metadata, :timezone
6
6
  def initialize(lrpe_key, fluentd_records)
7
- @metadata, @entityId, @entityType, @logSourceName, @logPath = lrpe_key
7
+ @metadata, @entityId, @entityType, @logSourceName, @logPath, @timezone = lrpe_key
8
8
  @logRecords = fluentd_records.map{ |record|
9
9
  record['message']
10
10
  }
@@ -17,8 +17,8 @@ class LogEvents
17
17
  entityType: @entityType,
18
18
  logSourceName: @logSourceName,
19
19
  logPath: @logPath,
20
- logRecords: @logRecords
20
+ logRecords: @logRecords,
21
+ timezone:@timezone
21
22
  }.compact
22
23
  end
23
-
24
24
  end
@@ -1,4 +1,4 @@
1
- ## Copyright (c) 2021, 2022 Oracle and/or its affiliates.
1
+ ## Copyright (c) 2021, 2024 Oracle and/or its affiliates.
2
2
  ## The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
3
3
 
4
4
  require_relative './logEvents'
@@ -20,5 +20,4 @@ class LogEventsJson
20
20
  end
21
21
  }.compact
22
22
  end
23
-
24
23
  end
@@ -0,0 +1,7 @@
1
+ ## Copyright (c) 2024 Oracle and/or its affiliates.
2
+ ## The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
3
+
4
+ module Source
5
+ FLUENTD = :fluentd
6
+ KUBERNETES_SOLUTION = :kubernetes_solution
7
+ end
@@ -1,5 +1,8 @@
1
+ ## Copyright (c) 2021, 2024 Oracle and/or its affiliates.
2
+ ## The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
3
+
1
4
  class MetricsLabels
2
- attr_accessor :worker_id, :tag, :logGroupId, :logSourceName, :logSet, :invalid_reason, :records_valid, :records_per_tag, :latency
5
+ attr_accessor :worker_id, :tag, :logGroupId, :logSourceName, :logSet, :invalid_reason, :records_valid, :records_per_tag, :latency,:timezone
3
6
  def initialize
4
7
  @worker_id = nil
5
8
  @tag = nil
@@ -10,5 +13,6 @@ class MetricsLabels
10
13
  @records_valid = 0
11
14
  @records_per_tag = 0
12
15
  @latency = 0
16
+ @timezone = nil
13
17
  end
14
- end
18
+ end
@@ -1,3 +1,6 @@
1
+ ## Copyright (c) 2021, 2024 Oracle and/or its affiliates.
2
+ ## The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
3
+
1
4
  require 'prometheus/client'
2
5
  require 'prometheus/client/registry'
3
6
  require 'prometheus/client/gauge'
@@ -35,4 +38,4 @@ class PrometheusMetrics
35
38
  registry.register(@chunk_time_to_receive) unless registry.exist?('oci_la_fluentd_output_plugin_chunk_time_to_receive')
36
39
  registry.register(@chunk_time_to_upload) unless registry.exist?('oci_la_fluentd_output_plugin_chunk_time_to_post')
37
40
  end
38
- end
41
+ end
@@ -1,4 +1,4 @@
1
- ## Copyright (c) 2021, 2022 Oracle and/or its affiliates.
1
+ ## Copyright (c) 2021, 2024 Oracle and/or its affiliates.
2
2
  ## The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
3
3
 
4
4
  require 'fluent/plugin/output'
@@ -7,11 +7,13 @@ require 'zip'
7
7
  require 'yajl'
8
8
  require 'yajl/json_gem'
9
9
 
10
+ # require 'tzinfo'
10
11
  require 'logger'
11
12
  require_relative '../dto/logEventsJson'
12
13
  require_relative '../dto/logEvents'
13
14
  require_relative '../metrics/prometheusMetrics'
14
15
  require_relative '../metrics/metricsLabels'
16
+ require_relative '../enums/source'
15
17
 
16
18
  # Import only specific OCI modules to improve load times and reduce the memory requirements.
17
19
  require 'oci/auth/auth'
@@ -36,7 +38,6 @@ require 'oci/version'
36
38
  require 'oci/waiter'
37
39
  require 'oci/retry/retry'
38
40
  require 'oci/object_storage/object_storage'
39
-
40
41
  module OCI
41
42
  class << self
42
43
  attr_accessor :sdk_name
@@ -91,13 +92,16 @@ module Fluent::Plugin
91
92
  config_param :endpoint, :string, :default => nil
92
93
  desc 'AuthType to be used.'
93
94
  config_param :auth_type, :string, :default => 'InstancePrincipal'
95
+ desc 'OCI Domain'
96
+ config_param :oci_domain, :string, :default => nil
94
97
  desc 'Enable local payload dump.'
95
98
  config_param :dump_zip_file, :bool, :default => false
96
99
  desc 'Payload zip File Location.'
97
100
  config_param :zip_file_location, :string, :default => nil
98
101
  desc 'The kubernetes_metadata_keys_mapping.'
99
102
  config_param :kubernetes_metadata_keys_mapping, :hash, :default => {"container_name":"Container","namespace_name":"Namespace","pod_name":"Pod","container_image":"Container Image Name","host":"Node"}
100
-
103
+ desc 'opc-meta-properties'
104
+ config_param :collection_source, :string, :default => Source::FLUENTD
101
105
 
102
106
  #****************************************************************
103
107
  desc 'The http proxy to be used.'
@@ -247,26 +251,62 @@ module Fluent::Plugin
247
251
  if is_valid(@config_file_location)
248
252
  @auth_type = "ConfigFile"
249
253
  end
254
+
250
255
  case @auth_type
251
- when "InstancePrincipal"
252
- instance_principals_signer = OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new
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
259
- when "ConfigFile"
260
- my_config = OCI::ConfigFileLoader.load_config(config_file_location: @config_file_location, profile_name: @profile_name)
261
- if is_valid(@endpoint)
262
- @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: my_config, endpoint: @endpoint)
263
- @@logger.info {"loganalytics_client initialised with endpoint: #{@endpoint}"}
264
- else
265
- @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config:my_config)
266
- end
256
+ when "InstancePrincipal"
257
+ instance_principals_signer = nil
258
+ la_endpoint = nil
259
+ if is_valid(@oci_domain)
260
+ fedration_endpoint = "https://auth.#{@oci_domain}/v1/x509"
261
+ instance_principals_signer = OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new(
262
+ federation_endpoint: fedration_endpoint)
263
+ @@logger.info "Custom Federation Endpoint: #{fedration_endpoint}"
267
264
  else
268
- raise Fluent::ConfigError, "Invalid authType @auth_type, authType must be either InstancePrincipal or ConfigFile."
269
- abort
265
+ instance_principals_signer = OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new
266
+ end
267
+ if is_valid(@endpoint)
268
+ la_endpoint = @endpoint
269
+ @@logger.info "Initializing loganalytics_client with endpoint: #{la_endpoint}"
270
+ elsif is_valid(@oci_domain)
271
+ la_endpoint = "https://loganalytics.#{@oci_domain}"
272
+ @@logger.info "Initializing loganalytics_client with custom domain endpoint: #{la_endpoint}"
273
+ end
274
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(
275
+ config: OCI::Config.new,
276
+ endpoint: la_endpoint,
277
+ signer: instance_principals_signer)
278
+ @@logger.info 'loganalytics_client initialized.'
279
+ when "WorkloadIdentity"
280
+ la_endpoint = nil
281
+ workload_identity_signer = OCI::Auth::Signers::oke_workload_resource_principal_signer
282
+ if is_valid(@endpoint)
283
+ la_endpoint = @endpoint
284
+ @@logger.info "Initializing loganalytics_client with endpoint: #{@endpoint}"
285
+ elsif is_valid(@oci_domain)
286
+ la_endpoint = "https://loganalytics.#{@oci_domain}"
287
+ @@logger.info "Initializing loganalytics_client with custom domain endpoint: #{la_endpoint}"
288
+ end
289
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(
290
+ config: OCI::Config.new,
291
+ endpoint: la_endpoint,
292
+ signer: workload_identity_signer)
293
+ @@logger.info 'loganalytics_client initialized.'
294
+ when "ConfigFile"
295
+ my_config = OCI::ConfigFileLoader.load_config(
296
+ config_file_location: @config_file_location,
297
+ profile_name: @profile_name)
298
+ la_endpoint = nil
299
+ if is_valid(@endpoint)
300
+ la_endpoint = @endpoint
301
+ @@logger.info "Initializing loganalytics_client with endpoint: #{la_endpoint}"
302
+ elsif is_valid(@oci_domain)
303
+ la_endpoint = "https://loganalytics.#{@oci_domain}"
304
+ @@logger.info "Initializing loganalytics_client with custom domain endpoint: #{la_endpoint}"
305
+ end
306
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: my_config, endpoint: la_endpoint)
307
+ @@logger.info 'loganalytics_client initialised'
308
+ else
309
+ raise Fluent::ConfigError, "Invalid authType: #{@auth_type}, valid inputs are - InstancePrincipal, ConfigFile, WorkloadIdentity"
270
310
  end
271
311
 
272
312
  if is_valid(@proxy_ip) && is_number(@proxy_port)
@@ -278,13 +318,18 @@ module Fluent::Plugin
278
318
  end
279
319
 
280
320
  rescue => ex
281
- @@logger.error {"Error occurred while initializing LogAnalytics Client:
282
- authType: #{@auth_type},
283
- errorMessage: #{ex}"}
321
+ @@logger.error {"Error occurred while initializing LogAnalytics Client:
322
+ authType: #{@auth_type},
323
+ errorMessage: #{ex}"}
284
324
  end
285
325
 
286
326
  def configure(conf)
287
327
  super
328
+
329
+ if is_valid(@oci_domain) && !@oci_domain.match(/\S.oci.\S/)
330
+ raise Fluent::ConfigError, "Invalid oci_domain: #{@oci_domain}, valid fmt: <oci-region>.oci.<oci-domain> | ex: us-ashburn-1.oci.oraclecloud.com"
331
+ end
332
+
288
333
  @@prometheusMetrics = PrometheusMetrics.instance
289
334
  initialize_logger
290
335
 
@@ -628,6 +673,8 @@ module Fluent::Plugin
628
673
  latency = 0
629
674
  records_per_tag = 0
630
675
 
676
+
677
+
631
678
  tag_metrics_set = Hash.new
632
679
  logGroup_labels_set = Hash.new
633
680
 
@@ -637,8 +684,8 @@ module Fluent::Plugin
637
684
  tags_per_logGroupId = Hash.new
638
685
  tag_logSet_map = Hash.new
639
686
  tag_metadata_map = Hash.new
687
+ timezoneValuesByTag = Hash.new
640
688
  incoming_records = 0
641
-
642
689
  chunk.each do |time, record|
643
690
  incoming_records += 1
644
691
  metricsLabels = MetricsLabels.new
@@ -722,6 +769,8 @@ module Fluent::Plugin
722
769
  end
723
770
  next
724
771
  end
772
+
773
+ # metricsLabels.timezone = record["oci_la_timezone"]
725
774
  metricsLabels.logGroupId = record["oci_la_log_group_id"]
726
775
  metricsLabels.logSourceName = record["oci_la_log_source_name"]
727
776
  if record["oci_la_log_set"] != nil
@@ -770,6 +819,25 @@ module Fluent::Plugin
770
819
  tags_per_logGroupId[record["oci_la_log_group_id"]] = record["tag"]
771
820
  end
772
821
  end
822
+ # validating the timezone field
823
+ if !timezoneValuesByTag.has_key?(record["tag"])
824
+ begin
825
+ timezoneIdentifier = record["oci_la_timezone"]
826
+ unless is_valid(timezoneIdentifier)
827
+ record["oci_la_timezone"] = nil
828
+ else
829
+ isTimezoneExist = timezone_exist? timezoneIdentifier
830
+ unless isTimezoneExist
831
+ @@logger.warn { "Invalid timezone '#{timezoneIdentifier}', using default UTC." }
832
+ record["oci_la_timezone"] = "UTC"
833
+ end
834
+
835
+ end
836
+ timezoneValuesByTag[record["tag"]] = record["oci_la_timezone"]
837
+ end
838
+ else
839
+ record["oci_la_timezone"] = timezoneValuesByTag[record["tag"]]
840
+ end
773
841
 
774
842
  records << record
775
843
  ensure
@@ -916,6 +984,14 @@ module Fluent::Plugin
916
984
  end
917
985
  end
918
986
  end
987
+ def timezone_exist?(tz)
988
+ begin
989
+ TZInfo::Timezone.get(tz)
990
+ return true
991
+ rescue TZInfo::InvalidTimezoneIdentifier
992
+ return false
993
+ end
994
+ end
919
995
 
920
996
  # Each oci_la_log_set will correspond to a separate file in the zip
921
997
  # Only MAX_FILES_PER_ZIP files are allowed per zip.
@@ -958,6 +1034,21 @@ module Fluent::Plugin
958
1034
 
959
1035
  # takes a fluentD chunk and converts it to an in-memory zipfile, populating metrics hash provided
960
1036
  # Any exception raised is passed into the metrics hash, to be re-thrown from write()
1037
+ def getCollectionSource(input)
1038
+ collections_src = []
1039
+ if !is_valid input
1040
+ collections_src.unshift("source:#{Source::FLUENTD}")
1041
+ else
1042
+ if input == Source::FLUENTD.to_s or input == Source::KUBERNETES_SOLUTION.to_s
1043
+ collections_src.unshift("source:#{input}")
1044
+ else
1045
+ # source not define ! using default source 'fluentd'
1046
+ collections_src.unshift("source:#{Source::FLUENTD}")
1047
+ end
1048
+ end
1049
+ collections_src
1050
+ end
1051
+
961
1052
  def get_zipped_stream(oci_la_log_group_id,oci_la_global_metadata,records_per_logSet_map)
962
1053
  begin
963
1054
  current, = Time.now
@@ -970,8 +1061,9 @@ module Fluent::Plugin
970
1061
  record['oci_la_metadata'],
971
1062
  record['oci_la_entity_id'],
972
1063
  record['oci_la_entity_type'],
973
- record['oci_la_log_source_name'] ,
974
- record['oci_la_log_path']
1064
+ record['oci_la_log_source_name'],
1065
+ record['oci_la_log_path'],
1066
+ record['oci_la_timezone']
975
1067
  ]}.map { |lrpe_key, records_per_lrpe|
976
1068
  number_of_records += records_per_lrpe.length
977
1069
  LogEvents.new(lrpe_key, records_per_lrpe)
@@ -1021,9 +1113,10 @@ module Fluent::Plugin
1021
1113
  # upload zipped stream to oci
1022
1114
  def upload_to_oci(oci_la_log_group_id, number_of_records, zippedstream, metricsLabels_array)
1023
1115
  begin
1116
+ collection_src_prop = getCollectionSource @collection_source
1024
1117
  error_reason = nil
1025
1118
  error_code = nil
1026
- opts = {payload_type: "ZIP"}
1119
+ opts = { payload_type: "ZIP", opc_meta_properties:collection_src_prop}
1027
1120
 
1028
1121
  response = @@loganalytics_client.upload_log_events_file(namespace_name=@namespace,
1029
1122
  logGroupId=oci_la_log_group_id ,
@@ -0,0 +1,8 @@
1
+ ## Copyright (c) 2021, 2024 Oracle and/or its affiliates.
2
+ ## The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
3
+
4
+ # frozen_string_literal: true
5
+
6
+ module Version
7
+ VERSION = "2.0.8".freeze
8
+ end
metadata CHANGED
@@ -1,15 +1,15 @@
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.6
4
+ version: 2.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oracle
8
8
  - 'OCI Observability: Logging Analytics'
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-02-05 00:00:00.000000000 Z
12
+ date: 2024-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -131,17 +131,19 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - lib/fluent/dto/logEvents.rb
133
133
  - lib/fluent/dto/logEventsJson.rb
134
+ - lib/fluent/enums/source.rb
134
135
  - lib/fluent/metrics/metricsLabels.rb
135
136
  - lib/fluent/metrics/prometheusMetrics.rb
136
137
  - lib/fluent/plugin/out_oci-logging-analytics.rb
137
- homepage:
138
+ - lib/fluent/version/version.rb
139
+ homepage:
138
140
  licenses:
139
141
  - UPL-1.0
140
142
  metadata:
141
143
  documentation_uri: https://docs.oracle.com/en/learn/oci_logging_analytics_fluentd/
142
144
  source_code_uri: https://github.com/oracle-quickstart/oci-logan-fluentd-output-plugin
143
145
  changelog_uri: https://github.com/oracle-quickstart/oci-logan-fluentd-output-plugin/blob/main/CHANGELOG.md
144
- post_install_message:
146
+ post_install_message:
145
147
  rdoc_options: []
146
148
  require_paths:
147
149
  - lib
@@ -156,8 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
158
  - !ruby/object:Gem::Version
157
159
  version: '0'
158
160
  requirements: []
159
- rubygems_version: 3.0.3.1
160
- signing_key:
161
+ rubygems_version: 3.3.27
162
+ signing_key:
161
163
  specification_version: 4
162
164
  summary: Fluentd output plugin for OCI Logging Analytics.
163
165
  test_files: []