diff --git a/source/code/plugin/ApplicationInsightsUtility.rb b/source/code/plugin/ApplicationInsightsUtility.rb index bb4831701..85b424e69 100644 --- a/source/code/plugin/ApplicationInsightsUtility.rb +++ b/source/code/plugin/ApplicationInsightsUtility.rb @@ -64,6 +64,7 @@ def initializeUtility() @@CustomProperties["ControllerType"] = ENV[@@EnvControllerType] encodedAppInsightsKey = ENV[@@EnvApplicationInsightsKey] appInsightsEndpoint = ENV[@@EnvApplicationInsightsEndpoint] + @@CustomProperties["WorkspaceCloud"] = getWorkspaceCloud #Check if telemetry is turned off telemetryOffSwitch = ENV["DISABLE_TELEMETRY"] @@ -230,5 +231,32 @@ def getWorkspaceId() $log.warn("Exception in AppInsightsUtility: getWorkspaceId - error: #{errorStr}") end end + + def getWorkspaceCloud() + begin + adminConf = {} + confFile = File.open(@OmsAdminFilePath, "r") + confFile.each_line do |line| + splitStrings = line.split("=") + adminConf[splitStrings[0]] = splitStrings[1] + end + workspaceDomain = adminConf["URL_TLD"].strip + workspaceCloud = "AzureCloud" + if workspaceDomain.casecmp("opinsights.azure.com") == 0 + workspaceCloud = "AzureCloud" + elsif workspaceDomain.casecmp("opinsights.azure.cn") == 0 + workspaceCloud = "AzureChinaCloud" + elsif workspaceDomain.casecmp("opinsights.azure.us") == 0 + workspaceCloud = "AzureUSGovernment" + elsif workspaceDomain.casecmp("opinsights.azure.de") == 0 + workspaceCloud = "AzureGermanCloud" + else + workspaceCloud = "Unknown" + end + return workspaceCloud + rescue => errorStr + $log.warn("Exception in AppInsightsUtility: getWorkspaceCloud - error: #{errorStr}") + end + end end end diff --git a/source/code/plugin/in_kube_nodes.rb b/source/code/plugin/in_kube_nodes.rb index 7249957ab..42bc13b68 100644 --- a/source/code/plugin/in_kube_nodes.rb +++ b/source/code/plugin/in_kube_nodes.rb @@ -8,6 +8,7 @@ class Kube_nodeInventory_Input < Input @@ContainerNodeInventoryTag = "oms.containerinsights.ContainerNodeInventory" @@MDMKubeNodeInventoryTag = "mdm.kubenodeinventory" @@promConfigMountPath = "/etc/config/settings/prometheus-data-collection-settings" + @@AzStackCloudFileName = "/etc/kubernetes/host/azurestackcloud.json" @@rsPromInterval = ENV["TELEMETRY_RS_PROM_INTERVAL"] @@rsPromFieldPassCount = ENV["TELEMETRY_RS_PROM_FIELDPASS_LENGTH"] @@ -84,6 +85,17 @@ def enumerate record["Labels"] = [items["metadata"]["labels"]] record["Status"] = "" + if !items["spec"]["providerID"].nil? && !items["spec"]["providerID"].empty? + if File.file?(@@AzStackCloudFileName) # existence of this file indicates agent running on azstack + record["KubernetesProviderID"] = "azurestack" + else + record["KubernetesProviderID"] = items["spec"]["providerID"] + end + else + record["KubernetesProviderID"] = "onprem" + end + + # Refer to https://kubernetes.io/docs/concepts/architecture/nodes/#condition for possible node conditions. # We check the status of each condition e.g. {"type": "OutOfDisk","status": "False"} . Based on this we # populate the KubeNodeInventory Status field. A possible value for this field could be "Ready OutofDisk" @@ -139,6 +151,9 @@ def enumerate properties["KubeletVersion"] = record["KubeletVersion"] properties["OperatingSystem"] = nodeInfo["operatingSystem"] properties["DockerVersion"] = dockerVersion + properties["KubernetesProviderID"] = record["KubernetesProviderID"] + properties["KernelVersion"] = nodeInfo["kernelVersion"] + properties["OSImage"] = nodeInfo["osImage"] capacityInfo = items["status"]["capacity"] ApplicationInsightsUtility.sendMetricTelemetry("NodeMemory", capacityInfo["memory"], properties)