MCPcopy Create free account
hub / github.com/prometheus/client_golang / QueryRange

Method QueryRange

api/prometheus/v1/api.go:1119–1146  ·  view source on GitHub ↗
(ctx context.Context, query string, r Range, opts ...Option)

Source from the content-addressed store, hash-verified

1117}
1118
1119func (h *httpAPI) QueryRange(ctx context.Context, query string, r Range, opts ...Option) (model.Value, Warnings, error) {
1120 u := h.client.URL(epQueryRange, nil)
1121 q := u.Query()
1122
1123 q.Set("query", query)
1124 q.Set("start", formatTime(r.Start))
1125 q.Set("end", formatTime(r.End))
1126 q.Set("step", strconv.FormatFloat(r.Step.Seconds(), 'f', -1, 64))
1127
1128 opt := &apiOptions{}
1129 for _, o := range opts {
1130 o(opt)
1131 }
1132
1133 d := opt.timeout
1134 if d > 0 {
1135 q.Set("timeout", d.String())
1136 }
1137
1138 _, body, warnings, err := h.client.DoGetFallback(ctx, u, q)
1139 if err != nil {
1140 return nil, warnings, err
1141 }
1142
1143 var qres queryResult
1144
1145 return qres.v, warnings, json.Unmarshal(body, &qres)
1146}
1147
1148func (h *httpAPI) Series(ctx context.Context, matches []string, startTime, endTime time.Time) ([]model.LabelSet, Warnings, error) {
1149 u := h.client.URL(epSeries, nil)

Callers 1

TestAPIsFunction · 0.95

Calls 6

formatTimeFunction · 0.85
URLMethod · 0.65
QueryMethod · 0.65
SetMethod · 0.65
DoGetFallbackMethod · 0.65
StringMethod · 0.45

Tested by 1

TestAPIsFunction · 0.76