MCPcopy Index your code
hub / github.com/prometheus/prometheus / NewInstantQuery

Method NewInstantQuery

promql/engine.go:544–561  ·  view source on GitHub ↗

NewInstantQuery returns an evaluation query for the given expression at the given time.

(ctx context.Context, q storage.Queryable, opts QueryOpts, qs string, ts time.Time)

Source from the content-addressed store, hash-verified

542
543// NewInstantQuery returns an evaluation query for the given expression at the given time.
544func (ng *Engine) NewInstantQuery(ctx context.Context, q storage.Queryable, opts QueryOpts, qs string, ts time.Time) (Query, error) {
545 pExpr, qry := ng.newQuery(q, qs, opts, ts, ts, 0*time.Second)
546 finishQueue, err := ng.queueActive(ctx, qry)
547 if err != nil {
548 return nil, err
549 }
550 defer finishQueue()
551 expr, err := ng.parser.ParseExpr(qs)
552 if err != nil {
553 return nil, err
554 }
555 if err := ng.validateOpts(expr); err != nil {
556 return nil, err
557 }
558 *pExpr, err = PreprocessExpr(expr, ts, ts, 0)
559
560 return qry, err
561}
562
563// NewRangeQuery returns an evaluation query for the given time range and with
564// the resolution set by the interval.

Callers 2

Calls 5

newQueryMethod · 0.95
queueActiveMethod · 0.95
validateOptsMethod · 0.95
PreprocessExprFunction · 0.85
ParseExprMethod · 0.65

Tested by 2