データの取得

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

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

共通のクエリパラメータ

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

タイプ説明
start整数返されるデータの開始時刻 (エポック秒単位)。デフォルトは、選択したグラフの時間範囲です。
end整数返されたデータの終了時刻 (エポック秒単位)。デフォルトは、選択したグラフの時間範囲です。
format文字列data | image | csv – 返されたデータを数値としてフォーマットする必要があるかどうかを指定します (data = json)または画像。デフォルトでは data.

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

デフォルトでは、過去 1 時間のデータが返されます。

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

注: リクエスト GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/data を作成する際には、クエリ パラメーター: start、end、format を含める必要があります。詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

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

タイプ説明
deviceId整数(必須の) デバイス ID。
hdsId整数(必須の) デバイスのデータソース ID。
id整数(必須の) インスタンス ID。
period現在の時刻で終了する時間数のデータを返す必要があります。例えば、 period=2 は過去 2 時間を意味します。
datapoints文字列データを返す必要があるデータソースに関連付けられたデータポイント。

次の Python スクリプトは、デバイス ID 533、デバイス データソース ID 12506、およびインスタンス ID 23 の過去 XNUMX 時間のデータを返します。

#!/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/12506/instances/23/data'
queryParams = '?period=2'
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: 取得 /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/graphs/{graphId}/data

注: リクエスト GET /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/graphs/{graphId}/data を作成するときに、クエリ パラメーター: start、end、format を含める必要があります。詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ deviceIdhdsIdidgraphId GET に固有のもの /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/graphs/{graphId}/data 次の表で説明します。

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

次の Python スクリプトは、インスタンス ID 1482865561、データソース ID 1482865719、およびデバイス ID 253 に関連付けられているグラフ ID 26657295 の 6842 から 258 までのデータを取得します。

#!/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/258/devicedatasources/6842/instances/26657295/graphs/253/data'
queryParams ='?start=1482865561&end=1482865719'
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: 取得 /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups/{dsigId}/graphs/{ographId}/data

注: リクエスト GET /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups/{dsigId}/graphs/{ographId}/data を作成するときに、クエリ パラメーター: start、end、format を含める必要があります。詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ deviceIddeviceDsIddsigId、およびographId GET に固有のもの /device/devices/{deviceId}/devicedatasources/{deviceDsId}/groups/{dsigId}/graphs/{ographId}/data 次の表で説明します。

タイプ説明
deviceId整数(必須の) データを取得するデバイスの ID。
deviceDsId整数(必須の) デバイス データソースの ID。
dsigId整数(必須の) 概要グラフ データを取得するインスタンス グループの ID。
ographId整数(必須の) データを取得する概要グラフの ID。

デバイスインスタンスグラフデータの取得

デフォルトでは、設定されたグラフ時間範囲のデータが返されます。

URI: 取得 /device/devicedatasourceinstances/{instanceId}/graphs/{graphId}/data

注: リクエスト GET /device/devicedatasourceinstances/{instanceId}/graphs/{graphId}/data を作成するときに、クエリ パラメーター: start、end、format を含める必要があります。詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ instanceId & graphId GET に固有のもの /device/devicedatasourceinstances/{instanceId}/graphs/{graphId}/data 次の表で説明します。

タイプ説明
instanceId整数(必須の) グラフ データを取得するデバイス データソース インスタンスの ID。
graphId整数(必須の) グラフデータを取得するグラフのID。

次の Python スクリプトは、デバイス データソース インスタンス ID 4825 に関連付けられているグラフ ID 420576596 の画像ファイル「instanceGraph.png」を保存します。

#!/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/devicedatasourceinstances/420576596/graphs/4825/data'
queryParams = '?format=image'
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 write image data to a png file
print('Response Status:',response.status_code)
file_ = open('instanceGraph.png', 'wb')
file_.write(response.content)
file_.close()
Pythonの3

Webサイトのグラフデータの取得

デフォルトでは、設定されたグラフ時間範囲のデータが返されます。

URI: 取得 /website/websites/{websiteId}/checkpoints/{checkpointId}/graphs/{graphName}/data

注: リクエスト GET /website/websites/{websiteId}/checkpoints/{checkpointId}/graphs/{graphName}/data を作成するときに、クエリ パラメーター: start、end、format を含める必要があります。詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ websiteIdcheckpointIdgraphName GET に固有のもの /website/websites/{websiteId}/checkpoints/{checkpointId}/graphs/{graphName}/data 次の表で説明します。

タイプ説明
websiteId整数(必須の) チェックポイントの詳細を取得する Web サイトの ID。
checkpointId整数(必須の) グラフ データを取得するチェックポイントの ID。
graphName文字列(必須の) 可能な値が次の場合にデータを取得するグラフの名前。 statusperformance (個々のチェックポイントの場合のみ)、および responsetime.

次の Python スクリプトは、Web サイト ID 1482865561、チェックポイント ID 1482865719、およびグラフ名の 58 から 294 までのパフォーマンス グラフ データをリクエストします。 performance.

#!/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 = '/service/services/58/checkpoints/294/graphs/performance/data'
queryParams ='?start=1482865561&end=1482865719'
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

Web サイトのチェックポイントのデータの取得

デフォルトでは、過去 1 時間のデータが返されます。

URI: 取得 /website/websites/{srvId}/checkpoints/{checkId}/data

注: リクエスト GET /website/websites/{srvId}/checkpoints/{checkId}/data を作成する際には、クエリ パラメーター: start、end、format を含める必要があります。詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

追加パラメータ srvIdcheckId, period, datapoints, aggregate GET に固有のもの /website/websites/{srvId}/checkpoints/{checkId}/data 次の表で説明します。

タイプ説明
srvId整数(必須の) Web サイトの ID。
checkId整数(必須の) データを取得するサービス チェックポイントの ID。
periodデータを返さなければならない時間数。
datapoints文字列データが返される Web サイトに関連付けられたデータポイント。
aggregate文字列利用可能な値は – firstlastminmaxsumaveragenone。 デフォルト値は none.

次の Python スクリプトは、Web サイト ID 1482865561 とチェックポイント ID 1482865719 の 58 から 294 までのデータを取得します。

#!/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 = '/website/websites/58/checkpoints/294/data'
queryParams ='?start=1482865561&end=1482865719'
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

ウィジェットデータの取得

このデータ リソースは、テキスト、HTML、および Flash ウィジェットでは機能しません。

  • 地図ウィジェットやアラート ウィジェットなど、時系列データを持たないウィジェットの場合、時間とは無関係に、ウィジェットに表示される内容 (場所と一致するアラート) に基づいてデータが返されます。
  • カスタム グラフ ウィジェットやデバイス グラフ ウィジェットなどの時系列データを含むウィジェットの場合、リクエストで構成または指定された時間範囲に基づいてデータが返されます。

応答には、ウィジェットのタイプに応じて追加の属性が含まれる場合があります。詳細については、このページの最後に記載されている特定のウィジェット タイプに対応するモデルを参照してください。

URI: 取得 /dashboard/widgets/{id}/data

注: リクエスト GET /dashboard/widgets/{id}/data を作成する際には、クエリ パラメーター: start、end、format を含める必要があります。詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。

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

タイプ説明
id整数(必須の) データを取得するウィジェットの ID。

次の Python スクリプトは、ウィジェット 1482865561 の 1482865719 から 362 までのデータを取得します。

#!/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 = '/dashboard/widgets/362/data'
queryParams ='?start=1482865561&end=1482865719'
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
記事上で