mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Merge pull request #6793 from roidelapluie/stepinterval
promql: fix promql query log step unit
This commit is contained in:
commit
32c9670b7e
|
@ -105,7 +105,7 @@ func (p *queryLogTest) query(t *testing.T) {
|
||||||
switch p.origin {
|
switch p.origin {
|
||||||
case apiOrigin:
|
case apiOrigin:
|
||||||
r, err := http.Get(fmt.Sprintf(
|
r, err := http.Get(fmt.Sprintf(
|
||||||
"http://%s:%d%s/api/v1/query?query=%s",
|
"http://%s:%d%s/api/v1/query_range?step=5&start=0&end=3600&query=%s",
|
||||||
p.host,
|
p.host,
|
||||||
p.port,
|
p.port,
|
||||||
p.prefix,
|
p.prefix,
|
||||||
|
@ -148,7 +148,15 @@ func (p *queryLogTest) queryString() string {
|
||||||
func (p *queryLogTest) validateLastQuery(t *testing.T, ql []queryLogLine) {
|
func (p *queryLogTest) validateLastQuery(t *testing.T, ql []queryLogLine) {
|
||||||
q := ql[len(ql)-1]
|
q := ql[len(ql)-1]
|
||||||
testutil.Equals(t, p.queryString(), q.Params.Query)
|
testutil.Equals(t, p.queryString(), q.Params.Query)
|
||||||
testutil.Equals(t, 0, q.Params.Step)
|
|
||||||
|
switch p.origin {
|
||||||
|
case apiOrigin:
|
||||||
|
testutil.Equals(t, 5, q.Params.Step)
|
||||||
|
testutil.Equals(t, "1970-01-01T00:00:00.000Z", q.Params.Start)
|
||||||
|
testutil.Equals(t, "1970-01-01T01:00:00.000Z", q.Params.End)
|
||||||
|
default:
|
||||||
|
testutil.Equals(t, 0, q.Params.Step)
|
||||||
|
}
|
||||||
|
|
||||||
if p.origin != ruleOrigin {
|
if p.origin != ruleOrigin {
|
||||||
host := p.host
|
host := p.host
|
||||||
|
@ -160,7 +168,7 @@ func (p *queryLogTest) validateLastQuery(t *testing.T, ql []queryLogLine) {
|
||||||
|
|
||||||
switch p.origin {
|
switch p.origin {
|
||||||
case apiOrigin:
|
case apiOrigin:
|
||||||
testutil.Equals(t, p.prefix+"/api/v1/query", q.Request.Path)
|
testutil.Equals(t, p.prefix+"/api/v1/query_range", q.Request.Path)
|
||||||
case consoleOrigin:
|
case consoleOrigin:
|
||||||
testutil.Equals(t, p.prefix+"/consoles/test.html", q.Request.Path)
|
testutil.Equals(t, p.prefix+"/consoles/test.html", q.Request.Path)
|
||||||
case ruleOrigin:
|
case ruleOrigin:
|
||||||
|
@ -356,6 +364,8 @@ type queryLogLine struct {
|
||||||
Params struct {
|
Params struct {
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
Step int `json:"step"`
|
Step int `json:"step"`
|
||||||
|
Start string `json:"start"`
|
||||||
|
End string `json:"end"`
|
||||||
} `json:"params"`
|
} `json:"params"`
|
||||||
Request struct {
|
Request struct {
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
|
|
|
@ -437,7 +437,8 @@ func (ng *Engine) exec(ctx context.Context, q *query) (v Value, w storage.Warnin
|
||||||
if eq, ok := q.Statement().(*EvalStmt); ok {
|
if eq, ok := q.Statement().(*EvalStmt); ok {
|
||||||
params["start"] = formatDate(eq.Start)
|
params["start"] = formatDate(eq.Start)
|
||||||
params["end"] = formatDate(eq.End)
|
params["end"] = formatDate(eq.End)
|
||||||
params["step"] = eq.Interval
|
// The step provided by the user is in seconds.
|
||||||
|
params["step"] = int64(eq.Interval / (time.Second / time.Nanosecond))
|
||||||
}
|
}
|
||||||
f := []interface{}{"params", params}
|
f := []interface{}{"params", params}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue