@@ -40,7 +40,8 @@ data class Monitor(
4040 val inputs : List <Input >,
4141 val triggers : List <Trigger >,
4242 val uiMetadata : Map <String , Any >,
43- val dataSources : DataSources = DataSources ()
43+ val dataSources : DataSources = DataSources (),
44+ val owner : String? = " alerting"
4445) : ScheduledJob {
4546
4647 override val type = MONITOR_TYPE
@@ -102,7 +103,8 @@ data class Monitor(
102103 DataSources (sin)
103104 } else {
104105 DataSources ()
105- }
106+ },
107+ owner = sin.readOptionalString()
106108 )
107109
108110 // This enum classifies different Monitors
@@ -151,6 +153,7 @@ data class Monitor(
151153 .optionalTimeField(LAST_UPDATE_TIME_FIELD , lastUpdateTime)
152154 if (uiMetadata.isNotEmpty()) builder.field(UI_METADATA_FIELD , uiMetadata)
153155 builder.field(DATA_SOURCES_FIELD , dataSources)
156+ builder.field(OWNER_FIELD , owner)
154157 if (params.paramAsBoolean(" with_type" , false )) builder.endObject()
155158 return builder.endObject()
156159 }
@@ -195,6 +198,7 @@ data class Monitor(
195198 out .writeMap(uiMetadata)
196199 out .writeBoolean(dataSources != null ) // for backward compatibility with pre-existing monitors which don't have datasources field
197200 dataSources.writeTo(out )
201+ out .writeOptionalString(owner)
198202 }
199203
200204 companion object {
@@ -214,6 +218,7 @@ data class Monitor(
214218 const val UI_METADATA_FIELD = " ui_metadata"
215219 const val DATA_SOURCES_FIELD = " data_sources"
216220 const val ENABLED_TIME_FIELD = " enabled_time"
221+ const val OWNER_FIELD = " owner"
217222
218223 // This is defined here instead of in ScheduledJob to avoid having the ScheduledJob class know about all
219224 // the different subclasses and creating circular dependencies
@@ -240,6 +245,7 @@ data class Monitor(
240245 val triggers: MutableList <Trigger > = mutableListOf ()
241246 val inputs: MutableList <Input > = mutableListOf ()
242247 var dataSources = DataSources ()
248+ var owner = " alerting"
243249
244250 XContentParserUtils .ensureExpectedToken(XContentParser .Token .START_OBJECT , xcp.currentToken(), xcp)
245251 while (xcp.nextToken() != XContentParser .Token .END_OBJECT ) {
@@ -287,6 +293,7 @@ data class Monitor(
287293 UI_METADATA_FIELD -> uiMetadata = xcp.map()
288294 DATA_SOURCES_FIELD -> dataSources = if (xcp.currentToken() == XContentParser .Token .VALUE_NULL ) DataSources ()
289295 else DataSources .parse(xcp)
296+ OWNER_FIELD -> owner = if (xcp.currentToken() == XContentParser .Token .VALUE_NULL ) owner else xcp.text()
290297 else -> {
291298 xcp.skipChildren()
292299 }
@@ -312,7 +319,8 @@ data class Monitor(
312319 inputs.toList(),
313320 triggers.toList(),
314321 uiMetadata,
315- dataSources
322+ dataSources,
323+ owner
316324 )
317325 }
318326
0 commit comments