Cannot execute composite monitor with scripted trigger condition

I’m working with OpenSearch version 2.17.1 and trying to set up a composite monitor (workflow)

On the OpenSearch Dashboards UI, it’s currently not possible to add a scripted condition (painless) for a trigger — only basic logical conditions (like A AND B) are available.

To work around this, I created the trigger via the Dev Tools console with a custom condition like this:
“condition”: {
“script”: {
“source”: “return true;”,
“lang”: “painless”
}
}

However, when I try to execute the workflow, I always get an error:

Error while processing the trigger expression: returntrue;

Even with this extremely basic script, the trigger fails to execute.

I’ve checked:
• Both input monitors return valid results with hits.hits
• Monitor IDs are correct in the composite input
• The script syntax is valid
• I’ve tried escaping and formatting in various ways (using “”" or \t, etc.)

It seems like the trigger script is either not parsed correctly, or the composite monitor cannot access ctx.monitors[…] during execution.

Has anyone experienced this? Any idea how to get around it?

Thanks in advance!

@MHR Did you follow this OpenSearch documentation?

Hello Pablo,
Thanks for your answer. Yes, i did. I have no issue when i use a simple condition like this:

"condition": {
					"script": {
						"source": "(monitor[id=grsbCIcBvEHfkjWFeCqb] && monitor[id=agasbCIcBvEHfkjWFeCqa])",
						"lang": "painless"
					}
				}

The probleme appears when i use another script, even something as simple as return true;

@MHR According to the RFC and OpenSearch documentation, the condition only checks the alert status of each defined monitor. Then, based on the defined Boolean logic composite alert is triggered.

I can’t find an option to define a custom script.