diff --git a/template/template_test.go b/template/template_test.go index 08b902410..647cb5389 100644 --- a/template/template_test.go +++ b/template/template_test.go @@ -18,6 +18,7 @@ import ( "testing" "github.com/prometheus/common/model" + "github.com/stretchr/testify/require" "golang.org/x/net/context" "github.com/prometheus/prometheus/pkg/labels" @@ -209,8 +210,13 @@ func TestTemplateExpansion(t *testing.T) { t.Fatalf("get appender: %s", err) } - app.Add(labels.FromStrings(labels.MetricName, "metric", "instance", "a"), 0, 11) - app.Add(labels.FromStrings(labels.MetricName, "metric", "instance", "b"), 0, 21) + aref, err := app.SetSeries(labels.FromStrings(labels.MetricName, "metric", "instance", "a")) + require.NoError(t, err) + bref, err := app.SetSeries(labels.FromStrings(labels.MetricName, "metric", "instance", "b")) + require.NoError(t, err) + + app.Add(aref, 0, 11) + app.Add(bref, 0, 21) if err := app.Commit(); err != nil { t.Fatalf("commit samples: %s", err) diff --git a/web/api/v1/api.go b/web/api/v1/api.go index de5610b4b..de3eeb58d 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -258,6 +258,11 @@ func (api *API) labelValues(r *http.Request) (interface{}, *apiError) { return vals, nil } +var ( + minTime = time.Unix(math.MinInt64/1000+62135596801, 0) + maxTime = time.Unix(math.MaxInt64/1000-62135596801, 999999999) +) + func (api *API) series(r *http.Request) (interface{}, *apiError) { r.ParseForm() if len(r.Form["match[]"]) == 0 { @@ -272,7 +277,7 @@ func (api *API) series(r *http.Request) (interface{}, *apiError) { return nil, &apiError{errorBadData, err} } } else { - start = time.Unix(math.MinInt64, 0) + start = minTime } var end time.Time @@ -283,8 +288,9 @@ func (api *API) series(r *http.Request) (interface{}, *apiError) { return nil, &apiError{errorBadData, err} } } else { - end = time.Unix(math.MaxInt64, 0) + end = maxTime } + fmt.Println("q range", timestamp.FromTime(start), timestamp.FromTime(end), r.FormValue("start"), r.FormValue("end")) var matcherSets [][]*labels.Matcher for _, s := range r.Form["match[]"] { diff --git a/web/api/v1/api_test.go b/web/api/v1/api_test.go index 86fb5ab28..490f649d2 100644 --- a/web/api/v1/api_test.go +++ b/web/api/v1/api_test.go @@ -429,6 +429,7 @@ func TestEndpoints(t *testing.T) { api.context = func(r *http.Request) context.Context { return ctx } + t.Logf("run query %q", test.query.Encode()) req, err := http.NewRequest("ANY", fmt.Sprintf("http://example.com?%s", test.query.Encode()), nil) if err != nil {