Merge branch 'main' of github.com:ccfos/nightingale
This commit is contained in:
commit
34082b44f1
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
NOW = $(shell date -u '+%Y%m%d%I%M%S')
|
NOW = $(shell date -u '+%Y%m%d%I%M%S')
|
||||||
|
|
||||||
RELEASE_VERSION = 5.9.3
|
RELEASE_VERSION = 5.9.4
|
||||||
|
|
||||||
APP = n9e
|
APP = n9e
|
||||||
SERVER_BIN = $(APP)
|
SERVER_BIN = $(APP)
|
||||||
|
|
|
@ -79,7 +79,7 @@ services:
|
||||||
sh -c "/wait && /app/ibex server"
|
sh -c "/wait && /app/ibex server"
|
||||||
|
|
||||||
nwebapi:
|
nwebapi:
|
||||||
image: ulric2019/nightingale:5.9.3
|
image: ulric2019/nightingale:5.9.4
|
||||||
container_name: nwebapi
|
container_name: nwebapi
|
||||||
hostname: nwebapi
|
hostname: nwebapi
|
||||||
restart: always
|
restart: always
|
||||||
|
@ -107,7 +107,7 @@ services:
|
||||||
sh -c "/wait && /app/n9e webapi"
|
sh -c "/wait && /app/n9e webapi"
|
||||||
|
|
||||||
nserver:
|
nserver:
|
||||||
image: ulric2019/nightingale:5.9.3
|
image: ulric2019/nightingale:5.9.4
|
||||||
container_name: nserver
|
container_name: nserver
|
||||||
hostname: nserver
|
hostname: nserver
|
||||||
restart: always
|
restart: always
|
||||||
|
|
|
@ -377,6 +377,7 @@ CREATE TABLE `alert_cur_event` (
|
||||||
`notify_channels` varchar(255) not null default '' comment 'split by space: sms voice email dingtalk wecom',
|
`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',
|
`notify_groups` varchar(255) not null default '' comment 'split by space: 233 43',
|
||||||
`notify_repeat_next` bigint not null default 0 comment 'next timestamp to notify, get repeat settings from rule',
|
`notify_repeat_next` bigint not null default 0 comment 'next timestamp to notify, get repeat settings from rule',
|
||||||
|
`notify_cur_number` int not null default 0 comment '',
|
||||||
`target_ident` varchar(191) not null default '' comment 'target ident, also in tags',
|
`target_ident` varchar(191) not null default '' comment 'target ident, also in tags',
|
||||||
`target_note` varchar(191) not null default '' comment 'target note',
|
`target_note` varchar(191) not null default '' comment 'target note',
|
||||||
`trigger_time` bigint not null,
|
`trigger_time` bigint not null,
|
||||||
|
@ -410,6 +411,7 @@ CREATE TABLE `alert_his_event` (
|
||||||
`notify_recovered` tinyint(1) not null comment 'whether notify when recovery',
|
`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_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',
|
`notify_groups` varchar(255) not null default '' comment 'split by space: 233 43',
|
||||||
|
`notify_cur_number` int not null default 0 comment '',
|
||||||
`target_ident` varchar(191) not null default '' comment 'target ident, also in tags',
|
`target_ident` varchar(191) not null default '' comment 'target ident, also in tags',
|
||||||
`target_note` varchar(191) not null default '' comment 'target note',
|
`target_note` varchar(191) not null default '' comment 'target note',
|
||||||
`trigger_time` bigint not null,
|
`trigger_time` bigint not null,
|
||||||
|
|
|
@ -404,6 +404,7 @@ CREATE TABLE alert_cur_event (
|
||||||
notify_channels varchar(255) NOT NULL DEFAULT ''::character varying,
|
notify_channels varchar(255) NOT NULL DEFAULT ''::character varying,
|
||||||
notify_groups varchar(255) NOT NULL DEFAULT ''::character varying,
|
notify_groups varchar(255) NOT NULL DEFAULT ''::character varying,
|
||||||
notify_repeat_next int8 NOT NULL DEFAULT 0,
|
notify_repeat_next int8 NOT NULL DEFAULT 0,
|
||||||
|
notify_cur_number int4 not null default 0,
|
||||||
target_ident varchar(191) NOT NULL DEFAULT ''::character varying,
|
target_ident varchar(191) NOT NULL DEFAULT ''::character varying,
|
||||||
target_note varchar(191) NOT NULL DEFAULT ''::character varying,
|
target_note varchar(191) NOT NULL DEFAULT ''::character varying,
|
||||||
trigger_time int8 NOT NULL,
|
trigger_time int8 NOT NULL,
|
||||||
|
@ -454,6 +455,7 @@ CREATE TABLE alert_his_event (
|
||||||
notify_recovered int2 NOT NULL,
|
notify_recovered int2 NOT NULL,
|
||||||
notify_channels varchar(255) NOT NULL DEFAULT ''::character varying,
|
notify_channels varchar(255) NOT NULL DEFAULT ''::character varying,
|
||||||
notify_groups varchar(255) NOT NULL DEFAULT ''::character varying,
|
notify_groups varchar(255) NOT NULL DEFAULT ''::character varying,
|
||||||
|
notify_cur_number int4 not null default 0,
|
||||||
target_ident varchar(191) NOT NULL DEFAULT ''::character varying,
|
target_ident varchar(191) NOT NULL DEFAULT ''::character varying,
|
||||||
target_note varchar(191) NOT NULL DEFAULT ''::character varying,
|
target_note varchar(191) NOT NULL DEFAULT ''::character varying,
|
||||||
trigger_time int8 NOT NULL,
|
trigger_time int8 NOT NULL,
|
||||||
|
|
|
@ -45,7 +45,7 @@ type AlertCurEvent struct {
|
||||||
NotifyUsersObj []*User `json:"notify_users_obj" gorm:"-"` // for notify.py
|
NotifyUsersObj []*User `json:"notify_users_obj" gorm:"-"` // for notify.py
|
||||||
LastEvalTime int64 `json:"last_eval_time" gorm:"-"` // for notify.py 上次计算的时间
|
LastEvalTime int64 `json:"last_eval_time" gorm:"-"` // for notify.py 上次计算的时间
|
||||||
LastSentTime int64 `json:"last_sent_time" gorm:"-"` // 上次发送时间
|
LastSentTime int64 `json:"last_sent_time" gorm:"-"` // 上次发送时间
|
||||||
NotifyCurNumber int `json:"notify_cur_number" gorm:"-"` // notify: current number
|
NotifyCurNumber int `json:"notify_cur_number"` // notify: current number
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *AlertCurEvent) TableName() string {
|
func (e *AlertCurEvent) TableName() string {
|
||||||
|
@ -179,6 +179,7 @@ func (e *AlertCurEvent) ToHis() *AlertHisEvent {
|
||||||
Tags: e.Tags,
|
Tags: e.Tags,
|
||||||
RecoverTime: recoverTime,
|
RecoverTime: recoverTime,
|
||||||
LastEvalTime: e.LastEvalTime,
|
LastEvalTime: e.LastEvalTime,
|
||||||
|
NotifyCurNumber: e.NotifyCurNumber,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ type AlertHisEvent struct {
|
||||||
LastEvalTime int64 `json:"last_eval_time"`
|
LastEvalTime int64 `json:"last_eval_time"`
|
||||||
Tags string `json:"-"`
|
Tags string `json:"-"`
|
||||||
TagsJSON []string `json:"tags" gorm:"-"`
|
TagsJSON []string `json:"tags" gorm:"-"`
|
||||||
|
NotifyCurNumber int `json:"notify_cur_number"` // notify: current number
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *AlertHisEvent) TableName() string {
|
func (e *AlertHisEvent) TableName() string {
|
||||||
|
|
|
@ -29,9 +29,5 @@ func isNoneffective(timestamp int64, alertRule *models.AlertRule) bool {
|
||||||
|
|
||||||
alertRule.EnableDaysOfWeek = strings.Replace(alertRule.EnableDaysOfWeek, "7", "0", 1)
|
alertRule.EnableDaysOfWeek = strings.Replace(alertRule.EnableDaysOfWeek, "7", "0", 1)
|
||||||
|
|
||||||
if !strings.Contains(alertRule.EnableDaysOfWeek, triggerWeek) {
|
return !strings.Contains(alertRule.EnableDaysOfWeek, triggerWeek)
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,6 +365,7 @@ func (r RuleEval) fireEvent(event *models.AlertCurEvent) {
|
||||||
if event.LastEvalTime > fired.LastSentTime+int64(r.rule.NotifyRepeatStep)*60 {
|
if event.LastEvalTime > fired.LastSentTime+int64(r.rule.NotifyRepeatStep)*60 {
|
||||||
if r.rule.NotifyMaxNumber == 0 {
|
if r.rule.NotifyMaxNumber == 0 {
|
||||||
// 最大可以发送次数如果是0,表示不想限制最大发送次数,一直发即可
|
// 最大可以发送次数如果是0,表示不想限制最大发送次数,一直发即可
|
||||||
|
event.NotifyCurNumber = fired.NotifyCurNumber + 1
|
||||||
r.pushEventToQueue(event)
|
r.pushEventToQueue(event)
|
||||||
} else {
|
} else {
|
||||||
// 有最大发送次数的限制,就要看已经发了几次了,是否达到了最大发送次数
|
// 有最大发送次数的限制,就要看已经发了几次了,是否达到了最大发送次数
|
||||||
|
|
Loading…
Reference in New Issue