告警hours支持 (#497)

Co-authored-by: alickliming <alickliming@didi.global.com>
This commit is contained in:
alick-liming 2021-01-11 11:42:28 +08:00 committed by GitHub
parent b9aacf28e5
commit f9cfcaeabe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 4 deletions

View File

@ -50,8 +50,24 @@ type AlertUpgrade struct {
func eventCurGets(c *gin.Context) {
stime := mustQueryInt64(c, "stime")
etime := mustQueryInt64(c, "etime")
stime := queryInt64(c, "stime", 0)
etime := queryInt64(c, "etime", 0)
hours := queryInt64(c, "hours", 0)
now := time.Now().Unix()
if hours != 0 {
stime = now - 3600*hours
etime = now + 3600*24
}
if stime != 0 && etime == 0 {
etime = now + 3600*24
}
if stime == 0 && hours == 0 {
dangerous(fmt.Errorf("stime and hours is nil"))
}
nodePath := queryStr(c, "nodepath", "")
limit := queryInt(c, "limit", 20)
@ -144,8 +160,24 @@ func eventCurGets(c *gin.Context) {
func eventHisGets(c *gin.Context) {
stime := mustQueryInt64(c, "stime")
etime := mustQueryInt64(c, "etime")
stime := queryInt64(c, "stime", 0)
etime := queryInt64(c, "etime", 0)
hours := queryInt64(c, "hours", 0)
now := time.Now().Unix()
if hours != 0 {
stime = now - 3600*hours
etime = now + 3600*24
}
if stime != 0 && etime == 0 {
etime = now + 3600*24
}
if stime == 0 && hours == 0 {
dangerous(fmt.Errorf("stime and hours is nil"))
}
nodePath := queryStr(c, "nodepath", "")
limit := queryInt(c, "limit", 20)