@@ -22,6 +22,7 @@ data class Alert(
22
22
val version : Long = NO_VERSION ,
23
23
val schemaVersion : Int = NO_SCHEMA_VERSION ,
24
24
val monitorId : String ,
25
+ val workflowId : String ,
25
26
val monitorName : String ,
26
27
val monitorVersion : Long ,
27
28
val monitorUser : User ? ,
@@ -48,6 +49,7 @@ data class Alert(
48
49
}
49
50
}
50
51
52
+ // constructor for chained alerts.
51
53
constructor (
52
54
startTime: Instant ,
53
55
lastNotificationTime: Instant ? ,
@@ -63,7 +65,7 @@ data class Alert(
63
65
lastNotificationTime = lastNotificationTime, errorMessage = errorMessage, errorHistory = emptyList(),
64
66
severity = chainedAlertTrigger.severity, actionExecutionResults = emptyList(), schemaVersion = schemaVersion,
65
67
aggregationResultBucket = null , findingIds = emptyList(), relatedDocIds = emptyList(),
66
- executionId = executionId
68
+ executionId = executionId, workflowId = workflow.id
67
69
)
68
70
69
71
constructor (
@@ -76,14 +78,15 @@ data class Alert(
76
78
errorHistory: List <AlertError > = mutableListOf (),
77
79
actionExecutionResults: List <ActionExecutionResult > = mutableListOf (),
78
80
schemaVersion: Int = NO_SCHEMA_VERSION ,
79
- executionId: String? = null
81
+ executionId: String? = null ,
82
+ workflow: Workflow ? = null ,
80
83
) : this (
81
84
monitorId = monitor.id, monitorName = monitor.name, monitorVersion = monitor.version, monitorUser = monitor.user,
82
85
triggerId = trigger.id, triggerName = trigger.name, state = state, startTime = startTime,
83
86
lastNotificationTime = lastNotificationTime, errorMessage = errorMessage, errorHistory = errorHistory,
84
87
severity = trigger.severity, actionExecutionResults = actionExecutionResults, schemaVersion = schemaVersion,
85
88
aggregationResultBucket = null , findingIds = emptyList(), relatedDocIds = emptyList(),
86
- executionId = executionId
89
+ executionId = executionId, workflowId = workflow?.id ? : " "
87
90
)
88
91
89
92
constructor (
@@ -97,14 +100,15 @@ data class Alert(
97
100
actionExecutionResults: List <ActionExecutionResult > = mutableListOf (),
98
101
schemaVersion: Int = NO_SCHEMA_VERSION ,
99
102
findingIds: List <String > = emptyList(),
100
- executionId: String? = null
103
+ executionId: String? = null ,
104
+ workflow: Workflow ? = null ,
101
105
) : this (
102
106
monitorId = monitor.id, monitorName = monitor.name, monitorVersion = monitor.version, monitorUser = monitor.user,
103
107
triggerId = trigger.id, triggerName = trigger.name, state = state, startTime = startTime,
104
108
lastNotificationTime = lastNotificationTime, errorMessage = errorMessage, errorHistory = errorHistory,
105
109
severity = trigger.severity, actionExecutionResults = actionExecutionResults, schemaVersion = schemaVersion,
106
110
aggregationResultBucket = null , findingIds = findingIds, relatedDocIds = emptyList(),
107
- executionId = executionId
111
+ executionId = executionId, workflowId = workflow?.id ? : " "
108
112
)
109
113
110
114
constructor (
@@ -119,14 +123,15 @@ data class Alert(
119
123
schemaVersion: Int = NO_SCHEMA_VERSION ,
120
124
aggregationResultBucket: AggregationResultBucket ,
121
125
findingIds: List <String > = emptyList(),
122
- executionId: String? = null
126
+ executionId: String? = null ,
127
+ workflow: Workflow ? = null ,
123
128
) : this (
124
129
monitorId = monitor.id, monitorName = monitor.name, monitorVersion = monitor.version, monitorUser = monitor.user,
125
130
triggerId = trigger.id, triggerName = trigger.name, state = state, startTime = startTime,
126
131
lastNotificationTime = lastNotificationTime, errorMessage = errorMessage, errorHistory = errorHistory,
127
132
severity = trigger.severity, actionExecutionResults = actionExecutionResults, schemaVersion = schemaVersion,
128
133
aggregationResultBucket = aggregationResultBucket, findingIds = findingIds, relatedDocIds = emptyList(),
129
- executionId = executionId
134
+ executionId = executionId, workflowId = workflow?.id ? : " "
130
135
)
131
136
132
137
constructor (
@@ -142,14 +147,15 @@ data class Alert(
142
147
errorHistory: List <AlertError > = mutableListOf (),
143
148
actionExecutionResults: List <ActionExecutionResult > = mutableListOf (),
144
149
schemaVersion: Int = NO_SCHEMA_VERSION ,
145
- executionId: String? = null
150
+ executionId: String? = null ,
151
+ workflow: Workflow ? = null ,
146
152
) : this (
147
153
id = id, monitorId = monitor.id, monitorName = monitor.name, monitorVersion = monitor.version, monitorUser = monitor.user,
148
154
triggerId = trigger.id, triggerName = trigger.name, state = state, startTime = startTime,
149
155
lastNotificationTime = lastNotificationTime, errorMessage = errorMessage, errorHistory = errorHistory,
150
156
severity = trigger.severity, actionExecutionResults = actionExecutionResults, schemaVersion = schemaVersion,
151
157
aggregationResultBucket = null , findingIds = findingIds, relatedDocIds = relatedDocIds,
152
- executionId = executionId
158
+ executionId = executionId, workflowId = workflow?.id ? : " "
153
159
)
154
160
155
161
constructor (
@@ -161,13 +167,15 @@ data class Alert(
161
167
state: State = State .ERROR ,
162
168
errorMessage: String ,
163
169
errorHistory: List <AlertError > = mutableListOf (),
164
- schemaVersion: Int = NO_SCHEMA_VERSION
170
+ schemaVersion: Int = NO_SCHEMA_VERSION ,
171
+ workflow: Workflow ? = null ,
165
172
) : this (
166
173
id = id, monitorId = monitor.id, monitorName = monitor.name, monitorVersion = monitor.version, monitorUser = monitor.user,
167
174
triggerId = trigger.id, triggerName = trigger.name, state = state, startTime = startTime,
168
175
lastNotificationTime = lastNotificationTime, errorMessage = errorMessage, errorHistory = errorHistory,
169
176
severity = trigger.severity, actionExecutionResults = listOf (), schemaVersion = schemaVersion,
170
- aggregationResultBucket = null , findingIds = listOf (), relatedDocIds = listOf ()
177
+ aggregationResultBucket = null , findingIds = listOf (), relatedDocIds = listOf (),
178
+ workflowId = workflow?.id ? : " "
171
179
)
172
180
173
181
enum class State {
@@ -185,6 +193,7 @@ data class Alert(
185
193
version = sin.readLong(),
186
194
schemaVersion = sin.readInt(),
187
195
monitorId = sin.readString(),
196
+ workflowId = sin.readString(),
188
197
monitorName = sin.readString(),
189
198
monitorVersion = sin.readLong(),
190
199
monitorUser = if (sin.readBoolean()) {
@@ -215,6 +224,7 @@ data class Alert(
215
224
out .writeLong(version)
216
225
out .writeInt(schemaVersion)
217
226
out .writeString(monitorId)
227
+ out .writeString(workflowId)
218
228
out .writeString(monitorName)
219
229
out .writeLong(monitorVersion)
220
230
out .writeBoolean(monitorUser != null )
@@ -247,6 +257,7 @@ data class Alert(
247
257
const val SCHEMA_VERSION_FIELD = " schema_version"
248
258
const val ALERT_VERSION_FIELD = " version"
249
259
const val MONITOR_ID_FIELD = " monitor_id"
260
+ const val WORKFLOW_ID_FIELD = " workflow_id"
250
261
const val MONITOR_VERSION_FIELD = " monitor_version"
251
262
const val MONITOR_NAME_FIELD = " monitor_name"
252
263
const val MONITOR_USER_FIELD = " monitor_user"
@@ -274,6 +285,7 @@ data class Alert(
274
285
@Throws(IOException ::class )
275
286
fun parse (xcp : XContentParser , id : String = NO_ID , version : Long = NO_VERSION ): Alert {
276
287
lateinit var monitorId: String
288
+ var workflowId = " "
277
289
var schemaVersion = NO_SCHEMA_VERSION
278
290
lateinit var monitorName: String
279
291
var monitorVersion: Long = Versions .NOT_FOUND
@@ -300,6 +312,7 @@ data class Alert(
300
312
301
313
when (fieldName) {
302
314
MONITOR_ID_FIELD -> monitorId = xcp.text()
315
+ WORKFLOW_ID_FIELD -> workflowId = xcp.text()
303
316
SCHEMA_VERSION_FIELD -> schemaVersion = xcp.intValue()
304
317
MONITOR_NAME_FIELD -> monitorName = xcp.text()
305
318
MONITOR_VERSION_FIELD -> monitorVersion = xcp.longValue()
@@ -360,7 +373,7 @@ data class Alert(
360
373
lastNotificationTime = lastNotificationTime, acknowledgedTime = acknowledgedTime,
361
374
errorMessage = errorMessage, errorHistory = errorHistory, severity = severity,
362
375
actionExecutionResults = actionExecutionResults, aggregationResultBucket = aggAlertBucket, findingIds = findingIds,
363
- relatedDocIds = relatedDocIds, executionId = executionId
376
+ relatedDocIds = relatedDocIds, executionId = executionId, workflowId = workflowId
364
377
)
365
378
}
366
379
@@ -383,6 +396,7 @@ data class Alert(
383
396
.field(ALERT_ID_FIELD , id)
384
397
.field(ALERT_VERSION_FIELD , version)
385
398
.field(MONITOR_ID_FIELD , monitorId)
399
+ .field(WORKFLOW_ID_FIELD , workflowId)
386
400
.field(SCHEMA_VERSION_FIELD , schemaVersion)
387
401
.field(MONITOR_VERSION_FIELD , monitorVersion)
388
402
.field(MONITOR_NAME_FIELD , monitorName)
0 commit comments