Add a Widget
Last updated on 29 June, 2022Overview
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 |
name | The name of the widget | Yes | String | “name”:”Apache Requests” |
description | The description of the widget | No | String | “description”:”My Widget Description” |
type | alert | deviceNOC | html | serviceOverallStatus | sgraph | ngraph | serviceNOC | serviceSLA | deviceSLA | bigNumber | gmap | serviceIndividualStatus | gauge | pieChart | ngraph | batchjob” | Yes | String | “type”:”alert” |
dashboardId | The id of the dashboard the widget will be added to | Yes | Integer | “dashboardId”:50 |
theme | The color scheme of the widget. Options are borderPurple | borderGray | borderBlue | solidPurple | solidGray | solidBlue | simplePurple | simpleBlue | simpleGray | newBorderGray | newBorderBlue | newBorderDarkBlue | newSolidGray | newSolidBlue | newSolidDarkBlue | newSimpleGray | newSimpleBlue |newSimpleDarkBlue | No. Defaults to borderPurple. | String | “theme”:”simplePurple” |
colSpan | The number of columns the widget’s width should consume | No. Defaults to 1. | Integer | “colSpan”:1 |
rowSpan | The number of rows the widget’s height should consume | No. Defaults to 1. | Integer | “rowSpan”:1 |
interval | The refresh interval of the widget. Options are 1 | 3 | 5 | 10 | 15 (all in minutes) | No. Defaults to 3. | Integer | “interval”:1 |
timescale | The default timescale of the widget. Options are 1hour | 2hour | 5hour | 1day | 2days | 7days | 1month | 3month | 1year | No. Defaults to 1hour. | String | “timescale”:”1day” |
extra | Only applies to alert widgets | No | JSON 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 |
group | Displayed 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*” |
host | Displayed 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”:”*” |
dataSource | Displayed 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”:”*” |
instance | Displayed 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″ |
dataPoint | Displayed 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”:”*” |
severity | Displayed alerts must have a severity that satisfies this criteria. Multiple severities are separated by commas. | No. Defaults to warn. | String | “severity”:”warn” |
acked | all | acked. Displayed alerts must have an acknowledgement status that satisfies this criteria. | No. Defaults to all. | String | “acked”:”all” |
sdted | all | sdted. Displayed alerts must have an SDT status that meets this criteria. | No. Defaults to all. | String | “sdted”:”all” |
rule | Displayed 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”:”*” |
chain | Displayed 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”:”*” |
cleared | all | 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 |
deviceDisplayName | The display name of the device in LogicMonitor that the batchjob is running on | No. Defaults to *. | String | “deviceDisplayName”:”10.36.11.240″ |
batchJobName | The name of the batchjob definition in LogicMonitor | One of batchJobName and batchJobId are required. | String | “batchJobName”:”myBatchJob” |
batchJobId | The id of the batchjob definition in LogicMonitor | One 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 |
dataPoints | The datapoints included in the widget, where each datapoint can include:
Note that a datapoint must be referenced in the bigNumberItems object in order to be displayed. | Yes | JSON 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”}] |
virtualDataPoints | The 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. | No | JSON Object | “virtualDataPoints”:[{“name”:”CPU Idle Percent”,”rpn”:”100 – CPUBusyPercent”}] |
bigNumberItems | The datapoints and virtual datapoints whose values should be displayed in the big number widget, where each item needs to include:
| Yes | JSON 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? |
title | The custom graph title | String | Yes |
aggregate | true: You can set this field to true to aggregate results into one line. false: Results will not be aggregated. | Boolean | No. Defaults to false. |
top10Only | true: 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 | Boolean | No. Defaults to false. |
base1024 | Change base scale from 1000 to 1024 | Boolean | No. Defaults to false |
maxValue | The maximum value that should be displayed on the y-axis | Integer | No. Defaults to no max |
minValue | The minimum value that should be displayed on the y-axis | Integer | No. Defaults to no min |
verticalLabel | The label that will be display along the y axis | String | Yes |
height | The number of pixels tall the graph is. If the widget rowSpan is set to 1, this value will be 120. | Integer | No. Defaults to 120. |
width | The number of pixels wide the graph is. If the widget rowSpan is set to 1, this value will be 360. | Integer | No. Defaulst to 360. |
dataPoints | The 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 Object | Yes |
virtualDataPoints | The 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 Object | No |
graphLines | The 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 Object | Yes |
Device NOC Widget Properties
You may also POST the following fields for widgets of type deviceNOC (device NOC widgets).
Property | Description | Required? | Type | Example |
sortBy | How NOC items are sorted. Options are name | alertSeverity. | No. Defaults to name. | String | “sortBy”:”name” |
displayColumn | The maximum number of columns displayed in the NOC widget. | No. Defaults to 1. | Integer | “displayColumn”:3 |
displayWarnAlert | Whether or not warning alerts are displayed in the NOC widget | No. Defaults to true. | Boolean | “displayWarnAlert”:true |
displayErrorAlert | Whether or not error alerts are displayed in the NOC widget | No. Defaults to true. | Boolean | “displayErrorAlert”:true |
displayCriticalAlert | Whether or not critical alerts are displayed in the NOC widget | No. Defaults to true. | Boolean | “displayCriticalAlert”:true |
ackChecked | Whether or not acknowledgements are displayed in the NOC widget | No. Defaults to true. | Boolean | “ackChecked”:true |
sdtChecked | Whether or not SDTs are displayed in the NOC widget | No. Defaults to true. | Boolean | “sdtChecked”:true |
items | The NOC items, where each item needs to include:
| Yes | JSON 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 |
showPeak | Whether or not the peak value is displayed on the gauge widget | No. Defaults to false. | Boolean | “showPeak”:false |
peakTimeRange | The time range over which the peak value is determined | No. Defaults to hour. | String | “peakTimeRange”:”30days” |
legend | The legend for the widget, displayed underneath the gauge | No | String | “legend”:”Apache Accesses” |
maxValue | The maximum value of the gauge widget, displayed on the right side of the gauge | Yes | Integer | “maxValue”:5.0 |
minValue | The minimum value of the gauge widget, displayed on the left side of the gauge | Yes | Integer | “minValue”:0.0 |
dataPoint | The datapoint whose value is displayed in the gauge widget. The following fields must be specified for each datapoint (unless otherwise noted below):
| Yes | JSON 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 |
type | Whether or not the mapPoint represents a device or a group | Yes | String | “type”:”group” |
deviceGroupFullPath | The 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. | Yes | String | “deviceGroupFullPath”:”Production/AWS” |
deviceDisplayName | The display name of the device the map point represents (if type=device). This field supports Glob (*). | Yes, if type=device | String | “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 |
type | html | iframe | Yes | String | “type”:”html” |
URL | If type = html this should be a url, if type = iframe this should be an iframe. | Yes | String | “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 |
hId | The id of the device the graph was pinned from | Yes | Integer | “hId”:199 |
dsiId | The id of the datasource instance the graph was pinned from | Yes | Integer | “dsiId”:2133 |
graphId | The id of the datasource graph this widget was pinned from | Yes | Integer | “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 |
title | The title that will be displayed above the pie chart | No | String | “title”:”CostPerRegion” |
showLabelsAndLinesOnPC | Whether or not labels and lines should be displayed on the pie chart widget | No. Defaults to false. | Boolean | “showLabelsAndLinesOnPC”:false |
maxSlicesCanBeShown | The 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 |
groupRemainingAsOthers | If the number of slices exceeds the maxSlicesCanBeShown, this value indicates whether the remaining slices should be grouped together | No. Defaults to false. | Boolean | “groupRemainingAsOthers”:false |
dataPoints | The 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:
| Yes | JSON Object | “dataPoints”:[{“deviceGroupFullPath”:”Website”,”deviceDisplayName”:”*”,”dataSourceFullName”:”Apache-“,”instanceName”:”Apache-80″,”dataPointName”:”ExtendedStatusNotEnabled”,”name”:”ExtendedStatusNotEnabled”,”aggregate”:true,”aggregateFunction”:”sum”}] |
virtualDataPoints | The 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. | No | JSON 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″}] |
pieChartItems | The datapoints and virtual datapoints that will be displayed in the pie chart
| Yes | JSON 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 |
serviceId | The id of the service that status is displayed for | Yes | Integer | “serviceId”:21 |
locations | The checkpoint locations for which data is displayed | Yes | JSON 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 |
sortBy | How NOC items are sorted. Options are name | severity. | No. Defaults to name. | String | “sortBy”:”name” |
displayColumn | The maximum number of columns displayed in the NOC widget. | No. Defaults to 2. | Integer | “displayColumn”:3 |
displayWarnAlert | Whether or not warning alerts are displayed in the NOC widget | No. Defaults to true. | Boolean | “displayWarnAlert”:true |
displayErrorAlert | Whether or not error alerts are displayed in the NOC widget | No. Defaults to true. | Boolean | “displayErrorAlert”:true |
displayCriticalAlert | Whether or not critical alerts are displayed in the NOC widget | No. Defaults to true. | Boolean | “displayCriticalAlert”:true |
ackChecked | Whether or not acknowledgements are displayed in the NOC widget | No. Defaults to true. | Boolean | “ackChecked”:true |
sdtChecked | Whether or not SDTs are displayed in the NOC widget | No. Defaults to true. | Boolean | “sdtChecked”:true |
items | The NOC items | Yes | JSON 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 |
serviceGroupId | The id of the service group. | Yes | JSON Object | “serviceGroupId”:1 |
chooseAll | Whether or not all services in the group should be included. | No. Defaults to false. | JSON Object | “chooseAll”:false |
services | The services that should be displayed in the widget, where each service needs to include name and id | Yes, 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 |
items | The services that should be used to compute the SLA, where each service should include serviceGroup and service | Yes | JSON 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 |
metrics | The 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) | Yes | JSON Object | “metrics”:[{“groupName”:”*”,”deviceName”:”*”,”dataSourceFullName”:”EC2 (AWS_EC2)”,”instances”:”*”,”metric”:”CPUUtilization”,”threshold”:”< 1″}] |
daysInWeek | The 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″ |
periodInOneDay | The 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″ |
unmonitoredTimeType | How 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 |
displayType | 0 | 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 |
topX | 1 | 10 | 25| 50 – The quantity of numbers to display per datapoint (if glob is used) | No. Defaults to 10. | Integer | “topX”:10 |
bottomLabel | The services that should be used to compute the SLA, where each service should include serviceGroup and service | No. Defaults to | String | “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 |
serviceCheckpointId | The id of the checkpoint this graph is associated with | Yes | Integer | “serviceCheckpointId”:99 |
graph | The name of the graph that was added as a widget | Yes | String | “graph”:”responseTime” |
serviceName | The name of the service this graph is associated with | Yes | String | “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? |
columnName | The name for the column | String | Yes |
dataPoint | The DataSource and DataPoint that are selected for the column | JSON Object | Yes |
alternateDataPoints | Any alternate DataSource and DataPoint combinations that should be selected for the column | JSON Object | No |
enableForecast | Whether or not forecasting is enabled | Boolean | No |
roundingDecimal | The number of decimal points to round the value to. Options are 0, 1 and 2. | Integer | No |
rpn | The expression in this field will be performed on the datapoint. The Column name should be referenced as the datapoint. | String | No |
And a ‘rows’ object needs to be included, where each row has the following fields.
Property | Description | Type | Required? |
label | The label for the row | String | Yes |
groupId | The ID of the group selected for the row | Integer | One of groupId and groupFullPath are required |
groupFullPath | The full path of the group selected for the row | String | One of groupId and groupFullPath are required |
deviceId | The id of the device selected for the row | Integer | Yes |
deviceDisplayName | The display name of the device selected for the row | String | No |
instances | The instances for each column of the row. You must include instanceId and dataPointId for each column in the row. | JSON Object | Yes |
And a ‘forecast’ object is required if you have enableForecast=true, where you need all three of the following fields.
Property | Description | Type | Example |
algorithm | Linear | ARIMA, where linear = line of best fit, and ARIMA = 95% confidence forecast | String | “algorithm”:”Linear” |
timeRange | The 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 range | String | “timeRange”:”Last 7 days” |
severity | The minimum alert severity the forecasting should include, one of warn | error | critical | String | “severity”:”warn” |
confidence | The 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? |
content | The html content that the text widget should display | String | Yes |
Examples
The following examples illustrate adding various widgets to an account api.logicmonitor.com via Python.
- Alert Widget
- BatchJob Widget
- Big Number Widget
- Device NOC Widget
- Gauge Widget
- Google Map Widget
- HTML Widget
- Device Graph (ngraph) Widget
- Pie Chart Widget
- Service Individual Status Widget
- Service NOC Widget
- Service Overall Status Widget
- Service SLA Widget
- Service Graph (sgraph) Widget
- Custom graph widget
- Table widget
- Text widget
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)