I am trying to return a field as NA in watcher alert email if that field is not available in _source.
I am using a transform script to see if the field is available in the _source, if not I am returning NA.
Please let me know if this is the correct way of doing this.
But I am getting watcher execution error below.
Here is my watcher job and the error trace.
Tried to loop through the transform script like below. I am getting below error.
Watcher: An internal server error occurred
Is transform script is the right choice to show NA (in email alert) for the fields that are not available with _source? If so, Once I transform this how can I access the returned value in the email alert?
Blockquote
A Transform processes and changes the payload in the watch execution context to prepare it for the watch actions.
The important part here is, that the word changes means, the existing payload gets overwritten. You cannot access the hits if you dont specify them in your transform. Also in your last example, you basically returned early, as soon as the first document has the key - I do think you want to create a list here?
It might make sense to check out our examples repo athttps://github.com/elastic/examples/tree/master/Alerting
I implemented this by creating a scripted field rather than transforming the payload.
Then I accessed the scripted field as ctx.payload.hits.hits.fields.scriptedfield.
Thanks for pointing me the right direction.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.