fluent-plugin-oci-logging-analytics 2.0.5 → 2.0.7

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
2
  SHA256:
3
- metadata.gz: b209883985bb866cf22a68d107f378f2345450017ff0273f70742b17bcbc8bfe
4
- data.tar.gz: 4e7a78239ef46e22991ea524e83dc2f95a0d9300c86753a8a874733a99d30b13
3
+ metadata.gz: 5b41804c02cd5e1dd39efc4c600f043cbed2a90972aabc39671c830fedcafe67
4
+ data.tar.gz: 24fc404d3f0f4d06f2e9f2167d7bc4fff337a235f9671e7e024ce71763750cb8
5
5
  SHA512:
6
- metadata.gz: 72ef3ff0b97ef16caf94b88f8bfc2f61651992b7f3507f987cefd65e841c3d12f60aff07451916b119177efb5c1f43150978862dd27efbc0d2418ff3b62dfaa2
7
- data.tar.gz: a690af49fc8e74b3851116121cdb9743ca118f1f38bd69353ea909bc6ed7c0ed5c9912e99f0d920ec231eb78db748b2302a9082f9efc77cc60937bdd72c92ff2
6
+ metadata.gz: a779a1971cabf78edf2c0b14ae6ba06235ce4113fe0ded3b264d626baba6c7f82f3aabdcb029890cb52697b2b01ae119691c7412e7920c79ada71ce8ed060fff
7
+ data.tar.gz: ef679bc249d8d16bc12a447f158c19faea8425c98170aecfbd7053da7d4081876f2b830f7c59dcef50e4abb9422d8e2cac30e91c16bffc4cf8e33072f931fe9c
@@ -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,9 @@ 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
25
  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,5 @@ class LogEventsJson
20
20
  end
21
21
  }.compact
22
22
  end
23
-
23
+
24
24
  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
@@ -97,7 +98,8 @@ module Fluent::Plugin
97
98
  config_param :zip_file_location, :string, :default => nil
98
99
  desc 'The kubernetes_metadata_keys_mapping.'
99
100
  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
-
101
+ desc 'opc-meta-properties'
102
+ config_param :collection_source, :string, :default => Source::FLUENTD
101
103
 
102
104
  #****************************************************************
103
105
  desc 'The http proxy to be used.'
@@ -250,11 +252,24 @@ module Fluent::Plugin
250
252
  case @auth_type
251
253
  when "InstancePrincipal"
252
254
  instance_principals_signer = OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new
253
- @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: OCI::Config.new, signer: instance_principals_signer)
255
+ if is_valid(@endpoint)
256
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: OCI::Config.new, endpoint: @endpoint, signer: instance_principals_signer)
257
+ @@logger.info {"loganalytics_client initialised with endpoint: #{@endpoint}"}
258
+ else
259
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: OCI::Config.new, signer: instance_principals_signer)
260
+ end
261
+ when "WorkloadIdentity"
262
+ workload_identity_signer = OCI::Auth::Signers::oke_workload_resource_principal_signer
263
+ if is_valid(@endpoint)
264
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: OCI::Config.new, endpoint: @endpoint, signer: workload_identity_signer)
265
+ @@logger.info {"loganalytics_client initialised with endpoint: #{@endpoint}"}
266
+ else
267
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: OCI::Config.new, signer: workload_identity_signer)
268
+ end
254
269
  when "ConfigFile"
255
270
  my_config = OCI::ConfigFileLoader.load_config(config_file_location: @config_file_location, profile_name: @profile_name)
256
- if is_valid(endpoint)
257
- @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config:my_config, endpoint:@endpoint)
271
+ if is_valid(@endpoint)
272
+ @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: my_config, endpoint: @endpoint)
258
273
  @@logger.info {"loganalytics_client initialised with endpoint: #{@endpoint}"}
259
274
  else
260
275
  @@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config:my_config)
@@ -623,6 +638,8 @@ module Fluent::Plugin
623
638
  latency = 0
624
639
  records_per_tag = 0
625
640
 
641
+
642
+
626
643
  tag_metrics_set = Hash.new
627
644
  logGroup_labels_set = Hash.new
628
645
 
@@ -632,8 +649,8 @@ module Fluent::Plugin
632
649
  tags_per_logGroupId = Hash.new
633
650
  tag_logSet_map = Hash.new
634
651
  tag_metadata_map = Hash.new
652
+ timezoneValuesByTag = Hash.new
635
653
  incoming_records = 0
636
-
637
654
  chunk.each do |time, record|
638
655
  incoming_records += 1
639
656
  metricsLabels = MetricsLabels.new
@@ -717,6 +734,8 @@ module Fluent::Plugin
717
734
  end
718
735
  next
719
736
  end
737
+
738
+ # metricsLabels.timezone = record["oci_la_timezone"]
720
739
  metricsLabels.logGroupId = record["oci_la_log_group_id"]
721
740
  metricsLabels.logSourceName = record["oci_la_log_source_name"]
722
741
  if record["oci_la_log_set"] != nil
@@ -765,6 +784,25 @@ module Fluent::Plugin
765
784
  tags_per_logGroupId[record["oci_la_log_group_id"]] = record["tag"]
766
785
  end
767
786
  end
787
+ # validating the timezone field
788
+ if !timezoneValuesByTag.has_key?(record["tag"])
789
+ begin
790
+ timezoneIdentifier = record["oci_la_timezone"]
791
+ unless is_valid(timezoneIdentifier)
792
+ record["oci_la_timezone"] = nil
793
+ else
794
+ isTimezoneExist = timezone_exist? timezoneIdentifier
795
+ unless isTimezoneExist
796
+ @@logger.warn { "Invalid timezone '#{timezoneIdentifier}', using default UTC." }
797
+ record["oci_la_timezone"] = "UTC"
798
+ end
799
+
800
+ end
801
+ timezoneValuesByTag[record["tag"]] = record["oci_la_timezone"]
802
+ end
803
+ else
804
+ record["oci_la_timezone"] = timezoneValuesByTag[record["tag"]]
805
+ end
768
806
 
769
807
  records << record
770
808
  ensure
@@ -911,6 +949,14 @@ module Fluent::Plugin
911
949
  end
912
950
  end
913
951
  end
952
+ def timezone_exist?(tz)
953
+ begin
954
+ TZInfo::Timezone.get(tz)
955
+ return true
956
+ rescue TZInfo::InvalidTimezoneIdentifier
957
+ return false
958
+ end
959
+ end
914
960
 
915
961
  # Each oci_la_log_set will correspond to a separate file in the zip
916
962
  # Only MAX_FILES_PER_ZIP files are allowed per zip.
@@ -953,6 +999,21 @@ module Fluent::Plugin
953
999
 
954
1000
  # takes a fluentD chunk and converts it to an in-memory zipfile, populating metrics hash provided
955
1001
  # Any exception raised is passed into the metrics hash, to be re-thrown from write()
1002
+ def getCollectionSource(input)
1003
+ collections_src = []
1004
+ if !is_valid input
1005
+ collections_src.unshift("source:#{Source::FLUENTD}")
1006
+ else
1007
+ if input == Source::FLUENTD.to_s or input == Source::KUBERNETES_SOLUTION.to_s
1008
+ collections_src.unshift("source:#{input}")
1009
+ else
1010
+ # source not define ! using default source 'fluentd'
1011
+ collections_src.unshift("source:#{Source::FLUENTD}")
1012
+ end
1013
+ end
1014
+ collections_src
1015
+ end
1016
+
956
1017
  def get_zipped_stream(oci_la_log_group_id,oci_la_global_metadata,records_per_logSet_map)
957
1018
  begin
958
1019
  current, = Time.now
@@ -965,8 +1026,9 @@ module Fluent::Plugin
965
1026
  record['oci_la_metadata'],
966
1027
  record['oci_la_entity_id'],
967
1028
  record['oci_la_entity_type'],
968
- record['oci_la_log_source_name'] ,
969
- record['oci_la_log_path']
1029
+ record['oci_la_log_source_name'],
1030
+ record['oci_la_log_path'],
1031
+ record['oci_la_timezone']
970
1032
  ]}.map { |lrpe_key, records_per_lrpe|
971
1033
  number_of_records += records_per_lrpe.length
972
1034
  LogEvents.new(lrpe_key, records_per_lrpe)
@@ -1016,9 +1078,10 @@ module Fluent::Plugin
1016
1078
  # upload zipped stream to oci
1017
1079
  def upload_to_oci(oci_la_log_group_id, number_of_records, zippedstream, metricsLabels_array)
1018
1080
  begin
1081
+ collection_src_prop = getCollectionSource @collection_source
1019
1082
  error_reason = nil
1020
1083
  error_code = nil
1021
- opts = {payload_type: "ZIP"}
1084
+ opts = { payload_type: "ZIP", opc_meta_properties:collection_src_prop}
1022
1085
 
1023
1086
  response = @@loganalytics_client.upload_log_events_file(namespace_name=@namespace,
1024
1087
  logGroupId=oci_la_log_group_id ,
@@ -0,0 +1,8 @@
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
+ # frozen_string_literal: true
5
+
6
+ module Version
7
+ VERSION = "2.0.7".freeze
8
+ end
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.5
4
+ version: 2.0.7
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: 2023-04-12 00:00:00.000000000 Z
12
+ date: 2024-10-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -93,14 +93,14 @@ 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
104
  - !ruby/object:Gem::Dependency
105
105
  name: yajl-ruby
106
106
  requirement: !ruby/object:Gem::Requirement
@@ -131,9 +131,11 @@ 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
138
+ - lib/fluent/version/version.rb
137
139
  homepage:
138
140
  licenses:
139
141
  - UPL-1.0
@@ -156,7 +158,7 @@ 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
161
+ rubygems_version: 3.0.3.1
160
162
  signing_key:
161
163
  specification_version: 4
162
164
  summary: Fluentd output plugin for OCI Logging Analytics.