add start/end parameter for LabelValues
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
This commit is contained in:
parent
6ce5f2ca8a
commit
3defbd9c7c
|
@ -234,7 +234,7 @@ type API interface {
|
|||
// LabelNames returns all the unique label names present in the block in sorted order.
|
||||
LabelNames(ctx context.Context, startTime time.Time, endTime time.Time) ([]string, Warnings, error)
|
||||
// LabelValues performs a query for the values of the given label.
|
||||
LabelValues(ctx context.Context, label string) (model.LabelValues, Warnings, error)
|
||||
LabelValues(ctx context.Context, label string, startTime time.Time, endTime time.Time) (model.LabelValues, Warnings, error)
|
||||
// Query performs a query for the given time.
|
||||
Query(ctx context.Context, query string, ts time.Time) (model.Value, Warnings, error)
|
||||
// QueryRange performs a query for the given range.
|
||||
|
@ -694,8 +694,12 @@ func (h *httpAPI) LabelNames(ctx context.Context, startTime time.Time, endTime t
|
|||
return labelNames, w, json.Unmarshal(body, &labelNames)
|
||||
}
|
||||
|
||||
func (h *httpAPI) LabelValues(ctx context.Context, label string) (model.LabelValues, Warnings, error) {
|
||||
func (h *httpAPI) LabelValues(ctx context.Context, label string, startTime time.Time, endTime time.Time) (model.LabelValues, Warnings, error) {
|
||||
u := h.client.URL(epLabelValues, map[string]string{"name": label})
|
||||
q := u.Query()
|
||||
q.Set("start", formatTime(startTime))
|
||||
q.Set("end", formatTime(endTime))
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, u.String(), nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
|
|
|
@ -159,7 +159,7 @@ func TestAPIs(t *testing.T) {
|
|||
|
||||
doLabelValues := func(label string) func() (interface{}, Warnings, error) {
|
||||
return func() (interface{}, Warnings, error) {
|
||||
return promAPI.LabelValues(context.Background(), label)
|
||||
return promAPI.LabelValues(context.Background(), label, time.Now().Add(-100*time.Hour), time.Now())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue