Come join our live training webinar every other Wednesday at 11am PST and hear LogicMonitor experts explain best practices and answer common questions. We understand these are uncertain times, and we are here to help!
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.
HTTP Method: POST
URI: /setting/opsnotes
Request Parameters: You can POST the following properties for all new ops notes.
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)
In This Article