Skip to content

Commit a39a7c6

Browse files
2rs2tsminoad
authored and
Ryan Eschinger
committed
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 <[email protected]> Signed-off-by: Ryan Eschinger <[email protected]>
1 parent 5150860 commit a39a7c6

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

pkg/custompluginmonitor/custom_plugin_monitor.go

+1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ func (c *customPluginMonitor) generateStatus(result cpmtypes.Result) *types.Stat
232232
condition.Type,
233233
status,
234234
newReason,
235+
newMessage,
235236
timestamp,
236237
)
237238

pkg/systemlogmonitor/log_monitor.go

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ func (l *logMonitor) generateStatus(logs []*logtypes.Log, rule systemlogtypes.Ru
192192
condition.Type,
193193
types.True,
194194
rule.Reason,
195+
message,
195196
timestamp,
196197
))
197198
}

pkg/systemlogmonitor/log_monitor_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func TestGenerateStatusForConditions(t *testing.T) {
8484
testConditionA,
8585
types.True,
8686
"test reason",
87+
"test message 1\ntest message 2",
8788
time.Unix(1000, 1000),
8889
)},
8990
Conditions: []types.Condition{

pkg/util/helpers.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import (
2323
)
2424

2525
// GenerateConditionChangeEvent generates an event for condition change.
26-
func GenerateConditionChangeEvent(t string, status types.ConditionStatus, reason string, timestamp time.Time) types.Event {
26+
func GenerateConditionChangeEvent(t string, status types.ConditionStatus, reason, message string, timestamp time.Time) types.Event {
2727
return types.Event{
2828
Severity: types.Info,
2929
Timestamp: timestamp,
3030
Reason: reason,
31-
Message: fmt.Sprintf("Node condition %s is now: %s, reason: %s", t, status, reason),
31+
Message: fmt.Sprintf("Node condition %s is now: %s, reason: %s, message: %s", t, status, reason, message),
3232
}
3333
}
3434

0 commit comments

Comments
 (0)