forked from JointCloud/pcm-coordinator
35 lines
755 B
Go
35 lines
755 B
Go
package monitoring
|
|
|
|
import (
|
|
"context"
|
|
"github.com/prometheus/alertmanager/api/v2/client/alert"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
|
)
|
|
|
|
type AlertRulesLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewAlertRulesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlertRulesLogic {
|
|
return &AlertRulesLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *AlertRulesLogic) AlertRules() error {
|
|
// todo: add your logic here and delete this line
|
|
alerts, err := l.svcCtx.AlertClient.Alert.GetAlerts(&alert.GetAlertsParams{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
println(alerts.Error())
|
|
return nil
|
|
return nil
|
|
}
|