prometheus/promql/parser
beorn7 9eafed0f79 promql: Add histogram_count and histogram_sum
This follow a simple function-based approach to access the count and
sum fields of a native Histogram. It might be more elegant to
implement “accessors” via the dot operator, as considered in the
brainstorming doc [1]. However, that would require the introduction of
a whole new concept in PromQL. For the PoC, we should be fine with the
function-based approch. Even the obvious inefficiencies (rate'ing a
whole histogram twice when we only want to rate each the count and the
sum once) could be optimized behind the scenes.

Note that the function-based approach elegantly solves the problem of
detecting counter resets in the sum of observations in the case of
negative observations. (Since the whole native Histogram is rate'd,
the counter reset is detected for the Histogram as a whole.)

We will decide later if an “accessor” approach is really needed. It
would change the example expression for average duration in
functions.md from

      histogram_sum(rate(http_request_duration_seconds[10m]))
	/
      histogram_count(rate(http_request_duration_seconds[10m]))

to

      rate(http_request_duration_seconds.sum[10m])
	/
      rate(http_request_duration_seconds.count[10m])

[1]: https://docs.google.com/document/d/1ch6ru8GKg03N02jRjYriurt-CZqUVY09evPg6yKTA1s/edit

Signed-off-by: beorn7 <beorn@grafana.com>
2022-06-28 18:16:48 +02:00
..
ast.go refactor (promql): move from github.com/pkg/errors to 'errors' and 'fmt' (#10817) 2022-06-08 10:47:52 +02:00
functions.go promql: Add histogram_count and histogram_sum 2022-06-28 18:16:48 +02:00
generated_parser.y Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
generated_parser.y.go Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
lex.go Add atan2 binary operator 2021-09-23 10:30:46 -04:00
lex_test.go Run gofumpt on all files (#10392) 2022-03-03 17:21:05 +01:00
parse.go refactor (promql): move from github.com/pkg/errors to 'errors' and 'fmt' (#10817) 2022-06-08 10:47:52 +02:00
parse_test.go refactor (promql): move from github.com/pkg/errors to 'errors' and 'fmt' (#10817) 2022-06-08 10:47:52 +02:00
printer.go Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
printer_test.go Move packages out of deprecated pkg directory 2021-11-09 08:03:10 +01:00
value.go promql: use explicit type declare instead of string. (#7716) 2020-08-02 09:57:38 +01:00