Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

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

Parameter
Limitation

message

Alert text limited to 130 character.

Optional Parameters

Parameter
Description

teams

List of teams which will be responsible for the alert. Team escalation policies are run to calculate which users will receive notifications.

alias

A 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.

description

To provide detailed information about the alert, limited to 15000 characters.

actions

A 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.

source

Field to specify source of alert. By default, it will be assigned to IP address of incoming request.

tags

A comma separated list of labels attached to the alert. You can overwrite Quiet Hours setting for urgent alerts by adding OverwriteQuietHours tag.

details

Set of user defined properties. This will be specified as a nested map such as "details" : { "prop1":"prop1Value" "prop2":"prop2Value" }

entity

The entity the alert is related to.

user

Default owner of the execution. If user is not specified, the owner of the account will be used.

note

Additional 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

Parameter
Description

requestId

Id 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

Parameter
Description

id

Id of the alert that will be closed.

alias

Alias of the alert that will be closed.

tinyId

Short 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the owner of the account will be used.

note

Additional alert note.

source

User defined field to specify source of close action.

Sample Request

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

Advanced Request

opsgenie.closeAlert(["alias":"demo","user":"user1@yourdomain.com","note":"closing demo alert"])

Delete Alert Request

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

Mandatory Parameters

Parameter
Description

id

Id of the alert that will be deleted.

alias

Alias of the alert that will be deleted.

tinyId

Short 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the owner of the account will be used.

source

User 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

Parameter
Description

id

Id of alert to be retrieved.

alias

Alias of alert to be retrieved.

tinyId

Short 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": "morpheus@opsgenie.com",
    "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": "agent_smith@opsgenie.com",
        "closedBy": "neo@opsgenie.com"
    ],
    "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

Parameter
Description

query

Search query to apply while filtering the alerts. You can refer Alerts Search Query Help for further information about search queries.

searchIdentifier

Identifier of the saved search query to apply while filtering the alerts.

searchIdentifierType

Identifier 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.

offset

Start index of the result set (to apply pagination). Minimum value (and also default value) is 0.

limit

Maximum number of items to provide in the result. Must be a positive integer value. Default value is 20 and maximum value is 100.

sort

Name 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

order

Sorting 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": "morpheus@opsgenie.com",
        "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": "agent_smith@opsgenie.com",
            "closedBy": "neo@opsgenie.com"
        ]
    ],
    [
        "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

Parameter
Description

id

Id of alert to be retrieved.

alias

Alias of alert to be retrieved.

tinyId

tinyId 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

Parameter
Description

offset

Starting value of the offset property.

direction

Page 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

limit

Maximum number of items to provide in the result. Must be a positive integer value. Default value is 20 and maximum value is 100.

order

Sorting 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": "neo@opsgenie.com",
            "createdAt": "2017-04-12T12:27:52.838Z",
            "offset": "1492000072838_1492000072838234593"
        ],
        [
            "log": "Viewed on [web]",
            "type": "alertRecipient",
            "owner": "trinity@opsgenie.com",
            "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

Parameter
Description

id

Id of alert to be retrieved.

alias

Alias of alert to be retrieved.

tinyId

tinyId 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": "neo@opsgenie.com"
            ],
            "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": "trinity@opsgenie.com"
            ],
            "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

Parameter
Description

id

Id of the alert to be retrieved.

alias

Alias of alert to be retrieved.

tinyId

Short 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

Parameter
Description

offset

Starting value of the offset property.

direction

Page 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

limit

Maximum number of items to provide in the result. Must be a positive integer value. Default value is 20 and maximum value is 100.

order

Sorting 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": "morpheus@opsgenie.com",
            "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": "merovingian@opsgenie.com",
            "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

Parameter
Description

id

Id of the alert that will be acknowledged.

alias

Alias of the alert that will be acknowledged.

tinyId

tinyId 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

Parameter
Description

user

Default owner of the execution. If user is not specified owner of account will be used.

note

Additional alert note.

source

User defined field to specify source of acknowledge action.

Sample Request

opsgenie.acknowledge(["id":"123", "user":"user1@yourdomain.com"])

UnAcknowledge Request

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

Mandatory Parameters

Parameter
Description

id

Id of the alert that will be un-acknowledged.

alias

Alias of the alert that will be un-acknowledged.

tinyId

Short 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the system becomes owner of the execution.

note

Additional alert note.

source

User 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

Parameter
Description

id

Id of the alert that will be snoozed.

alias

Alias of the alert that will be snoozed.

tinyId

short id assigned to the alert. All requests supports tinyId but using this field is not recommended because it rolls.

endDate

The 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the system becomes owner of the execution.

note

Additional alert note.

source

User 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

id

Id of the alert that will be acknowledged.

alias

Alias of the alert that will be acknowledged.

tinyId

tinyId 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

Parameter
Description

recipients

The user names of individual users or groups. If not specified alert recipients will be renotified.

user

Default owner of the execution. If user is not specified owner of account will be used.

note

Additional alert note.

source

User 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

id

Id of the alert whose ownership will be taken.

alias

Alias of the alert whose ownership will be taken.

tinyId

tinyId 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

Parameter
Description

user

Default owner of the execution. If user is not specified owner of account will be used.

note

Additional alert note.

source

User defined field to specify source of takeownership action.

Sample Request

opsgenie.takeOwnership(["id":"123", "user":"user2@yourdomain.com"])

Count Alerts Request

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

Mandatory Parameters

Parameter
Description

apiKey

API key is used for authenticating API requests.

Optional Parameters

Parameter
Description

createdAfter

Unix timestamp value which is converted to nano second. Request will return all alerts which are created after specified time.

createdBefore

Unix timestamp value which is converted to nano second. Request will return all alerts which are created before specified time.

updatedAfter

Unix timestamp value which is converted to nano second. Request will return all alerts which are updated after specified time.

updatedBefore

Unix timestamp value which is converted to nano second. Request will return all alerts which are updated before specified time.

limit

For performance reasons, the desired result is to limit that count. Max: 100000, default: 100000

status

Used to query alerts with specified status. May take one of open, acked, unacked, seen, notseen, closed

tags

A comma separated list of labels attached to the alert such as "tag1, tag2"

tagsOperator

tags 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

Parameter
Description

id

Id of the alert that will be assigned.

alias

Alias of the alert that will be assigned.

tinyId

tinyId of alert.

owner

User 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the owner of the account will be used.

note

Additional alert note.

source

User 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

Parameter
Description

id

Id of the alert that the new team will be added.

alias

Alias of the alert that the new team will be added.

tinyId

tinyId of alert.

team

Team 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the owner of the account will be used.

note

Additional alert note.

source

User 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

Parameter
Description

id

Id of the alert that the new recipient will be added.

alias

Alias of the alert that the new recipient will be added.

tinyId

tinyId of alert.

recipient

The 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the owner of the account will be used.

note

Additional alert note.

source

User defined field to specify source of add recipient action.

Sample Request

opsgenie.addRecipient(["id":"123", "recipient":"newRecipient@yourdomain.com"])

Add Tags Request

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

Mandatory Parameters

Parameter
Description

id

Id of the alert that new tags will be added.

alias

Alias of the alert that new tags will be added.

tinyId

tinyId of alert.

tags

List 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the owner of the account will be used.

note

Additional alert note.

source

User 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

Parameter
Description

id

Id of the alert given tags will be removed.

alias

Alias of the alert given tags will be removed.

tinyId

tinyId of alert.

tags

List 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the owner of the account will be used.

note

Additional alert note.

source

User 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

Parameter
Description

id

Id of the alert that details will be added.

alias

Alias of the alert that details will be added.

tinyId

Short id assigned to the alert. All requests supports tinyId but using this field is not recommended because it rolls.

details

Set 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the system becomes owner of the execution.

source

User defined field to specify source of add details action.

note

Additional 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

Parameter
Description

id

Id of the alert that details properties will be removed from.

alias

Alias of the alert that details properties will be removed from.

tinyId

Short id assigned to the alert. All requests supports tinyId but using this field is not recommended because it rolls.

keys

List 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the system becomes owner of the execution.

source

User defined field to specify source of remove details action.

note

Additional 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

Parameter
Description

id

Id of the alert that note will be added.

alias

Alias of the alert that note will be added.

tinyId

tinyId of alert.

note

Note 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the owner of the account will be used.

source

User 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

Parameter
Description

id

Id of the alert that action will be executed for.

alias

Alias of the alert that action will be executed for.

tinyId

tinyId of alert.

action

Action 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the owner of the account will be used.

note

Additional alert note.

source

User 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

Parameter
Description

id

Id of the alert that attachment will be added.

alias

Alias of the alert that attachment will be added.

tinyId

tinyId of alert.

attachment

Attachment 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

Parameter
Description

user

Default owner of the execution. If user is not specified owner of account will be used.

source

User defined field to specify source of attach action.

indexFile

Name 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.

note

Additional 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

Parameter
Description

id

Id of the alert that details will be added.

alias

Alias of the alert that details will be added.

tinyId

Short id assigned to the alert. All requests supports tinyId but using this field is not recommended because it rolls.

escalation

Escalation 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

Parameter
Description

user

Default owner of the execution. If user is not specified, the system becomes owner of the execution.

note

Additional alert note.

source

User 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

Parameter
Description

name

Unique name of the saved search. Maximum length is 100 characters.

query

Search query to be used while filtering the alerts. Maximum length is 1000 characters.

owner

User that will be assigned as owner of the saved search. Saved searches are always accessible to their owners.

Optional Parameters

Parameter
Description

description

Informational description of the saved search. Maximum length is 15000 characters.

teams

Teams 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":"owner@opsgenie.com"]])

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

Parameter
Description

name

Unique name of the saved search. Maximum length is 100 characters.

id

Unique 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

Parameter
Description

name

Unique name of the saved search. Maximum length is 100 characters.

id

Unique 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()

Script Proxy for Marid