Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Nightingale
提交
d590f6d5
N
Nightingale
项目概览
jobily
/
Nightingale
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
Nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d590f6d5
编写于
1月 08, 2022
作者:
U
Ulric Qin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enable_in_bg logic
上级
7b4eddc9
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
14 addition
and
6 deletion
+14
-6
docker/initsql/a-n9e.sql
docker/initsql/a-n9e.sql
+1
-0
src/models/alert_rule.go
src/models/alert_rule.go
+1
-0
src/server/engine/worker.go
src/server/engine/worker.go
+12
-6
未找到文件。
docker/initsql/a-n9e.sql
浏览文件 @
d590f6d5
...
...
@@ -207,6 +207,7 @@ CREATE TABLE `alert_rule` (
`enable_stime`
char
(
5
)
not
null
default
'00:00'
,
`enable_etime`
char
(
5
)
not
null
default
'23:59'
,
`enable_days_of_week`
varchar
(
32
)
not
null
default
''
comment
'split by space: 0 1 2 3 4 5 6'
,
`enable_in_bg`
tinyint
(
1
)
not
null
default
0
comment
'1: only this bg 0: global'
,
`notify_recovered`
tinyint
(
1
)
not
null
comment
'whether notify when recovery'
,
`notify_channels`
varchar
(
255
)
not
null
default
''
comment
'split by space: sms voice email dingtalk wecom'
,
`notify_groups`
varchar
(
255
)
not
null
default
''
comment
'split by space: 233 43'
,
...
...
src/models/alert_rule.go
浏览文件 @
d590f6d5
...
...
@@ -28,6 +28,7 @@ type AlertRule struct {
EnableEtime
string
`json:"enable_etime"`
// e.g. 23:59
EnableDaysOfWeek
string
`json:"-"`
// split by space: 0 1 2 3 4 5 6
EnableDaysOfWeekJSON
[]
string
`json:"enable_days_of_week" gorm:"-"`
// for fe
EnableInBG
int
`json:"enable_in_bg"`
// 0: global 1: enable one busi-group
NotifyRecovered
int
`json:"notify_recovered"`
// whether notify when recovery
NotifyChannels
string
`json:"-"`
// split by space: sms voice email dingtalk wecom
NotifyChannelsJSON
[]
string
`json:"notify_channels" gorm:"-"`
// for fe
...
...
src/server/engine/worker.go
浏览文件 @
d590f6d5
...
...
@@ -202,6 +202,12 @@ func (r RuleEval) judge(vectors []Vector) {
tagsMap
[
string
(
label
)]
=
string
(
value
)
}
// handle rule tags
for
_
,
tag
:=
range
r
.
rule
.
AppendTagsJSON
{
arr
:=
strings
.
SplitN
(
tag
,
"="
,
2
)
tagsMap
[
arr
[
0
]]
=
arr
[
1
]
}
// handle target note
targetIdent
,
has
:=
vectors
[
i
]
.
Labels
[
"ident"
]
targetNote
:=
""
...
...
@@ -209,13 +215,13 @@ func (r RuleEval) judge(vectors []Vector) {
target
,
exists
:=
memsto
.
TargetCache
.
Get
(
string
(
targetIdent
))
if
exists
{
targetNote
=
target
.
Note
// 对于包含ident的告警事件,check一下ident所属bg和rule所属bg是否相同
// 如果告警规则选择了只在本BG生效,那其他BG的机器就不能因此规则产生告警
if
r
.
rule
.
EnableInBG
==
1
&&
target
.
GroupId
!=
r
.
rule
.
GroupId
{
continue
}
}
// handle rule tags
for
_
,
tag
:=
range
r
.
rule
.
AppendTagsJSON
{
arr
:=
strings
.
SplitN
(
tag
,
"="
,
2
)
tagsMap
[
arr
[
0
]]
=
arr
[
1
]
}
event
:=
&
models
.
AlertCurEvent
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录