Chrome Management Telemetry API のコードサンプル

API 機能の概要については、Chrome Management Telemetry API をご覧ください。

以下に示すリクエストではすべて、次の変数を使用します。

  • $TOKEN - OAuth 2 トークン
  • $CUSTOMER - 顧客の ID またはリテラル my_customer

テレメトリー デバイスデータの一覧表示

Chrome デバイスのテレメトリー データを一覧表示するには、/telemetry/devices エンドポイントを使用します。readMask パラメータは、どのデバイス フィールドを返すかを指定するために使用されます。pageSize パラメータと pageToken パラメータを使用すると、結果のページ分けを制御できます。デバイスまたはレポートの条件に基づいて結果をさらに絞り込むには、filter を指定します。

リクエスト

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/devices?readMask=name,customer,orgUnitId,deviceId,serialNumber,cpuInfo,cpuStatusReport,memoryInfo,memoryStatusReport,osUpdateStatus&pageSize=2"

レスポンス

{
  "devices": [
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId>",
      "serialNumber": "0A2B213CDEFG",
      "cpuStatusReport": [
        {
          "reportTime": "2021-04-25T13:23:55.880Z",
          "cpuUtilizationPct": 76
        },
        {
          "reportTime": "2021-04-25T18:25:55.880Z",
          "cpuTemperatureInfo": [
            {
              "temperatureCelsius": 38,
              "label": "Core"
            },
          ]
        }
      ],
      "memoryStatusReport": [
        {
          "reportTime": "2021-04-25T13:23:55.880Z",
          "systemRamFreeBytes": "14358468900"
        }
      ],
      "osUpdateStatus": [
        {
          "lastUpdateTime": "2021-04-25T11:18:51.383Z",
          "lastUpdateCheckTime": "1970-01-01T00:00:00Z",
          "lastRebootTime": "2021-04-25T11:18:51.383Z"
        }
      ]
    },
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId>",
      "customer": "customers/<customer>",
      "orgUnitId": "FEDCBA",
      "deviceId": "<deviceId>",
      "serialNumber": "1B3D817LKUH",
      "cpuStatusReport": [
        {
          "reportTime": "2021-05-25T13:23:55.880Z",
          "cpuUtilizationPct": 50
        },
      ],
      "memoryStatusReport": [
        {
          "reportTime": "2021-05-25T13:23:55.880Z",
          "systemRamFreeBytes": "14358468900"
        }
      ],
      "osUpdateStatus": [
        {
          "lastUpdateTime": "2021-05-25T11:18:51.383Z",
          "lastUpdateCheckTime": "1970-01-01T00:00:00Z",
          "lastRebootTime": "2021-05-25T11:18:51.383Z"
        }
      ]
    }
  ],
  "nextPageToken": "PAGE_TOKEN"
}

単一組織部門のテレメトリー デバイスデータの一覧表示

1 つの組織部門のテレメトリー データを一覧表示するには、filter パラメータに orgUnitId の値を使用します。

リクエスト

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/devices?readMask=name,customer,orgUnitId,deviceId,serialNumber,cpuInfo,cpuStatusReport,memoryInfo,memoryStatusReport,osUpdateStatus&filter=orgUnitId=ABCDEFG"

レスポンス

{
  "devices": [
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId>",
      "serialNumber": "0A2B213CDEFG",
      "cpuStatusReport": [
        {
          "reportTime": "2021-04-25T13:23:55.880Z",
          "cpuUtilizationPct": 76
        },
        {
          "reportTime": "2021-04-25T18:25:55.880Z",
          "cpuTemperatureInfo": [
            {
              "temperatureCelsius": 38,
              "label": "Core"
            },
          ]
        }
      ],
      "memoryStatusReport": [
        {
          "reportTime": "2021-04-25T13:23:55.880Z",
          "systemRamFreeBytes": "14358468900"
        }
      ],
      "osUpdateStatus": [
        {
          "lastUpdateTime": "2021-04-25T11:18:51.383Z",
          "lastUpdateCheckTime": "1970-01-01T00:00:00Z",
          "lastRebootTime": "2021-04-25T11:18:51.383Z"
        }
      ]
    }
  ]
}

タイムスタンプ フィルタを使用してテレメトリー デバイスデータを一覧表示する

タイムスタンプ フィルタはすべてのデバイスを返しますが、含まれるのはタイムスタンプ フィルタと指定された read_mask に準拠するレポートのみです。

このフィルタを使用するには、filter パラメータで reports_timestamp 値を指定し、ミリ秒単位の Unix エポックのタイムスタンプ値(1679288169623)または RFC 3339 の「Zulu」形式の時刻(最大 9 桁の小数点以下 2 桁まで)。"2023-02-15T11:18:51.383Z")形式。API から返されるタイムスタンプは UTC タイムゾーンであるため、reports_timestamp フィルタ値も UTC タイムゾーンである必要があります。標準の数値比較演算子(<, >, <=, >=, =)はすべてサポートされています。

すべてのレポートを一覧表示

reports_timestamp 値が指定されていない場合は最近のレポートのみが返されるため、次の呼び出しを使用すると、すべてのデバイスの read_mask に含まれるすべてのデバイス レポートを取得できます。

リクエスト

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/devices?readMask=name,customer,orgUnitId,deviceId,serialNumber,audioStatusReport,cpuStatusReport,heartbeatStatusReport,memoryStatusReport&filter=reports_timestamp>=0"

レスポンス

{
  "devices": [
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId>",
      "serialNumber": "0A2B213CDEFG",
      "audioStatusReport": [
        {
          "reportTime": "2009-01-01T12:37:51.383Z",
          "inputMute": true,
          "inputDevice": "example input device 2009",
        },
        {
          "reportTime": "2010-02-01T12:37:51.383Z",
          "inputMute": false,
          "inputDevice": "example input device 2010",
        },
        {
          "reportTime": "2011-03-01T12:37:51.383Z",
          "inputMute": true,
          "inputDevice": "example input device 2011",
        },
        {
          "reportTime": "2024-01-01T12:37:51.383Z",
          "inputMute": false,
          "inputDevice": "example input device 2024",
        }
      ],
      "cpuStatusReport": [
        {
          "reportTime": "1960-10-15T01:18:51.383Z",
          "cpuUtilizationPct": 76
        },
        {
          "reportTime": "1997-10-31T11:18:51.383Z",
          "cpuTemperatureInfo": [
            {
              "temperatureCelsius": 38,
              "label": "Core"
            },
          ]
        }
      ]
    },
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId 1>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId 1>",
      "serialNumber": "HGFEDCBA",
      "heartbeatStatusReport": [
        {
          "reportTime": "2001-02-15T11:18:51.383Z",
          "state": "ONLINE"
        },
        {
          "reportTime": "2002-07-22T11:18:51.383Z",
          "state": "OFFLINE"
        },
        {
          "reportTime": "2012-01-04T11:18:51.383Z",
          "state": "UNKNOWN"
        },
        {
          "reportTime": "2024-02-29T11:18:51.383Z",
          "state": "ONLINE"
        }
      ],
      "memoryStatusReport": [
        {
          "reportTime": "2024-03-20T11:18:51.383Z",
          "systemRamFreeBytes": "112233445566778"
        }
      ]
    }
  ]
}

特定のタイムスタンプ後のレポートを一覧表示する

特定のタイムスタンプより後のレポートのクエリをリクエストするには、次の例に示すように reports_timestamp を使用します。

リクエスト

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/devices?readMask=name,customer,orgUnitId,deviceId,serialNumber,cpuStatusReport,memoryStatusReport,osUpdateStatus&filter=reports_timestamp>=\"2023-02-15T11:18:51.383Z\""

レスポンス

{
  "devices": [
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId>",
      "serialNumber": "0A2B213CDEFG",
      "cpuStatusReport": [
        {
          "reportTime": "2023-02-15T11:18:51.383Z",
          "cpuUtilizationPct": 76
        },
        {
          "reportTime": "2023-03-19T11:18:51.383Z",
          "cpuTemperatureInfo": [
            {
              "temperatureCelsius": 38,
              "label": "Core"
            },
          ]
        }
      ],
      "memoryStatusReport": [
        {
          "reportTime": "2023-04-19T11:18:51.383Z",
          "systemRamFreeBytes": "14358468900"
        }
      ]
    },
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId 1>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId 1>",
      "serialNumber": "HGFEDCBA",
      "memoryStatusReport": [
        {
          "reportTime": "2024-02-15T11:18:51.383Z",
          "systemRamFreeBytes": "112233445566778"
        }
      ]
    }
  ]
}

複数のフィルタを使用したテレメトリー デバイスデータの一覧表示(結合フィルタリング)

複数のフィルタを使用して、API から返されるレスポンスを絞り込むには、filter パラメータで AND キーワードを使用し、複数のフィルタ条件を含めます。

リクエスト

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/devices?readMask=name,customer,orgUnitId,deviceId,serialNumber,cpuStatusReport,memoryStatusReport,osUpdateStatus&filter=reports_timestamp=\"2023-02-15T11:18:51.383Z\" AND serialNumber=HGFEDCBA"

レスポンス

{
  "devices": [
    {
      "name": "customers/<customer>/telemetry/devices/<deviceId 1>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "deviceId": "<deviceId 1>",
      "serialNumber": "HGFEDCBA",
      "memoryStatusReport": [
        {
          "reportTime": "2023-02-15T11:18:51.383Z",
          "systemRamFreeBytes": "112233445566778"
        }
      ]
    }
  ]
}

テレメトリー ユーザーデータの一覧表示

Chrome デバイスのテレメトリー データを一覧表示するには、/telemetry/users エンドポイントを使用します。readMask パラメータは、どのデバイス フィールドを返すかを指定するために使用されます。pageSize パラメータと pageToken パラメータを使用すると、結果のページ分けを制御できます。

リクエスト

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/users?readMask=name,customer,orgUnitId,userId,userEmail,user_device.device_id,user_device.audio_status_report,user_device.peripherals_report&pageSize=2"

レスポンス

{
  "telemetryUsers": [
    {
      "name": "customers/<customer>/telemetry/users/<userId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "userEmail": "<userId>",
      "userEmail": "user@mytestdomain.com",
      "userDevice": [
        {
          "deviceId": "HIJKLMNOP",
          "audioStatusReport": [
            {
              "reportTime": "2021-04-25T13:23:55.880Z",
              "outputMute": true,
              "inputMute": true,
            }
          ],
          "peripheralsReport": [
            {
              "reportTime": "2021-04-25T18:25:55.880Z",
              "usbPeripheralReport": [
                {
                  "vendor": "Vendor",
                  "name": "Microphone",
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "customers/<customer>/telemetry/users/<userId>",
      "customer": "customers/<customer>",
      "orgUnitId": "QRSTUV",
      "userEmail": "<userId>",
      "userEmail": "user2@mytestdomain.com",
      "userDevice": [
        {
          "deviceId": "WXYZ",
          "audioStatusReport": [
            {
              "reportTime": "2021-04-25T13:23:55.880Z",
              "outputMute": true,
              "inputMute": true,
            }
          ],
          "peripheralsReport": [
            {
              "reportTime": "2021-04-25T18:25:55.880Z",
              "usbPeripheralReport": [
                {
                  "vendor": "Vendor",
                  "name": "Microphone",
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "nextPageToken": "PAGE_TOKEN"
}

単一の組織部門のテレメトリー ユーザーデータの一覧表示

1 つの組織部門のテレメトリー データを一覧表示するには、filter パラメータに orgUnitId の値を使用します。

リクエスト

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/users?readMask=name,customer,orgUnitId,userId,userEmail,user_device.device_id,user_device.audio_status_report,user_device.peripherals_report&pageSize=2&filter=orgUnitId=ABCDEFG"

レスポンス

{
  "telemetryUsers": [
    {
      "name": "customers/<customer>/telemetry/users/<userId>",
      "customer": "customers/<customer>",
      "orgUnitId": "ABCEDFG",
      "userEmail": "<userId>",
      "userEmail": "user@mytestdomain.com",
      "userDevice": [
        {
          "deviceId": "HIJKLMNOP",
          "audioStatusReport": [
            {
              "reportTime": "2021-04-25T13:23:55.880Z",
              "outputMute": true,
              "inputMute": true,
            }
          ],
          "peripheralsReport": [
            {
              "reportTime": "2021-04-25T18:25:55.880Z",
              "usbPeripheralReport": [
                {
                  "vendor": "Vendor",
                  "name": "Microphone",
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

テレメトリー イベントデータの一覧表示

顧客のテレメトリー イベントを一覧表示するには、/telemetry/events エンドポイントを使用します。readMask パラメータは、返されるフィールドを指定するために使用されます。近い将来、readMask パラメータは省略可能になり、少なくとも 1 つのイベントタイプを含む filter パラメータが必須になります。

デフォルトでは、イベントの namereport_timeevent_type の各フィールドがレスポンスに含まれます。pageSize パラメータと pageToken パラメータを使用すると、結果のページ分けを制御できます。さらに、次のパラメータを使用して結果をフィルタリングできます。

  • device_id
  • user_id
  • device_org_unit_id
  • user_org_unit_id
  • タイムスタンプ
    • 入力値は EPOCH ミリ秒(timestamp<1667423821001)または RFC 3339(timestamp<"2022-11-02T20:08:32.386Z")のいずれかです。
  • event_type
    • audio_severe_underrun
    • network_connection_state_change
    • usb_added
    • usb_removed
    • network_htps_latency_change

リクエスト

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/telemetry/events?readMask=device,usb_peripherals_event&filter=event_type=usb_added&pageSize=3"

レスポンス

{
  "telemetryEvents": [
    {
      "name": "customers/<customer>/telemetry/events/<event id>",
      "device": {
        "deviceId": "<device id>",
        "orgUnitId": "<device’s org unit id>"
      },
      "reportTime": "2022-11-02T11:14:09.034Z",
      "eventType": "USB_ADDED",
      "usbPeripheralsEvent": {
        "usbPeripheralReport": [
          {
            "vendor": "Microdia",
            "name": "Integrated_Webcam_HD",
            "vid": <vid>,
            "pid": <pid>
          }
        ]
      }
    },
    {
      "name": "customers/<customer>/telemetry/events/<event id>",
      "device": {
        "deviceId": "<device id>",
        "orgUnitId": "<device’s org unit id>"
      },
      "reportTime": "2022-11-02T10:10:36.481Z",
      "eventType": "USB_ADDED",
      "usbPeripheralsEvent": {
        "usbPeripheralReport": [
          {
            "vendor": "Hewlett-Packard",
            "name": "x304m",
            "vid": <vid>,
            "pid": <pid>,
            "categories": [
              "Mass storage"
            ]
          }
        ]
      }
    },
    {
      "name": "customers/<customer>/telemetry/events/<event id>",
      "device": {
        "deviceId": "<device id>",
        "orgUnitId": "<device’s org unit id>"
      },
      "reportTime": "2022-11-02T09:58:48.249Z",
      "eventType": "USB_ADDED",
      "usbPeripheralsEvent": {
        "usbPeripheralReport": [
          {
            "vendor": "Realtek Semiconductor Corp.",
            "name": "USB 10/100/1000 LAN",
            "vid": <vid>,
            "pid": <pid>,
            "categories": [
              "Vendor Specific"
            ]
          }
        ]
      }
    }
  ],
  "nextPageToken": "<page token>"
}