Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions source/code/plugin/ApplicationInsightsUtility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
15 changes: 15 additions & 0 deletions source/code/plugin/in_kube_nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down