Adding Ops Notes

Last updated on 07 October, 2024

You can use LogicMonitor REST API v3 to add ops notes to your LogicMonitor account. You must authenticate yourself before making the API request.

URI: POST /setting/opsnotes

ParametersTypeDescription
noteString(Mandatory) The note message.
Example – “note”:”software updated from 1.0.0 to 1.2.4″
scopesJSON objectThe scope associated with the note. A note with no scope will show up for everything in the account. The Ops Notes scope consists of type which is a mandatory parameter. For example, device. Each scope object has a type – device, service, deviceGroup, and serviceGroup.
  • For group scopes – Specify the groupId.
  • For device/service scopes – Specify the deviceId/serviceId. Optionally, you can include the groupId.
Example – “scopes”:[{“type”:”device”,”deviceId”:56},{“type”:”service”,”serviceId”:87,”groupId”:74}]
happenOnInSecIntegerThe date and time (in epoch seconds format) associated with the note. It defaults to the current time. Example – “happenOnInSec”:1488826440
tagsJSON objectTags should be associated with note. Each tag has a unique Id and name. You can either include name of a new or an existing tag, or the Id of an existing tag. Example – “tags”:[{“name”:”release”},{“name”:”upgrade”}]
The Ops Notes tag base consists of name which is a mandatory parameter.

The following Python script adds an ops note to account api.logicmonitor.com, with note “deploy version 3.4.5” and tag “reporting” to the device with Id 530.

#!/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/opsnotes'
queryParams =''
data = '{"note":"deploy version 3.4.5","tags":[{"name":"reporting"}],"scopes":[{"type":"device","deviceId":530}]}'
 
#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