-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add pct calculated fields for Pod and container CPU and memory usages #6158
Conversation
@exekias Tests somehow fail on darwin. Probably need to skip it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This PR also needs a CHANELOG.
// PerfMetrics stores known metrics from Kubernetes nodes and containers | ||
var PerfMetrics *PerfMetricsCache | ||
|
||
const defaultTimeout = 120 * time.Second |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little tricky cause it's a global cache. I used a somehow safe value, I don't think someone needs to worry about it, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do it until it breaks :-)
) | ||
|
||
// PerfMetrics stores known metrics from Kubernetes nodes and containers | ||
var PerfMetrics *PerfMetricsCache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about init it directly here
var PerfMetrics = NewPerfMetricsCache()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me, pushed the change, thanks!
Thanks for the reviews! @ruflin this one should be ready |
This PR adds the following set of calculated metrics for Pods and containers:
kubernetes.container.cpu.usage.node.pct
kubernetes.container.cpu.usage.limit.pct
kubernetes.container.memory.usage.node.pct
kubernetes.container.memory.usage.limit.pct
kubernetes.pod.cpu.usage.nanocores
kubernetes.pod.cpu.usage.node.pct
kubernetes.pod.cpu.usage.limit.pct
kubernetes.pod.memory.usage.bytes
kubernetes.pod.memory.usage.node.pct
kubernetes.pod.memory.usage.limit.pct
As the source of data to calculate these values comes from different places (kubelet & kube-state-metrics) I added a mechanism to share some performance metrics through an in-memory cache. For that reason, these new metrics will only be available when
state_*
metricsets are enabled.After talking with @simianhacker, I think this:
closes #6125
closes #6124
Please @simianhacker have a look and let me know if you need anything else