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

View File

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

View File

@ -325,7 +325,7 @@ func ToJudge(linkedList *SafeLinkedList, stra *models.AlertRule, val *vos.Metric
ReadableExpression: eventInfo, ReadableExpression: eventInfo,
TagMap: val.TagsMap, 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) sendEventIfNeed(statusArr, event, stra)
} }

View File

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

View File

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