Adding Note and Acknowledging Alerts

Last updated on 05 July, 2023

You can use LogicMonitor REST API v3 to acknowledge or add note to existing alerts. You must authenticate yourself before making the API request.

Adding Note to Existing Alert

Note: Adding a note to an alert does not mean the alert is acknowledged.

URI: POST /alert/alerts/{id}/note

ParameterTypeDescription
idString(Mandatory) The ID or the internal ID of the alert to which you want to add a note.
ackCommentString(Mandatory) The note acknowledging the alert. Example – "ackComment": "Looking into this alert."

Acknowledging Alert

URI: POST /alert/alerts/{id}/ack

ParameterTypeDescription
idString(Mandatory) The ID or the internal ID of the alert that you want to acknowledge.
ackCommentString(Mandatory) The comment acknowledging the alert. Example – "ackComment": "maintenance"

The following Python script acknowledges the alert DS304962 with comment ‘maintenance’.

#!/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 = '/alert/alerts/DS304962/ack'
queryParams =''
data = '{"ackComment":"maintenance"}'
 
#Construct URL
url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath + queryParams
 
#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)
Python 3
In This Article