Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
nightingale
提交
19c2fb6f
N
nightingale
项目概览
DiDi
/
nightingale
9 个月 前同步成功
通知
45
Star
7053
Fork
1161
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
19c2fb6f
编写于
9月 04, 2021
作者:
U
UlricQin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove processor logic
上级
882a9756
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
36 deletion
+34
-36
http/router.go
http/router.go
+1
-1
http/router_alert_event.go
http/router_alert_event.go
+7
-7
models/alert_event.go
models/alert_event.go
+26
-26
sql/n9e.sql
sql/n9e.sql
+0
-2
未找到文件。
http/router.go
浏览文件 @
19c2fb6f
...
...
@@ -158,7 +158,7 @@ func configRoutes(r *gin.Engine) {
pages
.
DELETE
(
"/alert-events"
,
login
(),
alertEventsDel
)
pages
.
GET
(
"/alert-event/:id"
,
login
(),
alertEventGet
)
pages
.
DELETE
(
"/alert-event/:id"
,
login
(),
alertEventDel
)
pages
.
PUT
(
"/alert-event/:id"
,
login
(),
alertEventNotePut
)
//
pages.PUT("/alert-event/:id", login(), alertEventNotePut)
pages
.
GET
(
"/history-alert-events"
,
login
(),
historyAlertEventGets
)
pages
.
GET
(
"/history-alert-event/:id"
,
login
(),
historyAlertEventGet
)
...
...
http/router_alert_event.go
浏览文件 @
19c2fb6f
...
...
@@ -58,15 +58,15 @@ type alertEventNoteForm struct {
EventNote
string
`json:"event_note"`
}
func
alertEventNotePut
(
c
*
gin
.
Context
)
{
var
f
alertEventNoteForm
bind
(
c
,
&
f
)
//
func alertEventNotePut(c *gin.Context) {
//
var f alertEventNoteForm
//
bind(c, &f)
me
:=
loginUser
(
c
)
.
MustPerm
(
"alert_event_modify"
)
ae
:=
AlertEvent
(
urlParamInt64
(
c
,
"id"
))
//
me := loginUser(c).MustPerm("alert_event_modify")
//
ae := AlertEvent(urlParamInt64(c, "id"))
renderMessage
(
c
,
models
.
AlertEventUpdateEventNote
(
ae
.
Id
,
ae
.
HashId
,
f
.
EventNote
,
me
.
Id
))
}
//
renderMessage(c, models.AlertEventUpdateEventNote(ae.Id, ae.HashId, f.EventNote, me.Id))
//
}
func
alertEventDel
(
c
*
gin
.
Context
)
{
loginUser
(
c
)
.
MustPerm
(
"alert_event_delete"
)
...
...
models/alert_event.go
浏览文件 @
19c2fb6f
...
...
@@ -17,9 +17,9 @@ type AlertEvent struct {
RuleId
int64
`json:"rule_id"`
RuleName
string
`json:"rule_name"`
RuleNote
string
`json:"rule_note"`
ProcessorUid
int64
`json:"processor_uid"`
ProcessorObj
User
`json:"processor_user_obj" xorm:"-"`
EventNote
string
`json:"event_note"`
//
ProcessorUid int64 `json:"processor_uid"`
//
ProcessorObj User `json:"processor_user_obj" xorm:"-"`
//
EventNote string `json:"event_note"`
HashId
string
`json:"hash_id"`
// 唯一标识
IsPromePull
int
`json:"is_prome_pull"`
// 代表是否是prometheus pull告警,为1时前端使用 ReadableExpression 拉取最近1小时数据
LastSend
bool
`json:"last_sent" xorm:"-"`
// true 代表上次发了,false代表还没发:给prometheus做for判断的
...
...
@@ -117,13 +117,13 @@ func (ae *AlertEvent) FillObjs() error {
ae
.
NotifyUserObjs
=
users
}
if
ae
.
ProcessorUid
!=
0
{
processor
,
err
:=
UserGetById
(
ae
.
ProcessorUid
)
if
err
!=
nil
{
return
err
}
ae
.
ProcessorObj
=
*
processor
}
//
if ae.ProcessorUid != 0 {
//
processor, err := UserGetById(ae.ProcessorUid)
//
if err != nil {
//
return err
//
}
//
ae.ProcessorObj = *processor
//
}
return
nil
}
...
...
@@ -269,23 +269,23 @@ func AlertEventGet(where string, args ...interface{}) (*AlertEvent, error) {
return
&
obj
,
nil
}
func
AlertEventUpdateEventNote
(
id
int64
,
hashId
string
,
note
string
,
uid
int64
)
error
{
session
:=
DB
.
NewSession
()
defer
session
.
Close
()
//
func AlertEventUpdateEventNote(id int64, hashId string, note string, uid int64) error {
//
session := DB.NewSession()
//
defer session.Close()
if
err
:=
session
.
Begin
();
err
!=
nil
{
return
err
}
//
if err := session.Begin(); err != nil {
//
return err
//
}
if
_
,
err
:=
session
.
Exec
(
"UPDATE alert_event SET event_note = ?, processor_uid = ? WHERE id = ?"
,
note
,
uid
,
id
);
err
!=
nil
{
logger
.
Errorf
(
"mysql.error: update alert_event event_note fail: %v"
,
err
)
return
err
}
//
if _, err := session.Exec("UPDATE alert_event SET event_note = ?, processor_uid = ? WHERE id = ?", note, uid, id); err != nil {
//
logger.Errorf("mysql.error: update alert_event event_note fail: %v", err)
//
return err
//
}
if
_
,
err
:=
session
.
Exec
(
"UPDATE history_alert_event SET event_note = ?, processor_uid = ? WHERE hash_id = ? ORDER BY id DESC LIMIT 1"
,
note
,
uid
,
hashId
);
err
!=
nil
{
logger
.
Errorf
(
"mysql.error: update history_alert_event event_note fail: %v"
,
err
)
return
err
}
//
if _, err := session.Exec("UPDATE history_alert_event SET event_note = ?, processor_uid = ? WHERE hash_id = ? ORDER BY id DESC LIMIT 1", note, uid, hashId); err != nil {
//
logger.Errorf("mysql.error: update history_alert_event event_note fail: %v", err)
//
return err
//
}
return
session
.
Commit
()
}
//
return session.Commit()
//
}
sql/n9e.sql
浏览文件 @
19c2fb6f
...
...
@@ -297,8 +297,6 @@ CREATE TABLE `alert_event` (
`rule_id`
bigint
unsigned
not
null
,
`rule_name`
varchar
(
255
)
not
null
,
`rule_note`
varchar
(
512
)
not
null
default
'alert rule note'
,
`processor_uid`
bigint
NOT
NULL
default
0
,
`event_note`
varchar
(
512
)
not
null
default
'alert event note'
,
`res_classpaths`
varchar
(
1024
)
not
null
default
''
comment
'belong classpaths'
,
`priority`
tinyint
(
1
)
not
null
,
`status`
tinyint
(
1
)
not
null
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录