diff --git a/alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/MonitorRunResult.kt b/alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/MonitorRunResult.kt index 3b79a823..ae9d42f0 100644 --- a/alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/MonitorRunResult.kt +++ b/alerting/src/main/kotlin/com/amazon/opendistroforelasticsearch/alerting/model/MonitorRunResult.kt @@ -77,10 +77,12 @@ data class TriggerRunResult( val actionResults: MutableMap = mutableMapOf() ) : ToXContent { override fun toXContent(builder: XContentBuilder, params: ToXContent.Params): XContentBuilder { + var msg = error?.message + if (error is ScriptException) msg = error.toJsonString() return builder.startObject() .field("name", triggerName) .field("triggered", triggered) - .field("error", error?.message) + .field("error", msg) .field("action_results", actionResults as Map) .endObject() }