LogicMonitor seeks to disrupt AI landscape with $800M strategic investment at $2.4B valuation to revolutionize data centers.

Learn More

Get Alerts

Last updated on 17 April, 2023

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
In This Article