Chrome Management Telemetry API용 코드 샘플

API 기능 개요는 Chrome Management Telemetry API를 참조하세요.

아래에 표시된 모든 요청은 다음 변수를 사용합니다.

  • $TOKEN - OAuth 2 토큰
  • $CUSTOMER - 고객 ID 또는 리터럴 my_customer

원격 분석 기기 데이터 나열

Chrome 기기의 원격 분석 데이터를 나열하려면 /telemetry/devices 엔드포인트를 사용합니다. readMask 매개변수는 반환되는 기기 필드를 지정하는 데 사용됩니다. pageSizepageToken 매개변수를 사용하여 결과의 페이지로 나누기를 제어할 수 있습니다. 기기 또는 보고서 기준에 따라 결과 범위를 더 좁히려면 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"
}

단일 조직 단위의 원격 분석 기기 데이터 나열

단일 조직 단위의 원격 분석 데이터를 나열하려면 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자리 소수 자릿수 등)을 사용합니다. "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 매개변수는 반환되는 기기 필드를 지정하는 데 사용됩니다. pageSizepageToken 매개변수를 사용하여 결과의 페이지로 나누기를 제어할 수 있습니다.

요청

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

단일 조직 단위의 원격 분석 사용자 데이터 나열

단일 조직 단위의 원격 분석 데이터를 나열하려면 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 매개변수가 필수사항이 됩니다.

기본적으로 이벤트의 name, report_time, event_type 필드가 응답에 포함됩니다. pageSizepageToken 매개변수를 사용하여 결과의 페이지로 나누기를 제어할 수 있습니다. 또한 다음 매개변수를 사용하여 결과를 필터링할 수 있습니다.

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