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

Alert rules with "constans" #1905

Closed
freeseacher opened this Issue Aug 22, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@freeseacher
Copy link

freeseacher commented Aug 22, 2016

Hi i want to separate constants with threshold from rules. and made such configuration.

rule_files:
  - "init.rules"
  - "rules/*.rules"

init.rules

prod:disk_used_percent:warning = 80
prod:disk_used_percent:critical = 95

I want to use it in such rule

cat rules/prod.rules 
ALERT disk_usage_percent_warning
  IF disk_used_percent > prod:disk_used_percent:warning
  LABELS {....}
  ANNOTATIONS { .....}

but when i do t manually

disk_used_percent{env="prod",host="wrk01"} > prod:disk_used_percent:warning

return empty result
but

disk_used_percent{dc="BAL",env="prod",fstype="xfs",host="wrk01",job="wrk01",path="/"}   82.29296049154334

and

prod:disk_used_percent:warning{}    80

According to https://prometheus.io/docs/querying/operators/#comparison-binary-operators that seems to be "Between two scalars" and should be fine.
Am i'am doing something wrong?

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Aug 22, 2016

prod:disk_used_percent:warning is a vector.

It's easiest to use hardcoded values when you can, it's simpler to understand. The more general solution is complicated.

@grobie

This comment has been minimized.

Copy link
Member

grobie commented Aug 22, 2016

We use threshold metrics in a few places where we want to allow users to configure different thresholds. It gets indeed a lot more complicated though.

@freeseacher Both sides are vectors. You'll either need to the right hand side to a scalar or specify the labels the vector matching should work on.

@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.