Get started with Opsgenie as a user
Learn how to configure your profile, get notifications from Opsgenie and view on-call schedules.
Marid is deprecated and will be permanently retired on November 21st, 2022. Read the community post for more details.
If you never used our extensibility platform before, visit Opsgenie Edge Connector as an extensibility platform to find out how to run it with your Opsgenie account.
If you're using Marid and want to migrate to Opsgenie Edge Connector, visit Why should you migrate to Opsgenie Edge Connector.
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
Setting | Description | Mandatory | Default Value |
---|---|---|---|
maridKey | 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. | No | changeme |
HTTP Web Server Configuration Settings
Setting | Description | Mandatory | Default Value |
---|---|---|---|
https.server.enabled | Enable/disable HTTPS web server | Yes | false |
https.server.host | Https web server host | No | 127.0.0.1 |
https.server.port | Https web server port | No | 8443 |
https.server.maxContentLength | Maximum HTTPS request content length for each request. Requests with higher content length will be discarded by the web server. (in bytes) | No | 2000000 |
https.server.keystore | HTTPS server keystore file path | No | <MARID_HOME>/conf/.keystore |
https.server.keyPassword | HTTPS server keystore file password | No | 123456 |
https.server.threadpool.size | The maximum number of simultaneous HTTP connection | No | 100 |
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:
Parameter | Description |
---|---|
params | The map variable to access parameters passed by HTTP/S requests. |
request | HTTP request object. HTTP request content, headers, method, remoteAddress can be accessed via this parameter. |
response | HTTP response which will be returned. Response content, contentType and status code may be modified via this parameter. |
conf | A reference to configuration file properties. Every configuration property is accessible via this parameter. |
logger | Logging utility. All script logs will be written to script.log file in LOGS_DIR directory. |
opsgenie | The variable to execute an operation on opsgenie server. |
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.
Sample Usage:
Add following entry to configuration file:
sample.usage.prop1=prop1value
Set maridKey in configuration file as
maridKey=key1
URL to be Called via CURL
cURL
1
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.
Script File
<SCRIPTS_DIR>/HelloWorld.groovy
Groovy
1
2
3
4
5
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
Groovy
1
2
3
4
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
Expected Output
1
Hello yourself
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.
The webhook can be created at Opsgenie Webhook Integration page. For more information about Webhook Integration, see the support document.
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:
https://<marid_server>:<marid_port>/alert/action
and If maridKey configuration is set in configuration file, Webhook URL should be:
https://<marid_server>:<marid_port>/alert/action?maridKey=changeme
For the parameters that are passed to the alert action script, you can see this document.
Was this helpful?