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

boolean expression only evaluates last element #2122

Closed
brymatm opened this Issue Oct 26, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@brymatm
Copy link

brymatm commented Oct 26, 2016

What did you do?
Created the following recording rule and included it in my alerts:

workhours=day_of_week() < BOOL 6 * hour() >= BOOL 13 * hour() < BOOL 22

What did you expect to see?
Did not expect to receive alerts outside of the specified hours.

What did you see instead? Under which circumstances?
At the time I wrote this, day_of_week() resolved to 3, hour() resolved to 11:

Received alerts outside of the specified hours for datafeeds undergoing nightly refreshes. When I manually input the expression in Prometheus I was surprised to see the expression returning 1 when the hour was less than 13. When I changed the order of the expression to this it returned 0 as expected:

day_of_week() < BOOL 6 * hour() < BOOL 22 * hour() >= BOOL 13

When I drop the expression to two elements and change it so that the day of week should cause the expression to fail, it still only evaluates the last element of the expression:

day_of_week() > BOOL 6  * hour() < BOOL 22

(see attached images)

Environment

  • System information:

Linux 2.6.32-358.el6.x86_64 x86_64

  • Prometheus version:

prometheus, version 1.3.0-beta.0 (branch: master, revision: 5273b55)
build user: root@cb83e777216a
build date: 20161020-08:51:20
go version: go1.7.1

expression-bug
expression-bug2

  • Alertmanager version:
  • Prometheus configuration file:
workhours=day_of_week() < bool 6 * hour() >= bool 13 * hour() < bool 22

ALERT rateAlert_server_datafeed
  IF rate(server_datafeed[10m]) == 0 and on () workhours == 1
  LABELS { topic = "datafeed", }
  ANNOTATIONS {
    summary = "Topic datafeed on {{ $labels.job }} has not received a message for at least 10 minutes",
    subject = "No messages for topic datafeed on {{ $labels.job }}",
  }
  • Alertmanager configuration file:
  • Logs:
@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Oct 26, 2016

Add parens to force evaluation order.

@lock

This comment has been minimized.

Copy link

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