REST API Developer's Guide

Add an Escalation Chain

You can use LogicMonitor's REST API to programmatically add Escalation Chains to your account.

As with all of our API calls, authentication is required.

HTTP Method:

POST

URI:

/setting/alert/chains

 

Request Parameters:

You can POST the following properties for all new escalation chains

Property

Description

Required?

Type

Example

name The name of the Escalation Chain Yes String "name":"MyEscalationChain"
description The description associated with the Escalation Chain No. Defaults to no description String "description":"routes to the on call engineer"
enableThrottling Whether or not throttling (rate limiting) is enabled for this Escalation Chain. If true, throttlingPeriod and throttlingAlerts indicate how alerts will be throttled. No. Defaults to false Boolean "enableThrottling":false
throttlingPeriod The throttling (rate limit) period if enableThrottling is true, in minutes Only if enableThrottling=true Integer "throttlingPeriod":30
throttlingAlerts If enableThrottling is true, throttingAlerts indicates the maximum number of alerts that can be routed in the throttlingPeriod. Only if enableThrottling=true Integer "throttlingAlerts":40
destinations The destinations associated with the Escalation Chain. For non-time based escalation chains, the destination object consists of a stages object and type=single, and each stage includes a type (admin | arbitrary | group), a method (for type=admin values can be email | sms, for type=arbitrary value must be email, does not apply for type=group), and addr (the username for type=admin, recipient group for type=group and email for type=arbitrary). For time based escalation chains, the destination object consists of one or more objects, each with type=timebased, a period (includes fields startMinutes (0-1440), endMinutes(0-1440) and weekDays(should be an array with days, where options are 1-7, e.g. [1, 2, 3, 4, 5, 6, 7])), and a stages object (see above re non-time based chains for info about stages object). Note that prior to v89/90, the stages object must be enclosed in double brackets, as shown in the example. Yes JSON Object "destinations":[{"type":"single","stages":[[{"type":"admin","method":"sms","addr":"Bob"},{"type":"group","addr":"OnCallGroup"},{"type":"arbitrary","method":"email","addr":"[email protected]"}]]}]
ccDestinations CC recipients - these recipients will receive all notifications sent to every stage. Each ccDestination (recipient) will include a type (always is ARBITRARY), method (always is email), and addr (email address) No. Defaults to no CC recipients JSON Object "ccDestinations":[{"type":"arbitrary","method":"email","addr":"[email protected]"}]

 

Example

The following Python script adds an Escalation Chain 'DBTeam' to the account api.logicmonitor.com, where the escalation chain has a single stage for the db team recipient group:

#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac

#Account Info
AccessId ='48v2wRzfK94y53sq5EuF'
AccessKey ='H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
Company = 'api'

#Request Info
httpVerb ='POST'
resourcePath = '/setting/alert/chains'
data='{"name":"DBTeam","destinations":[{"type":"single","stages":[[{"type":"group","addr":"dbTeam"}]]}]}'

#Construct URL 
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath

#Get current time in milliseconds
epoch = str(int(time.time() * 1000))

#Concatenate Request details
requestVars = httpVerb + epoch + data + resourcePath

#Construct signature
signature = base64.b64encode(hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature + ':' + epoch

headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.post(url, data=data, headers=headers)

#Print status and body of response
print 'Response Status:',response.status_code
print 'Response Body:',response.content