Script Proxy for Marid

Marid is an open source tool provided by Opsgenie, it supports Groovy & Ruby scripting. Normally Opsgenie Java API methods can be directly used within Marid scripts. Opsgenie also provides a special proxy to easily execute actions against Opsgenie Web API :

  • A special variable named opsgenie is available to Marid scripts
  • Calls to opsgenie is converted to Java API calls, Java API calls communicate with Web API
  • Using opsgenie is much easier then using Java API methods, less code more work
  • Almost all Web API features available in ScriptProxy
  • opsgenie can be used by both Groovy & Ruby scripts.
  • opsgenie variable is an instance of com.ifountain.opsgenie.client.script.util.ScriptProxy
  • ScriptProxy source code can be found at OpsgenieClient Github pages
  • To store in memory shared data, use static methods of com.ifountain.opsgenie.client.marid.MemoryStore class. To get more information, please refer to Memory Store section.

🚧

user parameter is optional when using script proxy. If not provided, it uses the user in the conf file.

Other API Requests

Create Alert Request

Create alert request is used to create alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterLimitation
messageAlert text limited to 130 character.

Optional Parameters

ParameterDescription
teamsList of teams which will be responsible for the alert. Team escalation policies are run to calculate which users will receive notifications.
aliasA user defined identifier for the alert and there can be only one alert with open status with the same alias. Provides ability to assign a known id and later use this id to perform additional actions such as log, close, attach for the same alert.
descriptionTo provide detailed information about the alert, limited to 15000 characters.
actionsA comma separated list of actions that can be executed. Custom actions can be defined to enable users to execute actions for each alert. If action callback URL is specified on Settings page of customer, that callback URL will be called when action is executed.
sourceField to specify source of alert. By default, it will be assigned to IP address of incoming request.
tagsA comma separated list of labels attached to the alert. You can overwrite Quiet Hours setting for urgent alerts by adding OverwriteQuietHours tag.
detailsSet of user defined properties. This will be specified as a nested map such as "details" : { "prop1":"prop1Value" "prop2":"prop2Value" }
entityThe entity the alert is related to.
userDefault owner of the execution. If user is not specified, the owner of the account will be used.
noteAdditional alert note.

Sample Request

opsgenie.createAlert(["message":"Sample Alert","note":"Alert note"])

Sample Advanced Request

opsgenie.createAlert([
        "message":"Sample Alert",
        "teams":[["id":"4513b7ea-3b91-438f-b7e4-e3e54af9147c"],["name":"rocket_team"]],
        "description":"for demo usage",
        "alias":"demo",
        "tags":["demo","sample"],
        "actions":["ping"]
])

Get Request Status Request

Get request status request is used to query the status of the request made to Opsgenie. Because some requests (e.g. Create Alert) made async, you can use this to query the status of the request after making it. It takes the following parameters:

Mandatory Parameters

ParameterDescription
requestIdId of the request which is given in the response of the request that you want to query.

Sample Request

opsgenie.getRequestStatus(["id":"8418d193-2dab-4490-b331-8c02cdd196b7"])

Response ( Groovy Map ) :

[
    "data": [
        "success": true,
        "action": "Create",
        "processedAt": "2017-05-24T14:24:20.844Z",
        "integrationId": "c9cec2cb-e782-4ebb-bc1d-1b2fa703cf03",
        "isSuccess": true,
        "status": "Created alert",
        "alertId": "8743a1b2-11da-480e-8493-744660987bef",
        "alias": "8743a1b2-11da-480e-8493-744660987bef"
    ],
    "took": 0.022,
    "requestId": "ec7e1d8e-1c75-442e-a271-731070a7fa4d"
]

Close Alert Request

Close alert request is used to close open alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that will be closed.
aliasAlias of the alert that will be closed.
tinyIdShort id assigned to the alert.

🚧

One of id, alias or tinyId parameters should be specified with close alert request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the owner of the account will be used.
noteAdditional alert note.
sourceUser defined field to specify source of close action.

Sample Request

opsgenie.closeAlert(["id":"123"])

Advanced Request

opsgenie.closeAlert(["alias":"demo","user":"[email protected]","note":"closing demo alert"])

Delete Alert Request

Delete alert request is used to delete alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that will be deleted.
aliasAlias of the alert that will be deleted.
tinyIdShort id assigned to the alert.

🚧

One of id, alias or tinyId parameters should be specified with delete alert request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the owner of the account will be used.
sourceUser defined field to specify source of delete action.

Sample Request

opsgenie.deleteAlert(["id":"123"])

Get Alert Request

Get alert request is used to search and retrieve alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of alert to be retrieved.
aliasAlias of alert to be retrieved.
tinyIdShort id assigned to the alert.

🚧

One of id, alias or tinyId parameters should be specified with get alert request. Alias option can only be used for open alerts.

Sample request to retrieve a single alert

opsgenie.getAlert(["id":"123"])
opsgenie.getAlert(["alias":"demo"])

Response ( Groovy Map ) :

[
    "id": "70413a06-38d6-4c85-92b8-5ebc900d42e2",
    "tinyId": "1791",
    "alias": "event_573",
    "message": "Our servers are in danger",
    "status": "closed",
    "acknowledged": false,
    "isSeen": true,
    "tags": [
        "OverwriteQuietHours",
        "Critical"
    ],
    "snoozed": true,
    "snoozedUntil": "2017-04-03T20:32:35.143Z",
    "count": 79,
    "lastOccurredAt": "2017-04-03T20:05:50.894Z",
    "createdAt": "2017-03-21T20:32:52.353Z",
    "updatedAt": "2017-04-03T20:32:57.301Z",
    "source": "Isengard",
    "owner": "[email protected]",
    "priority": "P5",
    "teams": [
        [
            "id": "8418d193-2dab-4490-b331-8c02cdd196b7"
        ],
        [
            "id": "43a29c5c-3dbf-4fa4-9c26-f4f71023e120"
        ]
    ],
    "integration": [
        "id": "4513b7ea-3b91-438f-b7e4-e3e54af9147c",
        "name": "Nebuchadnezzar",
        "type": "API"
    ],
    "report": [
        "ackTime": 15702,
        "closeTime": 60503,
        "acknowledgedBy": "[email protected]",
        "closedBy": "[email protected]"
    ],
    "actions": ["Restart", "Ping"],
    "entity": "EC2",
    "description": "Example description",
    "details": [
        "serverName": "Zion",
        "region": "Oregon"
    ]
]

List Alerts Request

List alerts request is used to list alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

Parameter
There is no mandatory parameter.

Optional Parameters

ParameterDescription
querySearch query to apply while filtering the alerts. You can refer Alerts Search Query Help for further information about search queries.
searchIdentifierIdentifier of the saved search query to apply while filtering the alerts.
searchIdentifierTypeIdentifier type of the saved search query. Possible values are id and name. Default value is id. If searchIdentifier is not provided, this value is ignored.
offsetStart index of the result set (to apply pagination). Minimum value (and also default value) is 0.
limitMaximum number of items to provide in the result. Must be a positive integer value. Default value is 20 and maximum value is 100.
sortName of the field that result set will be sorted by. Default value is createdAt. Possible values are specified below:
createdAt
updatedAt
tinyId
alias
message
status
acknowledged
isSeen
snoozed
snoozedUntil
count
lastOccurredAt
source
owner
integration.name
integration.type
report.ackTime
report.closeTime
report.acknowledgedBy
report.closedBy
orderSorting order of the result set. Possible values are desc and asc. Default value is desc.
desc: Sort result set in descending order
asc: Sort result set in ascending order

**Sample requests to retrieve list of alerts

retrieve the last 20 alerts (20 is the default for limit, 100 is the max for limit)**

opsgenie.listAlerts([:]).each{ alert ->
    logger.warn("Found alert ${alert.message}");
}

retrieve the last 10 closed alerts

opsgenie.listAlerts(["limit":10,"query":"status:open"])

Response ( Groovy List of Map ) :

[
    [
        "id": "70413a06-38d6-4c85-92b8-5ebc900d42e2",
        "tinyId": "1791",
        "alias": "event_573",
        "message": "Our servers are in danger",
        "status": "closed",
        "acknowledged": false,
        "isSeen": true,
        "tags": [
            "OverwriteQuietHours",
            "Critical"
        ],
        "snoozed": true,
        "snoozedUntil": "2017-04-03T20:32:35.143Z",
        "count": 79,
        "lastOccurredAt": "2017-04-03T20:05:50.894Z",
        "createdAt": "2017-03-21T20:32:52.353Z",
        "updatedAt": "2017-04-03T20:32:57.301Z",
        "source": "Isengard",
        "owner": "[email protected]",
        "priority": "P4",
        "teams": [
            [
                "id": "8418d193-2dab-4490-b331-8c02cdd196b7"
            ],
            [
                "id": "43a29c5c-3dbf-4fa4-9c26-f4f71023e120"
            ]
        ],
        "integration": [
            "id": "4513b7ea-3b91-438f-b7e4-e3e54af9147c",
            "name": "Nebuchadnezzar",
            "type": "API"
        ],
        "report": [
            "ackTime": 15702,
            "closeTime": 60503,
            "acknowledgedBy": "[email protected]",
            "closedBy": "[email protected]"
        ]
    ],
    [
        "id": "70413a06-38d6-4c85-92b8-5ebc900d42e2",
        "tinyId": "1791",
        "alias": "event_573",
        "message": "Life is too short for shitty software",
        "status": "open",
        "acknowledged": false,
        "isSeen": false,
        "tags": [
            "RandomTag"
        ],
        "snoozed": false,
        "count": 1,
        "lastOccurredAt": "2017-03-21T20:32:52.353Z",
        "createdAt": "2017-03-21T20:32:52.353Z",
        "updatedAt": "2017-04-03T20:32:57.301Z",
        "source": "Zion",
        "owner": "",
        "priority": "P5",
        "teams": [],
        "integration": [
            "id": "4513b7ea-3b91-b7e4-438f-e3e54af9147c",
            "name": "My_Lovely_Amazon",
            "type": "CloudWatch"
        ]
    ]
]

List Alert Logs Request

List alert logs request is used to retrieve alert logs in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of alert to be retrieved.
aliasAlias of alert to be retrieved.
tinyIdtinyId of alert.

🚧

One of id, alias or tinyId parameters should be specified with list alert logs request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
offsetStarting value of the offset property.
directionPage direction to apply for the given offset. Possible values are next and prev. Default value is next.
next: Offset values of provided logs should be greater than the given offset
prev: Offset values of provided logs should be less than the given offset
limitMaximum number of items to provide in the result. Must be a positive integer value. Default value is 20 and maximum value is 100.
orderSorting order of the result set. Possible values are desc and asc. Default value is desc.
desc: Sort result set in descending order
asc: Sort result set in ascending order

*Sample request to retrieve a single alert

opsgenie.listAlertLogs(["id":"123"])

Response:

[
    "logs": [
        [
            "log": "Alert acknowledged via web",
            "type": "system",
            "owner": "[email protected]",
            "createdAt": "2017-04-12T12:27:52.838Z",
            "offset": "1492000072838_1492000072838234593"
        ],
        [
            "log": "Viewed on [web]",
            "type": "alertRecipient",
            "owner": "[email protected]",
            "createdAt": "2017-04-12T12:27:46.379Z",
            "offset": "1492000066378_1492000066379000127"
        ]
    ],
    "requestId": "174abe1b-e2a8-48d6-a747-05f012760988",
    "took": 0.456,
    "paging": [
        "next": "https://api.opsgenie.com/v2/alerts/ee624ed0-3ee0-45be-9c9d-e7667eaf21e5/logs?identifierType=id&offset=1492000072838_1492000072838234593&direction=next&limit=2&order=desc",
        "first": "https://api.opsgenie.com/v2/alerts/ee624ed0-3ee0-45be-9c9d-e7667eaf21e5/logs?identifierType=id&limit=2&order=desc"
    ]
]

List Alert Recipients Request

List alert recipients request is used to retrieve alert recipeints in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of alert to be retrieved.
aliasAlias of alert to be retrieved.
tinyIdtinyId of alert.

🚧

One of id, alias or tinyId parameters should be specified with get alert request. Alias option can only be used for open alerts.

Sample request to retrieve a single alert

opsgenie.listAlertRecipients(["id":"123"])

Response:

[
    "users": [
        [
            "user": [
                "id": "2503a523-8ba5-4158-a4bd-7850074b5cca",
                "username": "[email protected]"
            ],
            "state": "action",
            "method": "Acknowledge",
            "createdAt": "2017-04-12T12:27:28.52Z",
            "updatedAt": "2017-04-12T12:27:52.86Z"
        ],
        [
            "user": [
                "id": "0966cfd8-fc9a-4f5c-a013-7d1f9318aef8",
                "username": "[email protected]"
            ],
            "state": "notactive",
            "method": "",
            "createdAt": "2017-04-12T12:27:28.571Z",
            "updatedAt": "2017-04-12T12:27:28.589Z"
        ]
    ],
    "took": 0.306,
    "requestId": "d90a7fb5-f5b6-4e1a-a1d1-0a37bded6a32"
]

List Alert Notes Request

List alert notes request is used to retrieve alert notes in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert to be retrieved.
aliasAlias of alert to be retrieved.
tinyIdShort id assigned to the alert. All requests supports tinyId but using this field is not recommended because it rolls.

🚧

One of id, alias or tinyId parameters should be specified with list alert notes request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
offsetStarting value of the offset property.
directionPage direction to apply for the given offset. Possible values are next and prev. Default value is next.
next: Offset values of provided logs should be greater than the given offset
prev: Offset values of provided logs should be less than the given offset
limitMaximum number of items to provide in the result. Must be a positive integer value. Default value is 20 and maximum value is 100.
orderSorting order of the result set. Possible values are desc and asc. Default value is desc.
desc: Sort result set in descending order
asc: Sort result set in ascending order

Sample Request

opsgenie.listAlertNotes(["id" : "123"])

Response:

[
    "notes": [
        [
            "note": "This is your last chance. After this, there is no turning back. You take the
  blue pill—the story ends, you wake up in your bed and believe whatever you want to believe. You
  take the red pill—you stay in Wonderland and I show you how deep the rabbit-hole goes.",
            "owner": "[email protected]",
            "createdAt": "2017-04-12T13:36:21.874Z",
            "offset": "1492004181874000155"
        ],
        [
            "note": "You see there is only one constant. One universal. It is the only real truth: Causality. Action, reaction. Cause and effect.",
            "owner": "[email protected]",
            "createdAt": "2017-04-12T13:36:18.098Z",
            "offset": "1492004178098000065"
        ]
    ],
    "requestId": "fbbd807d-6024-4572-8d51-bd4a047617d0",
    "took": 0.278,
    "paging": [
        "next": "https://api.opsgenie.com/v2/alerts/ee624ed0-3ee0-45be-9c9d-e7667eaf21e5/notes?identifierType=id&offset=1492004181874000155&direction=next&limit=2&order=desc",
        "first": "https://api.opsgenie.com/v2/alerts/ee624ed0-3ee0-45be-9c9d-e7667eaf21e5/notes?identifierType=id&limit=2&order=desc"
    ]
]

Acknowledge Request

Acknowledge request is used to acknowledge alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that will be acknowledged.
aliasAlias of the alert that will be acknowledged.
tinyIdtinyId of alert.

🚧

One of id, alias or tinyId parameters should be specified with get alert request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified owner of account will be used.
noteAdditional alert note.
sourceUser defined field to specify source of acknowledge action.

Sample Request

opsgenie.acknowledge(["id":"123", "user":"[email protected]"])

UnAcknowledge Request

UnAcknowledge request is used to revert back the alert state to un-acknowledged. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that will be un-acknowledged.
aliasAlias of the alert that will be un-acknowledged.
tinyIdShort id assigned to the alert. All requests supports tinyId but using this field is not recommended because it rolls.

🚧

One of id, alias or tinyId parameters should be specified with un-acknowledge alert request.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the system becomes owner of the execution.
noteAdditional alert note.
sourceUser defined field to specify source of unacknowledge action.

Sample Request

opsgenie.unAcknowledge(["id" : "123"])

Snooze Request

Snooze request is used to snooze alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that will be snoozed.
aliasAlias of the alert that will be snoozed.
tinyIdshort id assigned to the alert. All requests supports tinyId but using this field is not recommended because it rolls.
endDateThe date and time snooze will end.

🚧

One of id, alias or tinyId parameters should be specified with snooze alert request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the system becomes owner of the execution.
noteAdditional alert note.
sourceUser defined field to specify source of snooze action.

Sample Request

opsgenie.snooze(["id" : "123", "endDate" : new Date("11/16/2016 08:00")])

Renotify Request

Renotify request is used to renotify recipients about specified alert in Opsgenie. It takes the following parameters:

Mandatory Parameters

idId of the alert that will be acknowledged.
aliasAlias of the alert that will be acknowledged.
tinyIdtinyId of alert.

🚧

One of id, alias or tinyId parameters should be specified with renotify alert request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
recipientsThe user names of individual users or groups. If not specified alert recipients will be renotified.
userDefault owner of the execution. If user is not specified owner of account will be used.
noteAdditional alert note.
sourceUser defined field to specify source of renotify action.

Sample Request

opsgenie.renotify(["id":"123"])

Take Ownership Request

Take ownership request is used to take the ownership of the alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

idId of the alert whose ownership will be taken.
aliasAlias of the alert whose ownership will be taken.
tinyIdtinyId of alert.

🚧

One of id, alias or tinyId parameters should be specified with take ownership request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified owner of account will be used.
noteAdditional alert note.
sourceUser defined field to specify source of takeownership action.

Sample Request

opsgenie.takeOwnership(["id":"123", "user":"[email protected]"])

Count Alerts Request

Count alerts request is used to counts alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
apiKeyAPI key is used for authenticating API requests.

Optional Parameters

ParameterDescription
createdAfterUnix timestamp value which is converted to nano second. Request will return all alerts which are created after specified time.
createdBeforeUnix timestamp value which is converted to nano second. Request will return all alerts which are created before specified time.
updatedAfterUnix timestamp value which is converted to nano second. Request will return all alerts which are updated after specified time.
updatedBeforeUnix timestamp value which is converted to nano second. Request will return all alerts which are updated before specified time.
limitFor performance reasons, the desired result is to limit that count. Max: 100000, default: 100000
statusUsed to query alerts with specified status. May take one of open, acked, unacked, seen, notseen, closed
tagsA comma separated list of labels attached to the alert such as "tag1, tag2"
tagsOperatortags are combined with tagsOperator like "tag1 and tag2" when filtered. Accepted values: and/or, default: and.

Sample Request

opsgenie.countAlerts(["status":"open"])

Assign Request

Assign request is used to assign the ownership of the alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that will be assigned.
aliasAlias of the alert that will be assigned.
tinyIdtinyId of alert.
ownerUser that the alert will be assigned to. Either id or username of the user should be provided.

🚧

One of id, alias or tinyId parameters should be specified with assign alert request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the owner of the account will be used.
noteAdditional alert note.
sourceUser defined field to specify source of assign action.

Sample Request

opsgenie.assign(["id":"123", "owner":["id":"4513b7ea-3b91-438f-b7e4-e3e54af9147c"]])

Add Team Request

Add team request is used to add a new team to alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that the new team will be added.
aliasAlias of the alert that the new team will be added.
tinyIdtinyId of alert.
teamTeam to route the alert. Either id or name of the team should be provided.

🚧

One of id, alias or tinyId parameters should be specified with add team request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the owner of the account will be used.
noteAdditional alert note.
sourceUser defined field to specify source of add team action.

Sample Request

opsgenie.addTeam(["id":"123", "team":["id":"4513b7ea-3b91-438f-b7e4-e3e54af9147c"]])

Add Recipient Request

Add recipient request is used to add new recipients(user or group) to alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that the new recipient will be added.
aliasAlias of the alert that the new recipient will be added.
tinyIdtinyId of alert.
recipientThe new recipient that will be added.

🚧

One of id, alias or tinyId parameters should be specified with REQUEST_NAME alert request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the owner of the account will be used.
noteAdditional alert note.
sourceUser defined field to specify source of add recipient action.

Sample Request

opsgenie.addRecipient(["id":"123", "recipient":"[email protected]"])

Add Tags Request

Add Tags request is used to add new tags to alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that new tags will be added.
aliasAlias of the alert that new tags will be added.
tinyIdtinyId of alert.
tagsList of tags will be added to the alert.

🚧

One of id, alias or tinyId parameters should be specified with add tags request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the owner of the account will be used.
noteAdditional alert note.
sourceUser defined field to specify source of add tags action.

Sample Request

opsgenie.addTags(["id":"123", "tags":["autoClose", "support"]])

Remove Tags Request

Remove Tags request is used to remove tags from alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert given tags will be removed.
aliasAlias of the alert given tags will be removed.
tinyIdtinyId of alert.
tagsList of tags will be removed from the alert.

🚧

One of id, alias or tinyId parameters should be specified with remove tags request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the owner of the account will be used.
noteAdditional alert note.
sourceUser defined field to specify source of remove tags action.

Sample Request

opsgenie.removeTags(["id":"123", "tags":["autoClose", "support"]])

Add Details Request

Add details request is used to add properties to alert details in Opsgenie. If you send an existing alert property's key, it overwrites the existing one. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that details will be added.
aliasAlias of the alert that details will be added.
tinyIdShort id assigned to the alert. All requests supports tinyId but using this field is not recommended because it rolls.
detailsSet of properties to be added to alert details.

🚧

One of id, alias or tinyId parameters should be specified with add details request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the system becomes owner of the execution.
sourceUser defined field to specify source of add details action.
noteAdditional alert note.

Sample Request

opsgenie.addDetails(["id" : "123", "details" : ["prop1" : "val1", "prop2" : "val2"]])

Remove Details Request

Remove details request is used to remove properties from alert details in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that details properties will be removed from.
aliasAlias of the alert that details properties will be removed from.
tinyIdShort id assigned to the alert. All requests supports tinyId but using this field is not recommended because it rolls.
keysList of keys of alert details properties.

🚧

One of id, alias or tinyId parameters should be specified with remove details request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the system becomes owner of the execution.
sourceUser defined field to specify source of remove details action.
noteAdditional alert note.

Sample Request

opsgenie.removeDetails(["id" : "123", "keys" : ["key1", "key2"]])

Add Note Request

Add note request is used to add notes to alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that note will be added.
aliasAlias of the alert that note will be added.
tinyIdtinyId of alert.
noteNote text.

🚧

One of id, alias or tinyId parameters should be specified with add note request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the owner of the account will be used.
sourceUser defined field to specify source of add note action.

Sample Request

opsgenie.addNote(["id":"123", "note":"Sample Note"]);

Execute Action Request

Execute action request is used to execute predefined actions on alerts in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that action will be executed for.
aliasAlias of the alert that action will be executed for.
tinyIdtinyId of alert.
actionAction to execute.

🚧

One of id, alias or tinyId parameters should be specified with execute action request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the owner of the account will be used.
noteAdditional alert note.
sourceUser defined field to specify source of action execution.

Sample Request

opsgenie.executeAlertAction(["id":"123", "action":"ping"])

Attach File Request

Attach file request is used to attach files to alerts in Opsgenie. It should be sent as multipart HTTP request. It takes the following parameters:

Mandatory Parameters

ParameterDescription
idId of the alert that attachment will be added.
aliasAlias of the alert that attachment will be added.
tinyIdtinyId of alert.
attachmentAttachment file content.

🚧

One of id, alias or tinyId parameters should be specified with attach file request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified owner of account will be used.
sourceUser defined field to specify source of attach action.
indexFileName of html file which will be shown when attachment clicked on UI.
If it is not specified, following rules will be applied by order to determine index file name
if it is not a zip file, it will be assigned to attachment file name
If it is a zip file, it will be assigned to
HTML file whose name equals attachment file name
index.htm or index.html file
the first HTML file found in the ZIP
If no HTML file exists, it will be assigned to attachment zip file name and zip file will be downloaded from Opsgenie web site directly when clicked on attachment.
noteAdditional alert note.

Sample Request

opsgenie.attach(["id":"123", "attachment":"sample.txt"])

Escalate To Next Request

Escalate to Next request is used to immediately process the next available available rule in the specified escalation. It takes the following parameters:

For more details see Escalate to Next documentation page
Mandatory Parameters

ParameterDescription
idId of the alert that details will be added.
aliasAlias of the alert that details will be added.
tinyIdShort id assigned to the alert. All requests supports tinyId but using this field is not recommended because it rolls.
escalationEscalation that the alert will be escalated. Either id or name of the escalation should be provided.

🚧

One of id, alias or tinyId parameters should be specified with escalate to next request. Alias option can only be used for open alerts.

Optional Parameters

ParameterDescription
userDefault owner of the execution. If user is not specified, the system becomes owner of the execution.
noteAdditional alert note.
sourceUser defined field to specify source of unacknowledge action.

Sample Request

opsgenie.escalateToNext(["id" : "123", "escalation":["name":"Operations_Escalation"]])

Create Saved Search Request

Create saved search request is used to create a new saved search query in Opsgenie. It takes the following parameters:
Mandatory Parameters

ParameterDescription
nameUnique name of the saved search. Maximum length is 100 characters.
querySearch query to be used while filtering the alerts. Maximum length is 1000 characters.
ownerUser that will be assigned as owner of the saved search. Saved searches are always accessible to their owners.

Optional Parameters

ParameterDescription
descriptionInformational description of the saved search. Maximum length is 15000 characters.
teamsTeams that saved search is assigned to. If a saved-search is assigned to at least one team, saved-search will only be accessible to the owner and members of the assigned teams. A saved-search can be assigned to at most 20 teams.

Sample Request

opsgenie.addSavedSearch(["name":"New Saved Search", "query":"status=Open", "owner":["username":"[email protected]"]])

Delete Saved Search Request

Delete saved search request is used to delete a saved search query in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
nameUnique name of the saved search. Maximum length is 100 characters.
idUnique ID of the saved search.

🚧

One of id or name parameters should be specified with delete saved search request.

Sample Request

opsgenie.deleteSavedSearch(["name":"My Saved Search"]])

Get Saved Search Request

Get saved search request is used to get a saved search query in Opsgenie. It takes the following parameters:

Mandatory Parameters

ParameterDescription
nameUnique name of the saved search. Maximum length is 100 characters.
idUnique ID of the saved search.

🚧

One of id or name parameters should be specified with get saved search request.

Sample Request

opsgenie.getSavedSearch(["id":"8418d193-2dab-4490-b331-8c02cdd196b7"]])

List Saved Search Request

List saved search request is used to list saved search queries in Opsgenie. It takes the following parameters:

Mandatory Parameters

Parameter
There is no mandatory parameter.

Sample Request

opsgenie.listSavedSearch([:]])

Response ( Groovy Map ) :

[
    "data": [
        [
            "id": "62dca743-bddc-4d17-99ab-6d8e0c066d1c",
            "name": "unacked alerts query"
        ],
        [
            "id": "3155ddd1-8d6c-438e-9cdd-28b31edca301",
            "name": "team apollo alerts"
        ],
        [
            "id": "d8b16789-3b71-48e4-9ff2-48a76a789137",
            "name": "Critical_Open_Alerts"
        ]
    ],
    "requestId": "fbd4a99d-aa05-4549-870d-02fa3d6395e5"
]

Memory Store

You may need to load data to memory and use it later action executions. Opsgenie Marid provides com.ifountain.opsgenie.client.marid.MemoryStore class to meet these needs.
Memory Store class has following helper methods:

Store

Store method adds data as key,value pair into the memory.

Example Usage

import com.ifountain.opsgenie.client.marid.MemoryStore

MemoryStore.store("prop1","val1")

Lookup

Lookup method checks the memory and retrieves the data with the given key if exists.

Example Usage

import com.ifountain.opsgenie.client.marid.MemoryStore

def prop = MemoryStore.lookup("prop1")

Remove

Remove method removes the data with the given key, if exists.

Example Usage

import com.ifountain.opsgenie.client.marid.MemoryStore

MemoryStore.remove("prop1")

Reset

Reset method clears the in memory data store.

Example Usage

import com.ifountain.opsgenie.client.marid.MemoryStore

MemoryStore.reset()