データの取得
最終更新日: 07 年 2024 月 XNUMX 日LogicMonitor REST API v3 を使用してデータを取得できます。 API リクエストを行う前に、自分自身を認証する必要があります。
共通のクエリパラメータ
次のクエリ パラメータはすべてに共通です。 GET
データ API のリクエスト。
種類 | 説明 | |
start | 整数 | 返されるデータの開始時刻 (エポック秒単位)。デフォルトは、選択したグラフの時間範囲です。 |
end | 整数 | 返されたデータの終了時刻 (エポック秒単位)。デフォルトは、選択したグラフの時間範囲です。 |
format | String | 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をクリックします。
追加パラメータ deviceId
, hdsId
, id
, period
, datapoints
GET に固有のもの /device/devices/{deviceId}/devicedatasources/{hdsId}/instances/{id}/data
次の表で説明します。
種類 | 説明 | |
deviceId | 整数 | (必須の) デバイス ID。 |
hdsId | 整数 | (必須の) デバイスのデータソース ID。 |
id | 整数 | (必須の) インスタンス ID。 |
period | 数 | 現在の時刻で終了する時間数のデータを返す必要があります。例えば、 period =2 は過去 2 時間を意味します。 |
datapoints | String | データを返す必要があるデータソースに関連付けられたデータポイント。 |
例
次の 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)
デバイスインスタンスグラフデータの取得
デフォルトでは、設定されたグラフ時間範囲のデータが返されます。
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をクリックします。
追加パラメータ deviceId
, hdsId
, id
, graphId
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)
デバイスインスタンスグループ概要グラフデータの取得
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をクリックします。
追加パラメータ deviceId
, deviceDsId
, dsigId
、および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()
Webサイトのグラフデータの取得
デフォルトでは、設定されたグラフ時間範囲のデータが返されます。
URI: 取得 /website/websites/{websiteId}/checkpoints/{checkpointId}/graphs/{graphName}/data
ご注意: リクエスト GET /website/websites/{websiteId}/checkpoints/{checkpointId}/graphs/{graphName}/data を作成するときに、クエリ パラメーター: start、end、format を含める必要があります。詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。
追加パラメータ websiteId
, checkpointId
, graphName
GET に固有のもの /website/websites/{websiteId}/checkpoints/{checkpointId}/graphs/{graphName}/data
次の表で説明します。
種類 | 説明 | |
websiteId | 整数 | (必須の) チェックポイントの詳細を取得する Web サイトの ID。 |
checkpointId | 整数 | (必須の) グラフ データを取得するチェックポイントの ID。 |
graphName | String | (必須の) 可能な値が次の場合にデータを取得するグラフの名前。 status , performance (個々のチェックポイントの場合のみ)、および 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)
Web サイトのチェックポイントのデータの取得
デフォルトでは、過去 1 時間のデータが返されます。
URI: 取得 /website/websites/{srvId}/checkpoints/{checkId}/data
ご注意: リクエスト GET /website/websites/{srvId}/checkpoints/{checkId}/data を作成する際には、クエリ パラメーター: start、end、format を含める必要があります。詳細については、 一般的なクエリパラメータ 列で番号の横にあるXをクリックします。
追加パラメータ srvId
, checkId
, period
, datapoints
, aggregate
GET に固有のもの /website/websites/{srvId}/checkpoints/{checkId}/data
次の表で説明します。
種類 | 説明 | |
srvId | 整数 | (必須の) Web サイトの ID。 |
checkId | 整数 | (必須の) データを取得するサービス チェックポイントの ID。 |
period | 数 | データを返さなければならない時間数。 |
datapoints | String | データが返される Web サイトに関連付けられたデータポイント。 |
aggregate | String | 利用可能な値は – first , last , min , max , sum , average , none 。 デフォルト値は 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)
ウィジェットデータの取得
このデータ リソースは、テキスト、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)