mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 20:55:54 +08:00
fix: alerts work when "equals to" or "not equals to" used with "all the times" or "at least once" (#3244)
This commit is contained in:
parent
03220fcf11
commit
ec7c99dd26
@ -34,8 +34,9 @@ func (s Sample) MarshalJSON() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Point struct {
|
type Point struct {
|
||||||
T int64
|
T int64
|
||||||
V float64
|
V float64
|
||||||
|
Vs []float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Point) String() string {
|
func (p Point) String() string {
|
||||||
|
@ -550,7 +550,40 @@ func (r *ThresholdRule) runChQuery(ctx context.Context, db clickhouse.Conn, quer
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s, ok := resultMap[labelHash]; ok {
|
||||||
|
s.Point.Vs = append(s.Point.Vs, s.Point.V)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, s := range resultMap {
|
||||||
|
if r.matchType() == AllTheTimes && r.compareOp() == ValueIsEq {
|
||||||
|
for _, v := range s.Point.Vs {
|
||||||
|
if v != r.targetVal() { // if any of the values is not equal to target, alert shouldn't be sent
|
||||||
|
s.Point.V = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if r.matchType() == AllTheTimes && r.compareOp() == ValueIsNotEq {
|
||||||
|
for _, v := range s.Point.Vs {
|
||||||
|
if v == r.targetVal() { // if any of the values is equal to target, alert shouldn't be sent
|
||||||
|
s.Point.V = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if r.matchType() == AtleastOnce && r.compareOp() == ValueIsEq {
|
||||||
|
for _, v := range s.Point.Vs {
|
||||||
|
if v == r.targetVal() { // if any of the values is equal to target, alert should be sent
|
||||||
|
s.Point.V = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if r.matchType() == AtleastOnce && r.compareOp() == ValueIsNotEq {
|
||||||
|
for _, v := range s.Point.Vs {
|
||||||
|
if v != r.targetVal() { // if any of the values is not equal to target, alert should be sent
|
||||||
|
s.Point.V = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
zap.S().Debugf("ruleid:", r.ID(), "\t resultmap(potential alerts):", len(resultMap))
|
zap.S().Debugf("ruleid:", r.ID(), "\t resultmap(potential alerts):", len(resultMap))
|
||||||
|
|
||||||
for _, sample := range resultMap {
|
for _, sample := range resultMap {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user