func()

in pkg/admin/services/prometheus_service_impl.go [76:120]


func (p *PrometheusServiceImpl) ClusterMetrics() (model.ClusterMetricsRes, error) {
	res := model.ClusterMetricsRes{
		Data: make(map[string]int),
	}
	// total application number
	applications, err := providerService.FindApplications()
	appNum := 0
	if err != nil {
		logger.Sugar().Errorf("Error find applications: %v\n", err)
	} else {
		appNum = applications.Size()
	}
	res.Data["application"] = appNum

	// total service number
	services, err := providerService.FindServices()
	svc := 0
	if err != nil {
		logger.Sugar().Errorf("Error find services: %v\n", err)
	} else {
		svc = services.Size()
	}
	res.Data["services"] = svc

	providers, err := providerService.FindService(constant.IP, constant.AnyValue)
	pro := 0
	if err != nil {
		logger.Sugar().Errorf("Error find providers: %v\n", err)
	} else {
		pro = len(providers)
	}
	res.Data["providers"] = pro

	consumers, err := consumerService.FindAll()
	con := 0
	if err != nil {
		logger.Sugar().Errorf("Error find consumers: %v\n", err)
	} else {
		con = len(consumers)
	}
	res.Data["consumers"] = con

	res.Data["all"] = con
	return res, nil
}