# history

source:
  list(out.groupby(["Project Code", "Department Code"], as_index=False)[
              "Price*"
          ].sum()
          
          )

source_raw:
  list(out.groupby(["Project Code", "Department Code"], as_index=False)[
              "Price*"
          ].sum()
          
          )


source:
  import matplotlib as plt
  import numpy as np


  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib as plt
  import numpy as np


  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  import numpy as np


  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  import numpy as np


  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",
  ):

  # Define the time range for the query (last 1 hour)
  end_time = datetime.now(timezone.utc)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",
  ):

  # Define the time range for the query (last 1 hour)
  end_time = datetime.now(timezone.utc)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",
  ):

  # Define the time range for the query (last 1 hour)
  end_time = datetime.now(timezone.utc)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",
  ):

  # Define the time range for the query (last 1 hour)
  end_time = datetime.now(timezone.utc)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  # Define the time range for the query (last 1 hour)
  end_time = datetime.now(timezone.utc)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  # Define the time range for the query (last 1 hour)
  end_time = datetime.now(timezone.utc)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")
  days = 7


  resource_type: str = "gce_instance",
  days: int = 7,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  # Define the time range for the query (last 1 hour)
  end_time = datetime.now(timezone.utc)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")
  days = 7


  resource_type: str = "gce_instance",
  days: int = 7,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  # Define the time range for the query (last 1 hour)
  end_time = datetime.now(timezone.utc)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  end_time = datetime.now(timezone.utc)
  print(end_time)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  end_time = datetime.now(timezone.utc)
  print(end_time)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7.0,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  end_time = datetime.now(timezone.utc)
  print(end_time)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7.0,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  end_time = datetime.now(timezone.utc)
  print(end_time)
  start_time = end_time - timedelta(days=days)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7.0,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  end_time = datetime.now(timezone.utc)
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7.0,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  end_time = datetime.now(timezone.utc)
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner=aggregation,
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7.0,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  end_time = datetime.now(timezone.utc)
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7.0,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  end_time = datetime.now(timezone.utc)
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7.0,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance",
  days: int = 7.0,
  aggregation: str = "ALIGN_MEAN",
  metric: str = "compute.googleapis.com/instance/cpu/utilization",
  labels_filter: str = "",

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(dir(time_series))
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(dir(time_series))
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(dir(time_series.values))
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(dir(time_series.values))
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(dir(time_series['points']))
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(dir(time_series['points']))
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(time_series['points'])
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(time_series['points'])
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(time_series['points'])
      print(
          time_series['points'][0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []):
      print(time_series['points'])
      print(
          time_series['points'][0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []).get("points", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []).get("points", []):
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  response
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  response
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(response)
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(response)
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  from pprint import pprimt


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint(response)
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  from pprint import pprimt


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint(response)
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprimt


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response)
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprimt


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response)
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response)
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response)
  for time_series in response.get("timeSeries", []).get("points", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response)
  for time_series in response.get("timeSeries", []).get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response)
  for time_series in response.get("timeSeries", []).get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries"))
  for time_series in response.get("timeSeries", []).get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries"))
  for time_series in response.get("timeSeries", []).get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries", []))
  for time_series in response.get("timeSeries", []).get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries", []))
  for time_series in response.get("timeSeries", []).get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries").get("points"))
  for time_series in response.get("timeSeries", []).get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries").get("points"))
  for time_series in response.get("timeSeries", []).get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")
  for time_series in response.get("timeSeries", []).get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")
  for time_series in response.get("timeSeries", []).get("timeSeries", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries").get("metric"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries").get("metric"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.gert("timeSeries")))
  pprint.pprint(response.get("timeSeries").get("metric"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.gert("timeSeries")))
  pprint.pprint(response.get("timeSeries").get("metric"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries").get("metric"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries").get("metric"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0])
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0])
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].points)
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].points)
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries", []).get("metric", []):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in [0].get("points"):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in [0].get("points"):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print(
          time_series.points[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print(
          time_series.get("points")[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print(
          time_series.get("points")[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series)
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series)
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series[0])
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  print(type(response.get("timeSeries")))
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series[0])
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series[0])
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series[0])
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series[1])
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series[1])
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series)
      exit()
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series)
      exit()
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series)
      exit(0)
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points")[0]:
      print(time_series)
      exit(0)
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      exit(0)
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      exit(0)
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      exit(0)
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      exit(0)
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      exit(0)
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      exit(0)
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      # print(
      #     # time_series.get("points")[0].interval.start_time,
      #     # time_series.points[-1].interval.end_time,
      # )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      # print(
      #     # time_series.get("points")[0].interval.start_time,
      #     # time_series.points[-1].interval.end_time,
      # )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      print(
          # time_series.get("points")[0].interval.start_time,
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      print(
          time_series.get("points")[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      print(
          time_series.get("points")[0].interval.start_time,
          time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      print(
          time_series.get("points").get("startTime")
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      print(
          time_series.get("points").get("startTime")
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series.get("interval"))
      print("iter")
      print(
          time_series.get("points").get("startTime")
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series.get("interval"))
      print("iter")
      print(
          time_series.get("points").get("startTime")
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series.get("interval").get("startTime"))
      print("iter")
      print(
          time_series.get("points").get("startTime")
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series.get("interval").get("startTime"))
      print("iter")
      print(
          time_series.get("points").get("startTime")
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      # print(time_series.get("interval").get("startTime"))
      print("iter")
      print(
          time_series.get("points").get("startTime")
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      # print(time_series.get("interval").get("startTime"))
      print("iter")
      print(
          time_series.get("points").get("startTime")
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      # print(time_series.get("interval").get("startTime"))
      print("iter")
      print(
          time_series.get("interval").get("startTime")
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      # print(time_series.get("interval").get("startTime"))
      print("iter")
      print(
          time_series.get("interval").get("startTime")
          # time_series.points[-1].interval.end_time,
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      # print(time_series.get("interval").get("startTime"))
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      # print(time_series.get("interval").get("startTime"))
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )

  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      # print(time_series.get("interval"))
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      # print(time_series.get("interval"))
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series.get("interval"))
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series.get("interval"))
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series)
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series.get("value"))
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series.get("value"))
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series.get("value").doubleValue)
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series.get("value").doubleValue)
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series["value"])
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series["value"])
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series["value"]["doubleValue"])
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series["value"]["doubleValue"])
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
  for point in result.points:
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(point.value.double_value * 100)
  fig, ax = plt.subplots()  # Create a figure containing a single Axes.
  ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
  plt.show()  # Show the figure.


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series["value"]["doubleValue"])
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(time_series["value"]["doubleValue"])
  # Plotting the graph using matplotlib

  fig = plt.figure()
  ax = fig.add_subplot(111)
  ax.plot(time_list_x_axis, utilization_list_y_axis, color="lightblue", linewidth=2)
  fig.set_size_inches(20.5, 14.5)

  xfmt = plt.mdates.DateFormatter("%B/%d %H:%M:%S")
  ax.xaxis.set_major_formatter(xfmt)
  plt.show()

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series["value"]["doubleValue"])
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(time_series["value"]["doubleValue"])
  # Plotting the graph using matplotlib

  fig = plt.figure()
  ax = fig.add_subplot(111)
  ax.plot(time_list_x_axis, utilization_list_y_axis, color="lightblue", linewidth=2)
  fig.set_size_inches(20.5, 14.5)

  xfmt = plt.mdates.DateFormatter("%B/%d %H:%M:%S")
  ax.xaxis.set_major_formatter(xfmt)
  plt.show()


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import matplotlib.dates as mdates
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series["value"]["doubleValue"])
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(time_series["value"]["doubleValue"])
  # Plotting the graph using matplotlib

  fig = plt.figure()
  ax = fig.add_subplot(111)
  ax.plot(time_list_x_axis, utilization_list_y_axis, color="lightblue", linewidth=2)
  fig.set_size_inches(20.5, 14.5)

  xfmt = mdates.DateFormatter("%B/%d %H:%M:%S")
  ax.xaxis.set_major_formatter(xfmt)
  plt.show()

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import matplotlib.dates as mdates
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series["value"]["doubleValue"])
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(time_series["value"]["doubleValue"])
  # Plotting the graph using matplotlib

  fig = plt.figure()
  ax = fig.add_subplot(111)
  ax.plot(time_list_x_axis, utilization_list_y_axis, color="lightblue", linewidth=2)
  fig.set_size_inches(20.5, 14.5)

  xfmt = mdates.DateFormatter("%B/%d %H:%M:%S")
  ax.xaxis.set_major_formatter(xfmt)
  plt.show()


source:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import matplotlib.dates as mdates
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series["value"]["doubleValue"])
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(time_series["value"]["doubleValue"]*100)
  # Plotting the graph using matplotlib

  fig = plt.figure()
  ax = fig.add_subplot(111)
  ax.plot(time_list_x_axis, utilization_list_y_axis, color="lightblue", linewidth=2)
  fig.set_size_inches(20.5, 14.5)

  xfmt = mdates.DateFormatter("%B/%d %H:%M:%S")
  ax.xaxis.set_major_formatter(xfmt)
  plt.show()

source_raw:
  import matplotlib.pyplot as plt
  from googleapiclient import discovery
  import numpy as np
  from datetime import datetime, timedelta, timezone
  import matplotlib.dates as mdates
  import pprint


  project_id = "sandbox-388418"
  service = discovery.build("monitoring", "v3")


  resource_type: str = "gce_instance"
  days: int = 7.0
  aggregation: str = "ALIGN_MEAN"
  metric: str = "compute.googleapis.com/instance/cpu/utilization"
  labels_filter: str = ""

  end_time = datetime.utcnow()
  print(end_time)
  start_time = end_time - timedelta(days=7)

  # Convert datetime objects to RFC3339 format
  start_time_str = start_time.isoformat() + "Z"
  end_time_str = end_time.isoformat() + "Z"

  # Build the request
  request = (
      service.projects()
      .timeSeries()
      .list(
          name=f"projects/{project_id}",
          # filter=f'resource.type="{resource_type}" AND metric.type="{metric}"',
          filter=f'resource.type="{resource_type}" AND metric.type="{metric}" {labels_filter}',
          aggregation_alignmentPeriod="86400s",  # Daily aggregation
          aggregation_perSeriesAligner="ALIGN_MEAN",
          interval_startTime=start_time_str,
          interval_endTime=end_time_str,
      )
  )
  response = request.execute()
  time_list_x_axis = []
  utilization_list_y_axis = []
  # pprint.pprint(response.get("timeSeries")[0].get("points"))
  for time_series in response.get("timeSeries")[0].get("points"):
      print(time_series["value"]["doubleValue"])
      print("iter")
      print(
          time_series.get("interval").get("startTime"),
          time_series.get("interval").get("endTime"),
      )
      time_list_x_axis.append(time_series.get("interval").get("startTime"))
      utilization_list_y_axis.append(time_series["value"]["doubleValue"]*100)
  # Plotting the graph using matplotlib

  fig = plt.figure()
  ax = fig.add_subplot(111)
  ax.plot(time_list_x_axis, utilization_list_y_axis, color="lightblue", linewidth=2)
  fig.set_size_inches(20.5, 14.5)

  xfmt = mdates.DateFormatter("%B/%d %H:%M:%S")
  ax.xaxis.set_major_formatter(xfmt)
  plt.show()


source:
  from google.cloud.logging.handlers import CloudLoggingHandler
  from google.cloud.logging_v2.handlers import setup_logging
  client = Client()
  gcp_handler = CloudLoggingHandler(client)

source_raw:
  from google.cloud.logging.handlers import CloudLoggingHandler
  from google.cloud.logging_v2.handlers import setup_logging
  client = Client()
  gcp_handler = CloudLoggingHandler(client)


source:
  from google.cloud.logging.handlers import CloudLoggingHandler
  from google.cloud.logging_v2.handlers import setup_logging

  handler = CloudLoggingHandler(client)
  setup_logging(handler)

source_raw:
  from google.cloud.logging.handlers import CloudLoggingHandler
  from google.cloud.logging_v2.handlers import setup_logging

  handler = CloudLoggingHandler(client)
  setup_logging(handler)


source:
  def connect_mqtt():
      def on_connect(client, userdata, flags, rc):
      # For paho-mqtt 2.0.0, you need to add the properties parameter.
      # def on_connect(client, userdata, flags, rc, properties):
          if rc == 0:
              print("Connected to MQTT Broker!")
          else:
              print("Failed to connect, return code %d\n", rc)
      # Set Connecting Client ID
      client = mqtt_client.Client(client_id)

      # For paho-mqtt 2.0.0, you need to set callback_api_version.
      # client = mqtt_client.Client(client_id=client_id, callback_api_version=mqtt_client.CallbackAPIVersion.VERSION2)

      # client.username_pw_set(username, password)
      client.on_connect = on_connect
      client.connect(broker, port)
      return client

source_raw:
  def connect_mqtt():
      def on_connect(client, userdata, flags, rc):
      # For paho-mqtt 2.0.0, you need to add the properties parameter.
      # def on_connect(client, userdata, flags, rc, properties):
          if rc == 0:
              print("Connected to MQTT Broker!")
          else:
              print("Failed to connect, return code %d\n", rc)
      # Set Connecting Client ID
      client = mqtt_client.Client(client_id)

      # For paho-mqtt 2.0.0, you need to set callback_api_version.
      # client = mqtt_client.Client(client_id=client_id, callback_api_version=mqtt_client.CallbackAPIVersion.VERSION2)

      # client.username_pw_set(username, password)
      client.on_connect = on_connect
      client.connect(broker, port)
      return client


source:
  new = process_updated_file(spreadsheet_id='1GOrgcmlUoQt-oyHt5CsPf5wMUF-O8ucIu4zEsGM8ZJY', sheet_id='supplierfile_nonpo')

source_raw:
  new = process_updated_file(spreadsheet_id='1GOrgcmlUoQt-oyHt5CsPf5wMUF-O8ucIu4zEsGM8ZJY', sheet_id='supplierfile_nonpo')


source:
  new = process_updated_file(spreadsheet_id='1GOrgcmlUoQt-oyHt5CsPf5wMUF-O8ucIu4zEsGM8ZJY', sheet_id='supplierfile_nonpo', credentials='/Users/errol/gcpkeys/finops_svc_acct.json')

source_raw:
  new = process_updated_file(spreadsheet_id='1GOrgcmlUoQt-oyHt5CsPf5wMUF-O8ucIu4zEsGM8ZJY', sheet_id='supplierfile_nonpo', credentials='/Users/errol/gcpkeys/finops_svc_acct.json')


source:
  new = process_updated_file(spreadsheet_id='1ts18oj_d3QlUfWaNpH17RawhvEraDHrlRAZy4c7ph9s', sheet_id='supplierfile_nonpo', credentials='/Users/errol/gcpkeys/finops_svc_acct.json')

source_raw:
  new = process_updated_file(spreadsheet_id='1ts18oj_d3QlUfWaNpH17RawhvEraDHrlRAZy4c7ph9s', sheet_id='supplierfile_nonpo', credentials='/Users/errol/gcpkeys/finops_svc_acct.json')


source:
  with open(July.csv, 'w') as file:
      print(new.to_csv(sep=",",
                  encoding="utf-8",
                  index=False), file = file,)
                  

source_raw:
  with open(July.csv, 'w') as file:
      print(new.to_csv(sep=",",
                  encoding="utf-8",
                  index=False), file = file,)
                  


source:
  with open("July.csv", 'w') as file:
      print(new.to_csv(sep=",",
                  encoding="utf-8",
                  index=False), file = file,)
                  

source_raw:
  with open("July.csv", 'w') as file:
      print(new.to_csv(sep=",",
                  encoding="utf-8",
                  index=False), file = file,)
                  


source:
  dict1 = {'name': 'nginx-1-d888c47fc-zzcmk', 'cpu': '250m', 'memory': '64Mi'}
  dict2 = {'name': 'nginx-1-d888c47fc-zzcmk', 'cpu': '0', 'memory': '4808Ki'}

source_raw:
  dict1 = {'name': 'nginx-1-d888c47fc-zzcmk', 'cpu': '250m', 'memory': '64Mi'}
  dict2 = {'name': 'nginx-1-d888c47fc-zzcmk', 'cpu': '0', 'memory': '4808Ki'}


source:
  if dict1["name"] == dict2["name"]:
      print(f"Names are the same: {dict1['name']}")
  else:
      print(f"Names are different: {dict1['name']} and {dict2['name']}")
      

source_raw:
  if dict1["name"] == dict2["name"]:
      print(f"Names are the same: {dict1['name']}")
  else:
      print(f"Names are different: {dict1['name']} and {dict2['name']}")
      


source:
  my_weekly_schedule = {‘Monday’:’busy’, ‘Tuesday’:’very_busy’, Wednesday:’free’, ‘Thursday’: ‘free’, ‘Friday’: ‘busy’, ‘Saturday’:’free’, ‘Sunday’:’free’}

  my_free_days = []

  for i in my_weekly_schedule.keys()
    print i if my_weekly_schedule[i] == 'free' else ""

source_raw:
  my_weekly_schedule = {‘Monday’:’busy’, ‘Tuesday’:’very_busy’, Wednesday:’free’, ‘Thursday’: ‘free’, ‘Friday’: ‘busy’, ‘Saturday’:’free’, ‘Sunday’:’free’}

  my_free_days = []

  for i in my_weekly_schedule.keys()
    print i if my_weekly_schedule[i] == 'free' else ""


source:
  my_weekly_schedule = {‘Monday’:’busy’, ‘Tuesday’:’very_busy’, Wednesday:’free’, ‘Thursday’: ‘free’, ‘Friday’: ‘busy’, ‘Saturday’:’free’, ‘Sunday’:’free’}



  for i in my_weekly_schedule.keys()
    print i if my_weekly_schedule[i] == 'free' else ""

source_raw:
  my_weekly_schedule = {‘Monday’:’busy’, ‘Tuesday’:’very_busy’, Wednesday:’free’, ‘Thursday’: ‘free’, ‘Friday’: ‘busy’, ‘Saturday’:’free’, ‘Sunday’:’free’}



  for i in my_weekly_schedule.keys()
    print i if my_weekly_schedule[i] == 'free' else ""


