You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

controllermetricslogic.go 1.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package cloud
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
  6. error2 "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/error"
  7. "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker"
  8. "time"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type ControllerMetricsLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewControllerMetricsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ControllerMetricsLogic {
  17. return &ControllerMetricsLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *ControllerMetricsLogic) ControllerMetrics(req *types.ControllerMetricsReq) (resp *types.ControllerMetricsResp, err error) {
  24. resp = &types.ControllerMetricsResp{}
  25. if _, ok := l.svcCtx.MonitorClient[req.ParticipantId]; ok {
  26. if len(req.Pod) != 0 {
  27. resp.Data = l.svcCtx.MonitorClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.PodOption{
  28. PodName: req.Pod,
  29. })
  30. } else {
  31. resp.Data = l.svcCtx.MonitorClient[req.ParticipantId].GetNamedMetricsByTime(req.Metrics, req.Start, req.End, 60*time.Minute, tracker.ControllerOption{
  32. WorkloadName: req.WorkloadName,
  33. })
  34. }
  35. } else {
  36. return nil, error2.NewCodeError(400, "prometheus endpoint invalid!")
  37. }
  38. return resp, nil
  39. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.