mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-08-19 04:06:24 +00:00
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:
committed by
Ryan Eschinger
co-authored by
Micah Norman
parent
51508603fe
commit
a39a7c6e0f
@@ -232,6 +232,7 @@ func (c *customPluginMonitor) generateStatus(result cpmtypes.Result) *types.Stat
|
||||
condition.Type,
|
||||
status,
|
||||
newReason,
|
||||
newMessage,
|
||||
timestamp,
|
||||
)
|
||||
|
||||
|
||||
@@ -192,6 +192,7 @@ func (l *logMonitor) generateStatus(logs []*logtypes.Log, rule systemlogtypes.Ru
|
||||
condition.Type,
|
||||
types.True,
|
||||
rule.Reason,
|
||||
message,
|
||||
timestamp,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -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
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user