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 update widgets. As with all of our API resources, authentication is required.
HTTP Method: PUT(consistent with REST standards, any properties not specified in a PUT request will revert back to their default values)
URI: /dashboard/widgets/{id}
All PUT requests for updating widgets can include the following properties.
Note: colSpan and rowSpan can be used to change widget size, but will not change widget position (and do not allow half size widgets). The only way to currently change widget position (or create half size widgets) is to update the widgetsConfig string for the dashboard itself via the dashboards resource.
Additional properties are available depending on the widget you are updating.
You may additionally include a ‘filters’ object with the following properties for all widgets of type alert (alert widgets).
You may additionally include the following properties for all widgets of type batchjob (batchjob widgets).
All widgets of type bigNumber (big number widgets) must include an object bigNumberInfo with the following fields.
Note that a datapoint must be referenced in the bigNumberItems object in order to be displayed.
All widgets of type cgraph (custom graph widgets) must include an object graphInfo with the following fields.
You may also include the following fields for widgets of type deviceNOC (device NOC widgets).
You may also include the following fields for widgets of type gauge (gauge widgets).
You must also include an object mapPoints with the following fields for widgets of type gmap (google map widgets).
You must also include an object ‘resources’ with the following fields for widgets of type html (html widgets).
You may also include the following fields for widgets of type ngraph (pinned device level graphs).
You must also include an object pieChartInfo with the following fields for all widgets of type pieChart (pie chart widgets):
You may also include the following fields for widgets of type serviceIndividualStatus (service individual status widgets).
You may also include the following fields for widgets of type serviceNOC (service NOC widgets).
For widgets of type serviceOverallStatus (service overall status widgets) you must include an object selectedServices with the following fields:
You can additionally include the following fields for widgets of type serviceSLA (service SLA widgets).
You can additionally PUT the following fields for widgets of type deviceSLA (device SLA widgets).
You can additionally include the following fields for widgets of type sgraph (graph pinned from the services page).
All widgets of type table (table widgets) must include two additional objects. A ‘columns’ object must be included, where each column has the following fields.
And a ‘rows’ object must be included, where each row has the following fields.
And a ‘forecast’ object must be included if enableForecast=true, where the following fields are needed.
All widgets of type text (text widgets) must include a content field.
The following examples illustrate updating various widgets to an account api.logicmonitor.com via Python:
The following Python Script updated alert widget 540 on dashboard 26 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/540' data = '{"name":"Website Alert Widget","dashboardId":26,"type":"alert","filters":{"group":"US - LA/Website*","cleared":"all"}}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 485 on dashboard 26 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/485' data = '{"type":"batchjob","dashboardId":"26","name":"My Batch Job Widget","deviceDisplayName":"10.36.11.240","batchJobName":"myBatchJob"}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 308 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/308' data = '{"type":"bigNumber","dashboardId":"26","name":"DiskReadBps,"bigNumberInfo":{"dataPoints":[{"deviceGroupFullPath":"Website","deviceDisplayName":"AP-NE1:QA Develop (test01)_i-0fa41a680e9ea1d72","dataSourceId":648,"instanceName":"AWS_EC2","dataPointName":"DiskReadBps","name":"CPUBusyPercent"}],"bigNumberItems":[{"dataPointName":"CPUBusyPercent","rounding":"0"}]}}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 486 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/486' data = '{"type":"deviceNOC","dashboardId":"26","name":"Device NOC Widget","items":[{"deviceGroupFullPath":"*","deviceDisplayName":"ip-172-31-73-214.us-west-2.compute.internal","dataSourceDisplayName":"HTTP-","instanceName":"*","dataPointName":"*","groupBy":"device","name":"##HOSTNAME## - HTTP content/function"},{"deviceGroupFullPath":"*","deviceDisplayName":"ip-172-31-73-214.us-west-2.compute.internal","dataSourceDisplayName":"Apache-","instanceName":"*","dataPointName":"*","groupBy":"device","name":"##HOSTNAME## - Apache"}]}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 487 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/487' data = '{"type":"gauge","dashboardId":"26","name":"Gauge Widget","maxValue":100,"minValue":0,"dataPoint":{"deviceGroupFullPath":"*","deviceDisplayName":"ip-172-31-33-214.us-west-2.compute.internal","dataSourceFullName":"Apache-","instanceName":"*","dataPointName":"BusyWorkers"}}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 488 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/488' data = '{"type":"gmap","dashboardId":"26","name":"My Google Map Widget","mapPoints":[{"type":"group","deviceGroupFullPath":"US - LA/Website"}]}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 489 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/489' data = '{"type":"html","dashboardId":"26","name":"My HTML widget","resources":[{"type":"iframe","URL":"<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/s6Ax30Mz7uo\" frameborder=\"0\" allowfullscreen></iframe>'"}]}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 490 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/490' data = '{"type":"ngraph","dashboardId":"26","name":"NGRAPH WIDGET","hId":39,"dsiId":852,"graphId":2142}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 491 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/491' data = '{"type":"pieChart","dashboardId":"26","pieChartInfo":{"title":"anything","dataPoints":[{"deviceGroupFullPath":"Website","deviceDisplayName":"*","dataSourceFullName":"Apache-","instanceName":"Apache-80","dataPointName":"ExtendedStatusNotEnabled","name":"ExtendedStatusNotEnabled","aggregate":true,"aggregateFunction":"sum"}],"pieChartItems":[{"dataPointName":"ExtendedStatusNotEnabled","legend":"##HOSTNAME##_##DATASOURCENAME##_##INSTANCE##","color":"Auto"}]},"name":"MY PIE CHART WIDGET"}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 492 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/492' data = '{"type":"serviceIndividualStatus","dashboardId":"26","name":"SERVICE INDIVIDUAL WIDGET","serviceId":21,"locations":[{"smgId":1,"geoInfo":"US - Los Angeles","selected":true},{"smgId":2,"geoInfo":"US - Washington DC","selected":true},{"smgId":3,"geoInfo":"US - San Francisco","selected":true},{"smgId":4,"geoInfo":"Europe - Dublin","selected":true},{"smgId":5,"geoInfo":"Asia - Singapore","selected":true},{"smgId":6,"geoInfo":"Sydney - Australia","selected":false}]}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 493 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/493' data = '{"type":"serviceNOC","dashboardId":"26","name":"Service NOC Widget","items":[{"serviceGroupName":"Production","serviceName":"*","groupBy":"service","name":"##SERVICE##"},{"serviceGroupName":"Internal Services","serviceName":"*","groupBy":"service","name":"##SERVICE##"}]}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 494 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/494' data = '{"type":"serviceOverallStatus","dashboardId":"26","name":"Service Overall Status","selectedServices":[{"serviceGroupId":1,"chooseAll":true},{"serviceGroupId":1,"chooseAll":false,"services":[{"id":21,"name":"main page"},{"id":22,"name":"a record (ELB)"}]}]}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 495 in api.logicmonitor.com.
#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/495' data = '{"type":"serviceSLA","dashboardId":"26","name":"Service SLA Widget","items":[{"serviceGroup":"Production","service":"*"},{"serviceGroup":"Internal Services","service":"*"}]}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(url, data=data, headers=headers) # Print status and body of response print('Response Status:',response.status_code) print('Response Body:',response.content)
The following Python script updates widget 496 in api.logicmonitor.com.
>#!/bin/env python import requests import json import hashlib import base64 import time import hmac #Account Info AccessId ='YQQ75w6Mxx9zWIeAMq5H' AccessKey ='f)!Z}%spR=6en+4^s2$t32r-3=NpdQ]2T{-deI)8' Company = 'api' #Request Info httpVerb ='PUT' resourcePath = '/dashboard/widgets/496' data = '{"type":"sgraph","dashboardId":"26","name":"Service Graph Widget","serviceName":"CName_check","serviceCheckpointId":99,"graph":"responseTime"}' #Construct URL url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath #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() # Construct headers auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch headers = {'Content-Type':'application/json','Authorization':auth} #Make request response = requests.put(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