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.

Thanks for you answer pablo

1 Like

Hi Mustapha,

I’m encountering the same issue. Were you able to find a workaround?
I also noticed that the ‘Preview condition response’ button is missing for the Composite Monitor’s trigger.

Hi Sid,
Yes, the preview condition button is missing for composite monitor.
From what i understood, composite Monitors are quite limited when it comes to defining custon script conditions.
In the end, i gave up on using the composite monitoring feature. Instead, i implemented an external script that retrieves the results of the monitors and handles the logic separately.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.