监控添加校验
Former-commit-id: 3f71c6c2bd75918aa275449f1c0779436c5670e6
This commit is contained in:
parent
c42afa719a
commit
277a1b3549
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||||
|
error2 "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/error"
|
||||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/tracker"
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/tracker"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -26,15 +27,20 @@ func NewControllerMetricsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
||||||
|
|
||||||
func (l *ControllerMetricsLogic) ControllerMetrics(req *types.ControllerMetricsReq) (resp *types.ControllerMetricsResp, err error) {
|
func (l *ControllerMetricsLogic) ControllerMetrics(req *types.ControllerMetricsReq) (resp *types.ControllerMetricsResp, err error) {
|
||||||
resp = &types.ControllerMetricsResp{}
|
resp = &types.ControllerMetricsResp{}
|
||||||
if len(req.Pod) != 0 {
|
if _, ok := l.svcCtx.PromClient[req.ParticipantId]; ok {
|
||||||
resp.Data = l.svcCtx.PromClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.PodOption{
|
if len(req.Pod) != 0 {
|
||||||
PodName: req.Pod,
|
resp.Data = l.svcCtx.PromClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.PodOption{
|
||||||
})
|
PodName: req.Pod,
|
||||||
} else {
|
})
|
||||||
|
} else {
|
||||||
|
|
||||||
resp.Data = l.svcCtx.PromClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.ControllerOption{
|
resp.Data = l.svcCtx.PromClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.ControllerOption{
|
||||||
WorkloadName: req.WorkloadName,
|
WorkloadName: req.WorkloadName,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, error2.NewCodeError(400, "prometheus endpoint invalid!")
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue