Hi,
The meaning of metric names is defined by the application that exposes
them, so there's no overall fixed 1:1 relationship between a metric name
and its meaning in the Prometheus world. It depends on the code that
outputs the metric. However, of course there are many metric names that are
pretty standardized in practice, and for example,
"container_spec_cpu_quota" looks like a metric that cAdvisor (or the
equivalent code in a Kubernetes Kubelet) exposes about each container
running on the machine. It seems that
https://docs.signalfx.com/en/latest/integrations/agent/monitors/cadvisor.html
has a pretty good summary of the different cAdvisor metric names, but you
should also be able to go in a web browser to a cAdvisor /metrics endpoint
and see a HELP comment line explaining the meaning of each metric name
(this usually works for other metrics-exposing processes as well).
To get the current CPU usage (as averaged over 5 minutes) in %, summed over
all containers using a certain image (e.g. "my-image-name"), you could do
something like this:
sum by(image)
(rate(container_cpu_usage_seconds_total{image="my-image-name"}[5m])) * 100
See as an example: https://demo.promlens.com/?l=qsvckzomT2U
The "* 100" in the expression converts the per-core usage into a
percentage. Note that this can go above 100% if you have more than one CPU
core.
Regards,
Julius
On Wed, Mar 31, 2021 at 4:52 PM Bill Zalokostas <[email protected]>
wrote:
> Hello,
> I want to measure the percentage of cpu usage that is used for a specific
> image including all containers that run this image. Can you provide me
> the
> query function in order to solve my problem? Also, can you share a link
> in
> which every expression in prometheus query is being explained (basically
> what every exprassion mean e.x. container_spec_cpu_quota) because I can't
> find anything on the Internet and the docs that you have aren't mention
> anything?
>
> Thank you in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/5bd3df94-baec-41a5-b9f4-625ffb354245n%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/5bd3df94-baec-41a5-b9f4-625ffb354245n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Julius Volz
PromLabs - promlabs.com
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/CAObpH5xB6QfajD0dnLMzV2%3D_3J-_i%2Biuwqkdi8C2vreqNbhhLw%40mail.gmail.com.