Skip to content
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

Strange behavior of 'count' #2489

Closed
kehao95 opened this Issue Mar 10, 2017 · 6 comments

Comments

Projects
None yet
3 participants
@kehao95
Copy link

kehao95 commented Mar 10, 2017

I have totally no idea what was going on here. So I will just describe how I tried this and what did I see.
I was trying to calculate the cpu_load pre-CPU using the metrics exported by the node_expoter.
So I calculated as this:

{pre_cpu_load by instance}
= A/B
=  {load1 by instance}/{number of CPU by instance}
=  {load1 by instance}/{count of {all cpu} by instance}
# So the query is: 
node_load1 / (count by(instance)(count by(instance, cpu)(node_cpu)))

What did I do?
In the prometheus web interface, exec
node_load1 / (count by(instance)(count by(instance, cpu)(node_cpu)))
'no data'
for debug I specific the instance id and tear this apart:
Here is some experiments:

label query expect result
A node_load1{instance="xxxxx"} 0.3 0.3
A' node_load1 [0.3,0.3,0.3] [0.3,0.3,0.3]
A+1 ~ 1.3 1.3
B count by(instance)(count by(instance, cpu)(node_cpu{instance="xxxx"})) 4 4
B' count by(instance)(count by(instance, cpu)(node_cpu)) [2,2,4] [2,2,4]
B+1 ~ 5 5
A/B node_load1{instance="xxxxx"}/(count by(instance)(count by(instance, cpu)(node_cpu{instance="xxxx"}))) 0.075 no data
A'/B' node_load1 / (count by(instance)(count by(instance, cpu)(node_cpu))) [2,2,2,4] no data

Environment

  • System information:
    Linux 4.4.35-33.55.amzn1.x86_64 x86_64
  • Prometheus version:
prometheus, version 1.5.2 (branch: master, revision: bd1182d29f462c39544f94cc822830e1c64cf55b)
  build user:       root@a8af9200f95d
  build date:       20170210-14:41:22
  go version:       go1.7.5
@kehao95

This comment has been minimized.

Copy link
Author

kehao95 commented Mar 10, 2017

One more interesting things here may be helpful.

There is a result of '4' in Query B but the graph did show it correctly. The line seemed to drop off the graph.
screen shot 2017-03-10 at 11 54 10 am

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Mar 10, 2017

For usage questions, https://groups.google.com/forum/#!aboutgroup/prometheus-users is the best place to get answers.

@kehao95

This comment has been minimized.

Copy link
Author

kehao95 commented Mar 10, 2017

Well, I think this may be a bug. So I report it. Could you plz take another look?
In brief, I came across a situation where I got a query 'A' with result of a. And query 'B' with result of b.
But when I query 'A/B' I got no data

@beorn7

This comment has been minimized.

Copy link
Member

beorn7 commented Mar 10, 2017

It is not a bug.

You need to understand label matching, see https://prometheus.io/docs/querying/operators/#vector-matching .

If you discuss this questions on the mailing list, other users can benefit from the answers.

@kehao95

This comment has been minimized.

Copy link
Author

kehao95 commented Mar 10, 2017

Oh sorry, thank you for your reply.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.