Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upUnit testing for alert rules are not working as expected #4689
Comments
This comment has been minimized.
This comment has been minimized.
|
/cc @codesome |
This comment has been minimized.
This comment has been minimized.
|
@kentsanggds Thanks for this, looks like docs are not clear.
In the docs I missed the indentation (it should be lined with
I will update the docs with clear instructions. |
This comment has been minimized.
This comment has been minimized.
|
Thanks, I tried that out and that fixed it. Also is it possible to simulate missing metrics in the input_series? |
This comment has been minimized.
This comment has been minimized.
I am not clear what are we referring to.
I did not quite understand this, can you give an example? |
This comment has been minimized.
This comment has been minimized.
|
I managed to get what I thought was a working Regarding missing metrics it would be nice if we could simulate when at particular data points the metric was missing, perhaps something like this -
where dashes This would represent situations where the target metric was unavailable for scraping or the target was removed by accident for example. |
This comment has been minimized.
This comment has been minimized.
|
No And regarding having missing metrics, it is already supported. You use |
This comment has been minimized.
This comment has been minimized.
|
Thanks, ok I understand the reason for the With the missing metrics, I'm not sure it is working as expected as it doesn't trigger the alert, can you tell me how I would run the test so that I can modify the existing test to try things out. |
This comment has been minimized.
This comment has been minimized.
|
@kentsanggds Please compile |
This comment has been minimized.
This comment has been minimized.
|
I was actually referring to the tests here - https://github.com/prometheus/prometheus/blob/9bca041285e226410809b64ce2d178bc4ccabbcf/promql/parse_test.go, in the end I sorted it out and managed to get the alerting rule tests working as I would like, but it would be nice also to be able to run those tests to try things out without having to set up the tests. One thing which I find odd is that if it fails due to the expected not matching the actual response, it will report the failure a number of times rather than just the 1 test that I'm adding, which is slightly confusing. Also is it possible to make the tests more verbose to indicate which tests have passed as at the moment when it passes you just get |
This comment has been minimized.
This comment has been minimized.
|
Can you share your test files so that I can dig in more? |
This comment has been minimized.
This comment has been minimized.
|
Sure, I am working on a branch in github, have a look here for the test file - |
kentsanggds commentedOct 2, 2018
Bug Report
What did you do?
I'm trying to set up the unit testing for alert rules according to these docs - https://github.com/prometheus/prometheus/blob/master/docs/configuration/unit_testing_rules.md#testyml
I had to fix the yaml by using
- alert_rule_testrather thanalert_rule_testto get it runningWhat did you expect to see?
The example alert rule test to work and report success
What did you see instead? Under which circumstances?
Running
promtool test rules alerts.ymldoesn't work, it fails.Environment
Mac OS
Darwin 17.7.0 x86_64
promtool, version 2.4.2 (branch: master, revision: 6932030)
build user: xxx
build date: 20181002-14:56:44
go version: go1.10.3