-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "TRT-1625: Revert #28741 "OCPBUGS-32923: Fix allowed firing al…
…erts not triggering""
- Loading branch information
Showing
6 changed files
with
200 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package alerts | ||
|
||
import ( | ||
"github.com/openshift/origin/pkg/monitor/monitorapi" | ||
"github.com/prometheus/common/model" | ||
) | ||
|
||
type MetricCondition struct { | ||
AlertName string | ||
AlertNamespace string | ||
AlertLevel string | ||
|
||
// Text is the description of why this alert condition matched. | ||
Text string | ||
|
||
Matches func(sample *model.Sample) bool | ||
} | ||
|
||
type MetricConditions []MetricCondition | ||
|
||
func (c MetricConditions) MatchesInterval(alertInterval monitorapi.Interval) *MetricCondition { | ||
|
||
if alertInterval.Source != monitorapi.SourceAlert { | ||
return nil | ||
} | ||
|
||
checkAlertName := alertInterval.StructuredLocator.Keys[monitorapi.LocatorAlertKey] | ||
checkAlertNamespace := alertInterval.StructuredLocator.Keys[monitorapi.LocatorNamespaceKey] | ||
|
||
for _, condition := range c { | ||
matches := true | ||
// We can assume AlertName is set: | ||
if condition.AlertName != checkAlertName { | ||
matches = false | ||
// But Namespace may not be: | ||
} else if condition.AlertNamespace != "" && condition.AlertNamespace != checkAlertNamespace { | ||
matches = false | ||
} | ||
|
||
if matches { | ||
return &condition | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.