-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Prometheus HTTP API allows to pass timeout parameter for queries: https://prometheus.io/docs/prometheus/latest/querying/api/#instant-queries but API doesn't allow to pass it.
One easy way would be to add a new parameter to Query and QueryRange but that would be incompatible.
Another way could to to check if passed context has a deadline and set a timeout smaller than that deadline, like:
func (h *httpAPI) Query(ctx context.Context, query string, ts time.Time) (model.Value, Warnings, error) {
u := h.client.URL(epQuery, nil)
q := u.Query()
q.Set("query", query)
if !ts.IsZero() {
q.Set("time", formatTime(ts))
}
if deadline, ok := ctx.Deadline(); ok {
q.Set("timeout", fmt.Sprintf("%ds", int(time.Until(deadline).Truncate(time.Millisecond*500).Seconds())))
}
[...]
but smaller by what duration? So one way or another extra information is needed I think.