LogicMonitor seeks to disrupt AI landscape with $800M strategic investment at $2.4B valuation to revolutionize data centers.

Learn More

Update SDTs

Last updated on 25 February, 2021

With LogicMonitor’s REST API you can programmatically update an existing SDT.

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

Note that consistent with REST standards, any properties not specified in a PUT request will revert back to their default values.

HTTP Method:PUT

URI: /sdt/sdts/{id}

The parameters you can include in your request depends on what type of SDT you’re updating:

Update a One Time SDT

Request Parameters: You can specify the following properties in your PUT request for a one time SDT:

Property

Description

Required?

Values

Type

type The 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. Yes ServiceSDT | ServiceGroupSDT | DeviceSDT | DeviceGroupSDT | CollectorSDT | DeviceBatchJobSDT | DeviceDataSourceSDT | DeviceEventSourceSDT | DeviceDataSourceInstanceSDT | DeviceDataSourceInstanceGroupSDT String
sdtType The recurrence type of this SDT No For a One Time SDT, “sdtType”:1 Integer
comment The comment associated with the SDT No This value defaults to a blank String String
startDateTime The epoch time, in milliseconds,that the SDT will start No This value defaults to 0 Integer
endDateTime The epoch time, in milliseconds, that the SDT will end No This value defaults to 0 Integer

Service SDTs

 For SDTs of type=ServiceSDT, you must provide one of serviceId & serviceName:

Property

Description

Type

serviceId The id of the service that the SDT will be associated with Integer
serviceName The name of the service that this SDT will be associated with String

Service Group SDTs

 For SDTs of type=ServiceGroupSDT, you must provide one of serviceGroupId & serviceGroupName:

Property

Description

Type

serviceGroupId The id of the service group that the SDT will be associated with Integer
serviceGroupName The name of the service group that this SDT will be associated with String

Device SDTs

 For SDTs of type=DeviceSDT, you must provide one of deviceId & deviceDisplayName:

Property

Description

Type

deviceId The id of the device that the SDT will be associated with Integer
deviceDisplayName The name of the device that this SDT will be associated with String

Device Group SDTs

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

Property

Description

Type

deviceGroupId The id of the device group that the SDT will be associated with Integer
deviceGroupFullPath The full path of the device group that this SDT will be associated with String
dataSourceId The id of the datasource that this SDT will be associated with, for the specified group. dataSourceId 0 indicates all datasources. Integer
dataSourceName The 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

collectorId The id of the collector that the SDT will be associated with Integer

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

deviceDataSourceId The id of the device datasource that the SDT will be associated with Integer
deviceId The id of the device associated with the datasource that the SDT will apply to Integer
deviceDisplayName The display name of the device associated with the datasource that the SDT will apply to String
dataSourceName The name of the datasource that the SDT will apply to String

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

deviceEventSourceId The id of the device eventsource that the SDT will be associated with Integer
deviceId The id of the device associated with the eventsource that the SDT will apply to Integer
deviceDisplayName The display name of the device associated with the eventsource that the SDT will apply to String
eventSourceName The name of the eventsource that the SDT will apply to String

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

deviceBatchJobId The id of the device batchjob that the SDT will be associated with Integer
deviceId The id of the device associated with the batchjob that the SDT will apply to Integer
deviceDisplayName The display name of the device associated with the batchjob that the SDT will apply to String
batchJobName The name of the batchjob that the SDT will apply to String

Instance SDTs

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

Property

Description

Type

dataSourceInstanceId The id of the datasource instance that the SDT will be associated with Integer
deviceId The id of the device that the SDT will be associated with Integer

Instance Group SDTs

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

Property

Description

Type

deviceDataSourceInstanceGroupId The id of the device datasource instance group that the SDT will be associated with Integer
deviceDataSourceInstanceGroupName The name of the device datasource instance group that the SDT will be associated with String

Update a Repeating SDT

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

Property

Description

Required?

Values

Type

type The 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. Yes ServiceSDT | ServiceGroupSDT | DeviceSDT | DeviceGroupSDT | CollectorSDT | DeviceBatchJobSDT | DeviceDataSourceSDT | DeviceEventSourceSDT | DeviceDataSourceInstanceSDT | DeviceDataSourceInstanceGroupSDT String
sdtType The recurrence type of this SDT No

 

  • 2: Weekly SDT
  • 3: Monthly SDT
  • 4: Daily SDT

 

Integer
comment The comment associated with the SDT No This value defaults to a blank String String
weekDay The day of the week that the SDT will be active for a weekly SDT No

 

  • 1: Sunday
  • 2: Monday
  • 3: Tuesday
  • 4: Wednesday
  • 5: Thursday
  • 6: Friday
  • 7: Saturday


This value defaults to 1

Integer
monthDay The day of the month that the SDT will be active for a monthly SDT No 1 | 2….. | 31. This value defaults to 0 Integer
hour The hour that the SDT will be active for a repeating SDT (daily, weekly, monthly) No 1 | 2….. | 24. This value defaults to 0 Integer
minute The minute of the hour that the SDT will begin for a repeating SDT (daily, weekly, monthly) No 1 | 2….. | 60. This value defaults to 0 Integer
endHour The hour that the SDT will end for a repeating SDT (daily, weekly, monthly) No 1 | 2….. | 24. This value defaults to 0 Integer
endMinute The minute of the hour that the SDT will be ends for a repeating SDT (daily, weekly, monthly) No 1 | 2….. | 31. This value defaults to 0 Integer
duration The duration of the SDT, in minutes No This value defaults to 0 Integer

Example 1: Python

The following Python script updates a daily SDT for service 23:

#!/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 ='PUT'
resourcePath = '/sdt/sdts/S_11'
queryParams =''
data = '{"sdtType":4,"type":"ServiceSDT","serviceId":23,"hour":18,"minute":45,"endHour":19,"endMinute":45}'

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

#Construct headers
auth = 'LMv1 ' + AccessId + ':' + signature.decode() + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth}

#Make request
response = requests.put(url, data=data, headers=headers)

#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Python 3

Example 2: PowerShell

The following PowerShell script updates a daily SDT for service 23:

<# Use TLS 1.2 #>
[Net.ServicePointManager]::SecurityProtocol = <span class="error">[Net.SecurityProtocolType]</span>::Tls12

<# account info #>
$accessId = '48v2wRzfK94y53sq5EuF'
$accessKey = 'H_D9i(f5~B^U36^K6i42=^nS~e75gy382Bf6{)P+'
$company = 'api'

<# request details #>
$httpVerb = 'PUT'
$resourcePath = '/sdt/sdts/S_11'
$data = '{"sdtType":4,"type":"ServiceSDT","serviceId":23,"hour":18,"minute":45,"endHour":19,"endMinute":45}'

<# Construct URL #>
$url = 'https://' + $company + '.logicmonitor.com/santaba/rest' + $resourcePath

<# Get current time in milliseconds #>
$epoch = [Math]::Round((New-TimeSpan -start (Get-Date -Date "1/1/1970") -end (Get-Date).ToUniversalTime()).TotalMilliseconds)

<# Concatenate Request Details #>
$requestVars = $httpVerb + $epoch + $data + $resourcePath

<# Construct Signature #>
$hmac = New-Object System.Security.Cryptography.HMACSHA256
$hmac.Key = [Text.Encoding]::UTF8.GetBytes($accessKey)
$signatureBytes = $hmac.ComputeHash([Text.Encoding]::UTF8.GetBytes($requestVars))
$signatureHex = [System.BitConverter]::ToString($signatureBytes) -replace '-'
$signature = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($signatureHex.ToLower()))

<# Construct Headers #>
$auth = 'LMv1 ' + $accessId + ':' + $signature + ':' + $epoch
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization",$auth)
$headers.Add("Content-Type",'application/json')

<# Make Request #>
$response = Invoke-RestMethod -Uri $url -Method $httpVerb -Body $data -Header $headers 

<# Print status and body of response #>
$status = $response.status
$body = $response.data| ConvertTo-Json -Depth 5

Write-Host "Status:$status"
Write-Host "Response:$body"
PowerShell
In This Article