prometheus/rules
Julius Volz b7bf11230a Add absent() function.
A common problem in Prometheus alerting is to detect when no timeseries
exist for a given metric name and label combination. Unfortunately,
Prometheus alert expressions need to be of vector type, and
"count(nonexistent_metric)" results in an empty vector, yielding no
output vector elements to base an alert on. The newly introduced
absent() function solves this issue:

  ALERT FooAbsent IF absent(foo{job="myjob"}) [...]

absent() has the following behavior:

- if the vector passed to it has any elements, it returns an empty
  vector.

- if the vector passed to it has no elements, it returns a 1-element
  vector with the value 1.

In the second case, absent() tries to be smart about deriving labels of
the 1-element output vector from the input vector:

  absent(nonexistent{job="myjob"})                   => {job="myjob"}
  absent(nonexistent{job="myjob",instance=~".*"})    => {job="myjob"}
  absent(sum(nonexistent{job="myjob"}))              => {}

That is, if the passed vector is a literal vector selector, it takes all
"=" label matchers as the basis for the output labels, but ignores all
non-equals or regex matchers. Also, if the passed vector results from a
non-selector expression, no labels can be derived.

Change-Id: I948505a1488d50265ab5692a3286bd7c8c70cd78
2014-11-25 17:13:04 +01:00
..
ast Add absent() function. 2014-11-25 17:13:04 +01:00
fixtures Add alertmanager notification support to Prometheus. 2013-07-30 17:23:41 +02:00
manager Improve scraper shutdown time. 2014-11-25 17:10:39 +01:00
alerting.go Major code cleanup. 2014-11-25 17:02:53 +01:00
helpers.go Let consoles get graph links from experssions. 2014-11-25 17:01:59 +01:00
helpers_test.go Fix targetpool_test.go and other tests. 2014-11-25 17:08:26 +01:00
lexer.l Add regex-matching support for labels. 2014-04-01 14:24:53 +02:00
lexer.l.go Add regex-matching support for labels. 2014-04-01 14:24:53 +02:00
load.go Use github.com/golang/glog for all logging. 2013-08-12 17:54:36 +02:00
Makefile Simplify makefiles. 2014-11-25 17:10:39 +01:00
parser.y Allow alternative "by"-clause position in grammar. 2014-11-25 17:09:04 +01:00
parser.y.go Allow alternative "by"-clause position in grammar. 2014-11-25 17:09:04 +01:00
recording.go Major code cleanup. 2014-11-25 17:02:53 +01:00
rules.go Major code cleanup. 2014-11-25 17:02:53 +01:00
rules_test.go Add absent() function. 2014-11-25 17:13:04 +01:00