Skip to content

Add pct calculated fields for Pod and container CPU and memory usages#6158

Merged
ruflin merged 3 commits intoelastic:masterfrom
exekias:kubernetes-usage-percentages
Jan 28, 2018
Merged

Add pct calculated fields for Pod and container CPU and memory usages#6158
ruflin merged 3 commits intoelastic:masterfrom
exekias:kubernetes-usage-percentages

Conversation

@exekias
Copy link
Copy Markdown
Contributor

@exekias exekias commented Jan 24, 2018

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

@ruflin
Copy link
Copy Markdown
Contributor

ruflin commented Jan 25, 2018

@exekias Tests somehow fail on darwin. Probably need to skip it.

Copy link
Copy Markdown
Contributor

@ruflin ruflin left a 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
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Contributor

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
Copy link
Copy Markdown
Contributor

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()

Copy link
Copy Markdown
Contributor Author

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!

@exekias
Copy link
Copy Markdown
Contributor Author

exekias commented Jan 26, 2018

Thanks for the reviews! @ruflin this one should be ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants