opensearch-project / alerting

📟 Get notified when your data meets certain conditions by setting up monitors, alerts, and notifications
https://opensearch.org/docs/latest/monitoring-plugins/alerting/index/
Apache License 2.0
58 stars 99 forks source link

[BUG] ctx.alert data is not sent in JSON payload to custom webhook (OpsGenie) #1444

Open mattmooree opened 5 months ago

mattmooree commented 5 months ago

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

  1. Create a Notification Channel of type "Custom WebHook"
  2. Create a monitor in Alerting
  3. Create a trigger for the monitor which will put the monitor into Alerting state
  4. Create an action for the trigger which targets the Notification Channel created in step 1
  5. In the "Message" text box for the trigger action, set the following moustache template:
  6. {"message" : "alert data - {{ctx.alert}}", "priority": "P{{ctx.trigger.severity}}", "description": "{{ctx.monitor.name}} has been triggered", "alias":"{{ctx.trigger.name}}", "source": "OpenSearch"}
  7. 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.

Additional Details

Plugins Alerting

Screenshots OpenSearch trigger action configuration: Screenshot 2024-02-01 at 11 38 34

Payload received by OpsGenie: Screenshot 2024-02-01 at 11 39 02

Host/Environment (please complete the following information):

saratvemulapalli commented 4 months ago

@opensearch-project/triage can you transfer this issue to Alerting.