diff --git a/api/prometheus/v1/api.go b/api/prometheus/v1/api.go index cddf027fd..aa49d4232 100644 --- a/api/prometheus/v1/api.go +++ b/api/prometheus/v1/api.go @@ -1079,6 +1079,7 @@ func (h *httpAPI) LabelValues(ctx context.Context, label string, matches []strin type apiOptions struct { timeout time.Duration limit uint64 + nocache bool } type Option func(c *apiOptions) @@ -1099,6 +1100,13 @@ func WithLimit(limit uint64) Option { } } +// WithNoCache can be used to provide an optional nocache parameter for Query and QueryRange. +func WithNoCache() Option { + return func(o *apiOptions) { + o.nocache = true + } +} + func addOptionalURLParams(q url.Values, opts []Option) url.Values { opt := &apiOptions{} for _, o := range opts { @@ -1113,6 +1121,10 @@ func addOptionalURLParams(q url.Values, opts []Option) url.Values { q.Set("limit", strconv.FormatUint(opt.limit, 10)) } + if opt.nocache { + q.Set("nocache", "1") + } + return q }