diff --git a/source/plugins/ruby/ApplicationInsightsUtility.rb b/source/plugins/ruby/ApplicationInsightsUtility.rb index eaa1d903d..7691304a6 100644 --- a/source/plugins/ruby/ApplicationInsightsUtility.rb +++ b/source/plugins/ruby/ApplicationInsightsUtility.rb @@ -243,6 +243,9 @@ def sendTelemetry(pluginName, properties) getContainerRuntimeInfo() end @@CustomProperties["Computer"] = properties["Computer"] + if !properties["addonTokenAdapterImageTag"].nil? && !properties["addonTokenAdapterImageTag"].empty? + @@CustomProperties["addonTokenAdapterImageTag"] = properties["addonTokenAdapterImageTag"] + end sendHeartBeatEvent(pluginName) sendLastProcessedContainerInventoryCountMetric(pluginName, properties) rescue => errorStr diff --git a/source/plugins/ruby/in_containerinventory.rb b/source/plugins/ruby/in_containerinventory.rb index 9fcb7ab90..f52ed4026 100644 --- a/source/plugins/ruby/in_containerinventory.rb +++ b/source/plugins/ruby/in_containerinventory.rb @@ -57,6 +57,7 @@ def enumerate containerInventory = Array.new eventStream = Fluent::MultiEventStream.new hostName = "" + addonTokenAdapterImageTag = "" $log.info("in_container_inventory::enumerate : Begin processing @ #{Time.now.utc.iso8601}") if ExtensionUtils.isAADMSIAuthMode() $log.info("in_container_inventory::enumerate: AAD AUTH MSI MODE") @@ -82,6 +83,15 @@ def enumerate if hostName.empty? && !containerRecord["Computer"].empty? hostName = containerRecord["Computer"] end + if addonTokenAdapterImageTag.empty? && ExtensionUtils.isAADMSIAuthMode() + if !containerRecord["ElementName"].nil? && !containerRecord["ElementName"].empty? && + containerRecord["ElementName"].include?("kube-system") && + containerRecord["ElementName"].include?("addon-token-adapter_omsagent") + if !containerRecord["ImageTag"].nil? && !containerRecord["ImageTag"].empty? + addonTokenAdapterImageTag = containerRecord["ImageTag"] + end + end + end containerIds.push containerRecord["InstanceID"] containerInventory.push containerRecord end @@ -117,6 +127,9 @@ def enumerate telemetryProperties = {} telemetryProperties["Computer"] = hostName telemetryProperties["ContainerCount"] = containerInventory.length + if !addonTokenAdapterImageTag.empty? + telemetryProperties["addonTokenAdapterImageTag"] = addonTokenAdapterImageTag + end ApplicationInsightsUtility.sendTelemetry(@@PluginName, telemetryProperties) end rescue => errorStr