alert
Former-commit-id: b59e446af73f3fdbdfc9bcff0f7a6beaf6bac935
This commit is contained in:
parent
a46bd191d0
commit
2929b6e0f3
|
@ -33,6 +33,8 @@ type (
|
|||
Metrics string `form:"metrics"`
|
||||
}
|
||||
nodesLoadTopResp {
|
||||
code int `json:"code"`
|
||||
data interface{} `json:"data"`
|
||||
msg string `json:"msg"`
|
||||
}
|
||||
)
|
|
@ -1,6 +1,7 @@
|
|||
package monitoring
|
||||
|
||||
import (
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
|
@ -19,10 +20,6 @@ func NodesLoadTopHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
|
||||
l := monitoring.NewNodesLoadTopLogic(r.Context(), svcCtx)
|
||||
resp, err := l.NodesLoadTop(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ func NewAlertRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlertR
|
|||
|
||||
func (l *AlertRulesLogic) AlertRules() (resp *types.AlertRulesResp, err error) {
|
||||
resp = &types.AlertRulesResp{}
|
||||
l.svcCtx.DbEngin.Raw("SELECT ar.id,ar.*,GROUP_CONCAT(tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',') as cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id WHERE ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id;").Scan(&resp)
|
||||
var alertRules []types.AlertRule
|
||||
l.svcCtx.DbEngin.Raw("SELECT ar.id,ar.*,GROUP_CONCAT(tc.`name` ORDER BY tc.`name` ASC SEPARATOR ',') as cluster_name FROM alert_rule ar JOIN t_cluster tc ON ar.cluster_id = tc.id WHERE ar.deleted_at IS NULL AND tc.deleted_at IS NULL GROUP BY ar.id").Scan(&alertRules)
|
||||
resp.AlertRules = alertRules
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ func (l *NodesLoadTopLogic) NodesLoadTop(req *types.NodesLoadTopReq) (resp *type
|
|||
ForceContentType("application/json").
|
||||
Get(server + "/api/v1/monitoring/node")
|
||||
if err != nil || response.IsError() {
|
||||
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -5464,5 +5464,7 @@ type NodesLoadTopReq struct {
|
|||
}
|
||||
|
||||
type NodesLoadTopResp struct {
|
||||
Code int `json:"code"`
|
||||
Data interface{} `json:"data"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue