REST API Developer's Guide

Add OpsNotes

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

Property

Description

Required?

Type

Example

note The note message Yes String "note":"software update from 1.0.0 to 1.2.4"
happenedOnInSec The date and time associated with the note, in epoch seconds format No. Defaults to current time Integer "happenOnInSec":1488826440
scopes The 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 scope JSON Object "scopes":[{"type":"device","deviceId":56},{"type":"service","serviceId":87,"groupId":74}]
tags The 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 tags JSON 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:

#!/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 = '/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
signature = base64.b64encode(hmac.new(AccessKey,msg=requestVars,digestmod=hashlib.sha256).hexdigest())

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature + ':' + 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