MCPcopy
hub / github.com/prometheus/client_golang / Query

Method Query

api/prometheus/v1/api.go:1155–1171  ·  view source on GitHub ↗
(ctx context.Context, query string, ts time.Time, opts ...Option)

Source from the content-addressed store, hash-verified

1153}
1154
1155func (h *httpAPI) Query(ctx context.Context, query string, ts time.Time, opts ...Option) (model.Value, Warnings, error) {
1156 u := h.client.URL(epQuery, nil)
1157 q := addOptionalURLParams(u.Query(), opts)
1158
1159 q.Set("query", query)
1160 if !ts.IsZero() {
1161 q.Set("time", formatTime(ts))
1162 }
1163
1164 _, body, warnings, err := h.client.DoGetFallback(ctx, u, q)
1165 if err != nil {
1166 return nil, warnings, err
1167 }
1168
1169 var qres queryResult
1170 return qres.v, warnings, json.Unmarshal(body, &qres)
1171}
1172
1173func (h *httpAPI) QueryRange(ctx context.Context, query string, r Range, opts ...Option) (model.Value, Warnings, error) {
1174 u := h.client.URL(epQueryRange, nil)

Callers 1

TestAPIsFunction · 0.95

Calls 6

addOptionalURLParamsFunction · 0.85
formatTimeFunction · 0.85
URLMethod · 0.65
QueryMethod · 0.65
SetMethod · 0.65
DoGetFallbackMethod · 0.65

Tested by 1

TestAPIsFunction · 0.76