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

最終更新日: 12 年 2023 月 XNUMX 日

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

共通のクエリパラメータ

次のクエリ パラメータはすべてに共通です。 GET データソース API のリクエスト。 

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

演算子は次のとおりです。
  • 以上以上 >:
  • 以下 <:
  • 越える >
  • 以下 <
  • 等しいです :
  • 等しくない !:
  • 含まれています ~
  • 含まれていません !~
例– /setting/datasources?filter=name:QAservice

データソースに関連付けられたデバイスの取得

URI: 取得 /setting/datasources/{id}/devices

クエリパラメータ fieldssizeoffsetfilter リクエストを GET するときにも含める必要があります /setting/datasources/{id}/devices。 詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ id これは GET に特有のものです /setting/datasources/{id}/devices 次の表で説明します。

タイプ説明
id整数(必須の) これは、関連デバイスのリストを取得するデータソース ID です。

次の Python スクリプトは、データソース ID 247527051 のデバイスを要求します。

#!/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 = '/setting/datasources/247527051/devices'
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

データソースリストの取得

URI: 取得 /setting/datasources

クエリパラメータ fieldssizeoffsetfilter リクエストを GET するときにも含める必要があります /setting/datasources。 詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ format これは GET に特有のものです /setting/datasources 次の表で説明します。

タイプ説明
format文字列応答形式は JSON または XML です。 デフォルトでは、JSON として設定されています。

次の Python スクリプトは、api.logicmonitor.com アカウントのデータソースをリクエストします。

#!/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 = '/setting/datasources'
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

次の Python スクリプトは、 id & name api.logicmonitor.com のデータソースの場合、応答は ID の昇順で表示されます。

#!/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 = '/setting/datasources'
queryParams = '?fields=id,name&sort=+id'
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

次の Python リクエストは、次のような apply to 関数を持つ api.logicmonitor.com 内のデータソースを返します。 isLinux.

#!/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 = '/setting/datasources'
queryParams = '?filter=appliesTo~"isLinux"'
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

IDに基づいてデータソースを取得する

URI: 取得 /setting/datasources/{id}

クエリパラメータ fields リクエストを GET するときに含める必要があります /setting/datasources/{id}。 詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ id & format GET に特有のもの /setting/datasources/{id} 次の表で説明します。

タイプ説明
id整数(必須の) 詳細を取得したいデータソース ID です。
format文字列応答形式は JSON または XML です。 デフォルトでは、JSON として設定されています。

次の Python スクリプトは、データソース ID 345 の詳細を返します。

#!/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 = '/setting/datasources/345'
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

データソース概要グラフリストの取得

URI: 取得 /setting/datasources/{dsId}/ographs

クエリパラメータ fieldssizeoffsetfilter リクエストを GET するときに含める必要があります /setting/datasources/{dsid}/ographs。 詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ dsId これは GET に特有のものです /setting/datasources/{dsid}/ographs 次の表で説明します。

タイプ説明
dsId整数(必須の) データソースの ID です。

データソースの更新理由の取得

URI: 取得 /setting/datasources/{id}/updatereasons

クエリパラメータ fieldssizeoffsetfilter リクエストを GET するときに含める必要があります /setting/datasources/{id}/updatereasons。 詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ id これは GET に特有のものです /setting/datasources/{id}/updatereasons 次の表で説明します。

タイプ説明
id整数(必須の) 更新履歴を取得したいデータソースID。
記事上で