fix: process event mute

This commit is contained in:
710leo 2021-07-10 02:32:28 +08:00
parent 258e9738f7
commit 477cac6ca9
5 changed files with 23 additions and 21 deletions

View File

@ -22,7 +22,7 @@ import (
)
func popEvent() {
sema := semaphore.NewSemaphore(config.Config.Alert.NotifyConcurrency)
sema := semaphore.NewSemaphore(config.Config.Alert.NotifyScriptConcurrency)
duration := time.Duration(100) * time.Millisecond
for {
events := judge.EventQueue.PopBackBy(200)
@ -60,7 +60,7 @@ func consume(events []interface{}, sema *semaphore.Semaphore) {
event.ResClasspaths = strings.Join(classpaths, " ")
enrichTag(event, alertRule)
if isEventMute(event) {
if isEventMute(event) && event.IsAlert() {
// 被屏蔽的事件
event.MarkMuted()

View File

@ -39,9 +39,9 @@ type tplSection struct {
}
type alertSection struct {
NotifyScriptPath string `yaml:"notifyScriptPath"`
NotifyConcurrency int `yaml:"notifyConcurrency"`
MutedAlertPersist bool `yaml:"mutedAlertPersist"`
NotifyScriptPath string `yaml:"notifyScriptPath"`
NotifyScriptConcurrency int `yaml:"notifyScriptConcurrency"`
MutedAlertPersist bool `yaml:"mutedAlertPersist"`
}
type transSection struct {

View File

@ -325,7 +325,7 @@ func ToJudge(linkedList *SafeLinkedList, stra *models.AlertRule, val *vos.Metric
ReadableExpression: eventInfo,
TagMap: val.TagsMap,
}
logger.Debugf("[ToJudge.event.create][type=push][stra:%+v][val:%+v][event:%+v]", stra, val, event)
logger.Debugf("[ToJudge.event.create][statusArr:%v][type=push][stra:%+v][val:%+v][event:%+v]", statusArr, stra, val, event)
sendEventIfNeed(statusArr, event, stra)
}

View File

@ -45,6 +45,10 @@ func Query(reqs *vos.DataQueryParam) []*vos.HPoint {
//裁剪掉多余的点
for _, i := range fD.Values {
if i.Timestamp/1000000000 == 1000 {
i.Timestamp = i.Timestamp / 1000
}
oneV := &vos.HPoint{
Timestamp: i.Timestamp,
Value: i.Value,

View File

@ -48,24 +48,22 @@ func syncResourceTags() error {
resTagsMap := make(map[string]cache.ResourceAndTags)
for i := 0; i < len(resources); i++ {
resAndTags := cache.ResourceAndTags{
Resource: resources[i],
}
tagslst := strings.Fields(resources[i].Tags)
count := len(tagslst)
if count == 0 {
continue
}
tagsmap := make(map[string]string, count)
for i := 0; i < count; i++ {
arr := strings.Split(tagslst[i], "=")
if len(arr) != 2 {
continue
if count != 0 {
tagsmap := make(map[string]string, count)
for i := 0; i < count; i++ {
arr := strings.Split(tagslst[i], "=")
if len(arr) != 2 {
continue
}
tagsmap[arr[0]] = arr[1]
}
tagsmap[arr[0]] = arr[1]
}
resAndTags := cache.ResourceAndTags{
Tags: tagsmap,
Resource: resources[i],
resAndTags.Tags = tagsmap
}
resTagsMap[resources[i].Ident] = resAndTags