Skip to content

Instantly share code, notes, and snippets.

View Lp-Francois's full-sized avatar
:octocat:
Working on cool projects

François Lp-Francois

:octocat:
Working on cool projects
View GitHub Profile
@Lp-Francois
Lp-Francois / bash_strict_mode.md
Created July 10, 2024 14:12 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@Lp-Francois
Lp-Francois / prom-k8s-request-limits.md
Created October 12, 2020 10:57 — forked from max-rocket-internet/prom-k8s-request-limits.md
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /