diff --git a/pkg/api/query/v1.go b/pkg/api/query/v1.go index e186057208..b27031e6e3 100644 --- a/pkg/api/query/v1.go +++ b/pkg/api/query/v1.go @@ -247,6 +247,7 @@ func (qapi *QueryAPI) parseStep(r *http.Request, defaultRangeQueryStep time.Dura if err != nil { return 0, &api.ApiError{Typ: api.ErrorBadData, Err: errors.Wrapf(err, "'%s' parameter", Step)} } + return defaultRangeQueryStep, nil } // Default step is used this way to make it consistent with UI. diff --git a/pkg/api/query/v1_test.go b/pkg/api/query/v1_test.go index f87deff16b..f93f6b2b17 100644 --- a/pkg/api/query/v1_test.go +++ b/pkg/api/query/v1_test.go @@ -465,18 +465,20 @@ func TestQueryEndpoints(t *testing.T) { query: url.Values{ "query": []string{"time()"}, "start": []string{"0"}, - "end": []string{"2"}, + "end": []string{"500"}, "step": []string{"1"}, }, response: &queryData{ ResultType: parser.ValueTypeMatrix, Result: promql.Matrix{ promql.Series{ - Points: []promql.Point{ - {V: 0, T: timestamp.FromTime(start)}, - {V: 1, T: timestamp.FromTime(start.Add(1 * time.Second))}, - {V: 2, T: timestamp.FromTime(start.Add(2 * time.Second))}, - }, + Points: func(end, step float64) []promql.Point { + var res []promql.Point + for v := float64(0); v <= end; v += step { + res = append(res, promql.Point{V: v, T: timestamp.FromTime(start.Add(time.Duration(v) * time.Second))}) + } + return res + }(500, 1), Metric: nil, }, }, diff --git a/pkg/ui/static/js/graph.js b/pkg/ui/static/js/graph.js index 6ba577a6c1..30d1fcaf46 100644 --- a/pkg/ui/static/js/graph.js +++ b/pkg/ui/static/js/graph.js @@ -309,7 +309,7 @@ Prometheus.Graph.prototype.setDefaultStep = function(el) { self.showError("Error querying flags."); return; } - el.defaultStep = (json.data && "query.default-stp" in json.data) ? json.data["query.default-stp"] : "1s" + el.defaultStep = (json.data && "query.default-step" in json.data) ? json.data["query.default-step"] : "1s" }, error: function() {