• Products
  • Get started
  • Documentation
  • Resources

Use alert callbacks

Opsgenie is fundamentally a router for IT alerts. Opsgenie receives alerts from operations management systems via email and API, notifies the right people using defined rules. Opsgenie also supports callbacks, and can forward alert activity (an alert is created, acknowledged, closed, etc.) to external systems.

Alert activity can be forwarded to any system that can process HTTP requests as webhooks. Marid Integration Server provided by Opsgenie can also be used to subscribe to alert activity and integrate Opsgenie with external systems.

1. Webhook Callbacks

Opsgenie can call a web accessible URL endpoint (what's often referred as webhooks) and pass alert activity data. URL endpoint can be any platform, web server, etc. as long as the URL is accessible from the Web. Webhook data includes the alert activity (create, acknowledge, etc.) as well as a subset of the alert fields (alertId, username, alias, entity, userId) as part of the HTTP request payload (JSON).

The webhook can be created via Opsgenie Webhook Integration. For more information about Webhook Integration, see the support document.


For example, when an alert is created, the following information would be passed as part of the HTTP request body.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 { "source": { "name": "mytool", "type": "api" }, "alert": { "message": "testing webhooks", "username": "fili@opsgenie.com", "alertId": "44f717bf-44bd-11c9-44c7-2d0cf1d07b23", "alias": "webhooktest", "tinyId": "454", "entity": "", "userId": "4caaaa77-9222-4322-8622-d3522fbd7dda" }, "action": "Create" }

The "action" field value can be "Create", "Acknowledge", "AddNote", "AssignOwnership", "Close", "Delete", or name of a custom action.

Note that, using Opsgenie Alert API get alert request, it is possible to retrieve other alert fields using alertId that is included in the webhook payload.

2. Marid Callbacks

​Marid Integration Server can subscribe to OpsGenie alert activity, and execute a script for each alert activity. The main difference of this method is that the connection to Opsgenie is initiated by Marid, hence Marid server does not have to be accessible from the web. This method does not require any firewall changes, opening ports, etc. since Marid communicates with Opsgenie via HTTPS and initiates the connection from inside out.

An image showing how a Marid callback works.

You need to install Marid to your system by referring to Marid installation steps

To use this option, create a Marid Integration, obtain apiKey and paste to Marid's configuration file.

After adding a Marid integration, you need to restart Marid if it is already running.

Marid executes a groovy or ruby script for each alert action. Marid searches <MARID_HOME>/scripts directory for a file whose name is same as action and execute that script with some parameters by default. For example if action "restart" is executed, Marid looks for <MARID_HOME>/scripts/restart.groovy or <MARID_HOME>/scripts/restart.rb and if the script exist, Marid executes the script automatically. In addition, actions to script mapping can be configured in Marid's configuration file. For example, if Marid is started with following configuration actions.restart.script=script1.groovy, for each restart action execution <MARID_HOME>/scripts/script1.groovy will be executed.




Default Value


Alert actions to script mapping configuration. If specified for each execution of alert action configured groovy or ruby script file located in <MARID_HOME>/scripts directory will be called.



Alert Action Script Parameters




The variable to access alert properties which action is executed for. alertId, username and properties like this may be accessed through this variable.


Name of executed action


A reference to configuration file properties. Every configuration property is accessible via this parameter.


Logging utility. All script logs will be written to <MARID_HOME>/logs/script.log file.


The variable to execute an operation on Opsgenie server. Please refer to Script Proxy for Marid documentation for a list of available operations.

Additional Help