  def GetNodeAccelUsage(self, days: int = 7) -> List[Dict[str, Any]]:
    """Returns GPU usage metrics for GKE nodes.

    By default returns minute-wise usage for the last seven days for all
    GKE nodes within a project.

    Args:
      days (int): Optional. The number of days to collect metrics for.

    Returns:
      List[Dict[str, Any]]: a list of GPU usage for each instance in the format
        [
          {
            'gpu_name': str,
            'cluster_name': str,
            'container_name': str,
            'pod_name': str,
            'gpu_usage':
            [
              {
                'timestamp': str,
                'gpu_usage': float
              },
            ]
          },
        ]
    """
    service = self.GcmApi()
    gcm_timeseries_client = service.projects().timeSeries() # pylint: disable=no-member

    start_time = common.FormatRFC3339(
        datetime.datetime.utcnow() - datetime.timedelta(days=days))
    end_time = common.FormatRFC3339(datetime.datetime.utcnow())

    responses = common.ExecuteRequest(
        gcm_timeseries_client,
        'list',
        {
            'name':
                'projects/{0:s}'.format(self.project_id),
            'filter':
                'metric.type="kubernetes.io/container/accelerator/duty_cycle" '
                'resource.type="k8s_container"',
            'interval_startTime':
                start_time,
            'interval_endTime':
                end_time
        })

    gpu_usage_instances = []

    for response in responses:
      time_series = response.get('timeSeries', [])
      for ts in time_series:
        gpu_name = ts['metric']['labels']['model']
        cluster_name = ts['resource']['labels']['cluster_name']
        container_name = ts['resource']['labels']['container_name']
        pod_name = ts['resource']['labels']['pod_name']
        points = ts['points']
        gpu_usage = []
        all_points_zero = True
        for point in points:
          gpu_usage.append({
              'timestamp': point['interval']['startTime'],
              'gpu_usage': point['value']['int64Value']})
          if point['value']['int64Value'] != 0:
            all_points_zero = False

        if not all_points_zero:
          gpu_usage_instances.append({
              'gpu_name': gpu_name,
              'cluster_name': cluster_name,
              'container_name': container_name,
              'pod_name': pod_name,
              'gpu_usage': gpu_usage})

    return gpu_usage_instances
Returns GPU usage metrics for GKE nodes.

By default returns minute-wise usage for the last seven days for all
GKE nodes within a project.

Args:
days (int): Optional. The number of days to collect metrics for.

Returns:
List[Dict[str, Any]]: a list of GPU usage for each instance in the format
[
{
'gpu_name': str,
'cluster_name': str,
'container_name': str,
'pod_name': str,
'gpu_usage':
[
{
'timestamp': str,
'gpu_usage': float
},
]
},
]
libcloudforensics/providers/gcp/internal/monitoring.py