mirror of
https://gitee.com/winc-link/hummingbird.git
synced 2025-04-20 08:22:42 +00:00
Merge pull request #1 from suixinio/master
FIX: EkuiperAlert api alert bug.
This commit is contained in:
commit
d2365ecef9
16
.gitignore
vendored
16
.gitignore
vendored
@ -1,9 +1,15 @@
|
|||||||
|
## IDE
|
||||||
.idea
|
.idea
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
## golang
|
||||||
vendor
|
vendor
|
||||||
logs
|
logs
|
||||||
go.sum
|
go.sum
|
||||||
manifest
|
|
||||||
cmd/.DS_Store
|
## MacOS
|
||||||
cmd/hummingbird-ui/.DS_Store
|
.DS_Store
|
||||||
hummingbird
|
|
||||||
mqtt-broker
|
## binary
|
||||||
|
cmd/hummingbird-core/hummingbird-core
|
||||||
|
cmd/mqtt-broker/mqtt-broker
|
1
go.mod
1
go.mod
@ -4,7 +4,6 @@ go 1.18
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v1.1.0
|
github.com/BurntSushi/toml v1.1.0
|
||||||
github.com/alexmullins/zip v0.0.0-20180717182244-4affb64b04d0
|
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||||
github.com/docker/distribution v2.8.1+incompatible
|
github.com/docker/distribution v2.8.1+incompatible
|
||||||
github.com/docker/docker v20.10.17+incompatible
|
github.com/docker/docker v20.10.17+incompatible
|
||||||
|
@ -800,36 +800,25 @@ func (p alertApp) AddAlert(ctx context.Context, req map[string]interface{}) erro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if alertRule.SilenceTime > 0 {
|
||||||
|
alertSend, err := p.dbClient.AlertListLastSend(alertRule.Id)
|
||||||
|
if err != nil {
|
||||||
|
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
// 处理不是记录未找到的情况
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if alertSend.Created+alertRule.SilenceTime > utils.MakeTimestamp() {
|
||||||
|
// 在静默期内,不发送
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var alertList models.AlertList
|
var alertList models.AlertList
|
||||||
alertList.AlertRuleId = alertRule.Id
|
alertList.AlertRuleId = alertRule.Id
|
||||||
alertList.AlertResult = alertResult
|
alertList.AlertResult = alertResult
|
||||||
alertList.TriggerTime = time.Now().UnixMilli()
|
alertList.TriggerTime = time.Now().UnixMilli()
|
||||||
|
|
||||||
send := false
|
|
||||||
if alertRule.SilenceTime > 0 {
|
|
||||||
alertSend, err := p.dbClient.AlertListLastSend(alertRule.Id)
|
|
||||||
if err != nil {
|
|
||||||
if err == gorm.ErrRecordNotFound {
|
|
||||||
send = true
|
|
||||||
goto Jump
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if alertSend.Created+alertRule.SilenceTime <= utils.MakeTimestamp() {
|
|
||||||
send = true
|
|
||||||
goto Jump
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Jump:
|
|
||||||
if send == false {
|
|
||||||
alertList.IsSend = false
|
|
||||||
_, err = p.dbClient.AddAlertList(alertList)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
alertList.IsSend = true
|
alertList.IsSend = true
|
||||||
alertList.Status = constants.Untreated
|
alertList.Status = constants.Untreated
|
||||||
|
|
||||||
|
BIN
internal/pkg/packets/.DS_Store
vendored
BIN
internal/pkg/packets/.DS_Store
vendored
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user