feat: ingress metrics query apis

Signed-off-by: Roland.Ma <rolandma@yunify.com>
This commit is contained in:
Roland.Ma
2021-09-10 02:13:22 +00:00
parent b0506c35a4
commit 1ee5e49ac0
11 changed files with 228 additions and 0 deletions

View File

@@ -88,6 +88,8 @@ type reqParams struct {
applications string
openpitrixs string
cluster string
ingress string
job string
services string
pvcFilter string
queryType string
@@ -141,11 +143,15 @@ func parseRequestParams(req *restful.Request) reqParams {
r.workloadKind = req.PathParameter("kind")
r.nodeName = req.PathParameter("node")
r.workloadName = req.PathParameter("workload")
//will be overide if "pod" in the path parameter.
r.podName = req.QueryParameter("pod")
r.podName = req.PathParameter("pod")
r.containerName = req.PathParameter("container")
r.pvcName = req.PathParameter("pvc")
r.storageClassName = req.PathParameter("storageclass")
r.componentType = req.PathParameter("component")
r.ingress = req.PathParameter("ingress")
r.job = req.QueryParameter("job")
r.expression = req.QueryParameter("expr")
r.metric = req.QueryParameter("metric")
r.queryType = req.QueryParameter("type")
@@ -337,6 +343,26 @@ func (h handler) makeQueryOptions(r reqParams, lvl monitoring.Level) (q queryOpt
}
q.namedMetrics = model.PVCMetrics
case monitoring.LevelIngress:
q.identifier = model.IdentifierIngress
var step *time.Duration
// step param is reused in none Range Query to pass vector's time duration.
if r.time != "" {
s, err := time.ParseDuration(r.step)
if err == nil {
step = &s
}
}
q.option = monitoring.IngressOption{
ResourceFilter: r.resourceFilter,
NamespaceName: r.namespaceName,
Ingress: r.ingress,
Job: r.job,
Pod: r.podName,
Step: step,
}
q.namedMetrics = model.IngressMetrics
case monitoring.LevelComponent:
q.option = monitoring.ComponentOption{}
switch r.componentType {