mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Init work
This commit is contained in:
parent
6572b1fe63
commit
3eacd094a0
|
@ -685,6 +685,9 @@ func durationMilliseconds(d time.Duration) int64 {
|
||||||
func (ng *Engine) execEvalStmt(ctx context.Context, query *query, s *parser.EvalStmt) (parser.Value, annotations.Annotations, error) {
|
func (ng *Engine) execEvalStmt(ctx context.Context, query *query, s *parser.EvalStmt) (parser.Value, annotations.Annotations, error) {
|
||||||
prepareSpanTimer, ctxPrepare := query.stats.GetSpanTimer(ctx, stats.QueryPreparationTime, ng.metrics.queryPrepareTime)
|
prepareSpanTimer, ctxPrepare := query.stats.GetSpanTimer(ctx, stats.QueryPreparationTime, ng.metrics.queryPrepareTime)
|
||||||
mint, maxt := FindMinMaxTime(s)
|
mint, maxt := FindMinMaxTime(s)
|
||||||
|
// metric[5m] + metric[5m] offset 5m
|
||||||
|
// mint -10m (-5m - 5m offset)
|
||||||
|
// maxt now()
|
||||||
querier, err := query.queryable.Querier(mint, maxt)
|
querier, err := query.queryable.Querier(mint, maxt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
prepareSpanTimer.Finish()
|
prepareSpanTimer.Finish()
|
||||||
|
@ -2171,6 +2174,15 @@ func (ev *evaluator) matrixSelector(node *parser.MatrixSelector) (Matrix, annota
|
||||||
|
|
||||||
it = storage.NewBuffer(durationMilliseconds(node.Range))
|
it = storage.NewBuffer(durationMilliseconds(node.Range))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO Test for case where range of 1ms
|
||||||
|
if node.OpenLeft {
|
||||||
|
mint += 1
|
||||||
|
}
|
||||||
|
if node.OpenRight {
|
||||||
|
maxt -= 1
|
||||||
|
}
|
||||||
|
|
||||||
ws, err := checkAndExpandSeriesSet(ev.ctx, node)
|
ws, err := checkAndExpandSeriesSet(ev.ctx, node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ev.error(errWithWarnings{fmt.Errorf("expanding series: %w", err), ws})
|
ev.error(errWithWarnings{fmt.Errorf("expanding series: %w", err), ws})
|
||||||
|
|
|
@ -73,7 +73,7 @@ func extrapolatedRate(vals []parser.Value, args parser.Expressions, enh *EvalNod
|
||||||
var (
|
var (
|
||||||
samples = vals[0].(Matrix)[0]
|
samples = vals[0].(Matrix)[0]
|
||||||
rangeStart = enh.Ts - durationMilliseconds(ms.Range+vs.Offset)
|
rangeStart = enh.Ts - durationMilliseconds(ms.Range+vs.Offset)
|
||||||
rangeEnd = enh.Ts - durationMilliseconds(vs.Offset)
|
rangeEnd = enh.Ts - durationMilliseconds(vs.Offset) // TODO Open this in the vector selector
|
||||||
resultFloat float64
|
resultFloat float64
|
||||||
resultHistogram *histogram.FloatHistogram
|
resultHistogram *histogram.FloatHistogram
|
||||||
firstT, lastT int64
|
firstT, lastT int64
|
||||||
|
|
|
@ -126,6 +126,9 @@ type MatrixSelector struct {
|
||||||
VectorSelector Expr
|
VectorSelector Expr
|
||||||
Range time.Duration
|
Range time.Duration
|
||||||
|
|
||||||
|
OpenLeft bool
|
||||||
|
OpenRight bool
|
||||||
|
|
||||||
EndPos posrange.Pos
|
EndPos posrange.Pos
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,22 +28,23 @@ import (
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
node Node
|
node Node
|
||||||
item Item
|
item Item
|
||||||
matchers []*labels.Matcher
|
matchers []*labels.Matcher
|
||||||
matcher *labels.Matcher
|
matcher *labels.Matcher
|
||||||
label labels.Label
|
label labels.Label
|
||||||
labels labels.Labels
|
labels labels.Labels
|
||||||
lblList []labels.Label
|
lblList []labels.Label
|
||||||
strings []string
|
strings []string
|
||||||
series []SequenceValue
|
series []SequenceValue
|
||||||
histogram *histogram.FloatHistogram
|
histogram *histogram.FloatHistogram
|
||||||
descriptors map[string]interface{}
|
descriptors map[string]interface{}
|
||||||
bucket_set []float64
|
bucket_set []float64
|
||||||
int int64
|
int int64
|
||||||
uint uint64
|
uint uint64
|
||||||
float float64
|
float float64
|
||||||
duration time.Duration
|
duration time.Duration
|
||||||
|
range_duration rangeDuration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,7 +450,7 @@ at_modifier_preprocessors: START | END;
|
||||||
* Subquery and range selectors.
|
* Subquery and range selectors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
matrix_selector : expr LEFT_BRACKET duration RIGHT_BRACKET
|
matrix_selector : expr LEFT_BRACKET range_duration RIGHT_BRACKET
|
||||||
{
|
{
|
||||||
var errMsg string
|
var errMsg string
|
||||||
vs, ok := $1.(*VectorSelector)
|
vs, ok := $1.(*VectorSelector)
|
||||||
|
@ -468,7 +469,9 @@ matrix_selector : expr LEFT_BRACKET duration RIGHT_BRACKET
|
||||||
|
|
||||||
$$ = &MatrixSelector{
|
$$ = &MatrixSelector{
|
||||||
VectorSelector: $1.(Expr),
|
VectorSelector: $1.(Expr),
|
||||||
Range: $3,
|
Range: $3.duration,
|
||||||
|
OpenLeft: $3.openLeft,
|
||||||
|
OpenRight: $3.openRight,
|
||||||
EndPos: yylex.(*parser).lastClosing,
|
EndPos: yylex.(*parser).lastClosing,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -899,6 +902,47 @@ duration : DURATION
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
range_duration : DURATION
|
||||||
|
{
|
||||||
|
var err error
|
||||||
|
$$.duration, err = parseDuration($1.Val)
|
||||||
|
if err != nil {
|
||||||
|
yylex.(*parser).addParseErr($1.PositionRange(), err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| POW DURATION
|
||||||
|
{
|
||||||
|
var err error
|
||||||
|
$$.duration, err = parseDuration($1.Val)
|
||||||
|
if err != nil {
|
||||||
|
yylex.(*parser).addParseErr($1.PositionRange(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
$$.openLeft = true
|
||||||
|
}
|
||||||
|
| DURATION POW
|
||||||
|
{
|
||||||
|
var err error
|
||||||
|
$$.duration, err = parseDuration($1.Val)
|
||||||
|
if err != nil {
|
||||||
|
yylex.(*parser).addParseErr($1.PositionRange(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
$$.openRight = true
|
||||||
|
}
|
||||||
|
| POW DURATION POW
|
||||||
|
{
|
||||||
|
var err error
|
||||||
|
$$.duration, err = parseDuration($1.Val)
|
||||||
|
if err != nil {
|
||||||
|
yylex.(*parser).addParseErr($1.PositionRange(), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
$$.openLeft = true
|
||||||
|
$$.openRight = true
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
string_literal : STRING
|
string_literal : STRING
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,7 @@ package parser
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
@ -1000,3 +1001,9 @@ func isLabel(s string) bool {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type rangeDuration struct {
|
||||||
|
duration time.Duration
|
||||||
|
openLeft bool
|
||||||
|
openRight bool
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue