Skip to content

Commit

Permalink
target miss add append tags
Browse files Browse the repository at this point in the history
  • Loading branch information
710leo committed Apr 6, 2023
1 parent cc68b75 commit b142a57
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions alert/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ func (arw *AlertRuleWorker) GetHostAnomalyPoint(ruleConfig string) []common.Anom
for _, target := range targets {
m := make(map[string]string)
m["ident"] = target.Ident
target.FillTagsMap()
for k, v := range target.TagsMap {
if k == "ident" {
continue
}
m[k] = v
}
lst = append(lst, common.NewAnomalyPoint(trigger.Type, m, now, float64(now-target.UpdateAt), trigger.Severity))
}
case "offset":
Expand All @@ -211,10 +218,25 @@ func (arw *AlertRuleWorker) GetHostAnomalyPoint(ruleConfig string) []common.Anom
logger.Errorf("rule_eval:%s query:%v, error:%v", arw.Key(), query, err)
continue
}
var targetMap = make(map[string]*models.Target)
for _, target := range targets {
targetMap[target.Ident] = target
}

hostOffsetMap := arw.processor.TargetCache.GetOffsetHost(targets, now, int64(trigger.Duration))
for host, offset := range hostOffsetMap {
m := make(map[string]string)
m["ident"] = host
target, exists := targetMap[host]
if exists {
target.FillTagsMap()
for k, v := range target.TagsMap {
if k == "ident" {
continue
}
m[k] = v
}
}
lst = append(lst, common.NewAnomalyPoint(trigger.Type, m, now, float64(offset), trigger.Severity))
}
case "pct_target_miss":
Expand Down

0 comments on commit b142a57

Please sign in to comment.