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

Binary Operators not working as expected in Prometheus 2.0 #3683

Closed
pslobo opened this Issue Jan 13, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@pslobo
Copy link

pslobo commented Jan 13, 2018

I've got the following simple query that is working in older versions of Prometheus:

node_load1{instance=~"$instance.*"} / count by(job, instance)(count by(job, instance, cpu)(node_cpu{instance=~"$instance.*"}))

For some odd reason, this isn't working. When I test it out in Prometheus dashboard, it returns no_data. However, when I try each individual section of the query, it works just fine.

Example:

  • node_load1{instance=~"db_server.*"} => 0.54
  • count by(job, instance)(count by(job, instance, cpu)(node_cpu{instance=~"db_server.*"})) => 2

If I try any of these queries:

0.54 / count by(job, instance)(count by(job, instance, cpu)(node_cpu{instance=~"db_server.*"})) or node_load1{instance=~"db_server.*"} / 2 I get the expected results, but join the two and I get no_data

Environment
CentOS 7 server
Linux 3.10.0-693.11.1.el7.x86_64 x86_64
Prometheus, Grafana, Alertmanager all running on Docker

docker version
Client:
Version: 17.12.0-ce
API version: 1.35
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec 27 20:10:14 2017
OS/Arch: linux/amd64

Server:
Engine:
Version: 17.12.0-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec 27 20:12:46 2017
OS/Arch: linux/amd64
Experimental: false

@pslobo

This comment has been minimized.

Copy link
Author

pslobo commented Jan 14, 2018

Ok, so got this working. Changing the equation and surrounding the second part of the equation with scalar() did the trick. Odd that this wasn't needed in v1. Something change in that regard?

@gouthamve

This comment has been minimized.

Copy link
Member

gouthamve commented Jan 14, 2018

@brian-brazil Did we break anything here?

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jan 14, 2018

Looks like a typical misunderstanding of binary operator vector matching.

@pslobo

This comment has been minimized.

Copy link
Author

pslobo commented Jan 14, 2018

@brian-brazil totally possible given I'm rather new to all this. What puzzles me though is that the same query (without scalar() seems to be working in others instances of Prometheus (v1) and this was in fact taken from published Grafana Dashboards with the obvious tweaks for grafana templating (this one for instance: https://grafana.com/dashboards/893).

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Feb 26, 2018

I see no indications of a bug in PromQL here.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 22, 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 22, 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.