Stored script on trigger condition


It’s possible to use stored scripts on Opendistro trigger condition?
I was trying to use it, but I got error “Invalid script language”.

On queries, stored scripts works well.


Can you show how you’re getting to this error? Is this a painless script?

Yes, it’s a painless script. Below some print screens of my process to get the error.


after a few months, and no answer from anyone, I tried to update my Opendistro to Opensearch 1.1.0, wishing that it could solve my problem.

Unfortunatelly, the problem persist. When I try to specify a stored script to a trigger condition, I receive the error message: “Invalid script language. Allowed languages are [painless]”

I’m having too much trouble with script compilations rate on my server, and this could save my life.

Someone has been through this and could help me?

@qreshi @ashisagr-amzn Is this supported? If not does it look like it would take a lot of work to add support for it? Probably in the code we are compiling the script from the data model, but perhaps we can supplement it so if it sees this script id instead it knows its a stored script and to load it from whatever internal call loads a stored script.

Hi @brunogui0812, this feature you are asking about it is currently not supported in the Alerting plugin.
Currently, you will need to copy that script over to the trigger definition in the monitor.

You have also brought up an interesting feature and I recommend creating a feature request to the Alerting plugin, so this can be added in a future version.

You can submit a feature request here.

@dbbaughe @brunogui0812 To add a little more information here, I took a look at the current implementation and it looks like we’re failing the validation in the parse of the Trigger condition of the Monitor and this is because for a stored script the lang and options are null and are resolved after the stored script has been retrieved. So to support a stored script, we might be able to update our lang check to account for ScriptType.STORED and possibly add validations within the Trigger script execution after compilation if we still want to fail on script langs that are not Painless.