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