|
|
|
|
@ -171,8 +171,8 @@ func (api *API) Register(r *route.Router) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type queryData struct { |
|
|
|
|
ResultType promql.ValueType `json:"resultType"` |
|
|
|
|
Result promql.Value `json:"result"` |
|
|
|
|
ResultType promql.ValueType `json:"resultType"` |
|
|
|
|
Result promql.Value `json:"result"` |
|
|
|
|
Stats *stats.QueryStats `json:"stats,omitempty"` |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -221,9 +221,17 @@ func (api *API) query(r *http.Request) (interface{}, *apiError) { |
|
|
|
|
} |
|
|
|
|
return nil, &apiError{errorExec, res.Err} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Optional stats field in response if parameter "stats" is not empty.
|
|
|
|
|
var qs *stats.QueryStats |
|
|
|
|
if r.FormValue("stats") != "" { |
|
|
|
|
qs = stats.NewQueryStats(qry.Stats()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return &queryData{ |
|
|
|
|
ResultType: res.Value.Type(), |
|
|
|
|
Result: res.Value, |
|
|
|
|
Stats: qs, |
|
|
|
|
}, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -289,7 +297,7 @@ func (api *API) queryRange(r *http.Request) (interface{}, *apiError) { |
|
|
|
|
// Optional stats field in response if parameter "stats" is not empty.
|
|
|
|
|
var qs *stats.QueryStats |
|
|
|
|
if r.FormValue("stats") != "" { |
|
|
|
|
qs = stats.MakeQueryStats(qry.Stats()) |
|
|
|
|
qs = stats.NewQueryStats(qry.Stats()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return &queryData{ |
|
|
|
|
|