未验证 提交 f9cfcaea 编写于 作者: qd_lm's avatar qd_lm 提交者: GitHub

告警hours支持 (#497)

Co-authored-by: Nalickliming <alickliming@didi.global.com>
上级 b9aacf28
...@@ -50,8 +50,24 @@ type AlertUpgrade struct { ...@@ -50,8 +50,24 @@ type AlertUpgrade struct {
func eventCurGets(c *gin.Context) { func eventCurGets(c *gin.Context) {
stime := mustQueryInt64(c, "stime") stime := queryInt64(c, "stime", 0)
etime := mustQueryInt64(c, "etime") 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", "") nodePath := queryStr(c, "nodepath", "")
limit := queryInt(c, "limit", 20) limit := queryInt(c, "limit", 20)
...@@ -144,8 +160,24 @@ func eventCurGets(c *gin.Context) { ...@@ -144,8 +160,24 @@ func eventCurGets(c *gin.Context) {
func eventHisGets(c *gin.Context) { func eventHisGets(c *gin.Context) {
stime := mustQueryInt64(c, "stime") stime := queryInt64(c, "stime", 0)
etime := mustQueryInt64(c, "etime") 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", "") nodePath := queryStr(c, "nodepath", "")
limit := queryInt(c, "limit", 20) limit := queryInt(c, "limit", 20)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册