Skip to content

Instantly share code, notes, and snippets.

@WadeBarnes
Last active November 10, 2023 19:19
Show Gist options
  • Save WadeBarnes/1de4339bef10e6316e7806928b59a57f to your computer and use it in GitHub Desktop.
Save WadeBarnes/1de4339bef10e6316e7806928b59a57f to your computer and use it in GitHub Desktop.
Container throttling queries that I keep forgetting about

Queries to determine how much a container is being throttled

Examples courtesy of Jason Leach.

Example promql query for OCP:

avg(container_cpu_cfs_throttled_periods_total / container_cpu_cfs_periods_total {namespace=~"4a9599-prod", pod=~".*mediator.*", container_name!="POD", image!=""} * 100) BY (pod) 
  • The namespace portion of the query can be a problem when querying inside a namespace.

Example command line query:

$ cat /sys/fs/cgroup/cpu/cpu.stat
nr_periods 123978
nr_throttled 17778
throttled_time 360587202704

nr_throttled/nr_periods * 100 = 17778 / 123978 * 100 = Container is throttled 14.34% of the time

Additional Resources/Discussions:

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