-
Notifications
You must be signed in to change notification settings - Fork 115
Rashmi/april agent 2021 #538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2e45db7
job first stab
rashmichandrashekar 33bf7e0
telemetry changes
rashmichandrashekar 8928784
changes
rashmichandrashekar 6c71cbe
bug fix
rashmichandrashekar 9d8110d
hours fix
rashmichandrashekar 418efa7
bug fix
rashmichandrashekar f2e8281
bug fix
rashmichandrashekar 1e9689c
fix
rashmichandrashekar 968387a
merging with remote
rashmichandrashekar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -31,6 +31,8 @@ class KubernetesApiClient | |||
| @@TokenStr = nil | ||||
| @@NodeMetrics = Hash.new | ||||
| @@WinNodeArray = [] | ||||
| @@telemetryTimeTracker = DateTime.now.to_time.to_i | ||||
| @@resourceLimitsTelemetryHash = {} | ||||
|
|
||||
| def initialize | ||||
| end | ||||
|
|
@@ -403,9 +405,12 @@ def getPodUid(podNameSpace, podMetadata) | |||
|
|
||||
| def getContainerResourceRequestsAndLimits(pod, metricCategory, metricNameToCollect, metricNametoReturn, metricTime = Time.now.utc.iso8601) | ||||
| metricItems = [] | ||||
| timeDifference = (DateTime.now.to_time.to_i - @@telemetryTimeTracker).abs | ||||
| timeDifferenceInMinutes = timeDifference / 60 | ||||
| begin | ||||
| clusterId = getClusterId | ||||
| podNameSpace = pod["metadata"]["namespace"] | ||||
| podName = pod["metadata"]["name"] | ||||
| podUid = getPodUid(podNameSpace, pod["metadata"]) | ||||
| if podUid.nil? | ||||
| return metricItems | ||||
|
|
@@ -456,6 +461,33 @@ def getContainerResourceRequestsAndLimits(pod, metricCategory, metricNameToColle | |||
| metricProps["Collections"].push(metricCollections) | ||||
| metricItem["DataItems"].push(metricProps) | ||||
| metricItems.push(metricItem) | ||||
| #Telemetry about omsagent requests and limits | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding this. This works and also you are not adding additional calls. For future reference, you can easily pass this to us thru downward API. Please see here for reference -
|
||||
| begin | ||||
| if (podName.downcase.start_with?("omsagent-") && podNameSpace.eql?("kube-system") && containerName.downcase.start_with?("omsagent")) | ||||
| nodePodContainerKey = [nodeName, podName, containerName, metricNametoReturn].join("~~") | ||||
| @@resourceLimitsTelemetryHash[nodePodContainerKey] = metricValue | ||||
| end | ||||
| if (timeDifferenceInMinutes >= Constants::TELEMETRY_FLUSH_INTERVAL_IN_MINUTES) | ||||
| @@resourceLimitsTelemetryHash.each { |key, value| | ||||
| keyElements = key.split("~~") | ||||
| if keyElements.length != 4 | ||||
| next | ||||
| end | ||||
|
|
||||
| # get dimension values by key | ||||
| telemetryProps = {} | ||||
| telemetryProps["Computer"] = keyElements[0] | ||||
| telemetryProps["PodName"] = keyElements[1] | ||||
| telemetryProps["ContainerName"] = keyElements[2] | ||||
| metricNameFromKey = keyElements[3] | ||||
| ApplicationInsightsUtility.sendMetricTelemetry(metricNameFromKey, value, telemetryProps) | ||||
| } | ||||
| @@telemetryTimeTracker = DateTime.now.to_time.to_i | ||||
| @@resourceLimitsTelemetryHash = {} | ||||
| end | ||||
| rescue => errorStr | ||||
| $log.warn("Exception while generating Telemetry from getContainerResourceRequestsAndLimits failed: #{errorStr} for metric #{metricNameToCollect}") | ||||
| end | ||||
| #No container level limit for the given metric, so default to node level limit | ||||
| else | ||||
| nodeMetricsHashKey = clusterId + "/" + nodeName + "_" + "allocatable" + "_" + metricNameToCollect | ||||
|
|
@@ -791,7 +823,7 @@ def getKubeAPIServerUrl | |||
| def getKubeServicesInventoryRecords(serviceList, batchTime = Time.utc.iso8601) | ||||
| kubeServiceRecords = [] | ||||
| begin | ||||
| if (!serviceList.nil? && !serviceList.empty? && serviceList.key?("items") && !serviceList["items"].nil? && !serviceList["items"].empty? ) | ||||
| if (!serviceList.nil? && !serviceList.empty? && serviceList.key?("items") && !serviceList["items"].nil? && !serviceList["items"].empty?) | ||||
| servicesCount = serviceList["items"].length | ||||
| @Log.info("KubernetesApiClient::getKubeServicesInventoryRecords : number of services in serviceList #{servicesCount} @ #{Time.now.utc.iso8601}") | ||||
| serviceList["items"].each do |item| | ||||
|
|
||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.