Add SDTs

Last updated on 13 October, 2023

You can use LogicMonitor’s REST API to programmatically add new SDTs.

As with all of our API calls, authentication is required.

HTTP Method:POST

URI: /sdt/sdts

The request parameters that need to be included in your request depends on the type of SDT you’re adding:

Add a One Time SDT

Request Parameters: You can POST the following properties for a new one time SDT:

Property Description Required? Values Type
typeThe type resource that this SDT is for. You can set SDTs for Services, Service Groups, Devices, Device Groups, Collectors, Batchjobs, Eventsources, Datasources, Instances & Instance Groups. Depending on the type of SDT, you’ll need to include additional information — see below this table for details.YesServiceSDT | ServiceGroupSDT | DeviceSDT | DeviceGroupSDT | CollectorSDT | DeviceBatchJobSDT | DeviceDataSourceSDT | DeviceEventSourceSDT | DeviceDataSourceInstanceSDT | DeviceDataSourceInstanceGroupSDTString
sdtTypeThe recurrence type of this SDTYesFor a One Time SDT, “sdtType”:1Integer
commentThe comment associated with the SDTNoThis value defaults to a blank StringString
startDateTimeThe epoch time, in milliseconds,that the SDT will startYesInteger
endDateTimeThe epoch time, in milliseconds, that the SDT will endYesInteger

Website SDTs

For SDTs of type=ServiceSDT (note that this is a website SDT, and does not relate to LM Service Insight), you must provide one of serviceId & serviceName:

Property Description Type
serviceIdThe id of the website that the SDT will be associated withInteger
serviceNameThe name of the website that this SDT will be associated withString

Website Group SDTs

For SDTs of type=ServiceGroupSDT (note that this is a website group SDT, and does not relate to LM Service Insight), you must provide one of serviceGroupId. The serviceGroupName is optional:

Property Description Type
serviceGroupIdRequired. The id of the website group that the SDT will be associated withInteger
serviceGroupNameThe name of the website group that this SDT will be associated withString

Device SDTs

For SDTs of type=DeviceSDT, you must provide the deviceId or the deviceDisplayName:

Property Description Type
deviceIdThe id of the device that the SDT will be associated withInteger
deviceDisplayNameThe name of the device that this SDT will be associated withString

Device Group SDTs

For SDTs of type=DeviceGroupSDT, you must provide one of deviceGroupId & deviceGroupFullPath AND one of dataSourceId & dataSourceName:

Property Description Type
deviceGroupIdThe id of the device group that the SDT will be associated withInteger
deviceGroupFullPathThe full path of the device group that this SDT will be associated withString
dataSourceIdThe id of the datasource that this SDT will be associated with, for the specified group. dataSourceId 0 indicates all datasources. Integer
dataSourceNameThe name of the datasource that this SDT will be associated with, for the specified group. dataSourceName “All” indicates all datasources.String

Collector SDTs

For SDTs of type=CollectorSDT, the following parameter is required:

Property Description Type
collectorIdThe id of the collector that the SDT will be associated withInteger

Device DataSource SDTs

For SDTs of type=DeviceDataSourceSDT, you must provide either deviceDataSourceId OR the combination of dataSourceName, and either deviceId or deviceDisplayName:

Property Description Type
deviceDataSourceIdThe id of the device datasource that the SDT will be associated withInteger
deviceIdThe id of the device associated with the datasource that the SDT will apply toInteger
deviceDisplayNameThe display name of the device associated with the datasource that the SDT will apply toString
dataSourceNameThe name of the datasource that the SDT will apply toString

Device Eventsource SDTs

For SDTs of type=DeviceEventSourceSDT, you must provide either deviceEventSourceId OR the combination of eventSourceName and either deviceId or deviceDisplayName:

Property Description Type
deviceEventSourceIdThe id of the device eventsource that the SDT will be associated withInteger
deviceIdThe id of the device associated with the eventsource that the SDT will apply toInteger
deviceDisplayNameThe display name of the device associated with the eventsource that the SDT will apply toString
eventSourceNameThe name of the eventsource that the SDT will apply toString

Device Batchjob SDTs

For SDTs of type=DeviceBatchJobSDT, you must provide either deviceBatchJobId OR the combination of batchJobName and either deviceId or deviceDisplayName:

Property Description Type
deviceBatchJobIdThe id of the device batchjob that the SDT will be associated withInteger
deviceIdThe id of the device associated with the batchjob that the SDT will apply toInteger
deviceDisplayNameThe display name of the device associated with the batchjob that the SDT will apply toString
batchJobNameThe name of the batchjob that the SDT will apply toString

Instance SDTs

For SDTs of type=DeviceDataSourceInstanceSDT, the following parameters are required:

Property Description Type
dataSourceInstanceIdThe id of the datasource instance that the SDT will be associated withInteger
deviceIdThe id of the device that the SDT will be associated withInteger

Instance Group SDTs

For SDTs of type=DeviceDataSourceInstanceGroup, you must provide one of deviceDataSourceInstanceGroupId and deviceDataSourceInstanceGroupName:

Property Description Type
deviceDataSourceInstanceGroupIdThe id of the device datasource instance group that the SDT will be associated withInteger
deviceDataSourceInstanceGroupNameThe name of the device datasource instance group that the SDT will be associated withString

Example 1: Add a One-Time website SDT

The following Python script adds a one-time website SDT to the website with an id of 47:

#!/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 = '/sdt/sdts'
data = '{"sdtType":1,"type":"ServiceSDT","serviceId":47,"startDateTime":1469134752000,"endDateTime":1469144995000}'

#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()
signature = base64.b64encode(hmac1.encode())

#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 2: Add a One-Time Device SDT

The following Python script adds a one-time device SDT to the device with an id of 39:

#!/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 = '/sdt/sdts'
data = '{"sdtType":1,"type":"DeviceSDT","deviceId":39,"startDateTime":1469134752000,"endDateTime":1469144995000}'

#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()
signature = base64.b64encode(hmac1.encode())

#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

Add a Repeating SDT

Request Parameters: You can POST the following parameters for a new repeating SDT:

Property Description Required? Values Type
typeThe type resource that this SDT is for. You can set SDTs for Services, Service Groups, Devices, Device Groups, Collectors, Batchjobs, Eventsources, Datasources, Instances & Instance Groups. Depending on the type of SDT, you’ll need to include additional information — see above this table for details.YesServiceSDT | ServiceGroupSDT | DeviceSDT | DeviceGroupSDT | CollectorSDT | DeviceBatchJobSDT | DeviceDataSourceSDT | DeviceEventSourceSDT | DeviceDataSourceInstanceSDT | DeviceDataSourceInstanceGroupSDTString
sdtTypeThe recurrence type of this SDTYes
  • 2: Weekly SDT
  • 3: Monthly SDT
  • 4: Daily SDT
Integer
commentThe comment associated with the SDTNoThis value defaults to a blank StringString
weekDayThe day of the week that the SDT will be active for a weekly SDTNo
  • 1: Sunday
  • 2: Monday
  • 3: Tuesday
  • 4: Wednesday
  • 5: Thursday
  • 6: Friday
  • 7: Saturday

This value defaults to 1

Integer
monthDayThe day of the month that the SDT will be active for a monthly SDTYes, for sdtType=31 | 2….. | 31Integer
hourThe hour that the SDT will be active for a repeating SDT (daily, weekly, monthly)No0 | 2….. | 23. This value defaults to 0Integer
minuteThe minute of the hour that the SDT will begin for a repeating SDT (daily, weekly, monthly)No0 | 2….. | 59. This value defaults to 0Integer
endHourThe hour that the SDT will end for a repeating SDT (daily, weekly, monthly)No0 | 2….. | 23. This value defaults to 0Integer
endMinuteThe minute of the hour that the SDT will be ends for a repeating SDT (daily, weekly, monthly)No0 | 2….. | 59. This value defaults to 0Integer
durationThe duration of the SDT, in minutesNoThis value defaults to 0Integer

Example 3: Add a Weekly Website SDT

The following Python adds a weekly website SDT for website 23, where the SDT is effective for one hour every Sunday:

#!/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 = '/sdt/sdts'
data = '{"sdtType":2,"type":"ServiceSDT","serviceId":23,"weekDay":1,"hour":16,"minute":30,"endHour":17,"endMinute":30}'

#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()
signature = base64.b64encode(hmac1.encode())

#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 4: Add a Monthly Device SDT

The following Python script adds a monthly device SDT for device 47, where the SDT is effective for one hour on the 15th of every month:

#!/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 = '/sdt/sdts'
data = '{"sdtType":3,"type":"DeviceSDT","deviceId":47,"monthDay":15,"hour":16,"minute":30,"endHour":17,"endMinute":30}'

#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()
signature = base64.b64encode(hmac1.encode())

#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 5: Add a Daily Website SDT

The following Python script adds a daily website SDT for website 23, where the SDT is effective for one hour every day:

#!/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 = '/sdt/sdts'
data = '{"sdtType":4,"type":"ServiceSDT","serviceId":23,"hour":16,"minute":30,"endHour":17,"endMinute":30}'

#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()
signature = base64.b64encode(hmac1.encode())

#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