GKE TPU Metrics Monitoring Guide
This skill enables the agent to monitor GKE TPU workloads, nodes, and node pools using GKE system metrics. It helps diagnose if workload interruptions or performance issues are caused by underlying infrastructure.
Step 0: Mandatory Context
Independently gather required context (such as cluster details or node pool names) using available GKE and Cloud tools, or use the provided {variable} placeholders:
{project_id}: The GCP Project ID.
{cluster_name}: The GKE Cluster Name.
{location}: The GKE Cluster Location (region or zone).
{node_name}: (Optional) The name of the specific GKE node.
{node_pool_name}: (Optional) The name of the GKE node pool.
Diagnostic Steps
Step 1: Verify TPU Runtime Metrics Configuration [Low Risk] [Auto]
Before analyzing runtime metrics, verify that the workload is configured to export them.
- Action: Verify that the Pod specification for the TPU workload includes:
containerPort: 8431
- JAX version
0.4.14 or later (if using JAX).
- GKE version is
1.27.4-gke.900 or later.
- GKE System Metrics are enabled on the cluster.
Step 2: Monitor TPU Runtime Metrics [Low Risk] [Auto]
If configured correctly, the following metrics are available in Cloud Monitoring (monitored resources k8s_node and k8s_container):
- Container Metrics:
kubernetes.io/container/accelerator/duty_cycle: Percentage of time over the past sampling period (60 seconds) during which the TensorCores were actively processing on a TPU chip.
kubernetes.io/container/accelerator/memory_used: Amount of accelerator memory allocated in bytes.
kubernetes.io/container/accelerator/memory_total: Total accelerator memory in bytes.
- Node Metrics:
kubernetes.io/node/accelerator/duty_cycle
kubernetes.io/node/accelerator/memory_used
kubernetes.io/node/accelerator/memory_total
Step 3: Check Node Status Condition [Low Risk] [Auto]
Query the status condition of GKE nodes (GKE version 1.32.1-gke.1357001 or later).
- PromQL Query (Check if a specific node is Ready):
kubernetes_io:node_status_condition{monitored_resource="k8s_node", cluster_name="{cluster_name}", node_name="{node_name}", condition="Ready", status="True"}
- PromQL Query (List nodes with non-Ready conditions that are True):
kubernetes_io:node_status_condition{monitored_resource="k8s_node", cluster_name="{cluster_name}", condition!="Ready", status="True"}
- PromQL Query (List nodes that are NOT Ready):
kubernetes_io:node_status_condition{monitored_resource="k8s_node", cluster_name="{cluster_name}", condition="Ready", status="False"}
- PromQL Query (Fleet-wide node status):
avg by (condition,status)(avg_over_time(kubernetes_io:node_status_condition{monitored_resource="k8s_node"}[5m]))
Step 4: Check Node Pool Status [Low Risk] [Auto]
Query the status of multi-host TPU node pools.
- PromQL Query (Verify if a specific node pool is Running):
kubernetes_io:node_pool_status{monitored_resource="k8s_node_pool", cluster_name="{cluster_name}", node_pool_name="{node_pool_name}", status="Running"}
- PromQL Query (Monitor node pools grouped by status):
count by (status)(count_over_time(kubernetes_io:node_pool_status{monitored_resource="k8s_node_pool"}[5m]))
Possible statuses: Provisioning, Running, Error, Reconciling, Stopping.
Step 5: Check Node Pool Availability [Low Risk] [Auto]
Query if all nodes in a multi-host TPU node pool are available.
Step 6: Analyze Node Interruptions [Low Risk] [Auto]
Query the count of interruptions for GKE nodes.
- PromQL Query (Breakdown of interruptions and causes):
sum by (interruption_type,interruption_reason)(sum_over_time(kubernetes_io:node_interruption_count{monitored_resource="k8s_node"}[5m]))
Interruption Types: TerminationEvent, MaintenanceEvent, PreemptionEvent.
Interruption Reasons: HostError, Eviction, AutoRepair.
- PromQL Query (Filter for Host Maintenance events):
sum by (interruption_type,interruption_reason)(sum_over_time(kubernetes_io:node_interruption_count{monitored_resource="k8s_node", interruption_reason="HW/SW Maintenance"}[5m]))
- PromQL Query (Interruption count aggregated by node pool):
sum by (node_pool_name,interruption_type,interruption_reason)(sum_over_time(kubernetes_io:node_pool_interruption_count{monitored_resource="k8s_node_pool", interruption_reason="HW/SW Maintenance", node_pool_name="{node_pool_name}"}[5m]))
Step 7: Calculate Recovery and Interruption Metrics [Low Risk] [Auto]
Calculate Mean Time to Recovery (MTTR) and Mean Time Between Interruptions (MTBI) over the last 7 days.
- PromQL Query (MTTR - Mean Time to Recovery):
sum(sum_over_time(kubernetes_io:node_pool_accelerator_times_to_recover_sum{monitored_resource="k8s_node_pool", cluster_name="{cluster_name}"}[7d])) / sum(sum_over_time(kubernetes_io:node_pool_accelerator_times_to_recover_count{monitored_resource="k8s_node_pool",cluster_name="{cluster_name}"}[7d]))
- PromQL Query (MTBI - Mean Time Between Interruptions):
sum(count_over_time(kubernetes_io:node_memory_total_bytes{monitored_resource="k8s_node", node_name=~"gke-tpu.*|gk3-tpu.*", cluster_name="{cluster_name}"}[7d])) / sum(sum_over_time(kubernetes_io:node_interruption_count{monitored_resource="k8s_node", node_name=~"gke-tpu.*|gk3-tpu.*", cluster_name="{cluster_name}"}[7d]))
Step 8: Monitor TPU Host Metrics [Low Risk] [Auto]
For GKE version 1.28.1-gke.1066000 or later, monitor TPU host performance.
- Container Metrics:
kubernetes.io/container/accelerator/tensorcore_utilization: Current percentage of the TensorCore that is utilized.
kubernetes.io/container/accelerator/memory_bandwidth_utilization: Current percentage of the accelerator memory bandwidth that is being used.
- Node Metrics:
kubernetes.io/node/accelerator/tensorcore_utilization
kubernetes.io/node/accelerator/memory_bandwidth_utilization
1---2name: gke-tpu-metrics-monitoring3description: Monitors and troubleshoots GKE TPU workloads, nodes, and node pools using GKE system metrics and PromQL. Use when monitoring TensorCore duty cycle, TPU memory, node readiness, multi-host TPU node pool availability, host maintenance or preemption interruptions, and calculating MTTR or MTBI metrics for GKE TPUs. Don't use for general non-TPU GKE workload monitoring or non-metric TPU debugging.4---56# GKE TPU Metrics Monitoring Guide78This skill enables the agent to monitor GKE TPU workloads, nodes, and node pools using GKE system metrics. It helps diagnose if workload interruptions or performance issues are caused by underlying infrastructure.910## Step 0: Mandatory Context1112Independently gather required context (such as cluster details or node pool names) using available GKE and Cloud tools, or use the provided `{variable}` placeholders:1314- `{project_id}`: The GCP Project ID.15- `{cluster_name}`: The GKE Cluster Name.16- `{location}`: The GKE Cluster Location (region or zone).17- `{node_name}`: (Optional) The name of the specific GKE node.18- `{node_pool_name}`: (Optional) The name of the GKE node pool.1920---2122## Diagnostic Steps2324### Step 1: Verify TPU Runtime Metrics Configuration [Low Risk] [Auto]2526Before analyzing runtime metrics, verify that the workload is configured to export them.2728- **Action**: Verify that the Pod specification for the TPU workload includes:29 - `containerPort: 8431`30 - JAX version `0.4.14` or later (if using JAX).31 - GKE version is `1.27.4-gke.900` or later.32 - GKE System Metrics are enabled on the cluster.3334### Step 2: Monitor TPU Runtime Metrics [Low Risk] [Auto]3536If configured correctly, the following metrics are available in Cloud Monitoring (monitored resources `k8s_node` and `k8s_container`):3738- **Container Metrics**:39 - `kubernetes.io/container/accelerator/duty_cycle`: Percentage of time over the past sampling period (60 seconds) during which the TensorCores were actively processing on a TPU chip.40 - `kubernetes.io/container/accelerator/memory_used`: Amount of accelerator memory allocated in bytes.41 - `kubernetes.io/container/accelerator/memory_total`: Total accelerator memory in bytes.42- **Node Metrics**:43 - `kubernetes.io/node/accelerator/duty_cycle`44 - `kubernetes.io/node/accelerator/memory_used`45 - `kubernetes.io/node/accelerator/memory_total`4647### Step 3: Check Node Status Condition [Low Risk] [Auto]4849Query the status condition of GKE nodes (GKE version `1.32.1-gke.1357001` or later).5051- **PromQL Query (Check if a specific node is Ready)**:52 ```promql53 kubernetes_io:node_status_condition{monitored_resource="k8s_node", cluster_name="{cluster_name}", node_name="{node_name}", condition="Ready", status="True"}54 ```55- **PromQL Query (List nodes with non-Ready conditions that are True)**:56 ```promql57 kubernetes_io:node_status_condition{monitored_resource="k8s_node", cluster_name="{cluster_name}", condition!="Ready", status="True"}58 ```59- **PromQL Query (List nodes that are NOT Ready)**:60 ```promql61 kubernetes_io:node_status_condition{monitored_resource="k8s_node", cluster_name="{cluster_name}", condition="Ready", status="False"}62 ```63- **PromQL Query (Fleet-wide node status)**:64 ```promql65 avg by (condition,status)(avg_over_time(kubernetes_io:node_status_condition{monitored_resource="k8s_node"}[5m]))66 ```6768### Step 4: Check Node Pool Status [Low Risk] [Auto]6970Query the status of multi-host TPU node pools.7172- **PromQL Query (Verify if a specific node pool is Running)**:73 ```promql74 kubernetes_io:node_pool_status{monitored_resource="k8s_node_pool", cluster_name="{cluster_name}", node_pool_name="{node_pool_name}", status="Running"}75 ```76- **PromQL Query (Monitor node pools grouped by status)**:77 ```promql78 count by (status)(count_over_time(kubernetes_io:node_pool_status{monitored_resource="k8s_node_pool"}[5m]))79 ```80 _Possible statuses_: `Provisioning`, `Running`, `Error`, `Reconciling`, `Stopping`.8182### Step 5: Check Node Pool Availability [Low Risk] [Auto]8384Query if all nodes in a multi-host TPU node pool are available.8586- **PromQL Query (Check availability over time)**:87 ```promql88 avg by (node_pool_name)(avg_over_time(kubernetes_io:node_pool_multi_host_available{monitored_resource="k8s_node_pool", cluster_name="{cluster_name}"}[5m]))89 ```90 _Value_: `1` (True, all nodes available) or `0` (False, some nodes unavailable).9192### Step 6: Analyze Node Interruptions [Low Risk] [Auto]9394Query the count of interruptions for GKE nodes.9596- **PromQL Query (Breakdown of interruptions and causes)**:97 ```promql98 sum by (interruption_type,interruption_reason)(sum_over_time(kubernetes_io:node_interruption_count{monitored_resource="k8s_node"}[5m]))99 ```100 _Interruption Types_: `TerminationEvent`, `MaintenanceEvent`, `PreemptionEvent`.101 _Interruption Reasons_: `HostError`, `Eviction`, `AutoRepair`.102- **PromQL Query (Filter for Host Maintenance events)**:103 ```promql104 sum by (interruption_type,interruption_reason)(sum_over_time(kubernetes_io:node_interruption_count{monitored_resource="k8s_node", interruption_reason="HW/SW Maintenance"}[5m]))105 ```106- **PromQL Query (Interruption count aggregated by node pool)**:107 ```promql108 sum by (node_pool_name,interruption_type,interruption_reason)(sum_over_time(kubernetes_io:node_pool_interruption_count{monitored_resource="k8s_node_pool", interruption_reason="HW/SW Maintenance", node_pool_name="{node_pool_name}"}[5m]))109 ```110111### Step 7: Calculate Recovery and Interruption Metrics [Low Risk] [Auto]112113Calculate Mean Time to Recovery (MTTR) and Mean Time Between Interruptions (MTBI) over the last 7 days.114115- **PromQL Query (MTTR - Mean Time to Recovery)**:116 ```promql117 sum(sum_over_time(kubernetes_io:node_pool_accelerator_times_to_recover_sum{monitored_resource="k8s_node_pool", cluster_name="{cluster_name}"}[7d])) / sum(sum_over_time(kubernetes_io:node_pool_accelerator_times_to_recover_count{monitored_resource="k8s_node_pool",cluster_name="{cluster_name}"}[7d]))118 ```119- **PromQL Query (MTBI - Mean Time Between Interruptions)**:120 ```promql121 sum(count_over_time(kubernetes_io:node_memory_total_bytes{monitored_resource="k8s_node", node_name=~"gke-tpu.*|gk3-tpu.*", cluster_name="{cluster_name}"}[7d])) / sum(sum_over_time(kubernetes_io:node_interruption_count{monitored_resource="k8s_node", node_name=~"gke-tpu.*|gk3-tpu.*", cluster_name="{cluster_name}"}[7d]))122 ```123124### Step 8: Monitor TPU Host Metrics [Low Risk] [Auto]125126For GKE version `1.28.1-gke.1066000` or later, monitor TPU host performance.127128- **Container Metrics**:129 - `kubernetes.io/container/accelerator/tensorcore_utilization`: Current percentage of the TensorCore that is utilized.130 - `kubernetes.io/container/accelerator/memory_bandwidth_utilization`: Current percentage of the accelerator memory bandwidth that is being used.131- **Node Metrics**:132 - `kubernetes.io/node/accelerator/tensorcore_utilization`133 - `kubernetes.io/node/accelerator/memory_bandwidth_utilization`134