From b8463c09876452d8262a8d9258ee4f984c44bafc Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Sun, 23 Jan 2022 19:44:18 -0800 Subject: [PATCH 1/9] add telemetry related to windows containers records --- source/plugins/ruby/in_kube_nodes.rb | 43 ++++++----- source/plugins/ruby/in_kube_podinventory.rb | 86 ++++++++++++++------- 2 files changed, 82 insertions(+), 47 deletions(-) diff --git a/source/plugins/ruby/in_kube_nodes.rb b/source/plugins/ruby/in_kube_nodes.rb index a32a32769..72a8e8987 100644 --- a/source/plugins/ruby/in_kube_nodes.rb +++ b/source/plugins/ruby/in_kube_nodes.rb @@ -1,17 +1,17 @@ #!/usr/local/bin/ruby # frozen_string_literal: true -require 'fluent/plugin/input' +require "fluent/plugin/input" module Fluent::Plugin class Kube_nodeInventory_Input < Input Fluent::Plugin.register_input("kube_nodes", self) - def initialize (kubernetesApiClient=nil, - applicationInsightsUtility=nil, - extensionUtils=nil, - env=nil, - telemetry_flush_interval=nil) + def initialize(kubernetesApiClient = nil, + applicationInsightsUtility = nil, + extensionUtils = nil, + env = nil, + telemetry_flush_interval = nil) super() require "yaml" @@ -36,8 +36,7 @@ def initialize (kubernetesApiClient=nil, @@promConfigMountPath = "/etc/config/settings/prometheus-data-collection-settings" @@osmConfigMountPath = "/etc/config/osm-settings/osm-metric-collection-configuration" @@AzStackCloudFileName = "/etc/kubernetes/host/azurestackcloud.json" - - + @@rsPromInterval = @env["TELEMETRY_RS_PROM_INTERVAL"] @@rsPromFieldPassCount = @env["TELEMETRY_RS_PROM_FIELDPASS_LENGTH"] @@rsPromFieldDropCount = @env["TELEMETRY_RS_PROM_FIELDDROP_LENGTH"] @@ -119,6 +118,7 @@ def enumerate nodeInventory = nil currentTime = Time.now batchTime = currentTime.utc.iso8601 + nodeCount = 0 @nodesAPIE2ELatencyMs = 0 @nodeInventoryE2EProcessingLatencyMs = 0 @@ -138,7 +138,7 @@ def enumerate if @tag.nil? || !@tag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) @tag = @extensionUtils.getOutputStreamId(Constants::KUBE_NODE_INVENTORY_DATA_TYPE) end - $log.info("in_kube_nodes::enumerate: using perf tag -#{@kubeperfTag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_nodes::enumerate: using perf tag -#{@kubeperfTag} @ #{Time.now.utc.iso8601}") $log.info("in_kube_nodes::enumerate: using insightsmetrics tag -#{@insightsMetricsTag} @ #{Time.now.utc.iso8601}") $log.info("in_kube_nodes::enumerate: using containernodeinventory tag -#{@ContainerNodeInventoryTag} @ #{Time.now.utc.iso8601}") $log.info("in_kube_nodes::enumerate: using kubenodeinventory tag -#{@tag} @ #{Time.now.utc.iso8601}") @@ -155,6 +155,7 @@ def enumerate nodesAPIChunkEndTime = (Time.now.to_f * 1000).to_i @nodesAPIE2ELatencyMs = (nodesAPIChunkEndTime - nodesAPIChunkStartTime) if (!nodeInventory.nil? && !nodeInventory.empty? && nodeInventory.key?("items") && !nodeInventory["items"].nil? && !nodeInventory["items"].empty?) + nodeCount += nodeInventory["items"].length $log.info("in_kube_nodes::enumerate : number of node items :#{nodeInventory["items"].length} from Kube API @ #{Time.now.utc.iso8601}") parse_and_emit_records(nodeInventory, batchTime) else @@ -168,6 +169,7 @@ def enumerate nodesAPIChunkEndTime = (Time.now.to_f * 1000).to_i @nodesAPIE2ELatencyMs = @nodesAPIE2ELatencyMs + (nodesAPIChunkEndTime - nodesAPIChunkStartTime) if (!nodeInventory.nil? && !nodeInventory.empty? && nodeInventory.key?("items") && !nodeInventory["items"].nil? && !nodeInventory["items"].empty?) + nodeCount += nodeInventory["items"].length $log.info("in_kube_nodes::enumerate : number of node items :#{nodeInventory["items"].length} from Kube API @ #{Time.now.utc.iso8601}") parse_and_emit_records(nodeInventory, batchTime) else @@ -179,8 +181,10 @@ def enumerate timeDifference = (DateTime.now.to_time.to_i - @@nodeInventoryLatencyTelemetryTimeTracker).abs timeDifferenceInMinutes = timeDifference / 60 if (timeDifferenceInMinutes >= @TELEMETRY_FLUSH_INTERVAL_IN_MINUTES) - @applicationInsightsUtility.sendMetricTelemetry("NodeInventoryE2EProcessingLatencyMs", @nodeInventoryE2EProcessingLatencyMs, {}) - @applicationInsightsUtility.sendMetricTelemetry("NodesAPIE2ELatencyMs", @nodesAPIE2ELatencyMs, {}) + properties = {} + properties["NodeCount"] = nodeCount + @applicationInsightsUtility.sendMetricTelemetry("NodeInventoryE2EProcessingLatencyMs", @nodeInventoryE2EProcessingLatencyMs, properties) + @applicationInsightsUtility.sendMetricTelemetry("NodesAPIE2ELatencyMs", @nodesAPIE2ELatencyMs, properties) @@nodeInventoryLatencyTelemetryTimeTracker = DateTime.now.to_time.to_i end # Setting this to nil so that we dont hold memory until GC kicks in @@ -208,9 +212,9 @@ def parse_and_emit_records(nodeInventory, batchTime = Time.utc.iso8601) nodeInventoryRecord = getNodeInventoryRecord(item, batchTime) eventStream.add(emitTime, nodeInventoryRecord) if nodeInventoryRecord if @NODES_EMIT_STREAM_BATCH_SIZE > 0 && eventStream.count >= @NODES_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_node::parse_and_emit_records: number of node inventory records emitted #{@NODES_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_node::parse_and_emit_records: number of node inventory records emitted #{eventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@tag, eventStream) if eventStream - $log.info("in_kube_node::parse_and_emit_records: number of mdm node inventory records emitted #{@NODES_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_node::parse_and_emit_records: number of mdm node inventory records emitted #{eventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@MDMKubeNodeInventoryTag, eventStream) if eventStream if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) $log.info("kubeNodeInventoryEmitStreamSuccess @ #{Time.now.utc.iso8601}") @@ -223,7 +227,7 @@ def parse_and_emit_records(nodeInventory, batchTime = Time.utc.iso8601) containerNodeInventoryEventStream.add(emitTime, containerNodeInventoryRecord) if containerNodeInventoryRecord if @NODES_EMIT_STREAM_BATCH_SIZE > 0 && containerNodeInventoryEventStream.count >= @NODES_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_node::parse_and_emit_records: number of container node inventory records emitted #{@NODES_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_node::parse_and_emit_records: number of container node inventory records emitted #{containerNodeInventoryEventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@ContainerNodeInventoryTag, containerNodeInventoryEventStream) if containerNodeInventoryEventStream containerNodeInventoryEventStream = Fluent::MultiEventStream.new if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) @@ -272,7 +276,7 @@ def parse_and_emit_records(nodeInventory, batchTime = Time.utc.iso8601) kubePerfEventStream.add(emitTime, metricRecord) if metricRecord end if @NODES_EMIT_STREAM_BATCH_SIZE > 0 && kubePerfEventStream.count >= @NODES_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_nodes::parse_and_emit_records: number of node perf metric records emitted #{@NODES_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_nodes::parse_and_emit_records: number of node perf metric records emitted #{kubePerfEventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@kubeperfTag, kubePerfEventStream) if kubePerfEventStream kubePerfEventStream = Fluent::MultiEventStream.new if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) @@ -302,7 +306,7 @@ def parse_and_emit_records(nodeInventory, batchTime = Time.utc.iso8601) insightsMetricsEventStream.add(emitTime, insightsMetricsRecord) if insightsMetricsRecord end if @NODES_EMIT_STREAM_BATCH_SIZE > 0 && insightsMetricsEventStream.count >= @NODES_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_nodes::parse_and_emit_records: number of GPU node perf metric records emitted #{@NODES_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_nodes::parse_and_emit_records: number of GPU node perf metric records emitted #{insightsMetricsEventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@insightsMetricsTag, insightsMetricsEventStream) if insightsMetricsEventStream insightsMetricsEventStream = Fluent::MultiEventStream.new if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) @@ -572,12 +576,12 @@ def getNodeTelemetryProps(item) return properties end end # Kube_Node_Input + class NodeStatsCache # inner class for caching implementation (CPU and memory caching is handled the exact same way, so logic to do so is moved to a private inner class) # (to reduce code duplication) class NodeCache - - @@RECORD_TIME_TO_LIVE = 60*20 # units are seconds, so clear the cache every 20 minutes. + @@RECORD_TIME_TO_LIVE = 60 * 20 # units are seconds, so clear the cache every 20 minutes. def initialize @cacheHash = {} @@ -622,7 +626,7 @@ def clean_cache() end end - nodes_to_remove.each {|node_name| + nodes_to_remove.each { |node_name| @cacheHash.delete(node_name) @timeAdded.delete(node_name) } @@ -630,7 +634,6 @@ def clean_cache() end end # NodeCache - @@cpuCache = NodeCache.new @@memCache = NodeCache.new diff --git a/source/plugins/ruby/in_kube_podinventory.rb b/source/plugins/ruby/in_kube_podinventory.rb index 3f5f4f1cc..aaaa99109 100644 --- a/source/plugins/ruby/in_kube_podinventory.rb +++ b/source/plugins/ruby/in_kube_podinventory.rb @@ -1,7 +1,7 @@ #!/usr/local/bin/ruby # frozen_string_literal: true -require 'fluent/plugin/input' +require "fluent/plugin/input" module Fluent::Plugin require_relative "podinventory_to_mdm" @@ -12,7 +12,6 @@ class Kube_PodInventory_Input < Input @@MDMKubePodInventoryTag = "mdm.kubepodinventory" @@hostName = (OMS::Common.get_hostname) - def initialize super require "yaml" @@ -38,6 +37,11 @@ def initialize @serviceCount = 0 @controllerSet = Set.new [] @winContainerCount = 0 + @windowsNodeCount = 0 + @winContainerInventoryTotalSizeBytes = 0 + @winContainerCountWithEnvVarSize64KBOrMore = 0 + @winContainerCountWithPortsSize64KBOrMore = 0 + @winContainerCountWithCommandSize64KBOrMore = 0 @controllerData = {} @podInventoryE2EProcessingLatencyMs = 0 @podsAPIE2ELatencyMs = 0 @@ -103,6 +107,11 @@ def enumerate(podList = nil) @serviceCount = 0 @controllerSet = Set.new [] @winContainerCount = 0 + @winContainerInventoryTotalSizeBytes = 0 + @winContainerCountWithEnvVarSize64KBOrMore = 0 + @winContainerCountWithPortsSize64KBOrMore = 0 + @winContainerCountWithCommandSize64KBOrMore = 0 + @windowsNodeCount = 0 @controllerData = {} currentTime = Time.now batchTime = currentTime.utc.iso8601 @@ -110,27 +119,27 @@ def enumerate(podList = nil) @podInventoryE2EProcessingLatencyMs = 0 podInventoryStartTime = (Time.now.to_f * 1000).to_i if ExtensionUtils.isAADMSIAuthMode() - $log.info("in_kube_podinventory::enumerate: AAD AUTH MSI MODE") - if @kubeperfTag.nil? || !@kubeperfTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) - @kubeperfTag = ExtensionUtils.getOutputStreamId(Constants::PERF_DATA_TYPE) - end - if @kubeservicesTag.nil? || !@kubeservicesTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) - @kubeservicesTag = ExtensionUtils.getOutputStreamId(Constants::KUBE_SERVICES_DATA_TYPE) - end - if @containerInventoryTag.nil? || !@containerInventoryTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) - @containerInventoryTag = ExtensionUtils.getOutputStreamId(Constants::CONTAINER_INVENTORY_DATA_TYPE) - end - if @insightsMetricsTag.nil? || !@insightsMetricsTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) - @insightsMetricsTag = ExtensionUtils.getOutputStreamId(Constants::INSIGHTS_METRICS_DATA_TYPE) - end - if @tag.nil? || !@tag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) - @tag = ExtensionUtils.getOutputStreamId(Constants::KUBE_POD_INVENTORY_DATA_TYPE) - end - $log.info("in_kube_podinventory::enumerate: using perf tag -#{@kubeperfTag} @ #{Time.now.utc.iso8601}") - $log.info("in_kube_podinventory::enumerate: using kubeservices tag -#{@kubeservicesTag} @ #{Time.now.utc.iso8601}") - $log.info("in_kube_podinventory::enumerate: using containerinventory tag -#{@containerInventoryTag} @ #{Time.now.utc.iso8601}") - $log.info("in_kube_podinventory::enumerate: using insightsmetrics tag -#{@insightsMetricsTag} @ #{Time.now.utc.iso8601}") - $log.info("in_kube_podinventory::enumerate: using kubepodinventory tag -#{@tag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::enumerate: AAD AUTH MSI MODE") + if @kubeperfTag.nil? || !@kubeperfTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) + @kubeperfTag = ExtensionUtils.getOutputStreamId(Constants::PERF_DATA_TYPE) + end + if @kubeservicesTag.nil? || !@kubeservicesTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) + @kubeservicesTag = ExtensionUtils.getOutputStreamId(Constants::KUBE_SERVICES_DATA_TYPE) + end + if @containerInventoryTag.nil? || !@containerInventoryTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) + @containerInventoryTag = ExtensionUtils.getOutputStreamId(Constants::CONTAINER_INVENTORY_DATA_TYPE) + end + if @insightsMetricsTag.nil? || !@insightsMetricsTag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) + @insightsMetricsTag = ExtensionUtils.getOutputStreamId(Constants::INSIGHTS_METRICS_DATA_TYPE) + end + if @tag.nil? || !@tag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) + @tag = ExtensionUtils.getOutputStreamId(Constants::KUBE_POD_INVENTORY_DATA_TYPE) + end + $log.info("in_kube_podinventory::enumerate: using perf tag -#{@kubeperfTag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::enumerate: using kubeservices tag -#{@kubeservicesTag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::enumerate: using containerinventory tag -#{@containerInventoryTag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::enumerate: using insightsmetrics tag -#{@insightsMetricsTag} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::enumerate: using kubepodinventory tag -#{@tag} @ #{Time.now.utc.iso8601}") end # Get services first so that we dont need to make a call for very chunk @@ -207,6 +216,17 @@ def enumerate(podList = nil) ApplicationInsightsUtility.sendMetricTelemetry("ControllerCount", @controllerSet.length, telemetryProperties) if @winContainerCount > 0 telemetryProperties["ClusterWideWindowsContainersCount"] = @winContainerCount + telemetryProperties["WindowsNodeCount"] = @windowsNodeCount + telemetryProperties["WinContainerInventoryTotalSizeKB"] = @winContainerInventoryTotalSizeBytes / 1024 + if @winContainerCountWithEnvVarSize64KBOrMore > 0 + telemetryProperties["WinContainerCountWithEnvVarSize64KBOrMore"] = @winContainerCountWithEnvVarSize64KBOrMore + end + if @winContainerCountWithPortsSize64KBOrMore > 0 + telemetryProperties["WinContainerCountWithPortsSize64KBOrMore"] = @winContainerCountWithPortsSize64KBOrMore + end + if @winContainerCountWithCommandSize64KBOrMore > 0 + telemetryProperties["WinContainerCountWithCommandSize64KBOrMore"] = @winContainerCountWithCommandSize64KBOrMore + end ApplicationInsightsUtility.sendCustomEvent("WindowsContainerInventoryEvent", telemetryProperties) end ApplicationInsightsUtility.sendMetricTelemetry("PodInventoryE2EProcessingLatencyMs", @podInventoryE2EProcessingLatencyMs, telemetryProperties) @@ -249,6 +269,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc if !item["spec"]["nodeName"].nil? nodeName = item["spec"]["nodeName"] end + @windowsNodeCount = winNodes.length if (!nodeName.empty? && (winNodes.include? nodeName)) clusterCollectEnvironmentVar = ENV["AZMON_CLUSTER_COLLECT_ENV_VAR"] #Generate ContainerInventory records for windows nodes so that we can get image and image tag in property panel @@ -258,13 +279,24 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc containerInventoryRecords.each do |cirecord| if !cirecord.nil? containerInventoryStream.add(emitTime, cirecord) if cirecord + @winContainerInventoryTotalSizeBytes += ci.record.to_s.length + # collect the telemetry of variable fields of windows container records if its >= 64KB + if !cirecord["EnvironmentVar"].nil? && !cirecord["EnvironmentVar"].empty? && cirecord["EnvironmentVar"].length >= 65536 + @winContainerCountWithEnvVarSize64KBOrMore += 1 + end + if !cirecord["Ports"].nil? && !cirecord["Ports"].empty? && cirecord["Ports"].length >= 65536 + @winContainerCountWithPortsSize64KBOrMore += 1 + end + if !cirecord["Command"].nil? && !cirecord["Command"].empty? && cirecord["Command"].length >= 65536 + @winContainerCountWithCommandSize64KBOrMore += 1 + end end end end end if @PODS_EMIT_STREAM_BATCH_SIZE > 0 && eventStream.count >= @PODS_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_podinventory::parse_and_emit_records: number of pod inventory records emitted #{@PODS_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::parse_and_emit_records: number of pod inventory records emitted #{eventStream.count} @ #{Time.now.utc.iso8601}") if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) $log.info("kubePodInventoryEmitStreamSuccess @ #{Time.now.utc.iso8601}") end @@ -284,7 +316,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc end if @PODS_EMIT_STREAM_BATCH_SIZE > 0 && kubePerfEventStream.count >= @PODS_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_podinventory::parse_and_emit_records: number of container perf records emitted #{@PODS_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::parse_and_emit_records: number of container perf records emitted #{kubePerfEventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@kubeperfTag, kubePerfEventStream) if kubePerfEventStream if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) $log.info("kubeContainerPerfEventEmitStreamSuccess @ #{Time.now.utc.iso8601}") @@ -303,7 +335,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc end if @PODS_EMIT_STREAM_BATCH_SIZE > 0 && insightsMetricsEventStream.count >= @PODS_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_podinventory::parse_and_emit_records: number of GPU insights metrics records emitted #{@PODS_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::parse_and_emit_records: number of GPU insights metrics records emitted #{insightsMetricsEventStream.count} @ #{Time.now.utc.iso8601}") if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) $log.info("kubePodInsightsMetricsEmitStreamSuccess @ #{Time.now.utc.iso8601}") end @@ -368,7 +400,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc kubeServiceRecord["ClusterName"] = KubernetesApiClient.getClusterName kubeServicesEventStream.add(emitTime, kubeServiceRecord) if kubeServiceRecord if @PODS_EMIT_STREAM_BATCH_SIZE > 0 && kubeServicesEventStream.count >= @PODS_EMIT_STREAM_BATCH_SIZE - $log.info("in_kube_podinventory::parse_and_emit_records: number of service records emitted #{@PODS_EMIT_STREAM_BATCH_SIZE} @ #{Time.now.utc.iso8601}") + $log.info("in_kube_podinventory::parse_and_emit_records: number of service records emitted #{kubeServicesEventStream.count} @ #{Time.now.utc.iso8601}") router.emit_stream(@kubeservicesTag, kubeServicesEventStream) if kubeServicesEventStream kubeServicesEventStream = Fluent::MultiEventStream.new if (!@@istestvar.nil? && !@@istestvar.empty? && @@istestvar.casecmp("true") == 0) From 0f095067cab6404c4e907dd16fd441c5667341b6 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Sun, 23 Jan 2022 19:51:54 -0800 Subject: [PATCH 2/9] add telemetry related to windows containers records --- source/plugins/ruby/in_cadvisor_perf.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/plugins/ruby/in_cadvisor_perf.rb b/source/plugins/ruby/in_cadvisor_perf.rb index 862e88e44..aba24ecc2 100644 --- a/source/plugins/ruby/in_cadvisor_perf.rb +++ b/source/plugins/ruby/in_cadvisor_perf.rb @@ -64,12 +64,12 @@ def enumerate() begin eventStream = Fluent::MultiEventStream.new insightsMetricsEventStream = Fluent::MultiEventStream.new - metricData = CAdvisorMetricsAPIClient.getMetrics(winNode: nil, metricTime: batchTime ) + metricData = CAdvisorMetricsAPIClient.getMetrics(winNode: nil, metricTime: batchTime) metricData.each do |record| eventStream.add(time, record) if record end - if ExtensionUtils.isAADMSIAuthMode() + if ExtensionUtils.isAADMSIAuthMode() && !@@isWindows.nil? && @@isWindows == false $log.info("in_cadvisor_perf::enumerate: AAD AUTH MSI MODE") if @tag.nil? || !@tag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) @tag = ExtensionUtils.getOutputStreamId(Constants::PERF_DATA_TYPE) @@ -77,7 +77,7 @@ def enumerate() if @insightsmetricstag.nil? || !@insightsmetricstag.start_with?(Constants::EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX) @insightsmetricstag = ExtensionUtils.getOutputStreamId(Constants::INSIGHTS_METRICS_DATA_TYPE) end - $log.info("in_cadvisor_perf::enumerate: using perf tag -#{@tag} @ #{Time.now.utc.iso8601}") + $log.info("in_cadvisor_perf::enumerate: using perf tag -#{@tag} @ #{Time.now.utc.iso8601}") $log.info("in_cadvisor_perf::enumerate: using insightsmetrics tag -#{@insightsmetricstag} @ #{Time.now.utc.iso8601}") end router.emit_stream(@tag, eventStream) if eventStream @@ -95,9 +95,9 @@ def enumerate() containerGPUusageInsightsMetricsDataItems = [] containerGPUusageInsightsMetricsDataItems.concat(CAdvisorMetricsAPIClient.getInsightsMetrics(winNode: nil, metricTime: batchTime)) - containerGPUusageInsightsMetricsDataItems.each do |insightsMetricsRecord| - insightsMetricsEventStream.add(time, insightsMetricsRecord) if insightsMetricsRecord - end + containerGPUusageInsightsMetricsDataItems.each do |insightsMetricsRecord| + insightsMetricsEventStream.add(time, insightsMetricsRecord) if insightsMetricsRecord + end router.emit_stream(@insightsmetricstag, insightsMetricsEventStream) if insightsMetricsEventStream router.emit_stream(@mdmtag, insightsMetricsEventStream) if insightsMetricsEventStream From b033086154c9700af9d165a811c7d4deabdbac72 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Sun, 23 Jan 2022 20:35:55 -0800 Subject: [PATCH 3/9] containercount telemetry --- source/plugins/ruby/in_kube_podinventory.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/plugins/ruby/in_kube_podinventory.rb b/source/plugins/ruby/in_kube_podinventory.rb index aaaa99109..6df68b853 100644 --- a/source/plugins/ruby/in_kube_podinventory.rb +++ b/source/plugins/ruby/in_kube_podinventory.rb @@ -34,6 +34,7 @@ def initialize @PODS_EMIT_STREAM_BATCH_SIZE = 0 @podCount = 0 + @containerCount = 0 @serviceCount = 0 @controllerSet = Set.new [] @winContainerCount = 0 @@ -104,6 +105,7 @@ def enumerate(podList = nil) podInventory = podList telemetryFlush = false @podCount = 0 + @containerCount = 0 @serviceCount = 0 @controllerSet = Set.new [] @winContainerCount = 0 @@ -211,6 +213,7 @@ def enumerate(podList = nil) telemetryProperties["PODS_EMIT_STREAM_BATCH_SIZE"] = @PODS_EMIT_STREAM_BATCH_SIZE ApplicationInsightsUtility.sendCustomEvent("KubePodInventoryHeartBeatEvent", telemetryProperties) ApplicationInsightsUtility.sendMetricTelemetry("PodCount", @podCount, {}) + ApplicationInsightsUtility.sendMetricTelemetry("ContainerCount", @containerCount, {}) ApplicationInsightsUtility.sendMetricTelemetry("ServiceCount", @serviceCount, {}) telemetryProperties["ControllerData"] = @controllerData.to_json ApplicationInsightsUtility.sendMetricTelemetry("ControllerCount", @controllerSet.length, telemetryProperties) @@ -256,6 +259,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc podInventory["items"].each do |item| #podInventory block start # pod inventory records podInventoryRecords = getPodInventoryRecords(item, serviceRecords, batchTime) + @containerCount += podInventoryRecords.length podInventoryRecords.each do |record| if !record.nil? eventStream.add(emitTime, record) if record From 0f2ed41488788198c15029e35a7a8daf8b76ba3a Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Mon, 24 Jan 2022 11:43:21 -0800 Subject: [PATCH 4/9] add explicit exit code in ps scripts --- build/windows/Makefile.ps1 | 20 ++--- .../build-and-publish-dev-docker-image.ps1 | 8 +- .../build-and-publish-docker-image.ps1 | 8 +- .../dockerbuild/build-dev-base-image.ps1 | 6 +- .../windows/install-build-pre-requisites.ps1 | 16 ++-- .../aks/mdmonboarding/mdm_onboarding.ps1 | 22 ++--- .../mdmonboarding/mdm_onboarding_atscale.ps1 | 22 ++--- .../kubernetes/AddMonitoringWorkspaceTags.ps1 | 28 +++--- .../onboarding/managed/disable-monitoring.ps1 | 38 ++++---- .../onboarding/managed/enable-monitoring.ps1 | 40 ++++----- scripts/troubleshoot/TroubleshootError.ps1 | 86 +++++++++---------- .../TroubleshootError_AcsEngine.ps1 | 54 ++++++------ .../TroubleshootError_nonAzureK8s.ps1 | 68 +++++++-------- 13 files changed, 208 insertions(+), 208 deletions(-) diff --git a/build/windows/Makefile.ps1 b/build/windows/Makefile.ps1 index 9f3c438b0..52abbb071 100644 --- a/build/windows/Makefile.ps1 +++ b/build/windows/Makefile.ps1 @@ -13,21 +13,21 @@ Write-Host("current script dir : " + $currentdir + " ") if ($false -eq (Test-Path -Path $currentdir)) { Write-Host("Invalid current dir : " + $currentdir + " ") -ForegroundColor Red - exit + exit 1 } $builddir = Split-Path -Path $currentdir Write-Host("builddir dir : " + $builddir + " ") if ($false -eq (Test-Path -Path $builddir)) { Write-Host("Invalid build dir : " + $builddir + " ") -ForegroundColor Red - exit + exit 1 } $versionFilePath = Join-Path -Path $builddir -child "version" Write-Host("versionFilePath : " + $versionFilePath + " ") if ($false -eq (Test-Path -Path $versionFilePath)) { Write-Host("Version file path incorrect or doesnt exist : " + $versionFilePath + " ") -ForegroundColor Red - exit + exit 1 } # read the version info @@ -36,7 +36,7 @@ foreach($line in Get-Content -Path $versionFilePath) { $parts = $line.split("=") if ($parts.length -lt 2 ) { Write-Host("Invalid content in version file : " + $versionFilePath + " ") -ForegroundColor Red - exit + exit 1 } switch ($parts[0]) { "CONTAINER_BUILDVERSION_MAJOR" { $BuildVersionMajor = $parts[1] } @@ -57,7 +57,7 @@ if ([string]::IsNullOrEmpty($BuildVersionMajor) -or [string]::IsNullOrEmpty($BuildVersionDate) -or [string]::IsNullOrEmpty($BuildVersionStatus)) { Write-Host("Expected version info doesnt exist in this version file : " + $versionFilePath + " ") -ForegroundColor Red - exit + exit 1 } # build version format will be [major].[minior].[patch]-[revision] $buildVersionString = $BuildVersionMajor + "." + $BuildVersionMinor + "." + $BuildVersionPatch + "-" + $BuildVersionBuildNR @@ -68,7 +68,7 @@ $certsrcdir = Join-Path -Path $builddir -ChildPath "windows\installer\certificat Write-Host("certsrc dir : " + $certsrcdir + " ") if ($false -eq (Test-Path -Path $certsrcdir)) { Write-Host("Invalid certificate generator source dir : " + $certsrcdir + " ") -ForegroundColor Red - exit + exit 1 } Write-Host("set the cerificate generator source code directory : " + $certsrcdir + " ...") Set-Location -Path $certsrcdir @@ -100,13 +100,13 @@ Write-Host("Successfully published certificate generator code binaries") -Foregr $certreleasebinpath = Join-Path -PATH $certsrcdir -ChildPath "bin\Release\$dotnetcoreframework\win10-x64\publish\*.*" if ($false -eq (Test-Path -Path $certreleasebinpath)) { Write-Host("certificate release bin path doesnt exist : " + $certreleasebinpath + " ") -ForegroundColor Red - exit + exit 1 } $rootdir = Split-Path -Path $builddir if ($false -eq (Test-Path -Path $rootdir)) { Write-Host("Invalid docker provider root source dir : " + $rootdir + " ") -ForegroundColor Red - exit + exit 1 } $publishdir = Join-Path -Path $rootdir -ChildPath "kubernetes\windows\omsagentwindows" @@ -128,7 +128,7 @@ $outomsgoplugindir = Join-Path -Path $rootdir -ChildPath "source\plugins\go\src" Write-Host("Building Out_OMS go plugin code...") if ($false -eq (Test-Path -Path $outomsgoplugindir)) { Write-Host("Invalid Out oms go plugin code dir : " + $outomsgoplugindir + " ") -ForegroundColor Red - exit + exit 1 } Set-Location -Path $outomsgoplugindir @@ -178,7 +178,7 @@ if (Test-Path -Path $livenessprobeexepath){ Write-Host("livenessprobe.exe exists which indicates cpp build step succeeded") -ForegroundColor Green } else { Write-Host("livenessprobe.exe doesnt exist which indicates cpp build step failed") -ForegroundColor Red - exit + exit 1 } $installerdir = Join-Path -Path $builddir -ChildPath "common\installer" diff --git a/kubernetes/windows/dockerbuild/build-and-publish-dev-docker-image.ps1 b/kubernetes/windows/dockerbuild/build-and-publish-dev-docker-image.ps1 index 0fde7f379..b87132218 100644 --- a/kubernetes/windows/dockerbuild/build-and-publish-dev-docker-image.ps1 +++ b/kubernetes/windows/dockerbuild/build-and-publish-dev-docker-image.ps1 @@ -15,18 +15,18 @@ Write-Host("current script dir : " + $currentdir + " ") if ($false -eq (Test-Path -Path $currentdir)) { Write-Host("Invalid current dir : " + $currentdir + " ") -ForegroundColor Red - exit + exit 1 } if ([string]::IsNullOrEmpty($image)) { Write-Host "Image parameter shouldnt be null or empty" -ForegroundColor Red - exit + exit 1 } $imageparts = $image.split(":") if (($imageparts.Length -ne 2)){ Write-Host "Image not in valid format. Expected format should be /:" -ForegroundColor Red - exit + exit 1 } $imagetag = $imageparts[1].ToLower() @@ -48,7 +48,7 @@ $dockerFileDir = Split-Path -Path $currentdir Write-Host("builddir dir : " + $dockerFileDir + " ") if ($false -eq (Test-Path -Path $dockerFileDir)) { Write-Host("Invalid dockerFile Dir : " + $dockerFileDir + " ") -ForegroundColor Red - exit + exit 1 } Write-Host "changing directory to DockerFile dir: $dockerFileDir" diff --git a/kubernetes/windows/dockerbuild/build-and-publish-docker-image.ps1 b/kubernetes/windows/dockerbuild/build-and-publish-docker-image.ps1 index dbcfa6097..c1f655882 100644 --- a/kubernetes/windows/dockerbuild/build-and-publish-docker-image.ps1 +++ b/kubernetes/windows/dockerbuild/build-and-publish-docker-image.ps1 @@ -15,18 +15,18 @@ Write-Host("current script dir : " + $currentdir + " ") if ($false -eq (Test-Path -Path $currentdir)) { Write-Host("Invalid current dir : " + $currentdir + " ") -ForegroundColor Red - exit + exit 1 } if ([string]::IsNullOrEmpty($image)) { Write-Host "Image parameter shouldnt be null or empty" -ForegroundColor Red - exit + exit 1 } $imageparts = $image.split(":") if (($imageparts.Length -ne 2)){ Write-Host "Image not in valid format. Expected format should be /:" -ForegroundColor Red - exit + exit 1 } $imagetag = $imageparts[1].ToLower() @@ -48,7 +48,7 @@ $dockerFileDir = Split-Path -Path $currentdir Write-Host("builddir dir : " + $dockerFileDir + " ") if ($false -eq (Test-Path -Path $dockerFileDir)) { Write-Host("Invalid dockerFile Dir : " + $dockerFileDir + " ") -ForegroundColor Red - exit + exit 1 } Write-Host "changing directory to DockerFile dir: $dockerFileDir" diff --git a/kubernetes/windows/dockerbuild/build-dev-base-image.ps1 b/kubernetes/windows/dockerbuild/build-dev-base-image.ps1 index 142e20c3f..4b17239d2 100644 --- a/kubernetes/windows/dockerbuild/build-dev-base-image.ps1 +++ b/kubernetes/windows/dockerbuild/build-dev-base-image.ps1 @@ -1,6 +1,6 @@ <# .DESCRIPTION - Builds the Docker Image locally for the server core ltsc base and installs dependencies + Builds the Docker Image locally for the server core ltsc base and installs dependencies #> @@ -9,7 +9,7 @@ Write-Host("current script dir : " + $currentdir + " ") if ($false -eq (Test-Path -Path $currentdir)) { Write-Host("Invalid current dir : " + $currentdir + " ") -ForegroundColor Red - exit + exit 1 } Write-Host "start:Building the cert generator and out oms code via Makefile.ps1" @@ -20,7 +20,7 @@ $dockerFileDir = Split-Path -Path $currentdir Write-Host("builddir dir : " + $dockerFileDir + " ") if ($false -eq (Test-Path -Path $dockerFileDir)) { Write-Host("Invalid dockerFile Dir : " + $dockerFileDir + " ") -ForegroundColor Red - exit + exit 1 } Write-Host "changing directory to DockerFile dir: $dockerFileDir" diff --git a/scripts/build/windows/install-build-pre-requisites.ps1 b/scripts/build/windows/install-build-pre-requisites.ps1 index 7f1c9b54f..1ea316798 100755 --- a/scripts/build/windows/install-build-pre-requisites.ps1 +++ b/scripts/build/windows/install-build-pre-requisites.ps1 @@ -2,7 +2,7 @@ function Install-Go { $tempDir = $env:TEMP if ($false -eq (Test-Path -Path $tempDir)) { Write-Host("Invalid TEMP dir PATH : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $tempGo = Join-Path -Path $tempDir -ChildPath "gotemp" @@ -10,7 +10,7 @@ function Install-Go { New-Item -Path $tempGo -ItemType "directory" -Force -ErrorAction Stop if ($false -eq (Test-Path -Path $tempGo)) { Write-Host("Invalid tempGo : " + $tempGo + " ") -ForegroundColor Red - exit + exit 1 } $url = "https://dl.google.com/go/go1.15.14.windows-amd64.msi" @@ -35,7 +35,7 @@ function Build-Dependencies { $tempDir = $env:TEMP if ($false -eq (Test-Path -Path $tempDir)) { Write-Host("Invalid TEMP dir PATH : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $tempDependencies = Join-Path -Path $tempDir -ChildPath "gcctemp" @@ -43,7 +43,7 @@ function Build-Dependencies { New-Item -Path $tempDependencies -ItemType "directory" -Force -ErrorAction Stop if ($false -eq (Test-Path -Path $tempDependencies)) { Write-Host("Invalid temp Dir : " + $tempDependencies + " ") -ForegroundColor Red - exit + exit 1 } @@ -82,7 +82,7 @@ function Install-DotNetCoreSDK() { $tempDir = $env:TEMP if ($false -eq (Test-Path -Path $tempDir)) { Write-Host("Invalid TEMP dir : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $dotNetSdkTemp = Join-Path -Path $tempDir -ChildPath "dotNetSdk" @@ -90,7 +90,7 @@ function Install-DotNetCoreSDK() { New-Item -Path $dotNetSdkTemp -ItemType "directory" -Force -ErrorAction Stop if ($false -eq (Test-Path -Path $dotNetSdkTemp)) { Write-Host("Invalid dotNetSdkTemp : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $url = "https://download.visualstudio.microsoft.com/download/pr/4e88f517-196e-4b17-a40c-2692c689661d/eed3f5fca28262f764d8b650585a7278/dotnet-sdk-3.1.301-win-x64.exe" @@ -110,7 +110,7 @@ function Install-Docker() { $tempDir = $env:TEMP if ($false -eq (Test-Path -Path $tempDir)) { Write-Host("Invalid TEMP dir PATH : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $dockerTemp = Join-Path -Path $tempDir -ChildPath "docker" @@ -118,7 +118,7 @@ function Install-Docker() { New-Item -Path $dockerTemp -ItemType "directory" -Force -ErrorAction Stop if ($false -eq (Test-Path -Path $dockerTemp)) { Write-Host("Invalid dockerTemp : " + $tempDir + " ") -ForegroundColor Red - exit + exit 1 } $url = "https://download.docker.com/win/stable/Docker%20Desktop%20Installer.exe" diff --git a/scripts/onboarding/aks/mdmonboarding/mdm_onboarding.ps1 b/scripts/onboarding/aks/mdmonboarding/mdm_onboarding.ps1 index dcf73f098..a5d95c31e 100644 --- a/scripts/onboarding/aks/mdmonboarding/mdm_onboarding.ps1 +++ b/scripts/onboarding/aks/mdmonboarding/mdm_onboarding.ps1 @@ -39,7 +39,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az else { Write-Host("Please run the script as an administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } @@ -66,7 +66,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -77,7 +77,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -88,7 +88,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.Aks in a new powershell window: eg. 'Install-Module Az.Aks -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -103,7 +103,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -114,7 +114,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAksModule) { @@ -124,7 +124,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az catch { Write-Host("Could not import Az.Aks... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -132,7 +132,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azAksModule) -or ($null -eq $az 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -161,7 +161,7 @@ if ($account.Account -eq $null) { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -181,7 +181,7 @@ else { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -196,7 +196,7 @@ if ($notPresent) { Write-Host("Could not find Aks cluster. Please make sure that specified cluster exists: '" + $clusterName + "'is correct and you have access to the cluster") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully checked specified cluster exists details...") -ForegroundColor Green diff --git a/scripts/onboarding/aks/mdmonboarding/mdm_onboarding_atscale.ps1 b/scripts/onboarding/aks/mdmonboarding/mdm_onboarding_atscale.ps1 index a791bb18e..32311ca61 100644 --- a/scripts/onboarding/aks/mdmonboarding/mdm_onboarding_atscale.ps1 +++ b/scripts/onboarding/aks/mdmonboarding/mdm_onboarding_atscale.ps1 @@ -30,7 +30,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ else { Write-Host("Please run the script as an administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } @@ -57,7 +57,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -68,7 +68,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -79,7 +79,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.Aks in a new powershell window: eg. 'Install-Module Az.Aks -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -94,7 +94,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -105,7 +105,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAksModule) { @@ -115,7 +115,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ catch { Write-Host("Could not import Az.Aks... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -123,7 +123,7 @@ if (($null -eq $azAccountModule) -or ( $null -eq $azAksModule ) -or ($null -eq $ 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -152,7 +152,7 @@ if ($account.Account -eq $null) { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -172,7 +172,7 @@ else { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -187,7 +187,7 @@ if ($notPresent) { Write-Host("Failed to get Aks clusters in specified subscription. Please make sure that you have access to the existing clusters") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully got all aks clusters ...") -ForegroundColor Green diff --git a/scripts/onboarding/aksengine/kubernetes/AddMonitoringWorkspaceTags.ps1 b/scripts/onboarding/aksengine/kubernetes/AddMonitoringWorkspaceTags.ps1 index 29f629878..a0965f960 100644 --- a/scripts/onboarding/aksengine/kubernetes/AddMonitoringWorkspaceTags.ps1 +++ b/scripts/onboarding/aksengine/kubernetes/AddMonitoringWorkspaceTags.ps1 @@ -64,7 +64,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule)) { else { Write-Host("Please run the script as an administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -89,7 +89,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule)) { } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } try { Write-Host("Installing Az.Accounts...") @@ -97,7 +97,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule)) { } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -109,7 +109,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule)) { Write-Host("Could not import Az.Resources ...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } try { Import-Module Az.Accounts @@ -117,14 +117,14 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule)) { catch { Write-Host("Could not import Az.Accounts... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -138,7 +138,7 @@ if ($NameoftheCloud -like "AzureCloud" -or } else { Write-Host("Error: Monitoring not supported in this cloud: $NameoftheCloud") -ForegroundColor Red - exit + exit 1 } # @@ -151,7 +151,7 @@ if ($notPresent) { Write-Host("Could not find RG. Please make sure that the resource group name: '" + $ResourceGroupName + "'is correct and you have access to the aks-engine cluster") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully checked resource groups details...") -ForegroundColor Green @@ -179,20 +179,20 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { } else { Write-Host("Resource group name: '" + $ResourceGroupName + "'is doesnt have the aks-engine resources") -ForegroundColor Red - exit + exit 1 } } if ($isKubernetesCluster -eq $false) { Write-Host("Resource group name: '" + $ResourceGroupName + "' doesnt have the aks-engine or acs-engine resources") -ForegroundColor Red - exit + exit 1 } # validate specified logAnalytics workspace exists or not $workspaceResource = Get-AzResource -ResourceId $LogAnalyticsWorkspaceResourceId if ($null -eq $workspaceResource) { Write-Host("Specified Log Analytics workspace ResourceId: '" + $LogAnalyticsWorkspaceResourceId + "' doesnt exist or don't have access to it") -ForegroundColor Red - exit + exit 1 } # @@ -202,11 +202,11 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { $r = Get-AzResource -ResourceGroupName $ResourceGroupName -ResourceName $k8MasterVM.Name if ($null -eq $r) { Write-Host("Get-AzResource for Resource Group: " + $ResourceGroupName + "Resource Name :" + $k8MasterVM.Name + " failed" ) -ForegroundColor Red - exit + exit 1 } if ($null -eq $r.Tags) { Write-Host("K8s master VM should have the tags" ) -ForegroundColor Red - exit + exit 1 } if ($r.Tags.ContainsKey("logAnalyticsWorkspaceResourceId")) { $existingLogAnalyticsWorkspaceResourceId = $r.Tags["logAnalyticsWorkspaceResourceId"] @@ -225,7 +225,7 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { $existingclusterName = $r.Tags["clusterName"] if ($existingclusterName -eq $ClusterName) { Write-Host("Ignoring attaching clusterName tag to K8s master VM :" + $k8MasterVM.Name + " since it has already with same tag value" ) -ForegroundColor Yellow - exit + exit 1 } Write-Host("K8s master VM :" + $k8MasterVM.Name + " has the existing tag for clusterName with different from specified one" ) -ForegroundColor Green $r.Tags.Remove("clusterName") diff --git a/scripts/onboarding/managed/disable-monitoring.ps1 b/scripts/onboarding/managed/disable-monitoring.ps1 index bcd135dba..8be60c50d 100644 --- a/scripts/onboarding/managed/disable-monitoring.ps1 +++ b/scripts/onboarding/managed/disable-monitoring.ps1 @@ -61,7 +61,7 @@ if ([string]::IsNullOrEmpty($azureCloudName) -eq $true) { } else { Write-Host("Specified Azure Cloud name is : $azureCloudName") Write-Host("Only supported Azure clouds are : AzureCloud and AzureUSGovernment") - exit + exit 1 } } @@ -89,7 +89,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - else { Write-Host("Please re-launch the script with elevated administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -116,7 +116,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -127,7 +127,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -139,7 +139,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.OperationalInsights in a new powershell window: eg. 'Install-Module Az.OperationalInsights -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -154,7 +154,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -165,7 +165,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -176,7 +176,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Could not import Az.OperationalInsights... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -184,14 +184,14 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } if ([string]::IsNullOrEmpty($clusterResourceId)) { Write-Host("Specified Azure ClusterResourceId should not be NULL or empty") -ForegroundColor Red - exit + exit 1 } if ([string]::IsNullOrEmpty($kubeContext)) { @@ -211,7 +211,7 @@ if ($clusterResourceId.StartsWith("/") -eq $false) { if ($clusterResourceId.Split("/").Length -ne 9){ Write-Host("Provided Cluster Resource Id is not in expected format") -ForegroundColor Red - exit + exit 1 } if (($clusterResourceId.ToLower().Contains("microsoft.kubernetes/connectedclusters") -ne $true) -and @@ -219,7 +219,7 @@ if (($clusterResourceId.ToLower().Contains("microsoft.kubernetes/connectedcluste ($clusterResourceId.ToLower().Contains("microsoft.containerservice/managedclusters") -ne $true) ) { Write-Host("Provided cluster ResourceId is not supported cluster type: $clusterResourceId") -ForegroundColor Red - exit + exit 1 } if ($clusterResourceId.ToLower().Contains("microsoft.kubernetes/connectedclusters") -eq $true) { @@ -284,7 +284,7 @@ if ($null -eq $account.Account) { Write-Host("Could not select subscription with ID : " + $clusterSubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -304,7 +304,7 @@ else { Write-Host("Could not select subscription with ID : " + $clusterSubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -314,7 +314,7 @@ Write-Host("Checking specified Azure Managed cluster resource exists and got acc $clusterResource = Get-AzResource -ResourceId $clusterResourceId if ($null -eq $clusterResource) { Write-Host("specified Azure Managed cluster resource id either you dont have access or doesnt exist") -ForegroundColor Red - exit + exit 1 } $clusterRegion = $clusterResource.Location.ToLower() @@ -323,7 +323,7 @@ if ($isArcK8sCluster -eq $true) { $clusterIdentity = $clusterResource.identity.type.ToString().ToLower() if ($clusterIdentity.Contains("systemassigned") -eq $false) { Write-Host("Identity of Azure Arc enabled Kubernetes cluster should be systemassigned but it has identity: $clusterIdentity") -ForegroundColor Red - exit + exit 1 } } @@ -345,7 +345,7 @@ try { $releases = helm list --filter $helmChartReleaseName if ($releases.Count -lt 2) { Write-Host("There is no existing release with name : $helmChartReleaseName") -ForegroundColor Yellow - exit + exit 1 } for($index =0 ; $index -lt $releases.Count ; $index ++ ) { @@ -360,7 +360,7 @@ try { $releases = helm list --filter $helmChartReleaseName --kube-context $kubeContext if ($releases.Count -lt 2) { Write-Host("There is no existing release with name : $helmChartReleaseName") -ForegroundColor Yellow - exit + exit 1 } for($index =0 ; $index -lt $releases.Count ; $index ++ ) { @@ -374,7 +374,7 @@ try { } catch { Write-Host ("Failed to delete Azure Monitor for containers HELM chart : '" + $Error[0] + "' ") -ForegroundColor Red - exit + exit 1 } Write-Host("Successfully disabled Azure Monitor for containers for cluster: $clusteResourceId") -ForegroundColor Green diff --git a/scripts/onboarding/managed/enable-monitoring.ps1 b/scripts/onboarding/managed/enable-monitoring.ps1 index e79ef2138..27bc2fd62 100644 --- a/scripts/onboarding/managed/enable-monitoring.ps1 +++ b/scripts/onboarding/managed/enable-monitoring.ps1 @@ -81,7 +81,7 @@ if ([string]::IsNullOrEmpty($azureCloudName) -eq $true) { } else { Write-Host("Specified Azure Cloud name is : $azureCloudName") Write-Host("Only supported azure clouds are : AzureCloud and AzureUSGovernment") - exit + exit 1 } } @@ -109,7 +109,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - else { Write-Host("Please re-launch the script with elevated administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -136,7 +136,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -147,7 +147,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -159,7 +159,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - } catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.OperationalInsights in a new powershell window: eg. 'Install-Module Az.OperationalInsights -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } @@ -174,7 +174,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -185,7 +185,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -196,7 +196,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Could not import Az.OperationalInsights... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -204,14 +204,14 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } if ([string]::IsNullOrEmpty($clusterResourceId)) { Write-Host("Specified Azure Arc enabled Kubernetes ClusterResourceId should not be NULL or empty") -ForegroundColor Red - exit + exit 1 } if ([string]::IsNullOrEmpty($kubeContext)) { @@ -232,7 +232,7 @@ if ($clusterResourceId.StartsWith("/") -eq $false) { if ($clusterResourceId.Split("/").Length -ne 9) { Write-Host("Provided Cluster Resource Id is not in expected format") -ForegroundColor Red - exit + exit 1 } if (($clusterResourceId.ToLower().Contains("microsoft.kubernetes/connectedclusters") -ne $true) -and @@ -240,7 +240,7 @@ if (($clusterResourceId.ToLower().Contains("microsoft.kubernetes/connectedcluste ($clusterResourceId.ToLower().Contains("microsoft.containerservice/managedclusters") -ne $true) ) { Write-Host("Provided cluster ResourceId is not supported cluster type: $clusterResourceId") -ForegroundColor Red - exit + exit 1 } if (([string]::IsNullOrEmpty($servicePrincipalClientId) -eq $false) -and @@ -305,7 +305,7 @@ if ($null -eq $account.Account) { Write-Host("Could not select subscription with ID : " + $clusterSubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -325,7 +325,7 @@ else { Write-Host("Could not select subscription with ID : " + $clusterSubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -335,7 +335,7 @@ Write-Host("Checking specified Azure Managed cluster resource exists and got acc $clusterResource = Get-AzResource -ResourceId $clusterResourceId if ($null -eq $clusterResource) { Write-Host("specified Azure Managed cluster resource id either you dont have access or doesnt exist") -ForegroundColor Red - exit + exit 1 } $clusterRegion = $clusterResource.Location.ToLower() @@ -344,7 +344,7 @@ if ($isArcK8sCluster -eq $true) { $clusterIdentity = $clusterResource.identity.type.ToString().ToLower() if ($clusterIdentity.contains("systemassigned") -eq $false) { Write-Host("Identity of Azure Arc enabled Kubernetes cluster should be systemassigned but it has identity: $clusterIdentity") -ForegroundColor Red - exit + exit 1 } } @@ -450,7 +450,7 @@ else { Write-Host("using specified Log Analytics Workspace ResourceId: '" + $workspaceResourceId + "' ") if ([string]::IsNullOrEmpty($workspaceResourceId)) { Write-Host("Specified workspaceResourceId should not be NULL or empty") -ForegroundColor Red - exit + exit 1 } $workspaceResourceId = $workspaceResourceId.Trim() if ($workspaceResourceId.EndsWith("/")) { @@ -465,7 +465,7 @@ else { if (($workspaceResourceId.ToLower().Contains("microsoft.operationalinsights/workspaces") -ne $true) -or ($workspaceResourceId.Split("/").Length -ne 9)) { Write-Host("Provided workspace resource id should be in this format /subscriptions//resourceGroups//providers/Microsoft.OperationalInsights/workspaces/") -ForegroundColor Red - exit + exit 1 } $workspaceResourceParts = $workspaceResourceId.Split("/") @@ -482,7 +482,7 @@ else { $WorkspaceInformation = Get-AzOperationalInsightsWorkspace -ResourceGroupName $workspaceResourceGroup -Name $workspaceName -ErrorAction SilentlyContinue if ($null -eq $WorkspaceInformation) { Write-Host("Specified Log Analytics Workspace: '" + $workspaceName + "' in Resource Group: '" + $workspaceResourceGroup + "' in Subscription: '" + $workspaceSubscriptionId + "' does not exist") -ForegroundColor Red - exit + exit 1 } } @@ -520,7 +520,7 @@ try { } catch { Write-Host ("Failed to workspace details. Please validate whether you have Log Analytics Contributor role on the workspace error: '" + $Error[0] + "' ") -ForegroundColor Red - exit + exit 1 } diff --git a/scripts/troubleshoot/TroubleshootError.ps1 b/scripts/troubleshoot/TroubleshootError.ps1 index 4c2d95ac6..6d97c53d5 100644 --- a/scripts/troubleshoot/TroubleshootError.ps1 +++ b/scripts/troubleshoot/TroubleshootError.ps1 @@ -35,7 +35,7 @@ if (($null -eq $ClusterResourceId) -or ($ClusterResourceId.Split("/").Length -ne Write-Host("Resource Id Format for AKS cluster is : /subscriptions//resourceGroups//providers/Microsoft.ContainerService/managedClusters/") -ForegroundColor Red Write-Host("Resource Id Format for ARO cluster is : /subscriptions//resourceGroups//providers/Microsoft.ContainerService/openShiftManagedClusters/") -ForegroundColor Red Stop-Transcript - exit + exit 1 } $isClusterAndWorkspaceInDifferentSubs = $false @@ -70,7 +70,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco else { Write-Host("Please re-launch the script with elevated administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -97,7 +97,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.ResourceGraph in a new powershell window: eg. 'Install-Module Az.ResourceGraph -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAksModule) { @@ -108,7 +108,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.Aks in a new powershell window: eg. 'Install-Module Az.Aks -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -120,7 +120,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -132,7 +132,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -145,7 +145,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.OperationalInsights in a new powershell window: eg. 'Install-Module Az.OperationalInsights -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -159,7 +159,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco Write-Host("Could not Import Az.ResourceGraph...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.ResourceGraph in a new powershell window: eg. 'Install-Module Az.ResourceGraph -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -171,7 +171,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco Write-Host("Could not Import Az.Aks...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Aks in a new powershell window: eg. 'Install-Module Az.Aks -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -183,7 +183,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -194,7 +194,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -205,7 +205,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco catch { Write-Host("Could not import Az.OperationalInsights... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -213,7 +213,7 @@ if (($null -eq $azAksModule) -or ($null -eq $azARGModule) -or ($null -eq $azAcco 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -277,7 +277,7 @@ if ($null -eq $account.Account) { Write-Host("Could not select subscription with ID : " + $ClusterSubscriptionId + ". Please make sure the SubscriptionId you entered is correct and you have access to the Subscription" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -297,7 +297,7 @@ else { Write-Host("Could not select subscription with ID : " + $ClusterSubscriptionId + ". Please make sure the SubscriptionId you entered is correct and you have access to the Subscription" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -313,7 +313,7 @@ if ($notPresent) { Write-Host("Could not find RG. Please make sure that the resource group name: '" + $ResourceGroupName + "'is correct and you have access to the Resource Group") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully checked resource groups details...") -ForegroundColor Green @@ -327,7 +327,7 @@ try { Write-Host("Could not fetch cluster details: Please make sure that the '" + $ClusterType + "' Cluster name: '" + $ClusterName + "' is correct and you have access to the cluster") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } else { Write-Host("Successfully checked '" + $ClusterType + "' Cluster details...") -ForegroundColor Green @@ -342,7 +342,7 @@ try { Write-Host($AksOptInLink) -ForegroundColor Red; Write-Host(""); Stop-Transcript - exit + exit 1 } $omsagentconfig = $props.addonprofiles.omsagent.config; @@ -364,7 +364,7 @@ try { Write-Host("Could not fetch cluster details: Please make sure that the '" + $ClusterType + "' Cluster name: '" + $ClusterName + "' is correct and you have access to the cluster") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $monitorProfile = $ResourceDetail.aroproperties.monitorprofile @@ -373,7 +373,7 @@ try { Write-Host($AksOptInLink) -ForegroundColor Red; Write-Host(""); Stop-Transcript - exit + exit 1 } $LogAnalyticsWorkspaceResourceID = $monitorProfile.workspaceresourceid @@ -385,7 +385,7 @@ catch { Write-Host("Could not fetch cluster details: Please make sure that the '" + $ClusterType + "' Cluster name: '" + $ClusterName + "' is correct and you have access to the cluster") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } @@ -511,7 +511,7 @@ if ($null -eq $LogAnalyticsWorkspaceResourceID) { } Write-Host("") Stop-Transcript - exit + exit 1 } else { @@ -532,7 +532,7 @@ else { Write-Host("Could not change to Workspace subscriptionId : '" + $workspaceSubscriptionId + "'." ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } @@ -557,7 +557,7 @@ else { } Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully fetched workspace subcription details...") -ForegroundColor Green Write-Host("") @@ -581,7 +581,7 @@ else { Write-Host("Opt-in - " + $AksOptInLink) -ForegroundColor Red } Stop-Transcript - exit + exit 1 } Write-Host("Successfully fetched workspace resource group...") -ForegroundColor Green Write-Host("") @@ -610,7 +610,7 @@ else { } Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspaceLocation = $WorkspaceInformation.Location @@ -619,7 +619,7 @@ else { Write-Host("Cannot fetch workspace location. Please try again...") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspacePricingTier = $WorkspaceInformation.sku @@ -635,7 +635,7 @@ else { Write-Host("Failed to get the list of solutions onboarded to the workspace. Please make sure that it hasn't been deleted and you have access to it.") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } try { @@ -647,7 +647,7 @@ else { Write-Host("Failed to get ContainerInsights solution details from the workspace") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $isSolutionOnboarded = $WorkspaceIPDetails.Enabled[$ContainerInsightsIndex] @@ -711,7 +711,7 @@ try { if ($WorkspaceUsage.CurrentValue -ge $WorkspaceUsage.Limit) { Write-Host("Workspace usage has reached or over the configured daily cap. Please increase the daily cap limits or wait for next reset interval") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } Write-Host("Workspace doesnt have daily cap configured") -ForegroundColor Green @@ -720,7 +720,7 @@ catch { Write-Host("Failed to get usage details of the workspace") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } @@ -757,7 +757,7 @@ if ("AKS" -eq $ClusterType ) { Write-Host($AksOptInLink) -ForegroundColor Red Write-Host($contactUSMessage) Stop-Transcript - exit + exit 1 } $rsPodStatus = $rsPod.status @@ -778,7 +778,7 @@ if ("AKS" -eq $ClusterType ) { Write-Host($AksOptInLink) -ForegroundColor Red Write-Host($contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent replicaset pod running OK.") -ForegroundColor Green @@ -786,7 +786,7 @@ if ("AKS" -eq $ClusterType ) { catch { Write-Host ("Failed to get omsagent replicatset pod info using kubectl get rs : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the omsagent daemonset pod running correctly ...") @@ -795,7 +795,7 @@ if ("AKS" -eq $ClusterType ) { if (($null -eq $ds) -or ($null -eq $ds.Items) -or ($ds.Items.Length -ne 1)) { Write-Host( "omsagent replicaset pod not scheduled or failed to schedule." + $contactUSMessage) Stop-Transcript - exit + exit 1 } $dsStatus = $ds.Items[0].status @@ -809,7 +809,7 @@ if ("AKS" -eq $ClusterType ) { Write-Host($dsStatus) Write-Host($contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent daemonset pod running OK.") -ForegroundColor Green @@ -817,7 +817,7 @@ if ("AKS" -eq $ClusterType ) { catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the omsagent heatlhservice running correctly ...") @@ -826,7 +826,7 @@ if ("AKS" -eq $ClusterType ) { if ($healthservice.Items.Length -ne 1) { Write-Host( "omsagent healthservice not scheduled or failed to schedule." + $contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent healthservice running OK.") -ForegroundColor Green @@ -834,7 +834,7 @@ if ("AKS" -eq $ClusterType ) { catch { Write-Host ("Failed to execute kubectl get services command : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } if ($isClusterAndWorkspaceInDifferentSubs) { @@ -851,7 +851,7 @@ if ("AKS" -eq $ClusterType ) { catch { Write-Host ("Failed to get workspace details. Please validate whether you have Log Analytics Contributor role on the workspace error: '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the WorkspaceGuid and key matching with configured log analytics workspace ...") @@ -862,7 +862,7 @@ if ("AKS" -eq $ClusterType ) { if ((($workspaceGuidConfiguredOnAgent -eq $workspaceGUID) -and ($workspaceKeyConfiguredOnAgent -eq $workspacePrimarySharedKey)) -eq $false) { Write-Host ("Error - Log Analytics Workspace Guid and key configured on the agent not matching with details of the Workspace. Please verify and fix with the correct workspace Guid and Key") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Workspace Guid and Key on the agent matching with the Workspace") -ForegroundColor Green @@ -870,7 +870,7 @@ if ("AKS" -eq $ClusterType ) { catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking agent version...") @@ -885,7 +885,7 @@ if ("AKS" -eq $ClusterType ) { } catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } diff --git a/scripts/troubleshoot/TroubleshootError_AcsEngine.ps1 b/scripts/troubleshoot/TroubleshootError_AcsEngine.ps1 index 1f1e1ba5d..5662d3f79 100644 --- a/scripts/troubleshoot/TroubleshootError_AcsEngine.ps1 +++ b/scripts/troubleshoot/TroubleshootError_AcsEngine.ps1 @@ -45,7 +45,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o else { Write-Host("Please run the script as an administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } $message = "This script will try to install the latest versions of the following Modules : ` @@ -69,7 +69,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o } catch { Write-Host("Close other powershell logins and try installing the latest modules for AzureRM.profile in a new powershell window: eg. 'Install-Module AzureRM.profile -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } try { Write-Host("Installing AzureRM.Resources...") @@ -77,7 +77,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o } catch { Write-Host("Close other powershell logins and try installing the latest modules for AzureRM.Resoureces in a new powershell window: eg. 'Install-Module AzureRM.Resoureces -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } try { @@ -86,7 +86,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o } catch { Write-Host("Close other powershell logins and try installing the latest modules for AzureRM.OperationalInsights in a new powershell window: eg. 'Install-Module AzureRM.OperationalInsights -Repository PSGallery -Force'") -ForegroundColor Red - exit + exit 1 } } 1 { @@ -97,7 +97,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o Write-Host("Could not import AzureRM.profile...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for AzureRM.profile in a new powershell window: eg. 'Install-Module AzureRM.profile -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } try { Import-Module AzureRM.Resources @@ -105,7 +105,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o catch { Write-Host("Could not import AzureRM.Resources... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } try { Import-Module AzureRM.OperationalInsights @@ -113,7 +113,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o catch { Write-Host("Could not import AzureRM.OperationalInsights... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Running troubleshooting script... Please reinstall this Module") Write-Host("") @@ -121,7 +121,7 @@ if (($null -eq $azureRmProfileModule) -or ($null -eq $azureRmResourcesModule) -o 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -151,7 +151,7 @@ if ($null -eq $account.Account) { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the SubscriptionId you entered is correct and you have access to the Subscription" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -171,7 +171,7 @@ else { Write-Host("Could not select subscription with ID : " + $SubscriptionId + ". Please make sure the SubscriptionId you entered is correct and you have access to the Subscription" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -187,7 +187,7 @@ if ($notPresent) { Write-Host("Could not find RG. Please make sure that the resource group name: '" + $ResourceGroupName + "'is correct and you have access to the Resource Group") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully checked resource groups details...") -ForegroundColor Green @@ -197,13 +197,13 @@ Write-Host("Successfully checked resource groups details...") -ForegroundColor G if ([string]::IsNullOrEmpty($KubeConfig)) { Write-Host("KubeConfig should not be NULL or empty") -ForegroundColor Red Stop-Transcript - exit + exit 1 } if ((Test-Path $KubeConfig -PathType Leaf) -ne $true) { Write-Host("provided KubeConfig path : '" + $KubeConfig + "' doesnt exist or you dont have read access") -ForegroundColor Red Stop-Transcript - exit + exit 1 } # @@ -249,13 +249,13 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { } else { Write-Host("This Resource group : '" + $ResourceGroupName + "'does not have the AKS-engine or ACS-Engine Kubernetes resources") -ForegroundColor Red - exit + exit 1 } } if ($isKubernetesCluster -eq $false) { Write-Host("Monitoring only supported for AKS-Engine or ACS-Engine with Kubernetes") -ForegroundColor Red - exit + exit 1 } Write-Host("Successfully checked the AKS-Engine or ACS-Engine Kuberentes cluster resources in specified resource group") -ForegroundColor Green @@ -270,7 +270,7 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { if ($null -eq $r) { Write-Host("Get-AzureRmResource for Resource Group: " + $ResourceGroupName + "Resource Name :" + $k8MasterVM.Name + " failed" ) -ForegroundColor Red - exit + exit 1 } if ($null -eq $r.Tags) { @@ -279,7 +279,7 @@ foreach ($k8MasterVM in $k8sMasterVMsOrVMSSes) { Write-Host("Please try to opt out of monitoring and opt-in using the following links:") -ForegroundColor Red Write-Host("Opt-out - " + $OptOutLink) -ForegroundColor Red Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red - exit + exit 1 } if ($r.Tags.ContainsKey("logAnalyticsWorkspaceResourceId")) { @@ -300,7 +300,7 @@ if ($null -eq $LogAnalyticsWorkspaceResourceID) { Write-Host("There is no existing logAnalyticsWorkspaceResourceId tag on AKS-Engine k8 master nodes or VMSSes so this indicates this cluster not enabled monitoring or tags have been removed" ) -ForegroundColor Red Write-Host("Please try to opt-in for monitoring using the following links:") -ForegroundColor Red Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red - exit + exit 1 } else { @@ -309,7 +309,7 @@ else { Write-Host("Please add the clusterName tag with the value of clusterName used during the omsagent agent onboarding. Refer below link for details:") -ForegroundColor Red Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red - exit + exit 1 } Write-Host("Configured LogAnalyticsWorkspaceResourceId: : '" + $LogAnalyticsWorkspaceResourceID + "' ") @@ -328,7 +328,7 @@ else { Write-Host("Could not change to Workspace subscriptionId : '" + $workspaceSubscriptionId + "'." ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } @@ -347,7 +347,7 @@ else { Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } Write-Host("Successfully fetched workspace subcription details...") -ForegroundColor Green Write-Host("") @@ -364,7 +364,7 @@ else { Write-Host("Opt-out - " + $OptOutLink) -ForegroundColor Red Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Successfully fetched workspace resource group...") -ForegroundColor Green Write-Host("") @@ -386,7 +386,7 @@ else { Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspaceLocation = $WorkspaceInformation.Location @@ -396,7 +396,7 @@ else { Write-Host("Cannot fetch workspace location. Please try again...") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspacePricingTier = $WorkspaceInformation.sku @@ -413,7 +413,7 @@ else { Write-Host("Failed to get the list of solutions onboarded to the workspace. Please make sure that it hasn't been deleted and you have access to it.") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } try { @@ -425,7 +425,7 @@ else { Write-Host("Failed to get ContainerInsights solution details from the workspace") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $isSolutionOnboarded = $WorkspaceIPDetails.Enabled[$ContainerInsightsIndex] @@ -498,7 +498,7 @@ try { } catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("") diff --git a/scripts/troubleshoot/TroubleshootError_nonAzureK8s.ps1 b/scripts/troubleshoot/TroubleshootError_nonAzureK8s.ps1 index 14b080b23..76bbad16c 100644 --- a/scripts/troubleshoot/TroubleshootError_nonAzureK8s.ps1 +++ b/scripts/troubleshoot/TroubleshootError_nonAzureK8s.ps1 @@ -47,25 +47,25 @@ Write-Host("LogAnalyticsWorkspaceResourceId: : '" + $azureLogAnalyticsWorkspaceR if (($azureLogAnalyticsWorkspaceResourceId.ToLower().Contains("microsoft.operationalinsights/workspaces") -ne $true) -or ($azureLogAnalyticsWorkspaceResourceId.Split("/").Length -ne 9)) { Write-Host("Provided Azure Log Analytics resource id should be in this format /subscriptions//resourceGroups//providers/Microsoft.OperationalInsights/workspaces/") -ForegroundColor Red Stop-Transcript - exit + exit 1 } if ([string]::IsNullOrEmpty($kubeConfig)) { Write-Host("kubeConfig should not be NULL or empty") -ForegroundColor Red Stop-Transcript - exit + exit 1 } if ((Test-Path $kubeConfig -PathType Leaf) -ne $true) { Write-Host("provided kubeConfig path : '" + $kubeConfig + "' doesnt exist or you dont have read access") -ForegroundColor Red Stop-Transcript - exit + exit 1 } if ([string]::IsNullOrEmpty($clusterContextInKubeconfig)) { Write-Host("provide clusterContext should be valid context in the provided kubeconfig") -ForegroundColor Red Stop-Transcript - exit + exit 1 } # checks the all required Powershell modules exist and if not exists, request the user permission to install @@ -92,7 +92,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - else { Write-Host("Please re-launch the script with elevated administrator") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -120,7 +120,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -132,7 +132,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Close other powershell logins and try installing the latest modules forAz.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -145,7 +145,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Close other powershell logins and try installing the latest modules for Az.OperationalInsights in a new powershell window: eg. 'Install-Module Az.OperationalInsights -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -160,7 +160,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Resources...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Resources in a new powershell window: eg. 'Install-Module Az.Resources -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } if ($null -eq $azAccountModule) { @@ -171,7 +171,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - Write-Host("Could not import Az.Accounts...") -ForegroundColor Red Write-Host("Close other powershell logins and try installing the latest modules for Az.Accounts in a new powershell window: eg. 'Install-Module Az.Accounts -Repository PSGallery -Force'") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -182,7 +182,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - catch { Write-Host("Could not import Az.OperationalInsights... Please reinstall this Module") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -190,7 +190,7 @@ if (($null -eq $azAccountModule) -or ($null -eq $azResourcesModule) -or ($null - 2 { Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -222,7 +222,7 @@ if ($null -eq $account.Account) { Write-Host("Could not select subscription with ID : " + $workspaceSubscriptionId + ". Please make sure the SubscriptionId you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } else { @@ -242,7 +242,7 @@ else { Write-Host("Could not select subscription with ID : " + $workspaceSubscriptionId + ". Please make sure the ID you entered is correct and you have access to the cluster" ) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } } } @@ -253,7 +253,7 @@ $workspaceResource = Get-AzResource -ResourceId $azureLogAnalyticsWorkspaceResou if ($null -eq $workspaceResource) { Write-Host("specified Azure Log Analytics resource id: " + $azureLogAnalyticsWorkspaceResourceId + ". either you dont have access or doesnt exist") -ForegroundColor Red Stop-Transcript - exit + exit 1 } # @@ -272,7 +272,7 @@ catch { Write-Host("Opt-in - " + $OptInLink) -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspaceLocation = $WorkspaceInformation.Location @@ -281,7 +281,7 @@ if ($null -eq $WorkspaceLocation) { Write-Host("Cannot fetch workspace location. Please try again...") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $WorkspacePricingTier = $WorkspaceInformation.sku @@ -297,7 +297,7 @@ catch { Write-Host("Failed to get the list of solutions onboarded to the workspace. Please make sure that it hasn't been deleted and you have access to it.") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } try { @@ -309,7 +309,7 @@ catch { Write-Host("Failed to get ContainerInsights solution details from the workspace") -ForegroundColor Red Write-Host("") Stop-Transcript - exit + exit 1 } $isSolutionOnboarded = $WorkspaceIPDetails.Enabled[$ContainerInsightsIndex] @@ -317,7 +317,7 @@ if ($isSolutionOnboarded) { if ($WorkspacePricingTier -eq "Free") { Write-Host("Pricing tier of the configured LogAnalytics workspace is Free so you may need to upgrade to pricing tier to non-Free") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } else { @@ -356,13 +356,13 @@ else { Write-Host ("Template deployment failed with an error: '" + $Error[0] + "' ") -ForegroundColor Red Write-Host($contactUSMessage) -ForegroundColor Red Stop-Transcript - exit + exit 1 } } else { Write-Host("The container health solution isn't onboarded to your cluster. This required for the monitoring to work.") -ForegroundColor Red Stop-Transcript - exit + exit 1 } } @@ -382,7 +382,7 @@ try { if ($null -eq $rsPod) { Write-Host( "omsagent replicaset pod not scheduled or failed to scheduled." + $contactUSMessage) -ForegroundColor Red Stop-Transcript - exit + exit 1 } $rsPodStatus = $rsPod.status if ((($rsPodStatus.availableReplicas -eq 1) -and @@ -393,7 +393,7 @@ try { Write-Host($rsPodStatus) Write-Host($contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent replicaset pod running OK.") -ForegroundColor Green @@ -401,7 +401,7 @@ try { catch { Write-Host ("Failed to get omsagent replicatset pod info using kubectl get rs : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the omsagent daemonset pod running correctly ...") @@ -410,7 +410,7 @@ try { if ($ds.Items.Length -ne 1) { Write-Host( "omsagent replicaset pod not scheduled or failed to schedule." + $contactUSMessage) -ForegroundColor Red Stop-Transcript - exit + exit 1 } $dsStatus = $ds.Items[0].status @@ -424,7 +424,7 @@ try { Write-Host($rsPodStatus) Write-Host($contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent daemonset pod running OK.") -ForegroundColor Green @@ -432,7 +432,7 @@ try { catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the omsagent heatlhservice running correctly ...") @@ -441,7 +441,7 @@ try { if ($healthservice.Items.Length -ne 1) { Write-Host( "omsagent healthservice not scheduled or failed to schedule." + $contactUSMessage) Stop-Transcript - exit + exit 1 } Write-Host( "omsagent healthservice pod running OK.") -ForegroundColor Green @@ -449,7 +449,7 @@ try { catch { Write-Host ("Failed to execute kubectl get services command : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Retrieving WorkspaceGUID and WorkspacePrimaryKey of the workspace : " + $WorkspaceInformation.Name) @@ -462,7 +462,7 @@ try { catch { Write-Host ("Failed to workspace details. Please validate whether you have Log Analytics Contributor role on the workspace error: '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking whether the WorkspaceGuid and key matching with configured log analytics workspace ...") @@ -473,7 +473,7 @@ try { if ((($workspaceGuidConfiguredOnAgent -eq $workspaceGUID) -and ($workspaceKeyConfiguredOnAgent -eq $workspacePrimarySharedKey)) -eq $false) { Write-Host ("Error - Log Analytics Workspace Guid and key configured on the agent not matching with details of the Workspace. Please verify and fix with the correct workspace Guid and Key") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Workspace Guid and Key on the agent matching with the Workspace") -ForegroundColor Green @@ -481,7 +481,7 @@ try { catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("Checking agent version...") @@ -497,7 +497,7 @@ try { catch { Write-Host ("Failed to execute the script : '" + $Error[0] + "' ") -ForegroundColor Red Stop-Transcript - exit + exit 1 } Write-Host("resetting cluster context back, what it was before") From 886986de5a86a910b7ca9f1ac7933ac9c8e26f36 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Mon, 24 Jan 2022 13:28:50 -0800 Subject: [PATCH 5/9] node count telemetry --- source/plugins/ruby/in_kube_nodes.rb | 7 +++---- source/plugins/ruby/in_kube_podinventory.rb | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/source/plugins/ruby/in_kube_nodes.rb b/source/plugins/ruby/in_kube_nodes.rb index 72a8e8987..abbfe94a1 100644 --- a/source/plugins/ruby/in_kube_nodes.rb +++ b/source/plugins/ruby/in_kube_nodes.rb @@ -181,10 +181,9 @@ def enumerate timeDifference = (DateTime.now.to_time.to_i - @@nodeInventoryLatencyTelemetryTimeTracker).abs timeDifferenceInMinutes = timeDifference / 60 if (timeDifferenceInMinutes >= @TELEMETRY_FLUSH_INTERVAL_IN_MINUTES) - properties = {} - properties["NodeCount"] = nodeCount - @applicationInsightsUtility.sendMetricTelemetry("NodeInventoryE2EProcessingLatencyMs", @nodeInventoryE2EProcessingLatencyMs, properties) - @applicationInsightsUtility.sendMetricTelemetry("NodesAPIE2ELatencyMs", @nodesAPIE2ELatencyMs, properties) + @applicationInsightsUtility.sendMetricTelemetry("NodeInventoryE2EProcessingLatencyMs", @nodeInventoryE2EProcessingLatencyMs, {}) + @applicationInsightsUtility.sendMetricTelemetry("NodesAPIE2ELatencyMs", @nodesAPIE2ELatencyMs, {}) + @applicationInsightsUtility.sendMetricTelemetry("NodeCount", nodeCount, {}) @@nodeInventoryLatencyTelemetryTimeTracker = DateTime.now.to_time.to_i end # Setting this to nil so that we dont hold memory until GC kicks in diff --git a/source/plugins/ruby/in_kube_podinventory.rb b/source/plugins/ruby/in_kube_podinventory.rb index 6df68b853..6c39466d7 100644 --- a/source/plugins/ruby/in_kube_podinventory.rb +++ b/source/plugins/ruby/in_kube_podinventory.rb @@ -220,7 +220,7 @@ def enumerate(podList = nil) if @winContainerCount > 0 telemetryProperties["ClusterWideWindowsContainersCount"] = @winContainerCount telemetryProperties["WindowsNodeCount"] = @windowsNodeCount - telemetryProperties["WinContainerInventoryTotalSizeKB"] = @winContainerInventoryTotalSizeBytes / 1024 + telemetryProperties["ClusterWideWindowsContainerInventoryTotalSizeKB"] = @winContainerInventoryTotalSizeBytes / 1024 if @winContainerCountWithEnvVarSize64KBOrMore > 0 telemetryProperties["WinContainerCountWithEnvVarSize64KBOrMore"] = @winContainerCountWithEnvVarSize64KBOrMore end @@ -283,7 +283,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc containerInventoryRecords.each do |cirecord| if !cirecord.nil? containerInventoryStream.add(emitTime, cirecord) if cirecord - @winContainerInventoryTotalSizeBytes += ci.record.to_s.length + @winContainerInventoryTotalSizeBytes += cirecord.to_s.length # collect the telemetry of variable fields of windows container records if its >= 64KB if !cirecord["EnvironmentVar"].nil? && !cirecord["EnvironmentVar"].empty? && cirecord["EnvironmentVar"].length >= 65536 @winContainerCountWithEnvVarSize64KBOrMore += 1 From 642b326e063689c8bb8e75d8af10e572333ebc56 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Mon, 24 Jan 2022 15:03:18 -0800 Subject: [PATCH 6/9] telemetry for win cirecord 64KB or more --- source/plugins/ruby/in_kube_podinventory.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/plugins/ruby/in_kube_podinventory.rb b/source/plugins/ruby/in_kube_podinventory.rb index 6c39466d7..b15685203 100644 --- a/source/plugins/ruby/in_kube_podinventory.rb +++ b/source/plugins/ruby/in_kube_podinventory.rb @@ -40,6 +40,7 @@ def initialize @winContainerCount = 0 @windowsNodeCount = 0 @winContainerInventoryTotalSizeBytes = 0 + @winContainerCountWithInventoryRecordSize64KBOrMore = 0 @winContainerCountWithEnvVarSize64KBOrMore = 0 @winContainerCountWithPortsSize64KBOrMore = 0 @winContainerCountWithCommandSize64KBOrMore = 0 @@ -110,6 +111,7 @@ def enumerate(podList = nil) @controllerSet = Set.new [] @winContainerCount = 0 @winContainerInventoryTotalSizeBytes = 0 + @winContainerCountWithInventoryRecordSize64KBOrMore = 0 @winContainerCountWithEnvVarSize64KBOrMore = 0 @winContainerCountWithPortsSize64KBOrMore = 0 @winContainerCountWithCommandSize64KBOrMore = 0 @@ -221,6 +223,7 @@ def enumerate(podList = nil) telemetryProperties["ClusterWideWindowsContainersCount"] = @winContainerCount telemetryProperties["WindowsNodeCount"] = @windowsNodeCount telemetryProperties["ClusterWideWindowsContainerInventoryTotalSizeKB"] = @winContainerInventoryTotalSizeBytes / 1024 + telemetryProperties["WindowsContainerCountWithInventoryRecordSize64KBorMore"] = @winContainerCountWithInventoryRecordSize64KBOrMore if @winContainerCountWithEnvVarSize64KBOrMore > 0 telemetryProperties["WinContainerCountWithEnvVarSize64KBOrMore"] = @winContainerCountWithEnvVarSize64KBOrMore end @@ -283,8 +286,11 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc containerInventoryRecords.each do |cirecord| if !cirecord.nil? containerInventoryStream.add(emitTime, cirecord) if cirecord - @winContainerInventoryTotalSizeBytes += cirecord.to_s.length - # collect the telemetry of variable fields of windows container records if its >= 64KB + ciRecordSize = cirecord.to_s.length + @winContainerInventoryTotalSizeBytes += ciRecordSize + if ciRecordSize >= 65536 + @winContainerCountWithInventoryRecordSize64KBOrMore += 1 + end if !cirecord["EnvironmentVar"].nil? && !cirecord["EnvironmentVar"].empty? && cirecord["EnvironmentVar"].length >= 65536 @winContainerCountWithEnvVarSize64KBOrMore += 1 end From 0c185b01c7e8cb26e5e11c0c4b57a2688312d0d2 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Mon, 24 Jan 2022 16:50:56 -0800 Subject: [PATCH 7/9] metric to track wintelegraf metrics with tags 64kb --- source/plugins/go/src/oms.go | 286 ++++++++++---------- source/plugins/go/src/telemetry.go | 8 + source/plugins/ruby/in_kube_podinventory.rb | 2 +- 3 files changed, 155 insertions(+), 141 deletions(-) diff --git a/source/plugins/go/src/oms.go b/source/plugins/go/src/oms.go index ee221a60b..627f3bf01 100644 --- a/source/plugins/go/src/oms.go +++ b/source/plugins/go/src/oms.go @@ -21,9 +21,10 @@ import ( "github.com/google/uuid" "github.com/tinylib/msgp/msgp" - lumberjack "gopkg.in/natefinch/lumberjack.v2" "Docker-Provider/source/plugins/go/src/extension" + lumberjack "gopkg.in/natefinch/lumberjack.v2" + "github.com/Azure/azure-kusto-go/kusto/ingest" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" @@ -85,7 +86,6 @@ const WindowsContainerLogPluginConfFilePath = "/etc/omsagentwindows/out_oms.conf // IPName const IPName = "ContainerInsights" - const defaultContainerInventoryRefreshInterval = 60 const kubeMonAgentConfigEventFlushInterval = 60 @@ -252,29 +252,29 @@ type DataItemLAv1 struct { // DataItemLAv2 == ContainerLogV2 table in LA // Please keep the names same as destination column names, to avoid transforming one to another in the pipeline type DataItemLAv2 struct { - TimeGenerated string `json:"TimeGenerated"` - Computer string `json:"Computer"` - ContainerId string `json:"ContainerId"` - ContainerName string `json:"ContainerName"` - PodName string `json:"PodName"` - PodNamespace string `json:"PodNamespace"` - LogMessage string `json:"LogMessage"` - LogSource string `json:"LogSource"` + TimeGenerated string `json:"TimeGenerated"` + Computer string `json:"Computer"` + ContainerId string `json:"ContainerId"` + ContainerName string `json:"ContainerName"` + PodName string `json:"PodName"` + PodNamespace string `json:"PodNamespace"` + LogMessage string `json:"LogMessage"` + LogSource string `json:"LogSource"` //PodLabels string `json:"PodLabels"` } // DataItemADX == ContainerLogV2 table in ADX type DataItemADX struct { - TimeGenerated string `json:"TimeGenerated"` - Computer string `json:"Computer"` - ContainerId string `json:"ContainerId"` - ContainerName string `json:"ContainerName"` - PodName string `json:"PodName"` - PodNamespace string `json:"PodNamespace"` - LogMessage string `json:"LogMessage"` - LogSource string `json:"LogSource"` + TimeGenerated string `json:"TimeGenerated"` + Computer string `json:"Computer"` + ContainerId string `json:"ContainerId"` + ContainerName string `json:"ContainerName"` + PodName string `json:"PodName"` + PodNamespace string `json:"PodNamespace"` + LogMessage string `json:"LogMessage"` + LogSource string `json:"LogSource"` //PodLabels string `json:"PodLabels"` - AzureResourceId string `json:"AzureResourceId"` + AzureResourceId string `json:"AzureResourceId"` } // telegraf metric DataItem represents the object corresponding to the json that is sent by fluentbit tail plugin @@ -299,15 +299,15 @@ type InsightsMetricsBlob struct { // ContainerLogBlob represents the object corresponding to the payload that is sent to the ODS end point type ContainerLogBlobLAv1 struct { - DataType string `json:"DataType"` - IPName string `json:"IPName"` + DataType string `json:"DataType"` + IPName string `json:"IPName"` DataItems []DataItemLAv1 `json:"DataItems"` } // ContainerLogBlob represents the object corresponding to the payload that is sent to the ODS end point type ContainerLogBlobLAv2 struct { - DataType string `json:"DataType"` - IPName string `json:"IPName"` + DataType string `json:"DataType"` + IPName string `json:"IPName"` DataItems []DataItemLAv2 `json:"DataItems"` } @@ -361,6 +361,7 @@ const ( // DataType to be used as enum per data type socket client creation type DataType int + const ( // DataType to be used as enum per data type socket client creation ContainerLogV2 DataType = iota @@ -628,12 +629,12 @@ func flushKubeMonAgentEventRecords() { Log(message) SendException(message) } else { - msgPackEntry := MsgPackEntry{ + msgPackEntry := MsgPackEntry{ Record: stringMap, } - msgPackEntries = append(msgPackEntries, msgPackEntry) - } - } + msgPackEntries = append(msgPackEntries, msgPackEntry) + } + } } } @@ -670,8 +671,8 @@ func flushKubeMonAgentEventRecords() { msgPackEntry := MsgPackEntry{ Record: stringMap, } - msgPackEntries = append(msgPackEntries, msgPackEntry) - } + msgPackEntries = append(msgPackEntries, msgPackEntry) + } } } } @@ -713,18 +714,18 @@ func flushKubeMonAgentEventRecords() { } else { if err := json.Unmarshal(jsonBytes, &stringMap); err != nil { message := fmt.Sprintf("Error while UnMarshalling json bytes to stringmap: %s", err.Error()) - Log(message) - SendException(message) + Log(message) + SendException(message) } else { msgPackEntry := MsgPackEntry{ Record: stringMap, - } - msgPackEntries = append(msgPackEntries, msgPackEntry) + } + msgPackEntries = append(msgPackEntries, msgPackEntry) } } } } - if (IsWindows == false && len(msgPackEntries) > 0) { //for linux, mdsd route + if IsWindows == false && len(msgPackEntries) > 0 { //for linux, mdsd route if IsAADMSIAuthMode == true && strings.HasPrefix(MdsdKubeMonAgentEventsTagName, MdsdOutputStreamIdTagPrefix) == false { Log("Info::mdsd::obtaining output stream id for data type: %s", KubeMonAgentEventDataType) MdsdKubeMonAgentEventsTagName = extension.GetInstance(FLBLogger, ContainerType).GetOutputStreamId(KubeMonAgentEventDataType) @@ -757,7 +758,7 @@ func flushKubeMonAgentEventRecords() { } else { numRecords := len(msgPackEntries) Log("FlushKubeMonAgentEventRecords::Info::Successfully flushed %d records that was %d bytes in %s", numRecords, bts, elapsed) - // Send telemetry to AppInsights resource + // Send telemetry to AppInsights resource SendEvent(KubeMonAgentEventsFlushedEvent, telemetryDimensions) } } else { @@ -788,8 +789,8 @@ func flushKubeMonAgentEventRecords() { if IsAADMSIAuthMode == true { IngestionAuthTokenUpdateMutex.Lock() - ingestionAuthToken := ODSIngestionAuthToken - IngestionAuthTokenUpdateMutex.Unlock() + ingestionAuthToken := ODSIngestionAuthToken + IngestionAuthTokenUpdateMutex.Unlock() if ingestionAuthToken == "" { Log("Error::ODS Ingestion Auth Token is empty. Please check error log.") } @@ -910,86 +911,90 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int var msgPackEntries []MsgPackEntry var i int start := time.Now() - var elapsed time.Duration + var elapsed time.Duration for i = 0; i < len(laMetrics); i++ { - var interfaceMap map[string]interface{} - stringMap := make(map[string]string) - jsonBytes, err := json.Marshal(*laMetrics[i]) - if err != nil { - message := fmt.Sprintf("PostTelegrafMetricsToLA::Error:when marshalling json %q", err) + var interfaceMap map[string]interface{} + stringMap := make(map[string]string) + jsonBytes, err := json.Marshal(*laMetrics[i]) + if err != nil { + message := fmt.Sprintf("PostTelegrafMetricsToLA::Error:when marshalling json %q", err) + Log(message) + SendException(message) + return output.FLB_OK + } else { + if err := json.Unmarshal(jsonBytes, &interfaceMap); err != nil { + message := fmt.Sprintf("Error while UnMarshalling json bytes to interfaceMap: %s", err.Error()) Log(message) SendException(message) return output.FLB_OK } else { - if err := json.Unmarshal(jsonBytes, &interfaceMap); err != nil { - message := fmt.Sprintf("Error while UnMarshalling json bytes to interfaceMap: %s", err.Error()) - Log(message) - SendException(message) - return output.FLB_OK - } else { - for key, value := range interfaceMap { - strKey := fmt.Sprintf("%v", key) - strValue := fmt.Sprintf("%v", value) - stringMap[strKey] = strValue - } - msgPackEntry := MsgPackEntry{ - Record: stringMap, - } - msgPackEntries = append(msgPackEntries, msgPackEntry) + for key, value := range interfaceMap { + strKey := fmt.Sprintf("%v", key) + strValue := fmt.Sprintf("%v", value) + stringMap[strKey] = strValue + } + msgPackEntry := MsgPackEntry{ + Record: stringMap, } + msgPackEntries = append(msgPackEntries, msgPackEntry) } + } } - if (len(msgPackEntries) > 0) { - if IsAADMSIAuthMode == true && (strings.HasPrefix(MdsdInsightsMetricsTagName, MdsdOutputStreamIdTagPrefix) == false) { - Log("Info::mdsd::obtaining output stream id for InsightsMetricsDataType since Log Analytics AAD MSI Auth Enabled") - MdsdInsightsMetricsTagName = extension.GetInstance(FLBLogger, ContainerType).GetOutputStreamId(InsightsMetricsDataType) - } - msgpBytes := convertMsgPackEntriesToMsgpBytes(MdsdInsightsMetricsTagName, msgPackEntries) + if len(msgPackEntries) > 0 { + if IsAADMSIAuthMode == true && (strings.HasPrefix(MdsdInsightsMetricsTagName, MdsdOutputStreamIdTagPrefix) == false) { + Log("Info::mdsd::obtaining output stream id for InsightsMetricsDataType since Log Analytics AAD MSI Auth Enabled") + MdsdInsightsMetricsTagName = extension.GetInstance(FLBLogger, ContainerType).GetOutputStreamId(InsightsMetricsDataType) + } + msgpBytes := convertMsgPackEntriesToMsgpBytes(MdsdInsightsMetricsTagName, msgPackEntries) + if MdsdInsightsMetricsMsgpUnixSocketClient == nil { + Log("Error::mdsd::mdsd connection does not exist. re-connecting ...") + CreateMDSDClient(InsightsMetrics, ContainerType) if MdsdInsightsMetricsMsgpUnixSocketClient == nil { - Log("Error::mdsd::mdsd connection does not exist. re-connecting ...") - CreateMDSDClient(InsightsMetrics, ContainerType) - if MdsdInsightsMetricsMsgpUnixSocketClient == nil { - Log("Error::mdsd::Unable to create mdsd client for insights metrics. Please check error log.") - ContainerLogTelemetryMutex.Lock() - defer ContainerLogTelemetryMutex.Unlock() - InsightsMetricsMDSDClientCreateErrors += 1 - return output.FLB_RETRY - } - } - - deadline := 10 * time.Second - MdsdInsightsMetricsMsgpUnixSocketClient.SetWriteDeadline(time.Now().Add(deadline)) //this is based of clock time, so cannot reuse - bts, er := MdsdInsightsMetricsMsgpUnixSocketClient.Write(msgpBytes) - - elapsed = time.Since(start) - - if er != nil { - Log("Error::mdsd::Failed to write to mdsd %d records after %s. Will retry ... error : %s", len(msgPackEntries), elapsed, er.Error()) - UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0) - if MdsdInsightsMetricsMsgpUnixSocketClient != nil { - MdsdInsightsMetricsMsgpUnixSocketClient.Close() - MdsdInsightsMetricsMsgpUnixSocketClient = nil - } - + Log("Error::mdsd::Unable to create mdsd client for insights metrics. Please check error log.") ContainerLogTelemetryMutex.Lock() defer ContainerLogTelemetryMutex.Unlock() InsightsMetricsMDSDClientCreateErrors += 1 return output.FLB_RETRY - } else { - numTelegrafMetricsRecords := len(msgPackEntries) - UpdateNumTelegrafMetricsSentTelemetry(numTelegrafMetricsRecords, 0, 0) - Log("Success::mdsd::Successfully flushed %d telegraf metrics records that was %d bytes to mdsd in %s ", numTelegrafMetricsRecords, bts, elapsed) } + } + + deadline := 10 * time.Second + MdsdInsightsMetricsMsgpUnixSocketClient.SetWriteDeadline(time.Now().Add(deadline)) //this is based of clock time, so cannot reuse + bts, er := MdsdInsightsMetricsMsgpUnixSocketClient.Write(msgpBytes) + + elapsed = time.Since(start) + + if er != nil { + Log("Error::mdsd::Failed to write to mdsd %d records after %s. Will retry ... error : %s", len(msgPackEntries), elapsed, er.Error()) + UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0, 0) + if MdsdInsightsMetricsMsgpUnixSocketClient != nil { + MdsdInsightsMetricsMsgpUnixSocketClient.Close() + MdsdInsightsMetricsMsgpUnixSocketClient = nil + } + + ContainerLogTelemetryMutex.Lock() + defer ContainerLogTelemetryMutex.Unlock() + InsightsMetricsMDSDClientCreateErrors += 1 + return output.FLB_RETRY + } else { + numTelegrafMetricsRecords := len(msgPackEntries) + UpdateNumTelegrafMetricsSentTelemetry(numTelegrafMetricsRecords, 0, 0, 0) + Log("Success::mdsd::Successfully flushed %d telegraf metrics records that was %d bytes to mdsd in %s ", numTelegrafMetricsRecords, bts, elapsed) + } } } else { // for windows, ODS direct var metrics []laTelegrafMetric var i int + numWinMetricsWithTagsSize64KBorMore := 0 for i = 0; i < len(laMetrics); i++ { metrics = append(metrics, *laMetrics[i]) + if len(*&laMetrics[i].Tags) >= (64 * 1024) { + numWinMetricsWithTagsSize64KBorMore += 1 + } } laTelegrafMetrics := InsightsMetricsBlob{ @@ -1041,7 +1046,7 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int if err != nil { message := fmt.Sprintf("PostTelegrafMetricsToLA::Error:(retriable) when sending %v metrics. duration:%v err:%q \n", len(laMetrics), elapsed, err.Error()) Log(message) - UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0) + UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0, 0) return output.FLB_RETRY } @@ -1050,7 +1055,7 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int Log("PostTelegrafMetricsToLA::Error:(retriable) RequestID %s Response Status %v Status Code %v", reqID, resp.Status, resp.StatusCode) } if resp != nil && resp.StatusCode == 429 { - UpdateNumTelegrafMetricsSentTelemetry(0, 1, 1) + UpdateNumTelegrafMetricsSentTelemetry(0, 1, 1, 0) } return output.FLB_RETRY } @@ -1058,18 +1063,19 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int defer resp.Body.Close() numMetrics := len(laMetrics) - UpdateNumTelegrafMetricsSentTelemetry(numMetrics, 0, 0) + UpdateNumTelegrafMetricsSentTelemetry(numMetrics, 0, 0, numWinMetricsWithTagsSize64KBorMore) Log("PostTelegrafMetricsToLA::Info:Successfully flushed %v records in %v", numMetrics, elapsed) } return output.FLB_OK } -func UpdateNumTelegrafMetricsSentTelemetry(numMetricsSent int, numSendErrors int, numSend429Errors int) { +func UpdateNumTelegrafMetricsSentTelemetry(numMetricsSent int, numSendErrors int, numSend429Errors int, numWinMetricswith64KBorMoreSize int) { ContainerLogTelemetryMutex.Lock() TelegrafMetricsSentCount += float64(numMetricsSent) TelegrafMetricsSendErrorCount += float64(numSendErrors) TelegrafMetricsSend429ErrorCount += float64(numSend429Errors) + WinTelegrafMetricsCountWithTagsSize64KBorMore += float64(numWinMetricswith64KBorMoreSize) ContainerLogTelemetryMutex.Unlock() } @@ -1117,12 +1123,12 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { stringMap = make(map[string]string) //below id & name are used by latency telemetry in both v1 & v2 LA schemas id := "" - name := "" + name := "" logEntry := ToString(record["log"]) logEntryTimeStamp := ToString(record["time"]) //ADX Schema & LAv2 schema are almost the same (except resourceId) - if (ContainerLogSchemaV2 == true || ContainerLogsRouteADX == true) { + if ContainerLogSchemaV2 == true || ContainerLogsRouteADX == true { stringMap["Computer"] = Computer stringMap["ContainerId"] = containerID stringMap["ContainerName"] = containerName @@ -1171,29 +1177,29 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { stringMap["AzureResourceId"] = "" } dataItemADX = DataItemADX{ - TimeGenerated: stringMap["TimeGenerated"], - Computer: stringMap["Computer"], - ContainerId: stringMap["ContainerId"], - ContainerName: stringMap["ContainerName"], - PodName: stringMap["PodName"], - PodNamespace: stringMap["PodNamespace"], - LogMessage: stringMap["LogMessage"], - LogSource: stringMap["LogSource"], - AzureResourceId: stringMap["AzureResourceId"], + TimeGenerated: stringMap["TimeGenerated"], + Computer: stringMap["Computer"], + ContainerId: stringMap["ContainerId"], + ContainerName: stringMap["ContainerName"], + PodName: stringMap["PodName"], + PodNamespace: stringMap["PodNamespace"], + LogMessage: stringMap["LogMessage"], + LogSource: stringMap["LogSource"], + AzureResourceId: stringMap["AzureResourceId"], } //ADX dataItemsADX = append(dataItemsADX, dataItemADX) } else { - if (ContainerLogSchemaV2 == true) { + if ContainerLogSchemaV2 == true { dataItemLAv2 = DataItemLAv2{ - TimeGenerated: stringMap["TimeGenerated"], - Computer: stringMap["Computer"], - ContainerId: stringMap["ContainerId"], - ContainerName: stringMap["ContainerName"], - PodName: stringMap["PodName"], - PodNamespace: stringMap["PodNamespace"], - LogMessage: stringMap["LogMessage"], - LogSource: stringMap["LogSource"], + TimeGenerated: stringMap["TimeGenerated"], + Computer: stringMap["Computer"], + ContainerId: stringMap["ContainerId"], + ContainerName: stringMap["ContainerName"], + PodName: stringMap["PodName"], + PodNamespace: stringMap["PodNamespace"], + LogMessage: stringMap["LogMessage"], + LogSource: stringMap["LogSource"], } //ODS-v2 schema dataItemsLAv2 = append(dataItemsLAv2, dataItemLAv2) @@ -1211,10 +1217,10 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { Image: stringMap["Image"], Name: stringMap["Name"], } - //ODS-v1 schema - dataItemsLAv1 = append(dataItemsLAv1, dataItemLAv1) - name = stringMap["Name"] - id = stringMap["Id"] + //ODS-v1 schema + dataItemsLAv1 = append(dataItemsLAv1, dataItemLAv1) + name = stringMap["Name"] + id = stringMap["Id"] } } @@ -1364,18 +1370,18 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { numContainerLogRecords = len(dataItemsADX) Log("Success::ADX::Successfully wrote %d container log records to ADX in %s", numContainerLogRecords, elapsed) - } else if ((ContainerLogSchemaV2 == true && len(dataItemsLAv2) > 0) || len(dataItemsLAv1) > 0) { //ODS + } else if (ContainerLogSchemaV2 == true && len(dataItemsLAv2) > 0) || len(dataItemsLAv1) > 0 { //ODS var logEntry interface{} recordType := "" loglinesCount := 0 //schema v2 - if (len(dataItemsLAv2) > 0 && ContainerLogSchemaV2 == true) { + if len(dataItemsLAv2) > 0 && ContainerLogSchemaV2 == true { logEntry = ContainerLogBlobLAv2{ DataType: ContainerLogV2DataType, IPName: IPName, DataItems: dataItemsLAv2} - loglinesCount = len(dataItemsLAv2) - recordType = "ContainerLogV2" + loglinesCount = len(dataItemsLAv2) + recordType = "ContainerLogV2" } else { //schema v1 if len(dataItemsLAv1) > 0 { @@ -1383,8 +1389,8 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { DataType: ContainerLogDataType, IPName: IPName, DataItems: dataItemsLAv1} - loglinesCount = len(dataItemsLAv1) - recordType = "ContainerLog" + loglinesCount = len(dataItemsLAv1) + recordType = "ContainerLog" } } @@ -1416,7 +1422,7 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { return output.FLB_RETRY } // add authorization header to the req - req.Header.Set("Authorization", "Bearer "+ingestionAuthToken) + req.Header.Set("Authorization", "Bearer "+ingestionAuthToken) } resp, err := HTTPClient.Do(req) @@ -1444,7 +1450,7 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { numContainerLogRecords = loglinesCount Log("PostDataHelper::Info::Successfully flushed %d %s records to ODS in %s", numContainerLogRecords, recordType, elapsed) - } + } ContainerLogTelemetryMutex.Lock() defer ContainerLogTelemetryMutex.Unlock() @@ -1558,7 +1564,7 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Container Type %s", ContainerType) osType := os.Getenv("OS_TYPE") - IsWindows = false + IsWindows = false // Linux if strings.Compare(strings.ToLower(osType), "windows") != 0 { Log("Reading configuration for Linux from %s", pluginConfPath) @@ -1703,7 +1709,7 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { ContainerLogsRouteADX = false if strings.Compare(ContainerLogsRoute, ContainerLogsADXRoute) == 0 { - // Try to read the ADX database name from environment variables. Default to DefaultAdsDatabaseName if not set. + // Try to read the ADX database name from environment variables. Default to DefaultAdsDatabaseName if not set. // This SHOULD be set by tomlparser.rb so it's a highly unexpected event if it isn't. // It should be set by the logic in tomlparser.rb EVEN if ADX logging isn't enabled AdxDatabaseName := strings.TrimSpace(os.Getenv("AZMON_ADX_DATABASE_NAME")) @@ -1747,9 +1753,9 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { fmt.Fprintf(os.Stdout, "Routing container logs thru %s route...\n", ContainerLogsADXRoute) } } else if strings.Compare(strings.ToLower(osType), "windows") != 0 { //for linux, oneagent will be default route - ContainerLogsRouteV2 = true //default is mdsd route + ContainerLogsRouteV2 = true //default is mdsd route if strings.Compare(ContainerLogsRoute, ContainerLogsV1Route) == 0 { - ContainerLogsRouteV2 = false //fallback option when hiddensetting set + ContainerLogsRouteV2 = false //fallback option when hiddensetting set } Log("Routing container logs thru %s route...", ContainerLogsRoute) fmt.Fprintf(os.Stdout, "Routing container logs thru %s route... \n", ContainerLogsRoute) @@ -1768,14 +1774,14 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Creating MDSD clients for KubeMonAgentEvents & InsightsMetrics") CreateMDSDClient(KubeMonAgentEvents, ContainerType) CreateMDSDClient(InsightsMetrics, ContainerType) - } + } ContainerLogSchemaVersion := strings.TrimSpace(strings.ToLower(os.Getenv("AZMON_CONTAINER_LOG_SCHEMA_VERSION"))) Log("AZMON_CONTAINER_LOG_SCHEMA_VERSION:%s", ContainerLogSchemaVersion) - ContainerLogSchemaV2 = false //default is v1 schema + ContainerLogSchemaV2 = false //default is v1 schema - if strings.Compare(ContainerLogSchemaVersion, ContainerLogV2SchemaVersion) == 0 && ContainerLogsRouteADX != true { + if strings.Compare(ContainerLogSchemaVersion, ContainerLogV2SchemaVersion) == 0 && ContainerLogsRouteADX != true { ContainerLogSchemaV2 = true Log("Container logs schema=%s", ContainerLogV2SchemaVersion) fmt.Fprintf(os.Stdout, "Container logs schema=%s... \n", ContainerLogV2SchemaVersion) @@ -1801,15 +1807,15 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { if ContainerLogSchemaV2 == true { MdsdContainerLogTagName = MdsdContainerLogV2SourceName } else { - MdsdContainerLogTagName = MdsdContainerLogSourceName - } + MdsdContainerLogTagName = MdsdContainerLogSourceName + } MdsdInsightsMetricsTagName = MdsdInsightsMetricsSourceName - MdsdKubeMonAgentEventsTagName = MdsdKubeMonAgentEventsSourceName + MdsdKubeMonAgentEventsTagName = MdsdKubeMonAgentEventsSourceName Log("ContainerLogsRouteADX: %v, IsWindows: %v, IsAADMSIAuthMode = %v \n", ContainerLogsRouteADX, IsWindows, IsAADMSIAuthMode) if !ContainerLogsRouteADX && IsWindows && IsAADMSIAuthMode { Log("defaultIngestionAuthTokenRefreshIntervalSeconds = %d \n", defaultIngestionAuthTokenRefreshIntervalSeconds) - IngestionAuthTokenRefreshTicker = time.NewTicker(time.Second * time.Duration(defaultIngestionAuthTokenRefreshIntervalSeconds)) + IngestionAuthTokenRefreshTicker = time.NewTicker(time.Second * time.Duration(defaultIngestionAuthTokenRefreshIntervalSeconds)) go refreshIngestionAuthToken() } } diff --git a/source/plugins/go/src/telemetry.go b/source/plugins/go/src/telemetry.go index 31818dbb3..970bf2749 100644 --- a/source/plugins/go/src/telemetry.go +++ b/source/plugins/go/src/telemetry.go @@ -32,6 +32,8 @@ var ( TelemetryClient appinsights.TelemetryClient // ContainerLogTelemetryTicker sends telemetry periodically ContainerLogTelemetryTicker *time.Ticker + //Tracks the number of windows telegraf metrics count with Tags size 64KB or more between telemetry ticker periods (uses ContainerLogTelemetryTicker) + WinTelegrafMetricsCountWithTagsSize64KBorMore float64 //Tracks the number of telegraf metrics sent successfully between telemetry ticker periods (uses ContainerLogTelemetryTicker) TelegrafMetricsSentCount float64 //Tracks the number of send errors between telemetry ticker periods (uses ContainerLogTelemetryTicker) @@ -76,6 +78,7 @@ const ( metricNameNumberofTelegrafMetricsSentSuccessfully = "TelegrafMetricsSentCount" metricNameNumberofSendErrorsTelegrafMetrics = "TelegrafMetricsSendErrorCount" metricNameNumberofSend429ErrorsTelegrafMetrics = "TelegrafMetricsSend429ErrorCount" + metricNameNumberofWinTelegrafMetricsWithTagsSize64KBorMore = "winTelegrafMetricsCountWithTagsSize64KBorMore" metricNameErrorCountContainerLogsSendErrorsToMDSDFromFluent = "ContainerLogs2MdsdSendErrorCount" metricNameErrorCountContainerLogsMDSDClientCreateError = "ContainerLogsMdsdClientCreateErrorCount" metricNameErrorCountInsightsMetricsMDSDClientCreateError = "InsightsMetricsMDSDClientCreateErrorsCount" @@ -114,6 +117,7 @@ func SendContainerLogPluginMetrics(telemetryPushIntervalProperty string) { telegrafMetricsSentCount := TelegrafMetricsSentCount telegrafMetricsSendErrorCount := TelegrafMetricsSendErrorCount telegrafMetricsSend429ErrorCount := TelegrafMetricsSend429ErrorCount + winTelegrafMetricsCountWithTagsSize64KBorMore := WinTelegrafMetricsCountWithTagsSize64KBorMore containerLogsSendErrorsToMDSDFromFluent := ContainerLogsSendErrorsToMDSDFromFluent containerLogsMDSDClientCreateErrors := ContainerLogsMDSDClientCreateErrors containerLogsSendErrorsToADXFromFluent := ContainerLogsSendErrorsToADXFromFluent @@ -129,6 +133,7 @@ func SendContainerLogPluginMetrics(telemetryPushIntervalProperty string) { TelegrafMetricsSentCount = 0.0 TelegrafMetricsSendErrorCount = 0.0 TelegrafMetricsSend429ErrorCount = 0.0 + WinTelegrafMetricsCountWithTagsSize64KBorMore = 0.0 FlushedRecordsCount = 0.0 FlushedRecordsSize = 0.0 FlushedRecordsTimeTaken = 0.0 @@ -222,6 +227,9 @@ func SendContainerLogPluginMetrics(telemetryPushIntervalProperty string) { if kubeMonEventsMDSDClientCreateErrors > 0.0 { TelemetryClient.Track(appinsights.NewMetricTelemetry(metricNameErrorCountKubeMonEventsMDSDClientCreateError, kubeMonEventsMDSDClientCreateErrors)) } + if winTelegrafMetricsCountWithTagsSize64KBorMore > 0.0 { + TelemetryClient.Track(appinsights.NewMetricTelemetry(metricNameNumberofWinTelegrafMetricsWithTagsSize64KBorMore, winTelegrafMetricsCountWithTagsSize64KBorMore)) + } start = time.Now() } diff --git a/source/plugins/ruby/in_kube_podinventory.rb b/source/plugins/ruby/in_kube_podinventory.rb index b15685203..6e5fd3d09 100644 --- a/source/plugins/ruby/in_kube_podinventory.rb +++ b/source/plugins/ruby/in_kube_podinventory.rb @@ -288,7 +288,7 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc containerInventoryStream.add(emitTime, cirecord) if cirecord ciRecordSize = cirecord.to_s.length @winContainerInventoryTotalSizeBytes += ciRecordSize - if ciRecordSize >= 65536 + if ciRecordSize >= 65536 # 64KB @winContainerCountWithInventoryRecordSize64KBOrMore += 1 end if !cirecord["EnvironmentVar"].nil? && !cirecord["EnvironmentVar"].empty? && cirecord["EnvironmentVar"].length >= 65536 From a7208f124a5211ec0766daa55ba98edd6a10f9cb Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Mon, 24 Jan 2022 16:56:41 -0800 Subject: [PATCH 8/9] metric to track wintelegraf metrics with tags 64kb --- source/plugins/go/src/telemetry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/plugins/go/src/telemetry.go b/source/plugins/go/src/telemetry.go index 970bf2749..0560b79f6 100644 --- a/source/plugins/go/src/telemetry.go +++ b/source/plugins/go/src/telemetry.go @@ -78,7 +78,7 @@ const ( metricNameNumberofTelegrafMetricsSentSuccessfully = "TelegrafMetricsSentCount" metricNameNumberofSendErrorsTelegrafMetrics = "TelegrafMetricsSendErrorCount" metricNameNumberofSend429ErrorsTelegrafMetrics = "TelegrafMetricsSend429ErrorCount" - metricNameNumberofWinTelegrafMetricsWithTagsSize64KBorMore = "winTelegrafMetricsCountWithTagsSize64KBorMore" + metricNameNumberofWinTelegrafMetricsWithTagsSize64KBorMore = "WinTelegrafMetricsCountWithTagsSize64KBorMore" metricNameErrorCountContainerLogsSendErrorsToMDSDFromFluent = "ContainerLogs2MdsdSendErrorCount" metricNameErrorCountContainerLogsMDSDClientCreateError = "ContainerLogsMdsdClientCreateErrorCount" metricNameErrorCountInsightsMetricsMDSDClientCreateError = "InsightsMetricsMDSDClientCreateErrorsCount" From 3f089c854cc51169bf0da67b8c819854839da910 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Thu, 27 Jan 2022 18:29:10 -0800 Subject: [PATCH 9/9] fix pr feedback --- source/plugins/ruby/constants.rb | 12 ++++++++---- source/plugins/ruby/in_kube_podinventory.rb | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/source/plugins/ruby/constants.rb b/source/plugins/ruby/constants.rb index 69da56488..b9516c2ce 100644 --- a/source/plugins/ruby/constants.rb +++ b/source/plugins/ruby/constants.rb @@ -110,7 +110,7 @@ class Constants CONTAINER_INVENTORY_DATA_TYPE = "CONTAINER_INVENTORY_BLOB" CONTAINER_NODE_INVENTORY_DATA_TYPE = "CONTAINER_NODE_INVENTORY_BLOB" PERF_DATA_TYPE = "LINUX_PERF_BLOB" - INSIGHTS_METRICS_DATA_TYPE = "INSIGHTS_METRICS_BLOB" + INSIGHTS_METRICS_DATA_TYPE = "INSIGHTS_METRICS_BLOB" KUBE_SERVICES_DATA_TYPE = "KUBE_SERVICES_BLOB" KUBE_POD_INVENTORY_DATA_TYPE = "KUBE_POD_INVENTORY_BLOB" KUBE_NODE_INVENTORY_DATA_TYPE = "KUBE_NODE_INVENTORY_BLOB" @@ -119,17 +119,21 @@ class Constants KUBE_MON_AGENT_EVENTS_DATA_TYPE = "KUBE_MON_AGENT_EVENTS_BLOB" KUBE_HEALTH_DATA_TYPE = "KUBE_HEALTH_BLOB" CONTAINERLOGV2_DATA_TYPE = "CONTAINERINSIGHTS_CONTAINERLOGV2" - CONTAINERLOG_DATA_TYPE = "CONTAINER_LOG_BLOB" + CONTAINERLOG_DATA_TYPE = "CONTAINER_LOG_BLOB" #ContainerInsights Extension (AMCS) CI_EXTENSION_NAME = "ContainerInsights" - CI_EXTENSION_VERSION = "1" + CI_EXTENSION_VERSION = "1" #Current CI extension config size is ~5KB and going with 20KB to handle any future scenarios CI_EXTENSION_CONFIG_MAX_BYTES = 20480 - ONEAGENT_FLUENT_SOCKET_NAME = "/var/run/mdsd/default_fluent.socket" + ONEAGENT_FLUENT_SOCKET_NAME = "/var/run/mdsd/default_fluent.socket" #Tag prefix for output stream EXTENSION_OUTPUT_STREAM_ID_TAG_PREFIX = "dcr-" LINUX_LOG_PATH = $in_unit_test.nil? ? "/var/opt/microsoft/docker-cimprov/log/" : "./" WINDOWS_LOG_PATH = $in_unit_test.nil? ? "/etc/omsagentwindows/" : "./" + + #This is for telemetry to track if any of the windows customer has any of the field size >= 64KB + #To evaluate switching to Windows AMA 64KB impacts any existing customers + MAX_RECORD_OR_FIELD_SIZE_FOR_TELEMETRY = 65536 end diff --git a/source/plugins/ruby/in_kube_podinventory.rb b/source/plugins/ruby/in_kube_podinventory.rb index 6e5fd3d09..f979ef7c5 100644 --- a/source/plugins/ruby/in_kube_podinventory.rb +++ b/source/plugins/ruby/in_kube_podinventory.rb @@ -288,16 +288,16 @@ def parse_and_emit_records(podInventory, serviceRecords, continuationToken, batc containerInventoryStream.add(emitTime, cirecord) if cirecord ciRecordSize = cirecord.to_s.length @winContainerInventoryTotalSizeBytes += ciRecordSize - if ciRecordSize >= 65536 # 64KB + if ciRecordSize >= Constants::MAX_RECORD_OR_FIELD_SIZE_FOR_TELEMETRY @winContainerCountWithInventoryRecordSize64KBOrMore += 1 end - if !cirecord["EnvironmentVar"].nil? && !cirecord["EnvironmentVar"].empty? && cirecord["EnvironmentVar"].length >= 65536 + if !cirecord["EnvironmentVar"].nil? && !cirecord["EnvironmentVar"].empty? && cirecord["EnvironmentVar"].length >= Constants::MAX_RECORD_OR_FIELD_SIZE_FOR_TELEMETRY @winContainerCountWithEnvVarSize64KBOrMore += 1 end - if !cirecord["Ports"].nil? && !cirecord["Ports"].empty? && cirecord["Ports"].length >= 65536 + if !cirecord["Ports"].nil? && !cirecord["Ports"].empty? && cirecord["Ports"].length >= Constants::MAX_RECORD_OR_FIELD_SIZE_FOR_TELEMETRY @winContainerCountWithPortsSize64KBOrMore += 1 end - if !cirecord["Command"].nil? && !cirecord["Command"].empty? && cirecord["Command"].length >= 65536 + if !cirecord["Command"].nil? && !cirecord["Command"].empty? && cirecord["Command"].length >= Constants::MAX_RECORD_OR_FIELD_SIZE_FOR_TELEMETRY @winContainerCountWithCommandSize64KBOrMore += 1 end end