fix bug for node metrics on overview page

Signed-off-by: zhu733756 <talonzhu@yunify.com>
This commit is contained in:
zhu733756
2021-04-12 13:49:38 +08:00
parent 26e5c31d8f
commit f49a9c1620
4 changed files with 17 additions and 3 deletions

View File

@@ -90,6 +90,7 @@ type reqParams struct {
cluster string
services string
pvcFilter string
queryType string
}
type queryOptions struct {
@@ -145,6 +146,7 @@ func parseRequestParams(req *restful.Request) reqParams {
r.componentType = req.PathParameter("component")
r.expression = req.QueryParameter("expr")
r.metric = req.QueryParameter("metric")
r.queryType = req.QueryParameter("type")
return r
}
@@ -213,6 +215,7 @@ func (h handler) makeQueryOptions(r reqParams, lvl monitoring.Level) (q queryOpt
NodeName: r.nodeName,
PVCFilter: r.pvcFilter, // metering pvc
StorageClassName: r.storageClassName, // metering pvc
QueryType: r.queryType,
}
q.namedMetrics = model.NodeMetrics

View File

@@ -80,6 +80,7 @@ func AddToContainer(c *restful.Container, k8sClient kubernetes.Interface, monito
Param(ws.QueryParameter("sort_type", "Sort order. One of asc, desc.").DefaultValue("desc.").DataType("string").Required(false)).
Param(ws.QueryParameter("page", "The page number. This field paginates result data of each metric, then returns a specific page. For example, setting **page** to 2 returns the second page. It only applies to sorted metric data.").DataType("integer").Required(false)).
Param(ws.QueryParameter("limit", "Page size, the maximum number of results in a single page. Defaults to 5.").DataType("integer").Required(false).DefaultValue("5")).
Param(ws.QueryParameter("type", "The query type. This field can be set to 'rank' for node ranking query or '' for others. Defaults to ''.").DataType("string").Required(false).DefaultValue("")).
Metadata(restfulspec.KeyOpenAPITags, []string{constants.NodeMetricsTag}).
Writes(model.Metrics{}).
Returns(http.StatusOK, respOK, model.Metrics{})).