Add OpsNotes

Last updated on 14 February, 2022

Overview

You can use LogicMonitor’s REST API to programmatically add ops notes to your account. As with all of our API calls, authentication is required.

Request Information

HTTP Method: POST

URI: /setting/opsnotes

Request Parameters: You can POST the following properties for all new ops notes.

Property Description Required? Type Example
noteThe note messageYesString“note”:”software update from 1.0.0 to 1.2.4″
happenedOnInSecThe date and time associated with the note, in epoch seconds formatNo. Defaults to current timeInteger“happenOnInSec”:1488826440
scopesThe scopes associated with the note. A note with no scope will show up for everything in the account. Each scope object should have a type (device, service, deviceGroup, serviceGroup). For group scopes, a groupId should be specified. For device/service scopes, deviceId/serviceId should be specified & groupId can optionally be included.No. Defaults to no scopeJSON Object“scopes”:[{“type”:”device”,”deviceId”:56},{“type”:”service”,”serviceId”:87,”groupId”:74}]
tagsThe tags that should be associated with the note. Each tag has a unique id and a name – you can either include the name of a new or existing tag, or the id of an existing tag.No. Defaults to no tagsJSON Object“tags”:[{“name”:”release”},{“name”:”upgrade”}]

Example

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.

Note: The scripts provided below are for example illustration purpose only. You must securely store and retrieve sensitive information such as AccessId and AccessKey in your implementation.





#!/bin/env python

import requests
import json
import hashlib
import base64
import time
import hmac
import gatepass

#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
print(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
In This Article