Fix duplicate output vector if delayed name removal is disabled
This error is emitted in cleanupMetricLabels, but is skipped if
enableDelayedNameRemoval is false.
This makes it consistent with label_replace
Signed-off-by: Joshua Hesketh <josh@nitrotech.org>
---------
Signed-off-by: Joshua Hesketh <josh@nitrotech.org>
Signed-off-by: Björn Rabenstein <github@rabenste.in>
Co-authored-by: Björn Rabenstein <github@rabenste.in>
Related to #12318 .
Allow using a PromQL expression for setting the offset, provided that:
the expression evaluates to a scalar
the expression does not contain vector selector (no TSDB access)
the expression does not call the info() function (no TSDB access)
the time() function is only called on the top level of the expression,
not inside a subquery
We'll call such expression a time expression.
During parsing we no longer set OriginalOffset field in sub-queries and
vector selectors, instead we set a new OriginalOffsetExpr field to the
time expression, even if the expression is a literal number.
Before evaluating the overall PromQL expression, the engine shall
evaluate the time expressions and set the OriginalOffset field in vector
selectors and subqueries to the calculated value. This makes the change
fairly non intrusive. Later we can change the code to start using the
expression more directly. Note: this prohibits using time() function
inside a sub-query as the evaluation time is not constant inside a
sub-query.
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
A `HistogramTestExpression` was missed in one case, which made the
formatting weird in case a histogram got unexpectedly returned.
Signed-off-by: beorn7 <beorn@grafana.com>
If a rate (or increase) is calculated on native histograms, and there
is a counter reset between the 1st and 2nd histogram, we never have to
touch the 1st histogram, so it doesn't even matter if it has an
incompatible bucket layout. So we should not error out in that case.
This simply nulls out the 1st histogram in that case.
Signed-off-by: beorn7 <beorn@grafana.com>
Ensure metric name is present on histogram_quantile annotations
Previously the series __name__ label was dropped before the annotation
was emitted causing the annotation message to have a blank value.
This fix also allows delayed name removal for classic histograms.
This also adds a test for malformed le label
This annotation could be split into two to be clearer for the user
(one for missing, and one for malformed). This is outside of the scope
of this change.
Fixes: #15411
---------
Signed-off-by: Joshua Hesketh <josh@nitrotech.org>
Signed-off-by: Björn Rabenstein <github@rabenste.in>
Co-authored-by: Björn Rabenstein <github@rabenste.in>
Go 1.24 enhanced vet's printf analyzer to report calls of the form
fmt.Printf(s), where s is a non-constant format string, with no other
arguments. This change makes parser tests to fail.
Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
promql: Add additional incompatible nhcb schemas tests for functions and comparison operators
* Add agg_over_time tests for nhcb with incompatible schemas
* Add more function and comparison operator tests
---------
Signed-off-by: Fiona Liao <fiona.liao@grafana.com>
Fix issues raised by staticcheck
We are not enabling staticcheck explicitly, though, because it has too many false positives.
---------
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This also improves the documentation in the following ways:
- Clarifies that `eval` requires no annotations.
- Clarifies that `eval_ordered` ignores annotations.
- Clarifies that `eval_ordered` does not work with matrix returns
(which could very well be created by instant queries).
- Clarifies that there are more `eval` commands than just `eval`.
- Improves wording for `eval_ordered`.
- Replaces `...` by the typographical correct `…`.
- Fixes a numerical error in an example.
Signed-off-by: beorn7 <beorn@grafana.com>
Besides making eval_ordered ignore annotations, this does the following:
- Adds a test to verify that eval_ordered indeed ignores an info
annotations now, while eval complains about it, eval_info recognizes
it and, eval_warn flags the missing of the warn annotation.
- Refactors the annotation check into its own method.
- Moves closing of the query to the appropriate place where it wasn't
so far.
Signed-off-by: beorn7 <beorn@grafana.com>
Add test for `absent`, `absent_over_time` and `deriv` func with histograms
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
---------
Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com>
`funcDoubleExponentialSmoothing` did not get its doc comment updated
when we renamed it from the confusing `funcHoltWinters`.
Signed-off-by: beorn7 <beorn@grafana.com>