Adding Escalation Chain
Last updated - 03 January, 2024
You can use LogicMonitor REST API v3 to add escalation chain. You must authenticate yourself before making the API request.
URI: POST /setting/alert/chains
| Parameter | Type | Description | 
throttlingAlerts | Integer | If enableThrottling is set to true, then throttlingAlerts indicates the maximum number of alerts that can be send during the throttling period.Example – “throttlingAlerts”: 40 | 
enableThrottling | Boolean | Indicates whether or not throttling (rate limiting) is enabled for this escalation chain. If the field is set to true, then throttlingPeriod and throttlingAlerts indicate how alerts are throttled. Example – “enableThrottling”: false | 
destinations | (Mandatory) The destination consists of the following:
  | |
name | String | (Mandatory) The name of the escalation chain.  Example – “name”: ”MyEscalationChain” | 
description | String | The description of the escalation chain. | 
ccDestinations | The ccDestination consists of the recipient’s details:
  | |
throttlingPeriod | Integer | The throttling (rate limit) period in minutes if enableThrottling is set to true. Example – “throttlingPeriod”: 30 | 
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
import getpass
 
#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'  
 
#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
digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8')   
 
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':'3'} 
 
#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)