LogicMonitor’s REST API allows you to programmatically add a note to existing alerts.  

Notes:

  • Adding a note to an alert will not acknowledge it.  For more information about acknowledging alerts, see this page
  • As with all of our API calls, authentication is required.

 

 

HTTP Method: POST

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

Where {id} is the id or internalId of the alert you’d like to add a note for.

Request Parameters:

 

Property

Description

Required?

Type

Example

ackComment The note to be added Yes String “ackComment”:”investigating”

 

You can use LogicMonitor’s REST API to programmatically get and acknowledge your alerts.

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

 

 

Resource Properties

All alerts have the following properties:

 

Property

Description

Type

id The alert id String
type The type of alert String
internalId The internal id for the alert String
startEpoch The time (in epoch format) that the alert started Integer
endEpoch The time (in epoch format) that the alert ended Integer
acked Whether or not the alert has been acknowledged Boolean
ackedEpoch The time (in epoch format) that the alert was acknowledged Integer
ackedBy The user that acknowledged the alert String
ackComment The comment submitted with the acknowledgement String
rule The rule the alert matches String
ruleId The id of the rule the alert matches Integer
chain The escalation chain the alert was routed to String
chainId The id of the escalation chain the alert was routed to Integer
nextRecipient The next recipient in the escalation chain for this alert. Integer
receivedList The recipients that have received the alert JSON object
severity The alert severity, where 2=warning, 3=error and 4=critical String
cleared Whether or not the alert has cleared Boolean
sdted Whether or not the alert was triggered during an SDT Boolean
SDT The active SDT, if one exists String
alertValue The value that triggered the alert JSON Object
threshold The threshold associated with the object in alert String
clearValue The value that cleared the alert String
monitorObjectId The id of the object that the alert is associated with Integer
monitorObjectName The name of the object that the alert is associated with String
monitorObjectGroups Information about the groups the object is a member of JSON Object
resourceTemplateId The id of the datasource in alert Integer
resourceTemplateName The name of the datasource in alert String
instanceId The id of the instance in alert Integer
instanceName The name of the instance in alert String
instanceDescription The description of the instance in alert String
dataPointName The name of the datapoint in alert String
detailMessage The alert message, if needMessage=true is included in the query parameters JSON Object

 

Overview

LogicMonitor’s REST API allows you to programmatically acknowledge alerts. As with all of our API calls, authentication is required.

HTTP Method: POST

Resource URI: /alert/alerts/{id}/ack
(where {id} is the id OR internalId of the alert you’d like to acknowledge; you must include an ackComment in the body of your POST request)

Example

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

#!/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 = '/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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(hmac1.encode())
 
# Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + 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)
Python 3

Overview

LogicMonitor’s REST API allows you to programmatically get alerts for your account. As with all of our API calls, authentication is required.

Note: If you’re trying to request alerts for a specific device, device group, or service, consider using the alerts sub-resources for those resources.

Request Information

Returns a list of alerts

HTTP Method: GET

URI: /alert/alerts

Request Parameters: By default, a list of 50 alerts will be returned. You can include the following query parameters that control what data is included in the response and how it is formatted. Query parameters are not considered part of the resource path, and should not be included in the calculation of the LMv1 authentication signature.

Property Syntax Description Example URI
sortsort={+ or -}propertySorts the response by the property specified in either increasing (+) or decreasing (-) order/alert/alerts?sort=-startEpoch
filterfilter=_all~value Filters the response to include only the results that include the specified value. You can substitute _all with a field name to filter on only a specific field. Note that filtering is only available for id, type, acked, rule, chain, severity, cleared, sdted, startEpoch, monitorObjectName, monitorObjectGroups, resourceTemplateName, instanceName, and dataPointName. Operators include: 
  • Greater than or equals: >:
  • Less than or equals: <:
  • Greater than: >
  • Less than: <
  • Does not equal: !:
  • Equals: :
  • Includes: ~
  • Does not include: !~
/alert/alerts?filter=_all~serviceAlert
fieldsfields=list of properties separated by commas Filters the response to only include the following fields for each object/alert/alerts?fields=type,id,acked,severity
sizesize=integerThe number of results to display, where a maximum of 1000 results can be requested/alert/alerts?size=10
offsetoffset=integerThe number of results to offset the displayed results by/alert/alerts?offset=20
needMessageneedMessage=true|falseWhether or not the detailed alert messages should be included in the response/alert/alerts?needMessage=true
customColumnscustomColumns=value1,value2,value3The property or token values that should display with the alert details. Note that if referencing tokens, you’ll need to URL encode the # symbol. /alert/alerts?customColumns=%2523%2523system.collectorid%2523%2523,%2523%2523system.groups%2523%2523

Note: By default, only active alerts are returned. To get cleared alerts and active alerts in the response, add a filter for ‘cleared:*’. If you are using LogicMonitor REST API v2, add a filter for ‘cleared: “*”‘.

Note: The response ‘total’ will be a negative number if there are additional alerts that satisfy the request criteria that weren’t included in the request, and that “at least” that number of alerts exist. For example, if you request the first 500 alerts and you have 3000 alerts in your account, the response may include total=-1000 (i.e. you have at least 1000 alerts, but you didn’t ask for them all).

Example

The following Python script requests a list of alerts, and the value of ##externalticketid## for each alert.

#!/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
#Request Info
httpVerb ='GET'
resourcePath = '/alert/alerts'
data=''
queryParams ='?customColumns=%2523%2523externalticketid%2523%2523'

#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
hmac1 = hmac.new(AccessKey.encode(),msg=requestVars.encode(),digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(hmac1.encode())
 
# Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}
 
# Make request
response = requests.get(url, data=data, headers=headers)
 
# Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

14-day access to the full LogicMonitor platform