fluent-plugin-oci-logging-analytics 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fluent/dto/logEvents.rb +6 -5
- data/lib/fluent/dto/logEventsJson.rb +2 -2
- data/lib/fluent/enums/source.rb +7 -0
- data/lib/fluent/metrics/metricsLabels.rb +6 -2
- data/lib/fluent/metrics/prometheusMetrics.rb +4 -1
- data/lib/fluent/plugin/out_oci-logging-analytics.rb +65 -7
- data/lib/fluent/version/version.rb +8 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b41804c02cd5e1dd39efc4c600f043cbed2a90972aabc39671c830fedcafe67
|
4
|
+
data.tar.gz: 24fc404d3f0f4d06f2e9f2167d7bc4fff337a235f9671e7e024ce71763750cb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a779a1971cabf78edf2c0b14ae6ba06235ce4113fe0ded3b264d626baba6c7f82f3aabdcb029890cb52697b2b01ae119691c7412e7920c79ada71ce8ed060fff
|
7
|
+
data.tar.gz: ef679bc249d8d16bc12a447f158c19faea8425c98170aecfbd7053da7d4081876f2b830f7c59dcef50e4abb9422d8e2cac30e91c16bffc4cf8e33072f931fe9c
|
data/lib/fluent/dto/logEvents.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
## Copyright (c) 2021,
|
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,
|
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
|
@@ -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,
|
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.'
|
@@ -256,6 +258,14 @@ module Fluent::Plugin
|
|
256
258
|
else
|
257
259
|
@@loganalytics_client = OCI::LogAnalytics::LogAnalyticsClient.new(config: OCI::Config.new, signer: instance_principals_signer)
|
258
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
|
259
269
|
when "ConfigFile"
|
260
270
|
my_config = OCI::ConfigFileLoader.load_config(config_file_location: @config_file_location, profile_name: @profile_name)
|
261
271
|
if is_valid(@endpoint)
|
@@ -628,6 +638,8 @@ module Fluent::Plugin
|
|
628
638
|
latency = 0
|
629
639
|
records_per_tag = 0
|
630
640
|
|
641
|
+
|
642
|
+
|
631
643
|
tag_metrics_set = Hash.new
|
632
644
|
logGroup_labels_set = Hash.new
|
633
645
|
|
@@ -637,8 +649,8 @@ module Fluent::Plugin
|
|
637
649
|
tags_per_logGroupId = Hash.new
|
638
650
|
tag_logSet_map = Hash.new
|
639
651
|
tag_metadata_map = Hash.new
|
652
|
+
timezoneValuesByTag = Hash.new
|
640
653
|
incoming_records = 0
|
641
|
-
|
642
654
|
chunk.each do |time, record|
|
643
655
|
incoming_records += 1
|
644
656
|
metricsLabels = MetricsLabels.new
|
@@ -722,6 +734,8 @@ module Fluent::Plugin
|
|
722
734
|
end
|
723
735
|
next
|
724
736
|
end
|
737
|
+
|
738
|
+
# metricsLabels.timezone = record["oci_la_timezone"]
|
725
739
|
metricsLabels.logGroupId = record["oci_la_log_group_id"]
|
726
740
|
metricsLabels.logSourceName = record["oci_la_log_source_name"]
|
727
741
|
if record["oci_la_log_set"] != nil
|
@@ -770,6 +784,25 @@ module Fluent::Plugin
|
|
770
784
|
tags_per_logGroupId[record["oci_la_log_group_id"]] = record["tag"]
|
771
785
|
end
|
772
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
|
773
806
|
|
774
807
|
records << record
|
775
808
|
ensure
|
@@ -916,6 +949,14 @@ module Fluent::Plugin
|
|
916
949
|
end
|
917
950
|
end
|
918
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
|
919
960
|
|
920
961
|
# Each oci_la_log_set will correspond to a separate file in the zip
|
921
962
|
# Only MAX_FILES_PER_ZIP files are allowed per zip.
|
@@ -958,6 +999,21 @@ module Fluent::Plugin
|
|
958
999
|
|
959
1000
|
# takes a fluentD chunk and converts it to an in-memory zipfile, populating metrics hash provided
|
960
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
|
+
|
961
1017
|
def get_zipped_stream(oci_la_log_group_id,oci_la_global_metadata,records_per_logSet_map)
|
962
1018
|
begin
|
963
1019
|
current, = Time.now
|
@@ -970,8 +1026,9 @@ module Fluent::Plugin
|
|
970
1026
|
record['oci_la_metadata'],
|
971
1027
|
record['oci_la_entity_id'],
|
972
1028
|
record['oci_la_entity_type'],
|
973
|
-
record['oci_la_log_source_name']
|
974
|
-
record['oci_la_log_path']
|
1029
|
+
record['oci_la_log_source_name'],
|
1030
|
+
record['oci_la_log_path'],
|
1031
|
+
record['oci_la_timezone']
|
975
1032
|
]}.map { |lrpe_key, records_per_lrpe|
|
976
1033
|
number_of_records += records_per_lrpe.length
|
977
1034
|
LogEvents.new(lrpe_key, records_per_lrpe)
|
@@ -1021,9 +1078,10 @@ module Fluent::Plugin
|
|
1021
1078
|
# upload zipped stream to oci
|
1022
1079
|
def upload_to_oci(oci_la_log_group_id, number_of_records, zippedstream, metricsLabels_array)
|
1023
1080
|
begin
|
1081
|
+
collection_src_prop = getCollectionSource @collection_source
|
1024
1082
|
error_reason = nil
|
1025
1083
|
error_code = nil
|
1026
|
-
opts = {payload_type: "ZIP"}
|
1084
|
+
opts = { payload_type: "ZIP", opc_meta_properties:collection_src_prop}
|
1027
1085
|
|
1028
1086
|
response = @@loganalytics_client.upload_log_events_file(namespace_name=@namespace,
|
1029
1087
|
logGroupId=oci_la_log_group_id ,
|
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
|
+
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: 2024-
|
12
|
+
date: 2024-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -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
|