prometheus/rules/ast
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.go Drop metric names after transformations. 2014-11-25 17:13:04 +01:00
functions.go Add absent() function. 2014-11-25 17:13:04 +01:00
functions_test.go Initial experimental snapshot of next-gen storage. 2014-11-25 17:02:00 +01:00
printer.go Major code cleanup. 2014-11-25 17:02:53 +01:00
query_analyzer.go Squash a number of TODOs. 2014-11-25 17:09:04 +01:00
view_adapter.go Initial experimental snapshot of next-gen storage. 2014-11-25 17:02:00 +01:00
walk.go Make rules/ast golint clean. 2014-02-14 15:01:39 +01:00