When trying to send data from OpenSearch to OpsGenie via a custom webhook - the ctx.alert data is not present, although it is included in the moustache template for the action message. There appears to be some kind of race condition between the alert being created in OpenSearch and sending the data to OpsGenie, whereby the payload is sent to OpsGenie before the alert has entered an active state in OpenSearch.
Related component
Plugins
To Reproduce
Create a Notification Channel of type "Custom WebHook"
Create a monitor in Alerting
Create a trigger for the monitor which will put the monitor into Alerting state
Create an action for the trigger which targets the Notification Channel created in step 1
In the "Message" text box for the trigger action, set the following moustache template:
{"message" : "alert data - {{ctx.alert}}", "priority": "P{{ctx.trigger.severity}}", "description": "{{ctx.monitor.name}} has been triggered", "alias":"{{ctx.trigger.name}}", "source": "OpenSearch"}
When the alert is triggered and sent to your custom webhook, check the JSON payload sent to the webhook
You will notice that the ctx.alert data is not sent.
Here is an example of the JSON payload I recieved on the opsgenie side for an active alert - paying particular attention to the "message" field, which should contain the ctx.alert data.
"_parsedData": { "note": "null", "-responders": [], "-actions": [], "-tags": [], "description": "MattIsTesting has been triggered", "alias": "Things are broken", "source": "OpenSearch", "message": "alert-", "priority": "P3", "user": "Alert API", "_extraProperties": {}, "entity": "" },
Expected behavior
I expect that the active ctx.alert JSON data would be sent to my custom webhook.
Describe the bug
When trying to send data from OpenSearch to OpsGenie via a custom webhook - the ctx.alert data is not present, although it is included in the moustache template for the action message. There appears to be some kind of race condition between the alert being created in OpenSearch and sending the data to OpsGenie, whereby the payload is sent to OpsGenie before the alert has entered an active state in OpenSearch.
Related component
Plugins
To Reproduce
{"message" : "alert data - {{ctx.alert}}", "priority": "P{{ctx.trigger.severity}}", "description": "{{ctx.monitor.name}} has been triggered", "alias":"{{ctx.trigger.name}}", "source": "OpenSearch"}
You will notice that the ctx.alert data is not sent.
Here is an example of the JSON payload I recieved on the opsgenie side for an active alert - paying particular attention to the "message" field, which should contain the ctx.alert data.
"_parsedData": { "note": "null", "-responders": [], "-actions": [], "-tags": [], "description": "MattIsTesting has been triggered", "alias": "Things are broken", "source": "OpenSearch", "message": "alert-", "priority": "P3", "user": "Alert API", "_extraProperties": {}, "entity": "" },
Expected behavior
I expect that the active ctx.alert JSON data would be sent to my custom webhook.
Additional Details
Plugins Alerting
Screenshots OpenSearch trigger action configuration:![Screenshot 2024-02-01 at 11 38 34](https://github.com/opensearch-project/OpenSearch/assets/38468576/ad020fed-266e-4d2f-a7fc-71bc6355419c)
Payload received by OpsGenie:![Screenshot 2024-02-01 at 11 39 02](https://github.com/opensearch-project/OpenSearch/assets/38468576/5fe0107e-dfd7-469e-98a7-0c46ef581714)
Host/Environment (please complete the following information):