Lamp: Command Line

Lamp is a Go based command line utility to interact with Opsgenie service. It provides capabilities to create and close alerts, attach files, etc..

Lamp is used to integrate any management tool that can execute a shell script with Opsgenie. Lamp interacts with the Opsgenie service through the RESTful Web API.

Lamp has a built in contextual help system for obtaining information on available commands, and available options for their use. If you invoke lamp with the --help option, you will see the available list of commands. If you invoke lamp with the --help option with a specific command, you will see the options for that command.

For ease of use apiKey should be set in conf file that lamp will use, for some flexible use cases --apiKey parameter can also be used when executing lamp commands.

📘

To migrate your Java based Lamp to Go Based Lamp you can refer to Migration Guide

Installation

Prerequisites:

  • Opsgenie account: If you don't already have one create an Opsgenie account
  • If you're downloading from source, Opsgenie Lamp requires Go version 1.12 or above. Golang can be downloaded from here. One should make sure the GOPATH and GOROOT variables are set accordingly.

OpsGenie Lamp is a Go-based command line utility and can be obtained in two ways:

Downloading with go get

  1. Lamp can be installed via the command: go get github.com/opsgenie/opsgenie-lamp/...

🚧

The go get command will produce an executable named "opsgenie-lamp", hence you should use "opsgenie-lamp" instead of "lamp" like following:

opsgenie-lamp createAlert --message "host down"

Downloading Lamp Zip

  1. Download Lamp Zip
  2. Download the Lamp version based on your operating system.
  • For Mac use opsgenie-lamp_X.X_darwin_amd64.zip

📘

*Internet Requirement : By default Lamp requires internet connection to reach Opsgenie.
If Lamp host server does not have internet connection you can configure Lamp Proxy settings, see below.

Configuration

Application Configuration

Lamp is able to use configuration files in different locations. There are several ways to do it, and methods have an order:

  1. If you want to use a configuration file located in a custom location, you can define it in your commands.If Lamp command contains --config parameter, it uses the given file as configuration.
opsgenie-lamp createAlert --message "host down" --config /opt/conf/myConfigurationFile.conf
  1. If there is no --config parameter defined, Lamp looks for an Environment variable: LAMP_CONF_PATH. If this environment variable is set, lamp uses the given file as configuration.
  2. If none of the methods given above works, Lamp uses the default {{USER_HOME}}/.config/lamp.conf file as configuration

You can reach the sample configuration here. The following are the common configuration settings for Lamp:

Lamp Configuration Settings

SettingDescriptionMandatoryDefault Value
apiKeyAPI key used for authenticating API requests.
API key can be obtained by adding an API Integration.

* Optionally --apiKey parameter can also be set when executing lamp commands, in this case the apiKey in the configuration file will not be used.
No-
apiUrlThe URL for the Opsgenie API. If you are in the EU instance, you'll want to set this to api.eu.opsgenie.com

For the sandbox, you'll use api.sandbox.opsgenie.com
Noapi.opsgenie.com
userDefault owner of the execution. If user is not specified for Lamp action this value will be used.No
requestTimeoutTotal timeout value of the request executed across Opsgenie server. Unit: secondNo30 Sec
logPathThis would enable logging to a file. Path where log files will be created.No

Lamp Proxy Configuration Settings

In order to use Lamp on systems that are behind firewalls do not have direct access to the Internet, you need to configure Lamp proxy settings to interact with Opsgenie web services API, create alerts, etc.

SettingDescriptionMandatoryDefault Value
proxyHostProxy hostYes-
proxyPortProxy portNo-
proxyUsernameProxy authentication usernameNo-
proxyPasswordProxy authentication passwordNo-
proxyProtocolProxy connection protocol. It may be one of http depending on your proxy servers.Nohttps

Create Alert Command

Lamp createAlert command is used to create alerts in OpsGenie. createAlert command takes the following parameters:

Mandatory Parameters

Parameter
--messageAlert text limited to 130 characters

Optional Parameters

Parameter
--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.
--actionsA comma separated list of actions that can be executed. Custom actions can be defined to enable users to execute actions for each alert. All action executions will be posted to Outgoing Integrations like Webhook, OEC, Slack, HipChat etc
--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.
--descriptionAlert text in long form. Unlike the message field, not limited to 130 characters.
-DAdditional alert properties. The syntax is -D =
--entityThe entity the alert is related to.
--priorityThe priority of alert. Values: P1, P2, P3, P4, P5 default is P3
--userOwner of execution
--noteAdditional alert note
--teamsA comma separated list of teams for setting responders
--usersA comma separated list of users for setting responders
--escalationsA comma separated list of escalations for setting responders
--schedulesA comma separated list of schedules for setting responders
--apiKeyAPI key used for authenticating API requests * If not given the api key in the conf file will be used
Optional API key is valid for all Lamp commands
--configFileLocation of a custom configuration file
-vExecute commands in verbose mode.

Sample Usage:

With mandatory parameters:

opsgenie-lamp createAlert --message "appserver1 down"

With optional parameters:

opsgenie-lamp createAlert --message "appserver1 down  --description "appserver1 is not responding to requests and reported as down by the monitoring tools"  --tags "operations, servers" --actions "stop, restart" -D severity=critical

With optional apiKey parameter :

opsgenie-lamp createAlert --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --message "appserver1 down"

With optional config and verbose parameter:

opsgenie-lamp createAlert -v --message "appserver1 down" --config "/opt/conf/myConfigurationFile.conf"

Close Alert Command

Lamp closeAlert command is close open alerts in OpsGenie. closeAlert command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'.

Optional Parameters

Parameter
--userOwner of execution
--noteAdditional alert note
--sourceSource of action

Sample Usage:

opsgenie-lamp closeAlert --id 44d2e383-df30-49e1-820e-65e8e6e6387f
opsgenie-lamp closeAlert --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --alias appserver3Down

Delete Alert Command

Lamp deleteAlert command is delete alerts in Opsgenie. deleteAlert command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.

Optional Parameters

Parameter
--userOwner of execution
--sourceSource of action

Sample Usage:

opsgenie-lamp deleteAlert --id 44d2e383-df30-49e1-820e-65e8e6e6387f

Get Alert Command

Lamp getAlert command is used to get alerts details from OpsGenie. getAlert command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.

Optional Parameters

Parameter
--output-formatRetrieved alert can be printed as JSON or YAML format. Default value is json
--prettyBoolean flag to print retrieved alert as pretty json

Sample Usage:

opsgenie-lamp getAlert --id 44d2e383-df30-49e1-820e-65e8e6e6387f
opsgenie-lamp getAlert --alias appserver3Down
opsgenie-lamp getAlert --id 44d2e383-df30-49e1-820e-65e8e6e6387f --output-format yaml
opsgenie-lamp getAlert --id 44d2e383-df30-49e1-820e-65e8e6e6387f --pretty

List Alerts Command

Lamp listAlerts command is used to list alerts details from Opsgenie. listAlerts command takes the following parameters:

Optional Parameters

ParameterDescription
--querySearch query to apply while filtering the alerts. More on Search queries for alerts
--limitPage size. Default is 20. Max value for this parameter is 100.
--sortBycreatedAt, updatedAt, default is createdAt
--offsetStart index of the result set (to apply pagination). Minimum value (and also default value) is 0
--orderasc/desc, default: desc
--searchIdentifierIdentifier of the saved search query to apply while filtering the alerts
--searchIdentifierTypeIdentifier type of the value at searchIdentifier, which can be id or name. Default value is id. If searchIdentifier is not provided, this value is ignored.
--output-formatRetrieved alerts can be printed as JSON and YAML format. Default value is json.
--prettyBoolean flag to print retrieved alert as pretty json.

Sample Usage:

opsgenie-lamp listAlerts
opsgenie-lamp listAlerts --query "status: open AND teams = 'devops'"
opsgenie-lamp listAlerts --query "tag: (graylog AND dynamodb)" --output-format yaml
opsgenie-lamp listAlerts --limit 5 --pretty

Count Alerts Command

Lamp countAlerts command is used to count the number of alerts at Opsgenie. countAlerts command takes the following parameters:

Optional Parameters

Parameter
--querySearch query to apply while filtering the alerts. More on Search queries for alerts
--limitPage size. Default is 20. Max value for this parameter is 100.

Sample Usage:

opsgenie-lamp countAlerts --query "status: open"
opsgenie-lamp countAlerts --query "teams = 'devops'"
opsgenie-lamp countAlerts --query "tag: (graylog AND dynamodb)" --output-format yaml

List Alert Logs Command

Lamp listAlertLogs command is used to list alert logs from Opsgenie. listAlertLogs command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.

Optional Parameters

Parameter
--limitPage size. Default is 20. Max value for this parameter is 100
--offsetstarting value of the offset property
--orderasc/desc, default: desc
--directionPage direction to apply for the given offset. Possible values are next and prev. Default value is next.
-output-formatRetrieved alerts can be printed as JSON and YAML format. Default value is json
--prettyBoolean flag to print retrieved alert as pretty json

Sample usage:

opsgenie-lamp listAlertLogs --id 37d2c2b0-a64f-4dbe-b592-df06e34e7683
opsgenie-lamp listAlertLogs --id 37d2c2b0-a64f-4dbe-b592-df06e34e7683 --limit 5 --pretty
opsgenie-lamp listAlertLogs --id 37d2c2b0-a64f-4dbe-b592-df06e34e7683 --order asc

List Alert Notes Command

Lamp listAlertNotes command is used to list alert notes from Opsgenie. listAlertNotes command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.

Optional Parameters

Parameter
--limitPage size. Default is 20. Max value for this parameter is 100.
--orderasc/desc, default: desc
--offsetStarting value of the offset property.
--directionPage direction to apply for the given offset. Possible values are next and prev. Default value is next
--output-formatRetrieved alerts can be printed as JSON and YAML format. Default value is json.
--prettyBoolean flag to print retrieved alert as pretty json.

Sample Usage:

opsgenie-lamp listAlertNotes --id 37d2c2b0-a64f-4dbe-b592-df06e34e7683
opsgenie-lamp listAlertNotes --id 37d2c2b0-a64f-4dbe-b592-df06e34e7683 --limit 5 --pretty
opsgenie-lamp listAlertNotes --id 37d2c2b0-a64f-4dbe-b592-df06e34e7683 --order asc

Acknowledge Command

Lamp acknowledge command is used to acknowledge alerts in Opsgenie. acknowledge command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.

Optional Parameters

Parameter
--userOwner of execution
--noteAdditional alert note
--sourceSource of action

Sample Usage:

opsgenie-lamp acknowledge --id 44d2e383-df30-49e1-820e-65e8e6e6387f
opsgenie-lamp acknowledge --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --alias appserver3Down

Unacknowledge Command

Lamp unacknowledge command is used to unacknowledge alerts in Opsgenie. unacknowledge command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.

Optional Parameters

Parameter
--userOwner of execution
--noteAdditional alert note
--sourceSource of action

Sample Usage:

opsgenie-lamp unacknowledge --id 44d2e383-df30-49e1-820e-65e8e6e6387f
opsgenie-lamp unacknowledge --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --alias appserver3Down

Snooze Command

Lamp snooze command is used to snooze alert at Opsgenie. snooze command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--endDateThe date in ISO8601 format snooze will end. (e.g. 2017-06-13T16:54:42Z)

Optional Parameters

Parameter
--userOwner of execution
--noteAdditional alert note
--sourceSource of action

Sample Usage:

opsgenie-lamp snooze --id 44d2e383-df30-49e1-820e-65e8e6e6387f --endDate "2017-06-13T16:54:42Z"

Assign Command

Lamp assign command is used to assign the ownership of alerts in Opsgenie. assign command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--ownerThe users who will be the owner of the alert after the execution.

Optional Parameters

Parameter
--userOwner of execution
--noteAdditional alert note
--sourceSource of action

Sample Usage:

opsgenie-lamp assign --id 44d2e383-df30-49e1-820e-65e8e6e6387f --owner [email protected]
opsgenie-lamp assign --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --alias appserver3Down --owner [email protected]

Add Team Command

Lamp addTeam command is used to add new teams to alerts in Opsgenie. addRecipient command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--teamThe team that will be added to the alert.

Optional Parameters

Parameter
--userOwner of execution
--noteAdditional alert note
--sourceSource of action

Sample Usage:

opsgenie-lamp addTeam --id 44d2e383-df30-49e1-820e-65e8e6e6387f --team operations
opsgenie-lamp addTeam --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --alias appserver3Down --team operations

Add Responder Command

Lamp addResponder command is used to add new responders to alerts in Opsgenie. addResponder command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--responderThe responder that will be added to the alert.
--typeThe responder type that which is provided at responder which can be team, user, escalation or schedule.

Optional Parameters

Parameter
--userOwner of execution
--noteAdditional alert note
--sourceSource of action

Sample Usage:

opsgenie-lamp addResponder --id 44d2e383-df30-49e1-820e-65e8e6e6387f --recipient [email protected] --type user
opsgenie-lamp addRecipient --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --alias appserver3Down --recipient [email protected] --type user

Add Note Command

Lamp addNote command is used to add notes to alerts in Opsgenie. addNote command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--noteNote text

Optional Parameters

Parameter
--userOwner of execution
--sourceSource of action

Sample Usage:

opsgenie-lamp addNote --id 44d2e383-df30-49e1-820e-65e8e6e6387f --note "I'll work on this"
opsgenie-lamp addNote --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --alias appserver3Down --note "I'll work on this"

Add Tags Command

Lamp addTags command is used to add tags to alerts in Opsgenie. addTags command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--tagsA comma separated list of labels attached to the alert.

Optional Parameters

Parameter
--userOwner of execution
--sourceSource of action
--noteAdditional alert note

Sample Usage:

opsgenie-lamp addTags --id 44d2e383-df30-49e1-820e-65e8e6e6387f --tags "tag1, tag2"
opsgenie-lamp addTags --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --alias appserver3Down --tags "tag1, tag2"

Remove Tags Command

Lamp removeTags command is used to remove tags from alerts in Opsgenie. removeTags command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--tagsA comma separated list of labels attached to the alert.

Optional Parameters

Parameter
--userOwner of execution
--sourceSource of action
--noteAdditional alert note

Sample Usage

opsgenie-lamp removeTags --id 44d2e383-df30-49e1-820e-65e8e6e6387f --tags "tag1, tag2"
opsgenie-lamp removeTags --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --alias appserver3Down --tags "tag1, tag2"

Add Details Command

Lamp addDetails command is used to add details to alerts in Opsgenie. addDetails command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
-DAdditional alert properties. The syntax is -D =

Optional Parameters

Parameter
--userOwner of execution
--sourceSource of action
--noteAdditional alert note

Sample Usage:

opsgenie-lamp addDetails --id 44d2e383-df30-49e1-820e-65e8e6e6387f -D severity=critical

Remove Details Command

Lamp removeDetails command is used to remove details from alerts in Opsgenie. removeDetails command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--keysA comma separated list of detail keys attached to the alert.

Optional Parameters

Parameter
--userOwner of execution
--sourceSource of action
--noteAdditional alert note

Usage:

opsgenie-lamp removeDetails --id 44d2e383-df30-49e1-820e-65e8e6e6387f --keys severity

Execute Alert Action Command

Lamp executeAction command is used to execute custom actions on alerts in Opsgenie. executeAction command takes the following parameters:

Mandatory Parameters

Parameter
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--actionAction to execute

Optional Parameters

Parameter
--userOwner of execution
--noteAdditional alert note
--sourceSource of action

Sample Usage:

opsgenie-lamp executeAction --id 44d2e383-df30-49e1-820e-65e8e6e6387f --action restartEntity
opsgenie-lamp executeAction --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --alias appserver3Down --action restartEntity

Attach File Command

Lamp attachFile command is used to attach file to alerts in Opsgenie. attachFile command takes the following parameters:

Mandatory Parameters:

ParameterDescription
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--filePathAbsolute or relative path to the file
--fileNameFile name
--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

1. if it is not a zip file, it will be assigned to attachment file name
2. If it is a zip file, it will be assigned to
1. HTML file whose name equals attachment file name
2. index.htm or index.html file
3. the first HTML file found in the ZIP
4. 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.

Optional Parameters

Parameter
--userDefault owner of the execution. If user is not specified, the system becomes owner of the execution.

Sample Usage:

opsgenie-lamp attachFile --tinyId 5 --attachment ~/Desktop/attachment.jpg --user [email protected]
opsgenie-lamp attachFile --tinyId 5 --attachment ~/Desktop/attachment.jpg --user [email protected] --apiKey 123

Sample Response

Result : Attachment [attachment.jpg] successfully added to alert [c8daa4c3-951d-40ee-9711-bd332040c207].

Get Attachment File Command

Lamp getAttachment command is used to get a download url for file that was attached to an alert in Opsgenie. getAttachment command takes the following parameters:

Mandatory Parameters:

ParameterDescription
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--attachmentIdIdentifier of the alert attachment

**Sample Usage

opsgenie-lamp getAttachment --tinyId 5 --attachmentId 1503330358392000143 --apiKey 123

Sample Response

Download Link: 
{download link here}

Download Attachment File Command

Lamp downloadAttachment command is used to download attachment file that was attached to an alert to the specified path. downloadAttachment command takes the following parameters:

Mandatory Parameters:

ParameterDescription
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--attachmentIdIdentifier of the alert attachment
--destinationPathPath that file will be downloaded to

Sample Usage

opsgenie-lamp downloadAttachment --tinyId 5 --attachmentId 1503330358392000143 --apiKey 123 --destinationPath ~/Desktop/newfolder

List Alert Attachments Command

Lamp listAttachments command is used to list meta informations of attachments that were attached to an alert in Opsgenie. listAttachments command takes the following parameters:

Mandatory Parameters:

ParameterDescription
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.

Sample Usage

opsgenie-lamp listAttachments --tinyId 5 --apiKey 123

Sample Response

[
  {
    "name": "wl2.jpg",
    "id": 1503330358392000300
  },
  {
    "name": "wl2.jpg",
    "id": 1503388343129020000
  },
  {
    "name": "wl2.jpg",
    "id": 1503389457245022000
  },
  {
    "name": "wl2.jpg",
    "id": 1503389932719013600
  },
  {
    "name": "wl2.jpg",
    "id": 1503390131492009700
  }
]

Delete Attachment Command

Lamp deleteAttachment command is used to delete an attachment file that was attached to an alert in Opsgenie. deleteAttachment command takes the following parameters:

Mandatory Parameters:

ParameterDescription
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--attachmentIdIdentifier of the attachment

Sample Usage

opsgenie-lamp deleteAttachment --tinyId 5 --apiKey 123 --attachmentId 1503330358392000143

Sample Response

RequestID: 46d41737-5e29-4e99-a12b-0958bb467e26
Result: Deleted

Escalate To Next Command

Lamp escalateToNext command is used to immediately process the next available rule in the specified escalation in Opsgenie. escalateToNext command takes the following parameters:

Mandatory Parameters

ParameterDescription
--idId value of the alert that will be closed. Id, tiny Id or alias must be provided.
--identifierIdentifier type of the given id with '--id' flag, can be 'id', 'tiny' or 'alias'. Default value is id.
--escalationIdId of the escalation that will be escalated to the next level.
--escalationNameName of the escalation that will be escalated to the next level.

Optional Parameters

ParameterDescription
--userOwner of execution
--sourceSource of action
--noteAdditional alert note

Sample Usage:

opsgenie-lamp escalateToNext --id 44d2e383-df30-49e1-820e-65e8e6e6387f --escalationName escalation_name

Create Schedule Command

Lamp createSchedule command is used to add a new schedule in
Opsgenie.

Mandatory Parameters:

ParameterDescription
--nameName of the schedule to be created.

Optional Parameters:

ParameterDescription
--descriptionDescription of the schedule to be created
--tzTimezone for the schedule
--teamName of the team under which the schedule should be created
--enabledEnable the created schedule

Sample Usage:

opsgenie-lamp  createSchedule --name 'test-schedule'
opsgenie-lamp createSchedule --name "test-schedule-1" --description "test schedule created by lamp" --tz "Asia/Kolkata" --team "Foo Bar" --enabled

Get Schedule Command

Lamp getSchedule command is used to retrieve a schedule from Opsgenie.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id

Optional Parameters:

ParameterDescription
--output-formatPrints the output in json or yaml formats (default: "json")
--prettyFor more readable JSON output

Sample Usage:

opsgenie-lamp getSchedule --id '8971e253-4a38-4ea0-a7be-160ca61b1c03'
opsgenie-lamp getSchedule --id 'test-schedule' --identifierType name

List Schedules Command

Lamp listSchedules command is used to list all the schedules in Opsgenie.

Optional Parameters:

ParameterDescription
--expandGet more detailed response by expanding it
--output-formatPrints the output in json or yaml formats (default: "json")
--prettyFor more readable JSON output
opsgenie-lamp listSchedules
opsgenie-lamp listSchedules --output-format yaml

Update Schedule Command

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id
--nameName of the schedule

Optional Parameters:

ParameterDescription
--descriptionDescription of the schedule to be created
--tzTimezone for the schedule
--teamName of the team under which the schedule is
--enabledEnable the schedule

Sample Usage:

opsgenie-lamp updateSchedule --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --description "updated test schedule description" --enabled --name 'updated-schedule-name'

Delete Schedule Command

Lamp deleteSchedule command is used to delete a schedule from Opsgenie.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id
opsgenie-lamp deleteSchedule --id "7b55172e-b7a1-4c64-9060-1ecfa50e4e5a"

Get Schedule Timeline Command

Lamp getScheduleTimeline command is used to retrieve the timeline of the given schedule that includes time and on-call recipient details.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id

Optional Parameters:

ParameterDescription
--intervalLength of time as integer in intervalUnits
--intervalUnitUnit of the time to retrieve the timeline. Possible values: days, weeks and months
--expandGet a detailed response. Possible values: base, forwarding, override
--dateTime (in ISO8601) to return future date on-call participants. Default is no
--output-formatPrints the output in json or yaml formats (default: "json")
--prettyFor more readable JSON output
opsgenie-lamp getScheduleTimeline --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --intervalUnit days --expand override --interval 1 --date 2021-07-22T03:54:55+00:00 --output-format yaml
resultmetadata:
  requestid: ce7a5e2a-0d65-415f-b602-d12b7d52ddff
  responsetime: 0.025
  ratelimitstate: OK
  ratelimitreason: ""
  ratelimitperiod: ""
  retrycount: 0
scheduleinfo:
  id: 8971e253-4a38-4ea0-a7be-160ca61b1c03
  name: test-schedule
  enabled: true
description: ""
ownerteam:
  id: ""
  name: ""
startdate: 2021-07-22T03:54:55Z
enddate: 2021-07-23T03:54:55Z
finaltimeline:
  rotations:
  - id: d2df1964-fe62-4df8-94ea-040e2edcbf6d
    name: Rota1
    order: 1
    periods:
    - startdate: 2021-07-22T03:54:55Z
      enddate: 2021-07-22T12:00:00Z
      type: default
      recipient:
        type: user
        name: [email protected]
        id: ec9b1791-3bbb-4821-97fd-c09a62d0e55c
        username: ""
    - startdate: 2021-07-22T12:00:00Z
      enddate: 2021-07-23T03:54:55Z
      type: default
      recipient:
        type: user
        name: [email protected]
        id: 5599119a-230a-4d0d-83e8-4503796e9d46
        username: ""
basetimeline:
  rotations:
  - id: d2df1964-fe62-4df8-94ea-040e2edcbf6d
    name: Rota1
    order: 1
    periods:
    - startdate: 2021-07-22T03:54:55Z
      enddate: 2021-07-22T12:00:00Z
      type: default
      recipient:
        type: user
        name: [email protected]
        id: ec9b1791-3bbb-4821-97fd-c09a62d0e55c
        username: ""
    - startdate: 2021-07-22T12:00:00Z
      enddate: 2021-07-23T03:54:55Z
      type: default
      recipient:
        type: user
        name: [email protected]
        id: 5599119a-230a-4d0d-83e8-4503796e9d46
        username: ""
overridetimeline:
  rotations: []
forwardingtimeline:
  rotations: []
expandablefields: []

Create Schedule Rotation Command

Lamp createScheduleRotation command is used to add a rotation to a schedule on Opsgenie.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id
--typeType of rotation. Available values: daily, weekly and hourly
--startDateSchedule Start Date in ISO8601 format
--participantsA comma separated list of participants. Example: user:, team:, none.

Optional Parameters:

ParameterDescription
--endDateSchedule End Date in ISO8601 format
--lengthLength of the rotation. Default: 1
opsgenie-lamp createScheduleRotation --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --type weekly --startDate 2020-07-27T03:54:55+00:00 --participants user:[email protected],team:"Test Users 1"
opsgenie-lamp createScheduleRotation --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --type daily --startDate 2020-07-27T03:54:55+00:00 --endDate 2020-08-03T03:54:55+00:00 --length 2 --participants user:[email protected],team:"Test Users 1"

Get Schedule Rotation Command

Lamp getScheduleRotation command is used to retrieve a rotation to a schedule from Opsgenie.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id
--rotation-idID of the rotation

Optional Parameters:

ParameterDescription
--output-formatPrints the output in json or yaml formats (default: "json")
--prettyFor more readable JSON output
opsgenie-lamp getScheduleRotation --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --rotation-id bdba6200-de94-474b-b5d6-6ac8b85e4d7e
opsgenie-lamp getScheduleRotation --id test-schedule --identifierType name --rotation-id bdba6200-de94-474b-b5d6-6ac8b85e4d7e --output-format yaml
resultmetadata:
  requestid: fb016fe6-a56f-4545-8ab5-1113cb59a558
  responsetime: 0.012
  ratelimitstate: OK
  ratelimitreason: ""
  ratelimitperiod: ""
  retrycount: 0
rotation:
  id: bdba6200-de94-474b-b5d6-6ac8b85e4d7e
  name: Rot2
  startdate: 2020-07-27T04:00:55Z
  enddate: 2020-08-03T04:00:55Z
  type: daily
  length: 2
  participants:
  - type: user
    name: ""
    id: 7b903be8-899e-4bcc-b638-a6fc20416423
    username: [email protected]
  - type: team
    name: Test Users 1
    id: 3926aa77-e394-40c3-b8b8-8bda1dace3d9
    username: ""
  timerestriction: null
info:
  id: 8971e253-4a38-4ea0-a7be-160ca61b1c03
  name: test-schedule
  enabled: true

List Schedule Rotations Command

Lamp listScheduleRotations command is used to list all the rotations for a given schedule in Opsgenie.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id

Optional Parameters:

ParameterDescription
--output-formatPrints the output in json or yaml formats (default: "json")
--prettyFor more readable JSON output
opsgenie-lamp listScheduleRotations --id 8971e253-4a38-4ea0-a7be-160ca61b1c03

Update Schedule Rotation Command

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id
--rotation-idID of the rotation

Optional Parameters:

ParamterDescription
--nameName of the rotation
--startDateSchedule Start Date inISO8601 format
--endDateSchedule End Date in ISO8601 format
--typeType of rotation. Available values: daily, weekly and hourly
--participantsA comma separated list of participants. Example: user:, team:, none
--lengthLength of the rotation. Default: 1
opsgenie-lamp updateScheduleRotation --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --rotation-id bdba6200-de94-474b-b5d6-6ac8b85e4d7e --output-format yaml  --name 'rotation-2'
opsgenie-lamp updateScheduleRotation --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --rotation-id bdba6200-de94-474b-b5d6-6ac8b85e4d7e --output-format yaml  --endDate 2020-08-15T03:54:55+00:00 --length 3 --participants user:[email protected]

Delete Schedule Rotation Command

Lamp deleteScheduleRotation command is used to delete a rotation in an Opsgenie schedule.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id
--rotation
-id
ID of the rotation

Sample Usage:

opsgenie-lamp deleteScheduleRotation --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --rotation-id bdba6200-de94-474b-b5d6-6ac8b85e4d7e

Create Schedule Override Command

Lamp createScheduleOverride command is used to create a schedule override for the specified user and schedule.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id
--startDateSchedule override Start Date in ISO8601 format
--endDateSchedule override End Date in ISO8601 format
--responderResponder type and name. Examples: user:, team:, escalation:
--rotationsComma separated list of rotation ids

Optional Parameters:

ParmeterDescription
--aliasAlias of the schedule override

Sample Usage:

opsgenie-lamp createScheduleOverride  --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --startDate 2020-07-28T00:00:00+00:00 --endDate 2020-07-29T00:00:00+00:00 --responder user:[email protected] --rotations d2df1964-fe62-4df8-94ea-040e2edcbf6d,222c1326-3655-4b02-9412-7359fbba0ae8

Get Schedule Override Command

Lamp getScheduleOverride command is used to retrieve a specific schedule override from Opsgenie.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id
--aliasAlias of the schedule override

Optional Parameters:

ParameterIdentifier
--output-formatPrints the output in json or yaml formats (default: "json")
--prettyFor more readable JSON output

Sample Usage:

opsgenie-lamp getScheduleOverride --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --alias 3065798d-76da-4968-827b-4d316f35f436

List Schedule Override Command

Lamp listScheduleOverrides command is used to list all the schedule overrides for the specified schedule.

Mandatory Parameters:

ParameterDescription
--idIdentifier type of the specified schedule id, which can be id, name. Default value = id
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id

Optional Parameters:

ParameterDescription
--output-formatPrints the output in json or yaml formats (default: "json")
--prettyFor more readable JSON output

Sample Usage:

opsgenie-lamp listScheduleOverrides  --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --output-format yaml

Update Schedule Override Command

Lamp updateScheduleOverride command is used to update details of a specific schedule override from Opsgenie.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id
--aliasAlias of the schedule override

Optional Parameters:

ParameterDescription
--startDateSchedule override Start Date in ISO8601 format
--endDateSchedule override End Date in ISO8601 format
--responderResponder type and name. Examples: user:, team:, escalation:
--rotationsComma separated list of rotation ids

Sample Usage:

opsgenie-lamp updateScheduleOverride  --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --alias 3065798d-76da-4968-827b-4d316f35f436 --responder user:[email protected] --startDate 2020-07-26T00:00:00+00:00 --endDate 2020-07-28T00:00:00+00:00

Delete Schedule Override Command

Lamp deleteScheduleOverride command is used to delete a specific schedule override from Opsgenie.

Mandatory Parameters:

ParameterDescription
--idID of the schedule
--identifierTypeIdentifier type of the specified schedule id, which can be id, name. Default value = id
--aliasAlias of the schedule override

Sample Usage:

opsgenie-lamp deleteScheduleOverride  --id 8971e253-4a38-4ea0-a7be-160ca61b1c03 --alias 3065798d-76da-4968-827b-4d316f35f436

Enable Command

Lamp enable command is used to enable integrations and policies. enable command takes the following parameters.

Mandatory Parameters

ParameterDescription
--idId of the integration/policy that will be enabled. Either id or name must be provided
--typeType of the entity that will be enabled. It must be integration or policy.
--policyTypePolicy type should be one of alert or notification.
--teamIdTeam Id for policies which are created on a team.

Sample Usage

opsgenie-lamp enable --id ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --type policy --teamId 0216a8a8-caa9-4ff3-9dc3-428d3c6c16aa --policyType alert
opsgenie-lamp enable --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --id dc4488e2-58cc-4bae-ac37-32612fefb09b --type integration

Disable Command

Lamp disable command is used to disable integrations and policies. disable command takes the following parameters.

Mandatory Parameters

ParameterDescription
--idId of the integration/policy that will be disabled. Either id or name must be provided
--typeType of the entity that will be disabled. It must be integration or policy.
--policyTypePolicy type should be one of alert or notification.
--teamIdTeam Id for policies which are created on a team

Sample Usage

opsgenie-lamp disable --id ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --type policy --teamId 0216a8a8-caa9-4ff3-9dc3-428d3c6c16aa --policyType alert
opsgenie-lamp disable --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079 --id dc4488e2-58cc-4bae-ac37-32612fefb09b --type integration

Export Users Command

Lamp exportUsers command is used to export users to a csv file. exportUsers command takes the following parameters:

Optional Parameters

ParameterDescription
--destinationPathPath that file will be downloaded to
--querySearch query to apply while filtering the users. More on Search syntax for users

Sample Usage

opsgenie-lamp exportUsers --destinationPath ~/Desktop/ --query "role:Owner"
opsgenie-lamp exportUsers --apiKey ab5454992-fabb2-4ba2-ad44f-1af65ds8b5c079

Download Logs Command

Lamp downloadLogs command is used to download Opsgenie logs in a time period. downloadLogs command takes the following parameters:

ParameterDescription
-startDownload log files starting from this date. which should be in format as: YYYY-MM-DD-HH-mm-ss, i.e. 2018-10-26-15-30-00
-endDownload log files until this date. which should be in format as: YYYY-MM-DD-HH-mm-ss, i.e. 2018-10-26-15-30-00 (Optional) if not exist it will be set as now.
-pathDownload path. (Optional) If not exist, Lamp will use the current directory.

Sample usage

opsgenie-lamp downloadLogs -start "2018-10-24-07-30-00" -end "2018-10-31-11-53-51" -path "/tmp/opsgenie-logs" -v

Create Team Command

Lamp createTeam command is used to create a team in Opsgenie. You can choose to give a user to add to the team while creating and the user role. You can add more users using addMember command

ParameterDescription
-nameTeam name. Cannot be empty or duplicate
-descTeam description, can be empty, can be updated.
-userNameEmail of the user whom you are adding to the team, optional if you are providing userId.
-userIdUserId of the user, optional if you are providing userName.
-roleRole name of the user.

Sample usage

opsgenie-lamp createTeam  -n "New team" -d description -userName [email protected] -role user

Update Team Command

Lamp updateTeam command can be used to update an existing team. Add members to the team using addMember command

ParameterDescription
-idTeam Id of the team being updated. Optional if you are providing name.
-nameTeam name of the team being updated. Optional if you are providing id.
-descTeam description. Provide if you want to update description.
-userNameEmail of the user whom you are adding to the team, optional if you are providing userId.
-userIdUserId of the user, optional if you are providing userName.
-roleRole name of the user.

Sample usage

opsgenie-lamp updateTeam -v -id 123456 -d "description" -userName [email protected] -role admin

Get Team Command

Lamp getTeam command can be used to get team info using team Id or team name.

ParameterDescription
-idId of the team. Optional if you are providing team name.
-nameTeam name. Optional if you are providing id.

Sample usage

opsgenie-lamp getTeam -name "my awesome team"

Delete Team Command

Lamp deleteTeam command is useful for deleting a team in Opsgenie.

ParameterDescription
-nameTeam name to be deleted.
-idTeam id to be deleted.

Sample usage

opsgenie-lamp deleteTeam  -id teamid

Add Member Command

Lamp addMember command is useful for adding a member with role to a team.

-teamNameTeam name to add member to. Optional if providing teamId.
-teamIdTeam Id to add member to. Optional if providing teamName
-userNameUser email address.
-userIdUser Id, optional if you provide userName.
-roleUser role name.

Sample usage

opsgenie-lamp addMember -name "my team name" -role user -userName [email protected]

List Teams Command

Lamp listTeams command lists all the teams in your Opsgenie account.

Sample usage

opsgenie-lamp listTeams

Remove Member Command

Lamp removeMember command can be used to remove a member from team using username or userId.

ParameterDescription
-teamNameTeam name from which to remove member.
-teamIdTeam Id from which to remove member
-userIdUser id of the member.
-userNameUsername of the member.

Sample usage

opsgenie-lamp removeMember -teamName "my team name" -userName [email protected]

Create Role Command

Lamp createRole command is helpful in creating user roles from command line.

ParameterDescription
-nameTeam name for which to add role.
-idTeam Id for which to add role.
-roleNameRole name to be created.
-rightsList of rights to be added for the role, comma separated.

Sample usage

opsgenie-lamp createRole -name "my team name" -rights edit-routing-rules,edit-team-roles,manage-members -roleName role-1

List All Role Rights Command

Lamp listRoleRights command lists all the available role rights and their categories.

Sample usage

opsgenie-lamp listRoleRights

Get Role Command

Lamp getRole command is used to get details of a role by role name or role Id.

ParameterDescription
-teamNameTeam name of which the role belongs to.
-teamIdTeam id of which the role belongs to.
-roleNameName of the role.
-roleIdId of the role, optional if role name provided.

Sample usage

opsgenie-lamp getRole -name "my team name" -roleName role-1

Delete Role Command

Lamp deleteRole command is useful to delete an existing role from team.

-teamNameTeam name of which the role belongs to.
-teamIdTeam id of which the role belongs to.
-roleNameName of the role.
-roleIdId of the role, optional if role name provided.

Sample usage

opsgenie-lamp deleteRole -name "my team name" -roleName role-1

List Roles Command

Lamp listRoles command can be used to list roles from a team.

ParameterDescription
-nameTeam name, optional if team id provided.
-idTeam Id, optional if team name provided.

Sample usage

opsgenie-lamp listRoles -name "my team name"

List Team Routing Rules Command

Lamp listRoutingRules command can be used to list team's routing rules.

ParameterDescription
-nameTeam name to fetch routing rules for.
-idTeam Id to fetch routing rules for.

Sample usage

opsgenie-lamp listRoutingRules -name "my team"

Deleting Team Routing Rule Command

Lamp deleteRoutingRule command is used to deleting a routing rule by its Id.

ParameterDescription
-nameTeam name to delete the routing rule from.
-idTeam Id to delete the routing rule from.
-ruleIdRouting Rule Id.

Sample usage

opsgenie-lamp deleteRoutingRule -ruleId 6374203e -n "my team"

Get Routing Rule Command

Lamp getRoutingRule command is useful in getting information about the routing rule by id.

ParameterDescription
-teamNameTeam name that the rule belongs to.
-teamIdTeamId that the rule belongs to.
-ruleIdRouting rule Id.

Sample usage

opsgenie-lamp getRoutingRule -n "my team" -ruleId "ruleId"

List Team Logs Command

Lamp listTeamLogs command is useful for fetching team logs. The response is paginated, you can specify offsets , limit and the order of the logs to fetch.

ParameterDescription
-idTeam Id, optional if you provide team name.
-nameTeam name, optional if you provide team id.
-offsetOffset for the logs, default is 0.
-limitNumber of logs entries to fetch.
-orderOrder in which to fetch the logs asc or desc, default is desc.

Sample usage

opsgenie-lamp listTeamLogs -n "my team" -limit 10 -order desc

Get On-Call Command

Lamp getOncall command is useful for getting the current on-call details at the given time for a schedule.

ParametersDescription
-idId of the on-call schedule.
-nameName of the on-call schedule.
-flatIf the response should be flat, which does not included user details except for email.
-atTimeTime at which to check, need to specify time in 2006-01-02T15:04:05+07:00 format, default is current time.

Sample usage

opsgenie-lamp getOncall -name "Team A main" -atTime "2006-01-02T15:04:05+07:00" -flat

Get Next On-Call Command

Lamp getNextOncall ommand is useful for getting the next on-call details at the given time for a schedule.

ParameterDescription
-idId of the on-call schedule.
-nameName of the on-call schedule.
-flatIf the response should be flat, which does not included user details except for email.
-atTimeTime at which to check, need to specify time in 2006-01-02T15:04:05+07:00 format, default is current time.

Sample usage

opsgenie-lamp getOncall -name "Team A main" -atTime "2006-01-02T15:04:05+07:00" -flat

Export User On-Calls Command

Lamps exportUserOncalls command is useful for exporting upcoming on-calls schedules for a given user in an ics file, which user can add to his/her calendar application. This will export the schedule for the next 3 months.

ParameterDescription
-userNameUser email of the user for whom to export the schedules.
-userIdUser name of the user for whom to export the schedules.
-exportToFile path to save the file, default is current folder.

Sample usage

./opsgenie-lamp exportUserOncalls -userName [email protected] -exportTo "/Users/username/Documents/"

Version Command

It prompts the current Lamp Version

Sample Usage

opsgenie-lamp --version

Source

The source code is available at GitHub.