prometheus/rules/ast
Julius Volz d411a7d810 Allow reversing vector and scalar arguments in binops.
This allows putting a scalar as the first argument of a binary operator
in which the second argument is a vector:

  <scalar> <binop> <vector>

For example,

  1 / http_requests_total

...will output a vector in which every sample value is 1 divided by the
respective input vector element.

This even works for filter binary operators now:

  1 == http_requests_total

Returns a vector with all values set to 1 for every element in
http_requests_total whose initial value was 1.

Note: For filter binary operators, the resulting values are always taken
from the left-hand-side of the operation, no matter whether the scalar
or the vector argument is the left-hand-side. That is,

  1 != http_requests_total

...will set all result vector sample values to 1, although these are
exactly the sample elements that were != 1 in the input vector.

If you want to just filter elements without changing their sample
values, you still need to do:

  http_requests_total != 1

The new filter form is a bit exotic, and so probably won't be used
often. But it was easier to implement it than disallow it completely or
change its behavior.

Change-Id: Idd083f2bd3a1219ba1560cf4ace42f5b82e797a5
2014-04-08 17:16:18 +02:00
..
ast.go Allow reversing vector and scalar arguments in binops. 2014-04-08 17:16:18 +02:00
functions.go Rename {Scalar,Vector}Literal to {Scalar,Vector}Selector. 2014-02-22 22:33:42 +01:00
functions_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
printer.go Add regex-matching support for labels. 2014-04-01 14:24:53 +02:00
query_analyzer.go Add regex-matching support for labels. 2014-04-01 14:24:53 +02:00
view_adapter.go Convert metric.Values to slice of values. 2014-03-11 18:23:37 +01:00
walk.go Make rules/ast golint clean. 2014-02-14 15:01:39 +01:00