• Products
  • Get started
  • Documentation
  • Resources

Migrate Marid groovy scripts to Opsgenie Edge Connector

OEC does not execute Groovy scripts like Marid because OEC does not need a Java environment to work. Default groovy scripts for integrations written for Marid were replaced with Python scripts for OEC. So, we strongly recommend you to use Python scripts instead of Groovy if you are using default scripts, since Marid’s default groovy scripts are deprecated and will no longer be maintained.

However, if you still have to use your custom Groovy scripts which are for Marid, you can use migration package written for adapting legacy Groovy scripts with OEC. This package provides dependencies which are used by Marid to you.

If you don't have to use legacy Groovy scripts using Marid dependencies, using this adapter script is not recommended. Instead, you can follow regular installation steps. The aim of the migration is to support using your old custom Groovy scripts specifically. Please consider that identical built-in Python scripts exist in each OEC supported integration package.

Since the executor is basically a Groovy script, the requirements for executor.groovy are JVM (version 1.8 or above) and Groovy (Version 2.x.x and above)

If you do not have JAVA_HOME environment variable set or are not sure please follow this guide https://docs.opsgenie.com/docs/setting-java_home

OEC requires Groovy to be in PATH

On Linux the quick solution

Create a symbolic link from /bin/groovy to the groovy binary in your Groovy installation path's "bin" directory.

For the purpose of this example, let us assume that you installed Groovy in /opt/groovy/groovy-2.5.8 then the command to create the symbolic link is:

ln -s /opt/groovy/groovy-2.5.8/bin/groovy /bin/groovy

On Windows the quick solution

Use the Windows Installer provided on the Groovy https://groovy.apache.org/download.html

While installing make sure "Modify Variables" is checked on the "Choose Components" page. Then on the "Environment" page of the installer, there are 3 tick boxes "Create GROOVY_HOME", "Add to Path" and "Add to System Environment" make sure that all 3 boxes are ticked.

In order to use the package, you can follow these steps:

  1. Follow OEC installation steps first.

  2. Download and unzip migration package which allows you to execute your custom Groovy script in OEC as Marid does.

  3. Edit OEC configuration file to execute your custom scripts.

Do not use globalFlags or flags parameters in OEC config.

If you include globalFlags or flags in your config.json/yaml it will fail to pass the arguments to executor.groovy. You should rather pass additional properties from your Marid config located either /etc/opsgenie/conf/opsgenie-integration.conf or /etc/opsgenie/conf/marid.conf use this format:

[ProductName].[PropertyName]=[Value]

For example, if I want to pass my Jira instance URL to groovy, I would declare it as:

jira.url=https://example.atlassian.net

For your custom scripts to be executed on OEC, you should put your custom script’s path to globalArgs field and add executor.groovy’s path to actionMappings → mappedAction → filepath field on OEC configuration file.

Example

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 appName: Test apiKey: xxxxx-xxxx-xxxx-xxxx logLevel: debug globalArgs: ["/Users/userName/customScript.groovy"] actionMappings: Acknowledge: sourceType: local filepath: "/Users/userName/executor.groovy" stdout: "/Users/userName/customOut.txt" stderr: "/Users/userName/customErr.txt" Close: sourceType: local filepath: "/Users/userName/executor.groovy" stdout: "/Users/userName/customOut.txt" stderr: "/Users/userName/customErr.txt"

If you want to execute different scripts for each action, you can put your custom script’s path to actionMappings → mappedAction → args field and leave empty globalArgs field.

Example

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 appName: Test apiKey: xxxxx-xxxx-xxxx-xxxx logLevel: debug actionMappings: Acknowledge: sourceType: local filepath: "/Users/userName/executor.groovy" args: ["/Users/userName/customScript1.groovy"] stdout: "/Users/userName/customOut.txt" stderr: "/Users/userName/customErr.txt" Close: sourceType: local filepath: "/Users/userName/executor.groovy" args: ["/Users/userName/customScript2.groovy"] stdout: "/Users/userName/customOut.txt" stderr: "/Users/userName/customErr.txt"

Migration package includes:

  • executor.groovy reads Marid configuration files instead of OEC configuration files and Marid’s configuration locations are /etc/opsgenie/conf/opsgenie-integration.conf/etc/opsgenie/conf/marid.conf.

  • log4jconfig.groovy keeps the log properties in itself which is used by the custom Groovy script

  • build (directory) which has several .jar files.

If you want to use Marid's script proxy functionality, you can use our Go SDK.

 

Last modified on Mar 30, 2021
Cached at 8:47 AM on Aug 5, 2021 |

Additional Help

Ask the Community