Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend: Expose query lookback delta #10489

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/frontend/querymiddleware/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ type MetricsQueryRequest interface {
// GetHints returns hints that could be optionally attached to the request to pass down the stack.
// These hints can be used to optimize the query execution.
GetHints() *Hints
// GetLookbackDelta returns the lookback delta for the request.
GetLookbackDelta() time.Duration
// WithID clones the current request with the provided ID.
WithID(id int64) (MetricsQueryRequest, error)
// WithStartEnd clone the current request with different start and end timestamp.
Expand Down
8 changes: 8 additions & 0 deletions pkg/frontend/querymiddleware/model_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ func (r *PrometheusRangeQueryRequest) GetHints() *Hints {
return r.hints
}

func (r *PrometheusRangeQueryRequest) GetLookbackDelta() time.Duration {
return r.lookbackDelta
}

// WithID clones the current `PrometheusRangeQueryRequest` with the provided ID.
func (r *PrometheusRangeQueryRequest) WithID(id int64) (MetricsQueryRequest, error) {
newRequest := *r
Expand Down Expand Up @@ -345,6 +349,10 @@ func (r *PrometheusInstantQueryRequest) GetHints() *Hints {
return r.hints
}

func (r *PrometheusInstantQueryRequest) GetLookbackDelta() time.Duration {
return r.lookbackDelta
}

func (r *PrometheusInstantQueryRequest) WithID(id int64) (MetricsQueryRequest, error) {
newRequest := *r
newRequest.headers = cloneHeaders(r.headers)
Expand Down
5 changes: 5 additions & 0 deletions pkg/frontend/querymiddleware/remote_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/http"
"net/url"
"strconv"
"time"

"github.com/golang/snappy"
"github.com/opentracing/opentracing-go"
Expand Down Expand Up @@ -285,6 +286,10 @@ func (r *remoteReadQueryRequest) GetHeaders() []*PrometheusHeader {
return nil
}

func (r *remoteReadQueryRequest) GetLookbackDelta() time.Duration {
return 0
}

func (r *remoteReadQueryRequest) WithID(_ int64) (MetricsQueryRequest, error) {
return nil, apierror.New(apierror.TypeInternal, "remoteReadQueryRequest.WithID not implemented")
}
Expand Down
Loading