Add condition message to event message

If you're using some monitoring solution that aggregates events from
your Kubernetes cluster, having the underlying reason why a condition
triggered could be very useful, especially if you are using custom
plugin monitors.

Co-authored-by: Micah Norman <micnorman@paypal.com>
Signed-off-by: Ryan Eschinger <reschinger@paypal.com>
This commit is contained in:
Andrew Garrett
2022-06-08 21:42:40 +00:00
committed by Ryan Eschinger
co-authored by Micah Norman
parent 51508603fe
commit a39a7c6e0f
4 changed files with 5 additions and 2 deletions
@@ -232,6 +232,7 @@ func (c *customPluginMonitor) generateStatus(result cpmtypes.Result) *types.Stat
condition.Type,
status,
newReason,
newMessage,
timestamp,
)
+1
View File
@@ -192,6 +192,7 @@ func (l *logMonitor) generateStatus(logs []*logtypes.Log, rule systemlogtypes.Ru
condition.Type,
types.True,
rule.Reason,
message,
timestamp,
))
}
+1
View File
@@ -84,6 +84,7 @@ func TestGenerateStatusForConditions(t *testing.T) {
testConditionA,
types.True,
"test reason",
"test message 1\ntest message 2",
time.Unix(1000, 1000),
)},
Conditions: []types.Condition{
+2 -2
View File
@@ -23,12 +23,12 @@ import (
)
// GenerateConditionChangeEvent generates an event for condition change.
func GenerateConditionChangeEvent(t string, status types.ConditionStatus, reason string, timestamp time.Time) types.Event {
func GenerateConditionChangeEvent(t string, status types.ConditionStatus, reason, message string, timestamp time.Time) types.Event {
return types.Event{
Severity: types.Info,
Timestamp: timestamp,
Reason: reason,
Message: fmt.Sprintf("Node condition %s is now: %s, reason: %s", t, status, reason),
Message: fmt.Sprintf("Node condition %s is now: %s, reason: %s, message: %s", t, status, reason, message),
}
}