データソースインスタンスの詳細の取得

最終更新日: 10 年 2024 月 XNUMX 日

LogicMonitor REST API v3 を使用して、データソース インスタンスの詳細を取得できます。 API リクエストを行う前に、自分自身を認証する必要があります。

共通のクエリパラメータ

次のクエリ パラメーターは、データソース インスタンスのすべての GET 呼び出しに共通です。

タイプ説明
fields文字列応答はフィルター処理され、各オブジェクトの指定されたフィールドのみが含まれます。 プロパティのリストをカンマで区切って指定できます。 
例– /device/devices/9/devicedatasources/24/groups?fields=name,id
size整数表示する結果の数を示します。 GET 呼び出しでは最大 1000 件の結果を要求できます。このパラメータに値が指定されていない場合、デフォルトでは 50 個のデバイス データソースのリストが返されます。
例– /device/devices/87/devicedatasources/54/groups?size=5
offset整数表示された結果をオフセットする結果の数を示します。
例– /device/devices/34/devicedatasources/90/groups?offset=2
filter文字列応答は、演算子と指定された値に従ってフィルタリングされます。 filter=property:value
  • 複数の文字と一致するにはアスタリスク (*) を使用します
  • オブジェクト内の値をフィルターするには、ドット (.) 文字を使用します (例 – custom properties)
  • 複数のフィルターを区切るにはカンマ (,) を使用します。

演算子は次のとおりです。
  • 以上以上 >:
  • 以下 <:
  • 越える >
  • 以下 <
  • 等しいです :
  • 等しくない !:
  • 含まれています ~
  • 含まれていません !~
例– /device/devices/43/devicedatasources/76/groups?filter=name:"prod*"

詳細なインスタンス構成情報の取得

URI: 取得 /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/config

クエリパラメータ: fieldssizeoffsetfilter GET 呼び出しを行うときにも含める必要があります /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/config。 詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ deviceIdhdsIdinstanceId に特有のもの /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{instanceId}/config 次の表で説明します。

タイプ説明
deviceId整数(必須の) デバイス ID。
hdsId整数(必須の) デバイスのデータソース ID。
instanceId整数(必須の) インスタンス ID。

デバイス データソース インスタンス グループ リストの取得

URI: 取得 /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups

クエリパラメータ: fieldssizeoffsetfilter GET 呼び出しを行うときにも含める必要があります /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups。 詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ deviceId & deviceDsId に特有のもの /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups 次の表で説明します。

タイプ説明
deviceId整数(必須の) デバイス ID。
deviceDsId整数(必須の) インスタンス グループのリストを取得するデバイス データソース ID。

デバイスインスタンスリストの取得

URI: 取得 /device/devices/{deviceId}/devicedatasources/{hdsId}/instances

クエリパラメータ: fieldssizeoffsetfilter GET 呼び出しを行うときにも含める必要があります /device/devices/{deviceId}/devicedatasources/{hdsId}/instances。 詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ deviceId & hdsId に特有のもの /device/devices/{deviceId}/devicedatasources/{hdsId}/instances 次の表で説明します。

タイプ説明
deviceId整数(必須の) デバイス ID。
hdsId整数(必須の) デバイスのデータソース ID。

次の Python スクリプトを実行して、デバイス ID 533 とデバイス データソース ID 10256 のすべてのインスタンスを取得します。

#!/bin/env python
 
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass
 
#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'
 
#Request Info
httpVerb ='GET'
resourcePath = '/device/devices/533/devicedatasources/10256/instances'
queryParams = ''
data = ''
 
#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
digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8')
 
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}
 
#Make request
response = requests.get(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Pythonの3

デバイスインスタンスのSDT履歴の取得

URI: 取得 /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/historysdts

クエリパラメータ: fieldssizeoffsetfilter GET 呼び出しを行うときにも含める必要があります /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/historysdts。 詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ deviceIdhdsIdid に特有のもの /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/historysdts 次の表で説明します。

タイプ説明
deviceId整数(必須の)デバイスID。
hdsId整数(必須の) デバイスのデータソース ID。
id整数(必須の) SDT 履歴を取得するために必要なインスタンス ID。

デバイスインスタンスの取得

URI: 取得 /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}

クエリパラメータ fields GET 呼び出しを行うときにも含める必要があります /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}。 詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ deviceIdhdsIdid に特有のもの /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id} 次の表で説明します。

タイプ説明
deviceId整数(必須の) デバイス ID。
hdsId整数(必須の) デバイスのデータソース ID。
id整数(必須の) デバイス インスタンスを取得するために必要なインスタンス ID。

次の Python スクリプトを実行して、デバイス ID 533、デバイス データソース ID 10256、およびインスタンス ID 23 のすべてのインスタンスを取得します。

#!/bin/env python
 
import requests
import json
import hashlib
import base64
import time
import hmac
import getpass
 
#Account Info: LogicMonitor recommends to NEVER hardcode the credentials. Instead, retrieve the values from a secure storage.
#Note: The below is provided for illustration purposes only.
AccessId = getpass.getpass("Enter your AccessId: ")
AccessKey = getpass.getpass("Enter your AccessKey: ")
Company = 'apiAccount'
 
#Request Info
httpVerb ='GET'
resourcePath = '/device/devices/533/devicedatasources/10256/instances/23'
queryParams = ''
data = ''
 
#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
digest = hmac.new(
        AccessKey.encode('utf-8'),
        msg=requestVars.encode('utf-8'),
        digestmod=hashlib.sha256).hexdigest()
signature = base64.b64encode(digest.encode('utf-8')).decode('utf-8')
 
#Construct headers
auth = 'LMv1 ' + AccessId + ':' + str(signature) + ':' + epoch
headers = {'Content-Type':'application/json','Authorization':auth,'X-Version':3}
 
#Make request
response = requests.get(url, data=data, headers=headers)
 
#Print status and body of response
print('Response Status:',response.status_code)
print('Response Body:',response.content)
Pythonの3
記事上で