Support Center Home


Add a Widget

Overview

You can use LogicMonitor’s REST API to programmatically add new widgets to your LogicMonitor dashboards. As with all of our API resources, authentication is required.

Request Information

HTTP Method: POST

URI: /dashboard/widgets

Properties

Global Properties

You can POST the following properties for all new widgets.

Property Description Required? Type Example
nameThe name of the widgetYesString“name”:”Apache Requests”
descriptionThe description of the widgetNoString“description”:”My Widget Description”
typealert | deviceNOC | html | serviceOverallStatus | sgraph | ngraph | serviceNOC | serviceSLA | deviceSLA | bigNumber | gmap | serviceIndividualStatus | gauge | pieChart | ngraph | batchjob”YesString“type”:”alert”
dashboardIdThe id of the dashboard the widget will be added toYesInteger“dashboardId”:50
themeThe color scheme of the widget. Options are borderPurple | borderGray | borderBlue | solidPurple | solidGray | solidBlue | simplePurple | simpleBlue | simpleGray | newBorderGray | newBorderBlue | newBorderDarkBlue | newSolidGray | newSolidBlue | newSolidDarkBlue | newSimpleGray | newSimpleBlue |newSimpleDarkBlueNo. Defaults to borderPurple.String“theme”:”simplePurple”
colSpanThe number of columns the widget’s width should consumeNo. Defaults to 1.Integer“colSpan”:1
rowSpanThe number of rows the widget’s height should consumeNo. Defaults to 1.Integer“rowSpan”:1
intervalThe refresh interval of the widget. Options are 1 | 3 | 5 | 10 | 15 (all in minutes)No. Defaults to 3.Integer“interval”:1
timescaleThe default timescale of the widget. Options are 1hour | 2hour | 5hour | 1day | 2days | 7days | 1month | 3month | 1yearNo. Defaults to 1hour.String“timescale”:”1day”
extraOnly applies to alert widgetsNoJSON Object

Note: colSpan and rowSpan can be used to adjust widget size, but will not allow you to 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.

Widget-Specific Properties

Additional properties are available depending on the widget you are adding.

Alert Widget Properties

You may additionally POST a ‘filters’ object with the following properties for all widgets of type alert (alert widgets).

Property Description Required? Type Example
groupDisplayed alerts must be associated with groups that meet this filter criteria. Glob is accepted, and * and an empty string both indicate all groups.No. Defaults to all groups.String“group”:”Relay*”
hostDisplayed alerts must be associated with devices that meet this filter criteria. Glob is accepted, and * and an empty string both indicate all devices.No. Defaults to all hosts.String“host”:”*”
dataSourceDisplayed alerts must be associated with datasources that meet this filter criteria. Glob is accepted, and * and an empty string both indicate all datasources.No. Defaults to all datasources.String“dataSource”:”*”
instanceDisplayed alerts must be associated with instances that meet this filter criteria. Glob is accepted, and * and an empty string both match all instances.No. Defaults to all instances.String“instance”:”HTTP_Page-instance0″
dataPointDisplayed alerts must be associated with datapoints that meet this filter criteria. Glob is accepted, and * and an empty string both match all datapoints.No. Defaults to all datapoints.String“dataPoint”:”*”
severityDisplayed alerts must have a severity that satisfies this criteria. Multiple severities are separated by commas.No. Defaults to warn.String“severity”:”warn”
ackedall | acked. Displayed alerts must have an acknowledgement status that satisfies this criteria.No. Defaults to all.String“acked”:”all”
sdtedall | sdted. Displayed alerts must have an SDT status that meets this criteria.No. Defaults to all.String“sdted”:”all”
ruleDisplayed alerts must match a rule that satisfies this filter. Glob is accepted, and * and an empty string both match all rules. No. Defaults to all rules.String“rule”:”*”
chainDisplayed alerts must be routed to an escalation chain that satisfies this filter. Glob is accepted, and * and an empty string both match all escalation chains. No. Defaults to all chains.String“chain”:”*”
clearedall | no. Displayed alerts must be active if cleared=no, and must have cleared in the past 7 days if cleared=all.No. Defaults to no.String“cleared”:”no”

Batchjob Widget Properties

You may additionally POST the following properties for all widgets of type batchjob (batchjob widgets).

Property Description Required? Type Example
deviceDisplayNameThe display name of the device in LogicMonitor that the batchjob is running onNo. Defaults to *.String“deviceDisplayName”:”10.36.11.240″
batchJobNameThe name of the batchjob definition in LogicMonitorOne of batchJobName and batchJobId are required. String“batchJobName”:”myBatchJob”
batchJobIdThe id of the batchjob definition in LogicMonitorOne of batchJobName and batchJobId are required. String“batchJobId”:2

Big Number Widget

All widgets of type bigNumber (big number widgets) must include an object bigNumberInfo with the following fields.

Property Description Required? Type Example
dataPointsThe datapoints included in the widget, where each datapoint can include:

 

  • deviceGroupFullPath -Required, Glob accepted
  • deviceDisplayName -Required, Glob accepted
  • dataSourceId -Required
  • dataSourceFullName -Optional
  • instanceName -Required, Glob accepted
  • dataPointName – One of dataPointId and dataPointName are required.
  • dataPointId – One of dataPointId and dataPointName are required.
  • name (datapoint configuration name) – Required
  • aggregateFunction (sum | min | max | average) – Optional

Note that a datapoint must be referenced in the bigNumberItems object in order to be displayed.

YesJSON Object“dataPoints”:[{“deviceGroupFullPath”:”Website”,”deviceDisplayName”:”ip-172-31-37-162.us-west-2.compute.interal”,”dataSourceId”:559,”instanceName”:”NetSNMPCPUwithCores-Core Count: 1″,”dataPointName”:”CPUBusyPercent”,”name”:”CPUBusyPercent”}]
virtualDataPointsThe virtual datapoints included in the widget, where each virtual datapoint needs to include a name (of a datapoint configuration) and rpn (calculation). Note that a virtual datapoint must be referenced in the bigNumberItems object in order to be displayed. NoJSON Object“virtualDataPoints”:[{“name”:”CPU Idle Percent”,”rpn”:”100 – CPUBusyPercent”}]
bigNumberItemsThe datapoints and virtual datapoints whose values should be displayed in the big number widget, where each item needs to include:

 

  • position (1 | 2 | 3 | 4)
  • rightLabel
  • bottomLabel
  • dataPointName
  • rounding (0 | 1 | 2) where 0=no decimal, 1=one decimal place, 2=two decimal places
YesJSON Object“bigNumberItems”:[{“position”:1,”rightLabel”:”%”,”bottomLabel”:””,”dataPointName”:”CPUBusyPercent”,”rounding”:”0″},{“position”:3,”rightLabel”:””,”bottomLabel”:”%”,”dataPointName”:”CPU Idle Percent”,”rounding”:”1″}]

Custom Graph Widget

All widgets of type cgraph (custom graph widgets) must include an object graphInfo with the following fields.

Property Description Type Required?
titleThe custom graph titleStringYes
aggregatetrue: You can set this field to true to aggregate results into one line.
false: Results will not be aggregated.
BooleanNo. Defaults to false.
top10Onlytrue: You can set this field to true to limit results to 10 lines. Note that only one of aggregate and top10Only can be set to true, as results cannot be both aggregated and limited.
false: Results will not be limited
BooleanNo. Defaults to false.
base1024Change base scale from 1000 to 1024BooleanNo. Defaults to false
maxValueThe maximum value that should be displayed on the y-axisIntegerNo. Defaults to no max
minValueThe minimum value that should be displayed on the y-axisIntegerNo. Defaults to no min
verticalLabelThe label that will be display along the y axisStringYes
heightThe number of pixels tall the graph is. If the widget rowSpan is set to 1, this value will be 120.IntegerNo. Defaults to 120.
widthThe number of pixels wide the graph is. If the widget rowSpan is set to 1, this value will be 360.IntegerNo. Defaulst to 360.
dataPointsThe datapoints added to the widget (note that a datapoint must be referenced in a graph line to be displayed). You can to include a name (required), consolidateFunction (1=average, 2=max, 3=min)(Data Series field in the UI, and defaults to 1), aggregateFunction (min, max, sum, average), dataPointId or dataPointName (required), deviceDisplayName (required), dataSourceFullName or dataSourceId (required), instanceName (required), and deviceGroupFullPath (required)JSON ObjectYes
virtualDataPointsThe virtual datapoints added to the widget (note that a virtual datapoint must be referenced in a graph line to be displayed). You must include a name and rpn (calculation that references a dataPoint name in the dataPoints object)JSON ObjectNo
graphLinesThe graph lines to be displayed in the widget, where graph lines should reference the dataPoints and virtualDataPoints. You need to include dataPointName, legend, and type (1=line, 2=area, 3=stack, 4=column)JSON ObjectYes

Device NOC Widget Properties

You may also POST the following fields for widgets of type deviceNOC (device NOC widgets).

Property Description Required? Type Example
sortByHow NOC items are sorted. Options are name | alertSeverity.No. Defaults to name.String“sortBy”:”name”
displayColumnThe maximum number of columns displayed in the NOC widget.No. Defaults to 1.Integer“displayColumn”:3
displayWarnAlertWhether or not warning alerts are displayed in the NOC widgetNo. Defaults to true.Boolean“displayWarnAlert”:true
displayErrorAlertWhether or not error alerts are displayed in the NOC widgetNo. Defaults to true.Boolean“displayErrorAlert”:true
displayCriticalAlertWhether or not critical alerts are displayed in the NOC widgetNo. Defaults to true.Boolean“displayCriticalAlert”:true
ackCheckedWhether or not acknowledgements are displayed in the NOC widgetNo. Defaults to true.Boolean“ackChecked”:true
sdtCheckedWhether or not SDTs are displayed in the NOC widgetNo. Defaults to true.Boolean“sdtChecked”:true
itemsThe NOC items, where each item needs to include:

 

  • deviceGroupFullPath
  • deviceDisplayName
  • dataSourceDisplayName
  • instanceName
  • dataPointName
  • groupBy (optional – defaults to deviceGroup if omitted)
  • name (the item name, as it will be displayed in the widget)
YesJSON Object“items”:[{“deviceGroupFullPath”:”*”,”deviceDisplayName”:”ip-172-31-33-214.us-west-2.compute.internal”,”dataSourceDisplayName”:”HTTP-“,”instanceName”:”*”,”dataPointName”:”*”,”groupBy”:”device”,”name”:”##HOSTNAME## – HTTP content/function”},{“deviceGroupFullPath”:”*”,”deviceDisplayName”:”ip-172-31-33-214.us-west-2.compute.internal”,”dataSourceDisplayName”:”Apache-“,”instanceName”:”*”,”dataPointName”:”*”,”groupBy”:”device”,”name”:”##HOSTNAME## – Apache”},{“deviceGroupFullPath”:”*”,”deviceDisplayName”:”ip-172-31-33-214.us-west-2.compute.internal”,”dataSourceDisplayName”:”Host Status”,”instanceName”:”*”,”dataPointName”:”*”,”groupBy”:”device”,”name”:”##HOSTNAME## – Host Status”}]

Gauge Widget Properties

You may also POST the following fields for widgets of type gauge (gauge widgets).

Property Description Required? Type Example
showPeakWhether or not the peak value is displayed on the gauge widgetNo. Defaults to false.Boolean“showPeak”:false
peakTimeRangeThe time range over which the peak value is determinedNo. Defaults to hour. String“peakTimeRange”:”30days”
legendThe legend for the widget, displayed underneath the gaugeNoString“legend”:”Apache Accesses”
maxValueThe maximum value of the gauge widget, displayed on the right side of the gaugeYesInteger“maxValue”:5.0
minValueThe minimum value of the gauge widget, displayed on the left side of the gaugeYesInteger“minValue”:0.0
dataPointThe datapoint whose value is displayed in the gauge widget. The following fields must be specified for each datapoint (unless otherwise noted below):

 

  • deviceGroupFullPath – Required, Glob accepted
  • deviceDisplayName – Required, Glob accepted
  • dataSourceFullName – One of dataSourceFullName and dataSourceId are required
  • dataSourceId – One of dataSourceFullName and dataSourceId are required
  • instanceName – Required
  • dataPointName – One of dataPointName and dataPointId are required
  • dataPointId – One of dataPointName and dataPointId are required
  • aggregationFunction – this field determines how data is aggregated across instances (defaults to max if omitted). Options are SUM, MAX and MIN.
  • dataSeries (defaults to average if omitted)
  • rpn: Perform a calculation on a datapoint (defaults to blank if omitted)
YesJSON Object“dataPoint”:{“deviceGroupFullPath”:”Production”,”deviceDisplayName”:”ip-172-31-37-162.us-west-2.compute.interal”,”dataSourceId”:”124″,”instanceName”:”*”,”dataPointName”:”Accesses”,”aggregateFunction”:”SUM”,”rpn”:”Accesses + 10″,”dataSeries”:”average”}

Google Map Widget Properties

You must also POST an object mapPoints with the following fields for widgets of type gmap (google map widgets).

Property Description Required? Type Example
typeWhether or not the mapPoint represents a device or a groupYesString“type”:”group”
deviceGroupFullPathThe full path of the device group associated with the map point. This may be the group the map point represents, or the group of the device that the map point represents.YesString“deviceGroupFullPath”:”Production/AWS”
deviceDisplayNameThe display name of the device the map point represents (if type=device). This field supports Glob (*).Yes, if type=deviceString“deviceDisplayName”:”ProductionServer23″

HTML Widget Properties

You must also POST an object ‘resources’ with the following fields for widgets of type html (HTML widgets).

Property Description Required? Type Example
typehtml | iframeYesString“type”:”html”
URLIf type = html this should be a url, if type = iframe this should be an iframe.YesString“URL”:”https://api.logicmonitor.com”

Normal Graph Widget (Device Graphs) Properties

You may also POST the following fields for widgets of type ngraph (pinned device level graphs).

Property Description Required? Type Example
hIdThe id of the device the graph was pinned fromYesInteger“hId”:199
dsiIdThe id of the datasource instance the graph was pinned fromYesInteger“dsiId”:2133
graphIdThe id of the datasource graph this widget was pinned fromYesInteger“graphId”:1042

Pie Chart Widget Properties

You must also POST an object pieChartInfo with the following fields for all widgets of type pieChart (pie chart widgets).

Property Description Required? Type Example
titleThe title that will be displayed above the pie chartNoString“title”:”CostPerRegion”
showLabelsAndLinesOnPCWhether or not labels and lines should be displayed on the pie chart widgetNo. Defaults to false.Boolean“showLabelsAndLinesOnPC”:false
maxSlicesCanBeShownThe maximum number of slices you’d like displayed in the pie chart. The maximum number of allowed slices is 25.No. Defaults to 10.Integer“maxSlicesCanBeShown”:10
groupRemainingAsOthersIf the number of slices exceeds the maxSlicesCanBeShown, this value indicates whether the remaining slices should be grouped togetherNo. Defaults to false.Boolean“groupRemainingAsOthers”:false
dataPointsThe datapoints added to the widget. Note that datapoints must be included in the pieChartItems object to be displayed in the widget. Each dataPoint should include:

 

  • name (for the datapoint configuration) – required
  • dataPointName – One of dataPointName and dataPointId are required
  • deviceGroupFullPath (optional) – The path of the device group, relative to the root group
  • dataPointId – One of dataPointName and dataPointId are required
  • deviceDisplayName – Required
  • dataSourceId – One of dataSourceId and dataSourceName are required.
  • dataSourceFullName (this is the datasource name, not the display name, and should include any dashes present in the name) – One of dataSourceId and dataSourceName are required.
  • instanceName – Required
  • top10: true | false, where only one of top10 and aggregate can be true
  • aggregate: true | false, where only one of top10 and aggregate can be true
  • aggregationFunction – required if aggregate=true. Options are SUM, MAX and MIN.
YesJSON Object“dataPoints”:[{“deviceGroupFullPath”:”Website”,”deviceDisplayName”:”*”,”dataSourceFullName”:”Apache-“,”instanceName”:”Apache-80″,”dataPointName”:”ExtendedStatusNotEnabled”,”name”:”ExtendedStatusNotEnabled”,”aggregate”:true,”aggregateFunction”:”sum”}]
virtualDataPointsThe virtual datapoints added to the widget, where each virtual datapoint needs a name (configuration name) and rpn (calculation that references a datapoint name). Note that virtual datapoints must be included in the pieChartItems object to be displayed in the widget. NoJSON Object“virtualDataPoints”:[{“name”:”1″,”rpn”:”maxrtt + 1000″},{“name”:”2″,”rpn”:”maxrtt + 2000″},{“name”:”3″,”rpn”:”maxrtt +500″},{“name”:”4″,”rpn”:”maxrtt + 4000″},{“name”:”5″,”rpn”:”maxrtt + 100″}]
pieChartItemsThe datapoints and virtual datapoints that will be displayed in the pie chart

 

  • dataPointName (which should reference a dataPoint or virtualDataPoint config name)
  • legend
  • color: Auto | yellow | teal | silver | red | purple | orange | olive | navy | maroon | lime | green | gray | fuschia | blue | black | aqua
YesJSON Object“pieChartItems”:[{“dataPointName”:”ExtendedStatusNotEnabled”,”legend”:”SA-EAST1″,”color”:”Auto”},{“dataPointName”:”1″,”legend”:”EU-CENTRAL1″,”color”:”Auto”}]

Service Individual Status Widget Properties

You may also POST the following fields for widgets of type serviceIndividualStatus (service individual status widgets).

Property Description Required? Type Example
serviceIdThe id of the service that status is displayed forYesInteger“serviceId”:21
locationsThe checkpoint locations for which data is displayedYesJSON Object“locations”:[{“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}]

Service NOC Widget Properties  

You may also POST the following fields for widgets of type serviceNOC (service NOC widgets).

Property Description Required? Type Example
sortByHow NOC items are sorted. Options are name | severity.No. Defaults to name.String“sortBy”:”name”
displayColumnThe maximum number of columns displayed in the NOC widget.No. Defaults to 2.Integer“displayColumn”:3
displayWarnAlertWhether or not warning alerts are displayed in the NOC widgetNo. Defaults to true.Boolean“displayWarnAlert”:true
displayErrorAlertWhether or not error alerts are displayed in the NOC widgetNo. Defaults to true.Boolean“displayErrorAlert”:true
displayCriticalAlertWhether or not critical alerts are displayed in the NOC widgetNo. Defaults to true.Boolean“displayCriticalAlert”:true
ackCheckedWhether or not acknowledgements are displayed in the NOC widgetNo. Defaults to true.Boolean“ackChecked”:true
sdtCheckedWhether or not SDTs are displayed in the NOC widgetNo. Defaults to true.Boolean“sdtChecked”:true
itemsThe NOC itemsYesJSON Object“items”:[{“serviceGroupName”:”Production”,”serviceName”:”*”,”groupBy”:”service”,”name”:”##SERVICE##”},{“serviceGroupName”:”Internal Services”,”serviceName”:”*”,”groupBy”:”service”,”name”:”##SERVICE##”}

Service Overall Status Widget Properties

For widgets of type serviceOverallStatus (service overall status widgets) you must POST an object selectedServices with the following fields.

Property Description Required? Type Example
serviceGroupIdThe id of the service group.YesJSON Object“serviceGroupId”:1
chooseAllWhether or not all services in the group should be included.No. Defaults to false.JSON Object“chooseAll”:false
servicesThe services that should be displayed in the widget, where each service needs to include name and idYes, unless chooseAll=false.JSON Object“services”:[{“id”:21,”name”:”main page”},{“id”:22,”name”:”a record (ELB)”}]

Service SLA Widget Properties  

You can additionally POST the following fields for widgets of type serviceSLA (service SLA widgets).

Property Description Required? Type Example
itemsThe services that should be used to compute the SLA, where each service should include serviceGroup and serviceYesJSON Object“items”:[{“serviceGroup”:”Production”,”service”:”*”},{“serviceGroup”:”Internal Services”,”service”:”*”}]

Device SLA Widget Properties  

You can additionally POST the following fields for widgets of type deviceSLA (device SLA widgets).

Property Description Required? Type Example
metricsThe metrics (datapoints) that should be used to compute the SLA, where each service should include groupName (can be *), deviceName (can be *), dataSourceId or dataSourceFullName, instances (can be *), metric (datapoint), threshold, and exclusionSDTType (empty string means SDT periods will not be excluded, “group” means SDT periods at the device group level will be excluded, and “device” means SDT periods at the device level will be excluded)YesJSON Object“metrics”:[{“groupName”:”*”,”deviceName”:”*”,”dataSourceFullName”:”EC2 (AWS_EC2)”,”instances”:”*”,”metric”:”CPUUtilization”,”threshold”:”< 1″}]
daysInWeekThe days that SLA should be computed for, separated by commas. 1=Sunday, 2=Monday, 3=Tuesday, 4=Wednesday, 5=Thursday, 6=Friday, 7=Saturday.No. Defaults to “*”String“daysInWeek”:”1,2,3,4,5,6,7″
periodInOneDayThe period during the selected days that the SLA should be computed for. * = all day, or a time range can be specified in the format of “hh:mm TO hh:mm”, e.g. “01:15 TO 17:15”.No. Defaults to “*”.String“periodInOneDay”:”08:00 TO 12:00″
unmonitoredTimeTypeHow no data should be treated: 0 = unmonitored time will be ignored & subtracted from the total possible time, 1 = unmonitored time will be subtracted from uptime and counted as a violation, 2 = unmonitored time will be added to uptime and counted as available.No. Defaults to 0.Integer“unmonitoredTimeType”:0
displayType0 | 1 | 2 – Whether or not selected metrics should be combined into one number (displayType:0), displayed individually, up to four metrics (displayType:1), or displayed one per line in a table (displayType:2) .No. Defaults to 0.Integer“displayType”:0
topX1 | 10 | 25| 50 – The quantity of numbers to display per datapoint (if glob is used)No. Defaults to 10.Integer“topX”:10
bottomLabelThe services that should be used to compute the SLA, where each service should include serviceGroup and serviceNo. Defaults toString“bottomLabel”:”Time Available”

Service Graph Widget (graphs pinned from the services tab) Properties

You can additionally POST the following fields for widgets of type sgraph (graph pinned from the services page).

Property Description Required? Type Example
serviceCheckpointIdThe id of the checkpoint this graph is associated withYesInteger“serviceCheckpointId”:99
graphThe name of the graph that was added as a widgetYesString“graph”:”responseTime”
serviceNameThe name of the service this graph is associated withYesString“serviceName”:”CName_check”

Table Widget Properties

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.

Property Description Type Required?
columnNameThe name for the columnStringYes
dataPointThe DataSource and DataPoint that are selected for the columnJSON ObjectYes
alternateDataPointsAny alternate DataSource and DataPoint combinations that should be selected for the columnJSON ObjectNo
enableForecastWhether or not forecasting is enabledBooleanNo
roundingDecimalThe number of decimal points to round the value to. Options are 0, 1 and 2.IntegerNo
rpnThe expression in this field will be performed on the datapoint. The Column name should be referenced as the datapoint.StringNo

And a ‘rows’ object needs to be included, where each row has the following fields.

Property Description Type Required?
labelThe label for the rowStringYes
groupIdThe ID of the group selected for the rowIntegerOne of groupId and groupFullPath are required
groupFullPathThe full path of the group selected for the rowStringOne of groupId and groupFullPath are required
deviceIdThe id of the device selected for the rowIntegerYes
deviceDisplayNameThe display name of the device selected for the rowStringNo
instancesThe instances for each column of the row. You must include instanceId and dataPointId for each column in the row.JSON ObjectYes

And a ‘forecast’ object is required if you have enableForecast=true, where you need all three of the following fields.

Property Description Type Example
algorithmLinear | ARIMA, where linear = line of best fit, and ARIMA = 95% confidence forecastString“algorithm”:”Linear”
timeRangeThe training data time range (the data on which forecasting is calculated). Options are Last 7 days, Last 14 days, Last 30 days, Last calendar month, Last 365 days or a custom time rangeString“timeRange”:”Last 7 days”
severityThe minimum alert severity the forecasting should include, one of warn | error | criticalString“severity”:”warn”
confidenceThe percent confidence that should be required for a forecasted alert.Integer“confidence”:90

Text Widget Properties

All widgets of type text (text widgets) must include a content field.

Property Description Type Required?
contentThe html content that the text widget should displayStringYes

Examples

The following examples illustrate adding various widgets to an account api.logicmonitor.com via Python.

Example: Alert Widget

The following Python script adds an Alert widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
data = '{"name":"Website Alert Widget","dashboardId":26,"type":"alert","filters":{"group":"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.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

Example: BatchJob Widget

The following Python script adds a BatchJob widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
data = '{"type":"batchjob","dashboardId":"26","name":"batch job test","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.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

Example: Big Number Widget

The following Python script adds a Big Number Widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
data = '{"type":"bigNumber","dashboardId":"26","name":"big number test","bigNumberInfo":{"dataPoints":[{"deviceGroupFullPath":"Website","deviceDisplayName":"ip-172-31-37-162.us-west-2.compute.interal","dataSourceId":559,"instanceName":"NetSNMPCPUwithCores-Core Count: 1","dataPointId":2899,"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.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

Example: Device NOC Widget

The following Python script adds a Device NOC Widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
data = '{"type":"deviceNOC","dashboardId":"26","name":"Device NOC Widget","items":[{"deviceGroupFullPath":"*","deviceDisplayName":"ip-172-31-33-214.us-west-2.compute.internal","dataSourceDisplayName":"HTTP-","instanceName":"*","dataPointName":"*","groupBy":"device","name":"##HOSTNAME## - HTTP content/function"},{"deviceGroupFullPath":"*","deviceDisplayName":"ip-172-31-33-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.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

Example: Gauge Widget

The following Python script adds a Gauge Widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
data = '{"type":"gauge","dashboardId":"26","name":"Gauge Widget","maxValue":100,"minValue":0,"dataPoint":{"deviceGroupFullPath":"Production","deviceDisplayName":"ip-172-31-37-162.us-west-2.compute.interal","dataSourceId":"124","instanceName":"*","dataPointName":"Accesses","aggregateFunction":"SUM","rpn":"Accesses + 10","dataSeries":"average"}}'

#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.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

Example: Google Map Widget

The following Python script adds a Google Map Widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
data = '{"type":"gmap","dashboardId":"26","name":"Google Map Widget","mapPoints":[{"type":"device","deviceGroupFullPath":"US - LA/Website","deviceDisplayName":"ip-172-31-37-162.us-west-2.compute.interal"}]}'

#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.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

Example: HTML Widget

The following Python script adds an HTML widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
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.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

Example: Device Graph Widget (pinned from the devices page)

The following Python script adds a Device Graph to 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 ='POST'
resourcePath = '/dashboard/widgets'
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.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

Example: Pie Chart Widget

The following Python script adds a Pie Chart Widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
data = '{"type":"pieChart","dashboardId":"26","pieChartInfo":{"title":"testWidget","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":"PIE CHART WIDGET TEST"}'

#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.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

Example: Service Individual Status Widget

The following Python script adds a Service Individual Status Widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
data = '{"type":"serviceIndividualStatus","dashboardId":"26","name":"SERVICE IND WIDGET","serviceId":21,"locations":[{"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.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

Example: Service NOC Widget

The following Python script adds a Service NOC Widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
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.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

Example: Service Overall Status Widget

The following Python script adds a Service Overall Status Widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
data = '{"type":"serviceOverallStatus","dashboardId":"26","name":"Service Overall Status","selectedServices":[{"serviceGroupId":1,"serviceGroupName":"api","chooseAll":true},{"serviceGroupId":1,"serviceGroupName":"api","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.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

Example: Service SLA Widget

The following Python script adds a Service SLA Widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
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.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

Example: Service Graph Widget (pinned from the services page)

The following Python script adds a Service Graph Widget to 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 ='POST'
resourcePath = '/dashboard/widgets'
data = '{"type":"sgraph","dashboardId":"26","name":"SGRAPH 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.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

Example: Custom Graph Widget

The following Python script adds a Custom Graph Widget to dashboard 26 in api.logicmonitor.com.

#!/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 = '/dashboard/widgets'
queryParams =''
data = '{"name":"Custom Graph Widget","dashboardId":26,"type":"cgraph","graphInfo":{"title":"My Custom Graph Widget","verticalLabel":"percent","dataPoints":[{"name":"cpu","dataPointName":"CPUBusyPercent","dataSourceFullName":"WinCPU","instanceName":"*","deviceDisplayName":"ip-172-31-37-162.us-west-2.compute.interal","deviceGroupFullPath":"*"}],"graphLines":[{"dataPointName":"cpu","legend":"##INSTANCE##","type":1}]}}'

#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
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.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

Example: Table Widget

The following Python script adds a Table Widget to dashboard 26 in api.logicmonitor.com.

#!/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 = '/dashboard/widgets'
queryParams =''
data = '{"name":"Table Widget","dashboardId":26,"type":"table","columns":[{"columnName":"cpu","dataPoint":{"dataSourceId":7960532,"dataPointId":5349}}],"rows":[{"label":"prodServer1","groupId":7,"deviceId":39,"instances":[{"instanceId":96678897,"dataPointId":5349}]}]}'

#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
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.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

Example: Text Widget

The following Python script adds a Text Widget to dashboard 26 in api.logicmonitor.com.

#!/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 = '/dashboard/widgets'
queryParams =''
data = '{"name":"Text Widget","dashboardId":26,"type":"text","content":"<p>My Text Widget</p>"}'

#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
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.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