Marid has an embedded web server and can be used to receive and process web requests (HTTP/HTTPS) from external systems such as Amazon SNS and Opsgenie.
Install Marid by referring to Overview & Installation document.
Configuration parameters when using Marid to execute script via web requests are:
Script Directories (Will be referred as SCRIPTS_DIR in the rest of documentation)
- On Linux: /var/opsgenie/marid/scripts
- On Windows: <MARID_HOME>/scripts
Script Executor Configuration
Marid key is used to authorize incoming script execution request and value can be any custom token. If not specified, no authorization will be done. If set, script url should be called with maridKey parameter and the value should be the same in configuration file.
HTTP Web Server Configuration Settings
Enable/disable HTTPS web server
Https web server host
Https web server port
Maximum HTTPS request content length for each request. Requests with higher content length will be discarded by the web server. (in bytes)
HTTPS server keystore file path
HTTPS server keystore file password
The maximum number of simultaneous HTTP connection
Script reloading is automatically handled by Marid: After a script file is changed on the next run Marid will use the latest version regardless of Marid run state.
Marid executes the groovy or ruby scripts via web server /script/<script_file_name> URL. Marid executes the script file specified in URL for each web request. It will determine the script engine via script file extension.
For example if the URL is:
https://<server>:<port>/script/HelloWorld.groovy then Groovy scripting engine executes the specified script. If maridKey configuration is set in configuration file, it should be passed with the HTTP request to successfully execute it. Following parameters are passed to script by default:
The map variable to access parameters passed by HTTP/S requests.
HTTP request object. HTTP request content, headers, method, remoteAddress can be accessed via this parameter.
HTTP response which will be returned. Response content, contentType and status code may be modified via this parameter.
A reference to configuration file properties. Every configuration property is accessible via this parameter.
Logging utility. All script logs will be written to script.log file in LOGS_DIR directory.
The variable to execute an operation on opsgenie server.
Please refer to Script Proxy for Marid documentation for a list of available operations.
Parameters are passed as global variables to Ruby scripts hence they should be accessed as $parameter_name. For example, logger parameter can be accessed as $logger in Ruby script.
Add following entry to configuration file:
Set maridKey in configuration file as
URL to be Called via CURL
curl -XPOST 'http://<marid_server>:<marid_port>/script/HelloWorld.groovy?maridKey=key1¶m1=value1¶m2=value2' -d 'content data'
Marid supports async script execution, which can be used by adding async=true http parameter in run script url.
logger.warn(params.param1) logger.warn(params.param2) logger.warn(request.content) logger.warn(conf["sample.usage.prop1"]) response.content = "Hello yourself"
Expected Output in Log File <LOGS_DIR>/Script.log
12/06/18 16:44:08.288 WARN: value1 12/06/18 16:44:08.288 WARN: value2 12/06/18 16:44:08.292 WARN: content data 12/06/18 16:44:08.298 WARN: prop1value
Expected curl Output
Opsgenie can call a web-accessible URL endpoint and pass action data (what's often referred to as webhooks). Webhook URL can be any platform, web server, etc. as long as the URL is accessible from the Web.
Thanks to the script execution capabilities described above, Marid can be used to receive and process the web request from Opsgenie. Marid has a built-in awareness of Opsgenie user actions, hence can be configured easily. When Marid is used to process Opsgenie user actions, the Webhook URL of the Webhook Integration should be:
and If maridKey configuration is set in configuration file, Webhook URL should be:
For the parameters that are passed to the alert action script, you can see this document.