@@ -43,6 +43,7 @@ data class Alert(
43
43
val aggregationResultBucket : AggregationResultBucket ? = null ,
44
44
val executionId : String? = null ,
45
45
val associatedAlertIds : List <String >,
46
+ val clusters : List <String >? = null ,
46
47
) : Writeable, ToXContent {
47
48
48
49
init {
@@ -61,6 +62,7 @@ data class Alert(
61
62
chainedAlertTrigger: ChainedAlertTrigger ,
62
63
workflow: Workflow ,
63
64
associatedAlertIds: List <String >,
65
+ clusters: List <String >? = null
64
66
) : this (
65
67
monitorId = NO_ID ,
66
68
monitorName = " " ,
@@ -82,7 +84,8 @@ data class Alert(
82
84
executionId = executionId,
83
85
workflowId = workflow.id,
84
86
workflowName = workflow.name,
85
- associatedAlertIds = associatedAlertIds
87
+ associatedAlertIds = associatedAlertIds,
88
+ clusters = clusters
86
89
)
87
90
88
91
constructor (
@@ -97,6 +100,7 @@ data class Alert(
97
100
schemaVersion: Int = NO_SCHEMA_VERSION ,
98
101
executionId: String? = null ,
99
102
workflowId: String? = null ,
103
+ clusters: List <String >? = null
100
104
) : this (
101
105
monitorId = monitor.id,
102
106
monitorName = monitor.name,
@@ -118,7 +122,8 @@ data class Alert(
118
122
executionId = executionId,
119
123
workflowId = workflowId ? : " " ,
120
124
workflowName = " " ,
121
- associatedAlertIds = emptyList()
125
+ associatedAlertIds = emptyList(),
126
+ clusters = clusters
122
127
)
123
128
124
129
constructor (
@@ -134,6 +139,7 @@ data class Alert(
134
139
findingIds: List <String > = emptyList(),
135
140
executionId: String? = null ,
136
141
workflowId: String? = null ,
142
+ clusters: List <String >? = null
137
143
) : this (
138
144
monitorId = monitor.id,
139
145
monitorName = monitor.name,
@@ -155,7 +161,8 @@ data class Alert(
155
161
executionId = executionId,
156
162
workflowId = workflowId ? : " " ,
157
163
workflowName = " " ,
158
- associatedAlertIds = emptyList()
164
+ associatedAlertIds = emptyList(),
165
+ clusters = clusters
159
166
)
160
167
161
168
constructor (
@@ -172,6 +179,7 @@ data class Alert(
172
179
findingIds: List <String > = emptyList(),
173
180
executionId: String? = null ,
174
181
workflowId: String? = null ,
182
+ clusters: List <String >? = null
175
183
) : this (
176
184
monitorId = monitor.id,
177
185
monitorName = monitor.name,
@@ -193,7 +201,8 @@ data class Alert(
193
201
executionId = executionId,
194
202
workflowId = workflowId ? : " " ,
195
203
workflowName = " " ,
196
- associatedAlertIds = emptyList()
204
+ associatedAlertIds = emptyList(),
205
+ clusters = clusters
197
206
)
198
207
199
208
constructor (
@@ -211,6 +220,7 @@ data class Alert(
211
220
schemaVersion: Int = NO_SCHEMA_VERSION ,
212
221
executionId: String? = null ,
213
222
workflowId: String? = null ,
223
+ clusters: List <String >? = null
214
224
) : this (
215
225
id = id,
216
226
monitorId = monitor.id,
@@ -233,7 +243,8 @@ data class Alert(
233
243
executionId = executionId,
234
244
workflowId = workflowId ? : " " ,
235
245
workflowName = " " ,
236
- associatedAlertIds = emptyList()
246
+ associatedAlertIds = emptyList(),
247
+ clusters = clusters
237
248
)
238
249
239
250
constructor (
@@ -248,6 +259,7 @@ data class Alert(
248
259
schemaVersion: Int = NO_SCHEMA_VERSION ,
249
260
workflowId: String? = null ,
250
261
executionId: String? ,
262
+ clusters: List <String >? = null
251
263
) : this (
252
264
id = id,
253
265
monitorId = monitor.id,
@@ -270,7 +282,8 @@ data class Alert(
270
282
relatedDocIds = listOf (),
271
283
workflowId = workflowId ? : " " ,
272
284
executionId = executionId,
273
- associatedAlertIds = emptyList()
285
+ associatedAlertIds = emptyList(),
286
+ clusters = clusters
274
287
)
275
288
276
289
enum class State {
@@ -311,7 +324,8 @@ data class Alert(
311
324
actionExecutionResults = sin.readList(::ActionExecutionResult ),
312
325
aggregationResultBucket = if (sin.readBoolean()) AggregationResultBucket (sin) else null ,
313
326
executionId = sin.readOptionalString(),
314
- associatedAlertIds = sin.readStringList()
327
+ associatedAlertIds = sin.readStringList(),
328
+ clusters = sin.readOptionalStringList()
315
329
)
316
330
317
331
fun isAcknowledged (): Boolean = (state == State .ACKNOWLEDGED )
@@ -349,6 +363,7 @@ data class Alert(
349
363
}
350
364
out .writeOptionalString(executionId)
351
365
out .writeStringCollection(associatedAlertIds)
366
+ out .writeOptionalStringArray(clusters?.toTypedArray())
352
367
}
353
368
354
369
companion object {
@@ -379,6 +394,7 @@ data class Alert(
379
394
const val ASSOCIATED_ALERT_IDS_FIELD = " associated_alert_ids"
380
395
const val BUCKET_KEYS = AggregationResultBucket .BUCKET_KEYS
381
396
const val PARENTS_BUCKET_PATH = AggregationResultBucket .PARENTS_BUCKET_PATH
397
+ const val CLUSTERS_FIELD = " clusters"
382
398
const val NO_ID = " "
383
399
const val NO_VERSION = Versions .NOT_FOUND
384
400
@@ -409,6 +425,7 @@ data class Alert(
409
425
val actionExecutionResults: MutableList <ActionExecutionResult > = mutableListOf ()
410
426
var aggAlertBucket: AggregationResultBucket ? = null
411
427
val associatedAlertIds = mutableListOf<String >()
428
+ val clusters = mutableListOf<String >()
412
429
ensureExpectedToken(XContentParser .Token .START_OBJECT , xcp.currentToken(), xcp)
413
430
while (xcp.nextToken() != XContentParser .Token .END_OBJECT ) {
414
431
val fieldName = xcp.currentName()
@@ -475,6 +492,12 @@ data class Alert(
475
492
AggregationResultBucket .parse(xcp)
476
493
}
477
494
}
495
+ CLUSTERS_FIELD -> {
496
+ ensureExpectedToken(XContentParser .Token .START_ARRAY , xcp.currentToken(), xcp)
497
+ while (xcp.nextToken() != XContentParser .Token .END_ARRAY ) {
498
+ clusters.add(xcp.text())
499
+ }
500
+ }
478
501
}
479
502
}
480
503
@@ -503,7 +526,8 @@ data class Alert(
503
526
executionId = executionId,
504
527
workflowId = workflowId,
505
528
workflowName = workflowName,
506
- associatedAlertIds = associatedAlertIds
529
+ associatedAlertIds = associatedAlertIds,
530
+ clusters = if (clusters.size > 0 ) clusters else null
507
531
)
508
532
}
509
533
@@ -553,6 +577,9 @@ data class Alert(
553
577
.optionalTimeField(END_TIME_FIELD , endTime)
554
578
.optionalTimeField(ACKNOWLEDGED_TIME_FIELD , acknowledgedTime)
555
579
aggregationResultBucket?.innerXContent(builder)
580
+
581
+ if (! clusters.isNullOrEmpty()) builder.field(CLUSTERS_FIELD , clusters.toTypedArray())
582
+
556
583
builder.endObject()
557
584
return builder
558
585
}
@@ -576,7 +603,8 @@ data class Alert(
576
603
BUCKET_KEYS to aggregationResultBucket?.bucketKeys?.joinToString(" ," ),
577
604
PARENTS_BUCKET_PATH to aggregationResultBucket?.parentBucketPath,
578
605
FINDING_IDS to findingIds.joinToString(" ," ),
579
- RELATED_DOC_IDS to relatedDocIds.joinToString(" ," )
606
+ RELATED_DOC_IDS to relatedDocIds.joinToString(" ," ),
607
+ CLUSTERS_FIELD to clusters?.joinToString(" ," )
580
608
)
581
609
}
582
610
}
0 commit comments