デバイス/デバイス API のデルタサポート

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

私たちは、顧客がデバイスやそのプロパティなどの最新アップデートを取得するために、5 日を通して LogicMonitor API を複数回クエリしていることを観察しました。 これには人間の努力が必要であり、数時間を要し、エラーが発生しやすくなります。 たとえば、LogicMonitor は XNUMX 台のデバイスを監視します。 API呼び出しを行う /device/devices これらのデバイスを取得してローカル データベースに保存します。 通常、デバイスには、名前の変更、デバイスのプロパティの更新など、いくつかの変更が加えられます。 LogicMonitor によって監視されるデータが最新で信頼できるものであることを確認するには、LogicMonitor API を複数回クエリし、データを保存し、自動化を実行してデルタ (最新の変更) を特定し、有益なダッシュボードを作成します。 このプロセスでは、レート制限を急速に消費します。 たとえば、10 台のデバイスしか更新されていない場合でも、最終的には 5 台のデバイスに相当するデータを消費することになります。 これは、LogicMonitor のパフォーマンスにも影響します。

このギャップを埋めてデルタを迅速に取得できるようにするために、XNUMX つの新しいエンドポイントを追加しました。 /device/devices API。 彼らです:

  • GET /santaba/rest/device/devices/delta – デルタリクエストを登録し、新しいデルタ ID を生成します。 また、フィルター条件に一致するすべてのデバイスも返します。
  • GET /santaba/rest/device/devices/delta/<DELTAID> – 前回の API 呼び出しと現在の API 呼び出しの間にデルタがあるデバイスを返します。

注: 現在、デルタ機能は /device/devices API エンドポイントにのみ追加されています。

デバイスの読み取り権限を持つユーザーは、これら XNUMX つを作成できます。 GET デバイスの差分を取得するために呼び出します。 

デルタIDの生成

デルタ ID は、API リクエスト GET /santaba/rest/device/devices/delta を使用して生成されます。その後、デルタ ID は API リクエスト GET /santaba/rest/device/devices/delta/ で使用されます。変更されたデバイスのデータを取得します。

注:

  • デルタ ID は、生成時から 30 分で期限切れになります。変更されたデバイス データを取得するためにデルタ ID が 30 分以内に使用された場合、その有効期限は使用時から 30 分増加します。
  • デルタは、LogicMonitor UI で実行されるパラメータのみで表示されます。したがって、アクティブディスカバリ (AD) によって更新されたプロパティはデルタの一部ではありません。

基本フィルターまたはネストされたフィルターを GET を呼び出して、更新されたデバイスと指定されたフィルターを含む応答を取得します。

URI: 取得 /santaba/rest/device/devices/delta

タイプ説明
size整数表示する結果の数を示します。 一度に最大 1000 件の結果をリクエストできます。 GET call.例 – /santaba/rest/device/devices/delta?size=1000 
offset整数表示された結果をオフセットする結果の数を示します。
例– /santaba/rest/device/devices/delta?offset=1000
filter文字列応答は、指定されたフィルター基準のみを含むようにフィルター処理されます。 デルタ応答には、フィルター基準に一致するデバイスのみが含まれることに注意してください。基本的なフィルターについては、を参照してください。 REST API 基本フィルター 例– /santaba/rest/device/devices/delta?filter=name~"127.0.0.1"
deltaId整数  deltaId ページネーションで使用されます。 最初に GET 呼び出しの場合、フィールドは空のままで、応答は deltaId.

XNUMX 回目のページネーションリクエスト以降は、同じものを提供します deltaId 最初の API 呼び出しで返されたもの。例 – /santaba/rest/device/devices/delta?deltaId=e3c7cb05f23e477eb06ea1a1cc5d6c96

ページネーション

ページネーションの場合は、次のように指定します。 sizeoffsetfilterdeltaId 同じ結果に対するすべての結果を返す deltaId.

最初のページのリクエスト:

/santaba/rest/device/devices/delta?offset=0&size=1000&filter=name~"127.0.0.1"
Pythonの3

このリクエストは、フィルタに一致するすべてのデバイスを返します。 deltaId.

XNUMX ページ目のリクエスト以降、 deltaIdすべてのページリクエストに対して。 フィルターに一致するすべてのデバイスを取得するには、同じ API を同じメソッドで複数回呼び出します。 deltaId (最初の呼び出しで生成) offset=0.

/santaba/rest/device/devices/delta?offset=1000&size=1000&filter=name~"127.0.0.1"&deltaId=XXXXXXXXXX
Pythonの3

リクエストとレスポンス

応答は次のものと同様です GET device/devices API。 見る デバイスフィールド.

観察してください。 deltaId 応答の最後の方に表示されます。 

注: 応答には、削除されたデバイスの詳細は含まれません。

リクエスト例

API - /santaba/rest/device/devices/delta?filter=name~"127.0.0.1"&size=10&offset=0
Pythonの3

応答例

Response
{
    "total": 1,
    "searchId": null,
    "items": [
        {
            "id": 1,
            "name": "127.0.0.1",
            "displayName": "127.0.0.1_collector_1",
            "deviceType": 0,
            "relatedDeviceId": -1,
            "currentCollectorId": 1,
            "preferredCollectorId": 1,
            "autoBalancedCollectorGroupId": 0,
            "preferredCollectorGroupId": 1,
            "preferredCollectorGroupName": "@default",
            "description": "",
            "createdOn": 1678369453,
            "updatedOn": 1678450158,
            "disableAlerting": false,
            "autoPropsAssignedOn": 0,
            "autoPropsUpdatedOn": 0,
            "scanConfigId": 0,
            "link": "",
            "enableNetflow": false,
            "netflowCollectorId": 0,
            "netflowCollectorGroupId": 0,
            "netflowCollectorGroupName": null,
            "isPreferredLogCollectorConfigured": false,
            "currentLogCollectorId": 0,
            "logCollectorId": 0,
            "logCollectorDescription": null,
            "logCollectorGroupId": 0,
            "logCollectorGroupName": null,
            "lastDataTime": 0,
            "lastRawdataTime": 0,
            "hostGroupIds": "17,16,13,4",
            "sdtStatus": "none-none-none",
            "userPermission": "write",
            "rolePrivileges": [],
            "hostStatus": "dead-collector",
            "alertStatus": "unconfirmed-critical-none",
            "alertStatusPriority": 1,
            "awsState": 1,
            "azureState": 1,
            "gcpState": 1,
            "alertDisableStatus": "none-none-none",
            "alertingDisabledOn": null,
            "collectorDescription": "8a9c17559226",
            "netflowCollectorDescription": null,
            "customProperties": [
                {
                    "name": "test",
                    "value": "55"
                },
                {
                    "name": "snmp.community",
                    "value": "********"
                },
                {
                    "name": "system.categories",
                    "value": "snmpHR,linux,collector"
                }
            ],
            "resourceIds": null,
            "upTimeInSeconds": 0,
            "deletedTimeInMs": 0,
            "toDeleteTimeInMs": 0,
            "hasDisabledSubResource": false,
            "ancestorHasDisabledLogicModule": false,
            "systemProperties": [
                {
                    "name": "system.enablenetflow",
                    "value": "false"
                },
                {
                    "name": "system.collectorplatform",
                    "value": "linux"
                },
                {
                    "name": "system.collectorid",
                    "value": "1"
                },
                {
                    "name": "system.deviceId",
                    "value": "1"
                },
                {
                    "name": "system.prefcollectordesc",
                    "value": "8a9c17559226"
                },
                {
                    "name": "system.collectordesc",
                    "value": "8a9c17559226"
                },
                {
                    "name": "system.groups",
                    "value": "DeltaTestDeviceGroup,Minimal Monitoring,Devices by Type/Collectors,Devices by Type/Linux Servers"
                },
                {
                    "name": "system.deviceGroupId",
                    "value": "17,16,13,4"
                },
                {
                    "name": "system.collector",
                    "value": "true"
                },
                {
                    "name": "system.ips",
                    "value": "127.0.0.1"
                },
                {
                    "name": "system.resourceCreatedOn",
                    "value": "1678369453"
                },
                {
                    "name": "system.devicetype",
                    "value": "0"
                },
                {
                    "name": "system.collectorversion",
                    "value": "33002"
                },
                {
                    "name": "system.prefcollectorid",
                    "value": "1"
                },
                {
                    "name": "system.displayname",
                    "value": "127.0.0.1_collector_1"
                },
                {
                    "name": "system.hoststatus",
                    "value": "dead-collector"
                },
                {
                    "name": "system.hostname",
                    "value": "127.0.0.1"
                }
            ],
            "autoProperties": [],
            "inheritedProperties": [
                {
                    "name": "PropUpdate",
                    "value": "updated-2023/3/27-03:34:11"
                },
                {
                    "name": "netapp.ssl",
                    "value": "true"
                }
            ],
            "syntheticsCollectorIds": []
            "status": ""
        }
    ],
    "deltaId": "XXXXXXXXXX"
}
Pythonの3

注: デフォルトでは、GET リクエストは deltaId のみを生成し、フィルターに一致するデバイスを取得するため、ステータス フィールドは空のままです。

デルタの取得

URI: 取得 /santaba/rest/device/devices/delta/<DELTAID>

この API 呼び出しは、前回の API 呼び出しと現在の API 呼び出しの間にデルタがあるデバイスのみを返します。

生成時に指定されたフィルター基準に一致するデバイスのみを返します。 deltaId.

タイプ説明
offset整数表示された結果をオフセットする結果の数を示します。
例– /santaba/rest/device/devices/delta/XXXXXXXXXX?offset=1000
size整数表示する結果の数を示します。 一度に最大 1000 件の結果をリクエストできます。 GET コール。 
例– /santaba/rest/device/devices/delta/XXXXXXXXXX?size=1000

ページネーション

ページネーションの場合は、サイズとオフセットの値を指定します。 もし offset が 0 の場合は、次のデルタを返します。 その後、ページごとに、ページ サイズごとにオフセット値を増やします。 たとえば、1000、2000、3000 などです。

/santaba/rest/device/devices/delta/XXXXXXXXXX?offset=0&size=1000
Pythonの3

&

/santaba/rest/device/devices/delta/XXXXXXXXXX?offset=1000&size=1000
Pythonの3

リクエストとレスポンス

応答には、デバイスのプロパティの更新や LogicMonitor UI で実行された操作など、デバイスの更新情報のみが表示されます。 応答は次のようになります GET /device/devices。 見る デバイスフィールド。 新しい分野 deltaId 最後のほうに追加されます。

  status フィールドは、データが addedupdatedまたは deleted.

  • 追加または更新されたデバイスの場合、応答には最新の値を含むすべてのフィールドが表示されます。
  • 削除されたデバイスの場合 – 応答には、 idnamedisplayName そしてステータスとしては deleted。 残りのフィールドにはすべてデフォルト値が表示されます。

リクエスト例

/santaba/rest/device/devices/delta/XXXXXXXXXX?size=10&offset=0
Pythonの3

応答例

更新されたデバイスのサンプル応答。

{
    "total": 1,
    "searchId": null,
    "items": [
        {
            "id": 1,
            "name": "127.0.0.1",
            "displayName": "127.0.0.1_collector_1",
            "deviceType": 0,
            "relatedDeviceId": -1,
            "currentCollectorId": 1,
            "preferredCollectorId": 1,
            "autoBalancedCollectorGroupId": 0,
            "preferredCollectorGroupId": 1,
            "preferredCollectorGroupName": "@default",
            "description": "Updated Description...",
            "createdOn": 1678369453,
            "updatedOn": 1678450158,
            "disableAlerting": false,
            "autoPropsAssignedOn": 0,
            "autoPropsUpdatedOn": 0,
            "scanConfigId": 0,
            "link": "",
            "enableNetflow": false,
            "netflowCollectorId": 0,
            "netflowCollectorGroupId": 0,
            "netflowCollectorGroupName": null,
            "isPreferredLogCollectorConfigured": false,
            "currentLogCollectorId": 0,
            "logCollectorId": 0,
            "logCollectorDescription": null,
            "logCollectorGroupId": 0,
            "logCollectorGroupName": null,
            "lastDataTime": 0,
            "lastRawdataTime": 0,
            "hostGroupIds": "17,16,13,4",
            "sdtStatus": "none-none-none",
            "userPermission": "write",
            "rolePrivileges": [],
            "hostStatus": "dead-collector",
            "alertStatus": "unconfirmed-critical-none",
            "alertStatusPriority": 1,
            "awsState": 1,
            "azureState": 1,
            "gcpState": 1,
            "alertDisableStatus": "none-none-none",
            "alertingDisabledOn": null,
            "collectorDescription": "8a9c17559226",
            "netflowCollectorDescription": null,
            "customProperties": [
                {
                    "name": "test",
                    "value": "55"
                },
                {
                    "name": "snmp.community",
                    "value": "********"
                },
                {
                    "name": "system.categories",
                    "value": "snmpHR,linux,collector"
                }
            ],
            "resourceIds": null,
            "upTimeInSeconds": 0,
            "deletedTimeInMs": 0,
            "toDeleteTimeInMs": 0,
            "hasDisabledSubResource": false,
            "ancestorHasDisabledLogicModule": false,
            "systemProperties": [
                {
                    "name": "system.enablenetflow",
                    "value": "false"
                },
                {
                    "name": "system.collectorplatform",
                    "value": "linux"
                },
                {
                    "name": "system.description",
                    "value": "Updated Description..."
                },
                {
                    "name": "system.collectorid",
                    "value": "1"
                },
                {
                    "name": "system.deviceId",
                    "value": "1"
                },
                {
                    "name": "system.prefcollectordesc",
                    "value": "8a9c17559226"
                },
                {
                    "name": "system.collectordesc",
                    "value": "8a9c17559226"
                },
                {
                    "name": "system.groups",
                    "value": "DeltaTestDeviceGroup,Minimal Monitoring,Devices by Type/Collectors,Devices by Type/Linux Servers"
                },
                {
                    "name": "system.deviceGroupId",
                    "value": "17,16,13,4"
                },
                {
                    "name": "system.collector",
                    "value": "true"
                },
                {
                    "name": "system.ips",
                    "value": "127.0.0.1"
                },
                {
                    "name": "system.resourceCreatedOn",
                    "value": "1678369453"
                },
                {
                    "name": "system.devicetype",
                    "value": "0"
                },
                {
                    "name": "system.collectorversion",
                    "value": "33002"
                },
                {
                    "name": "system.prefcollectorid",
                    "value": "1"
                },
                {
                    "name": "system.displayname",
                    "value": "127.0.0.1_collector_1"
                },
                {
                    "name": "system.hoststatus",
                    "value": "dead-collector"
                },
                {
                    "name": "system.hostname",
                    "value": "127.0.0.1"
                }
            ],
            "autoProperties": [],
            "inheritedProperties": [
                {
                    "name": "PropUpdate",
                    "value": "updated-2023/3/27-03:34:11"
                },
                {
                    "name": "netapp.ssl",
                    "value": "true"
                }
            ],
            "syntheticsCollectorIds": [],
            "status": "updated"
        }
    ],
    "deltaId": "XXXXXXXXXX"
}
Pythonの3

削除されたデバイスのサンプル応答。

{
    "total": 1,
    "searchId": null,
    "items": [     
            {
            "id": 17,
            "name": "1.1.1.1",
            "displayName": "1.1.1.1",
            "deviceType": 0,
            "relatedDeviceId": -1,
            "currentCollectorId": 0,
            "preferredCollectorId": 0,
            "autoBalancedCollectorGroupId": 0,
            "preferredCollectorGroupId": 0,
            "preferredCollectorGroupName": null,
            "description": null,
            "createdOn": 0,
            "updatedOn": 0,
            "disableAlerting": false,
            "autoPropsAssignedOn": 0,
            "autoPropsUpdatedOn": 0,
            "scanConfigId": 0,
            "link": null,
            "enableNetflow": false,
            "netflowCollectorId": 0,
            "netflowCollectorGroupId": 0,
            "netflowCollectorGroupName": null,
            "isPreferredLogCollectorConfigured": false,
            "currentLogCollectorId": 0,
            "logCollectorId": 0,
            "logCollectorDescription": null,
            "logCollectorGroupId": 0,
            "logCollectorGroupName": null,
            "lastDataTime": 0,
            "lastRawdataTime": 0,
            "hostGroupIds": null,
            "sdtStatus": "none-none-none",
            "userPermission": null,
            "rolePrivileges": null,
            "hostStatus": "normal",
            "alertStatus": "none",
            "alertStatusPriority": 100000,
            "awsState": 1,
            "azureState": 1,
            "gcpState": 1,
            "alertDisableStatus": "none-none-none",
            "alertingDisabledOn": null,
            "collectorDescription": null,
            "netflowCollectorDescription": null,
            "customProperties": null,
            "resourceIds": null,
            "op": null,
            "upTimeInSeconds": 0,
            "deletedTimeInMs": 0,
            "toDeleteTimeInMs": 0,
            "hasDisabledSubResource": false,
            "ancestorHasDisabledLogicModule": false,
            "systemProperties": null,
            "autoProperties": null,
            "inheritedProperties": null,
            "syntheticsCollectorIds": null,
            "status": "deleted"
        }],
         "deltaId": "XXXXXXXXXX"
}
Pythonの3
記事上で