Contoh Kode untuk Chrome Management Telemetry API

Buka Chrome Management Telemetry API untuk mengetahui ringkasan fitur API.

Semua permintaan yang ditampilkan di bawah ini menggunakan variabel berikut:

  • $TOKEN - Token OAuth 2
  • $CUSTOMER - ID pelanggan atau literal my_customer

Mencantumkan Data Perangkat Telemetri

Untuk menampilkan daftar data telemetri untuk perangkat Chrome, gunakan endpoint /telemetry/devices. Parameter readMask digunakan untuk menentukan kolom perangkat yang ditampilkan. Anda dapat mengontrol penomoran halaman hasil menggunakan parameter pageSize dan pageToken. Tentukan filter untuk lebih mempersempit hasil berdasarkan kriteria laporan atau perangkat.

Permintaan

  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"

Respons

{
  "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"
}

Mencantumkan Data Perangkat Telemetri untuk Satu Unit Org

Untuk mencantumkan data telemetri untuk satu unit org, gunakan nilai orgUnitId dalam parameter filter.

Permintaan

  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"

Respons

{
  "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"
        }
      ]
    }
  ]
}

Mencantumkan Data Perangkat Telemetri Menggunakan Filter Stempel Waktu

Filter stempel waktu menampilkan semua perangkat, tetapi hanya menyertakan laporan yang sesuai dengan filter stempel waktu dan read_mask yang ditentukan.

Untuk menggunakan filter ini, tentukan nilai reports_timestamp dalam parameter filter dan sertakan nilai stempel waktu di Unix Epoch dalam milidetik (yaitu 1679288169623) atau waktu berformat RFC 3339 "Zulu" (hingga sembilan digit pecahan, yaitu "2023-02-15T11:18:51.383Z"). Stempel waktu yang ditampilkan oleh API berada dalam zona waktu UTC, sehingga nilai filter reports_timestamp juga harus berada dalam zona waktu UTC. Semua operator perbandingan angka standar (<, >, <=, >=, =) didukung.

Mencantumkan Semua Laporan

Karena hanya laporan terbaru yang ditampilkan jika tidak ada nilai reports_timestamp yang ditentukan, panggilan berikut dapat digunakan untuk mengambil semua laporan perangkat yang disertakan dalam read_mask untuk semua perangkat.

Permintaan

  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"

Respons

{
  "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"
        }
      ]
    }
  ]
}

Mencantumkan Laporan Setelah Stempel Waktu Tertentu

Untuk membuat permintaan guna mengkueri laporan setelah stempel waktu tertentu, gunakan reports_timestamp seperti yang ditunjukkan dalam contoh berikut.

Permintaan

  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\""

Respons

{
  "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"
        }
      ]
    }
  ]
}

Mencantumkan Data Perangkat Telemetri Menggunakan Beberapa Filter (Filter Konjungsi)

Untuk menggunakan beberapa filter guna mempersempit respons yang ditampilkan oleh API, gunakan kata kunci AND di parameter filter dan sertakan beberapa kriteria pemfilteran.

Permintaan

  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"

Respons

{
  "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"
        }
      ]
    }
  ]
}

Mencantumkan Data Pengguna Telemetri

Untuk menampilkan daftar data telemetri untuk perangkat Chrome, gunakan endpoint /telemetry/users. Parameter readMask digunakan untuk menentukan kolom perangkat yang ditampilkan. Anda dapat mengontrol penomoran halaman hasil menggunakan parameter pageSize dan pageToken.

Permintaan

  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"

Respons

{
  "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"
}

Mencantumkan Data Pengguna Telemetri untuk Satu Unit Org

Untuk mencantumkan data telemetri untuk satu unit org, gunakan nilai orgUnitId dalam parameter filter.

Permintaan

  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"

Respons

{
  "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",
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

Mencantumkan Data Peristiwa Telemetri

Untuk menampilkan daftar peristiwa telemetri bagi pelanggan, gunakan endpoint /telemetry/events. Parameter readMask digunakan untuk menentukan kolom yang ditampilkan. Dalam waktu dekat, parameter readMask akan menjadi opsional, dan parameter filter dengan setidaknya 1 jenis peristiwa akan diperlukan.

Secara default, kolom name, report_time, dan event_type peristiwa disertakan dalam respons. Anda dapat mengontrol penomoran halaman hasil menggunakan parameter pageSize dan pageToken. Selain itu, Anda dapat memfilter hasil dengan parameter berikut:

  • device_id
  • user_id
  • device_org_unit_id
  • user_org_unit_id
  • stempel waktu
    • Nilai input dapat berupa EPOCH milidetik, yaitu timestamp<1667423821001 atau RFC 3339, misalnya timestamp<"2022-11-02T20:08:32.386Z"
  • event_type
    • audio_severe_underrun
    • network_connection_state_change
    • usb_added
    • usb_removed
    • network_htps_latency_change

Permintaan

  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"

Respons

{
  "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>"
}