Compare commits

...

4 Commits

Author SHA1 Message Date
Yening Qin
8ce021c458 refactor: event recovery notify (#2308) 2024-11-21 10:48:46 +08:00
Yening Qin
72d8ac9e30 fix proxy urls (#2298) 2024-11-15 16:54:57 +08:00
710leo
9173bf1668 fix: proxy api parse url 2024-11-13 23:11:57 +08:00
Yening Qin
d2ff106ac8 refactor: event notify (#2286) 2024-11-13 19:49:33 +08:00
3 changed files with 12 additions and 12 deletions

View File

@@ -141,6 +141,7 @@ func (e *Dispatch) HandleEventNotify(event *models.AlertCurEvent, isSubscribe bo
}
if e.blockEventNotify(rule, event) {
logger.Infof("block event notify: rule_id:%d event:%+v", rule.Id, event)
return
}
@@ -192,9 +193,10 @@ func (e *Dispatch) blockEventNotify(rule *models.AlertRule, event *models.AlertC
}
// 规则配置是否改变
if event.RuleHash != rule.Hash() {
return true
}
// TODO: 这里后面加一个配置项控制,先注释掉
// if event.RuleHash != rule.Hash() {
// return true
// }
return false
}

View File

@@ -12,7 +12,6 @@ import (
"github.com/ccfos/nightingale/v6/pkg/poster"
"github.com/pkg/errors"
"github.com/toolkits/pkg/logger"
"github.com/toolkits/pkg/net/httplib"
"github.com/toolkits/pkg/str"
)
@@ -104,14 +103,13 @@ func (h HTTP) NewReq(reqUrl *string) (req *http.Request, err error) {
func (h HTTP) ParseUrl() (target *url.URL, err error) {
urls := h.GetUrls()
for i := 0; i < len(urls); i++ {
if target, err = url.Parse(urls[i]); err != nil {
continue
}
if len(urls) == 0 {
return nil, errors.New("no urls")
}
if _, err = httplib.Get(urls[i]).SetTimeout(time.Duration(h.Timeout) * time.Millisecond).Response(); err == nil {
return
}
target, err = url.Parse(urls[0])
if err != nil {
return nil, err
}
return
}

View File

@@ -585,9 +585,9 @@ func CanMigrateBg(ctx *ctx.Context) bool {
}
if maxGroupId == 0 {
log.Println("migration bgid has been completed.")
return false
}
return true
}