GKE Observability

GKE Observability

Guides an agent to configure and troubleshoot GKE logging, monitoring and managed Prometheus, including control plane, scheduling and missing-metrics issues, using gcloud and MCP tools.

Skill files5 files

references/

SKILL.md204 lines
1
---
2
name: gke-observability
3
description: >-
4
Configures GKE observability, including Cloud Logging, Cloud Monitoring, and
5
managed Prometheus. Use when configuring GKE monitoring, setting up GKE
6
logging, or configuring Prometheus metrics collection, to diagnose GKE control
7
plane, API server, admission webhook, etcd storage, node registration or
8
label, and pod eviction, preemption, or scheduling issues using GKE metrics,
9
Kubernetes events, and Cloud Logging, and to troubleshoot Managed Service for
10
Prometheus (GMP) issues such as missing metrics, unhealthy scrape targets,
11
PodMonitoring misconfiguration, rule/alert evaluation failures, and monitoring
12
permission errors. Don't use to configure local application logging frameworks
13
or external APMs outside GKE.
14
metadata:
15
version: "1.2.1"
16
category: CloudObservabilityAndMonitoring
17
---
18
19
# GKE Observability
20
21
This reference covers monitoring, logging, and metrics configuration and
22
troubleshooting for Google Kubernetes Engine (GKE). The golden path enables
23
comprehensive observability including control-plane metrics and Managed Service
24
for Prometheus (GMP).
25
26
> **MCP Tools:** `get_cluster`, `list_k8s_events`, `get_k8s_logs`,
27
> `get_k8s_cluster_info`, `describe_k8s_resource`. **CLI-only:** `gcloud
28
> container clusters update --monitoring=...`, `gcloud logging read`
29
30
## Usage Attribution
31
32
Do not run live `kubectl`, `gcloud`, or `curl` commands unless the user names a
33
target cluster/project or asks to inspect a live cluster (output commands and
34
queries with placeholders, and skip [Usage Attribution](references/attribution.md)).
35
Before running any live command, read [Usage Attribution](references/attribution.md),
36
prefix `gcloud` with `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-observability)"`,
37
and append `agent-skills/1.0 (skill:gke-observability)` to `User-Agent` headers
38
(never in generated scripts, Terraform, or user-facing code).
39
40
## Sub-Skill Reference Routing (Progressive Disclosure)
41
42
> **Complete Reference Index** (no `scripts/` directory or unlisted reference
43
> files exist — do not run `ls` on the skill folder; read only the matching
44
> reference below when answering deep diagnostic, metric, log, or GMP questions):
45
46
1. **[Control-Plane Metrics, Storage, Webhooks & Capacity](references/control-plane-metrics-and-storage.md)**:
47
Read for GKE control-plane (KCP) VM CPU or RAM/memory usage questions (not
48
publicly exposed) and customer-visible alternatives; cluster etcd /
49
etcd-compatible storage left, quota & per-resource scalability limits;
50
admission webhook latency, system namespace/Lease/upgrade exclusions,
51
`APIService` discovery bloat, client discovery caching bursts
52
(`/apis/custom.metrics.k8s.io`, `/apis/metrics.k8s.io`) & proactive GKE
53
Recommender insights; watch storms; controller-manager workqueue & scheduler
54
lag; or control-plane headroom, VM autoscaling & node-count pre-scaling,
55
network egress, connections (`65k`, no per-replica metric) & Protobuf.
56
2. **[Cloud Logging, Audit Attribution, APF & API Server Traces](references/logging-audit-and-apiserver-traces.md)**:
57
Read for `kube-apiserver` slow-request `Trace[` logs (`trace.go` & KEP-647);
58
`httplog.go` client load (`user_agent`, `verb`, `apf_iseats`); Cloud Audit
59
Log noisy-neighbor, heavy `LIST` & unindexed CRD `fieldSelector` scan
60
tail-latency attribution; API Priority and Fairness (APF) `429`/`504`/`404`
61
throttling; `409 Conflict` hot objects (`ConfigMap` -> `Lease` heartbeats) &
62
`RenewDeadline / 2` leader-election timeouts; `pods/exec` saturation,
63
Konnectivity (`No agent available`), disabled Cloud KMS keys, or in-cluster
64
GCP IAM OAuth token webhook authorizer saturation.
65
3. **[Cluster/Node/Pod Health, Maintenance & Managed Prometheus (GMP)](references/cluster-node-pod-health-and-gmp.md)**:
66
Read for control-plane availability (`kubernetes.io/cluster/kcp_healthchecks`
67
rate ratio & ruling out KCP outages); maintenance windows
68
(`in_maintenance_window`), zonal resize downtime & cluster access errors
69
(`EOF` / `masterAuthorizedNetworksConfig`); node readiness, registration
70
(`AUTO_REPAIR_NODES`, Private Google Access) & persistent node-pool labels;
71
pod startup timelines, crashing pod logs, `tolerationSeconds: 0` mass
72
eviction & Autopilot preemption; or multi-burn-rate SLO alerting
73
(`GlobalRules`) & GMP / Grafana / `PodMonitoring` manifests & troubleshooting.
74
75
## Golden Path Observability Defaults
76
77
Setting | Golden Path Value | Notes
78
--------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | -----
79
`loggingConfig` components | SYSTEM_COMPONENTS, WORKLOADS | Full workload logging
80
`monitoringConfig` components | SYSTEM_COMPONENTS, STORAGE, POD, DEPLOYMENT, STATEFULSET, DAEMONSET, HPA, JOBSET, CADVISOR, KUBELET, DCGM, APISERVER, SCHEDULER, CONTROLLER_MANAGER | Full suite including control-plane
81
`managedPrometheusConfig.enabled` | `true` | Google-managed Prometheus
82
`advancedDatapathObservabilityConfig.enableMetrics` | `true` | Dataplane V2 flow metrics
83
`loggingService` | `logging.googleapis.com/kubernetes` | Cloud Logging
84
`monitoringService` | `monitoring.googleapis.com/kubernetes` | Cloud Monitoring
85
86
## Enabling Full Monitoring & Logging
87
88
Include all four caveats whenever providing a `--monitoring` or `--logging`
89
command so users avoid accidental metric loss, surprise billing, or silent IAM
90
failures:
91
92
1. **Control-plane metrics and logs are NOT enabled by default.** State this
93
outright: `API_SERVER`, `SCHEDULER`, and `CONTROLLER_MANAGER` are off on
94
every new cluster (as are `DCGM`, `CADVISOR`, `KUBELET`, and kube-state
95
`POD`, `DEPLOYMENT`, `STATEFULSET`, `DAEMONSET`, `HPA`, `STORAGE`,
96
`JOBSET`). Only `SYSTEM` is enabled by default. Link to
97
https://docs.cloud.google.com/kubernetes-engine/docs/how-to/control-plane-metrics
98
and
99
https://docs.cloud.google.com/kubernetes-engine/docs/how-to/view-logs#control_plane_logs.
100
2. **The flag replaces, it does not append.** Passing `--monitoring` or
101
`--logging` overrides the existing component list; pass the full desired
102
list including `SYSTEM`.
103
3. **Control-plane and kube-state metrics bill per sample ingested** via
104
Managed Service for Prometheus (GMP). Mention the cost impact on large
105
clusters; use `--monitoring=SYSTEM` in non-production to reduce cost.
106
4. **Verify APIs and IAM permissions (`PermissionDenied`).** Check `gcloud
107
container clusters describe {cluster_name} --region {region}
108
--format="yaml(loggingConfig,monitoringConfig)"`, ensure
109
`logging.googleapis.com` and `monitoring.googleapis.com` are enabled, and
110
verify the node service account / GKE service agent has
111
`roles/monitoring.metricWriter` and
112
`roles/container.defaultNodeServiceAgent`.
113
114
> **CLI flag vs. API enum spelling (mixing them fails the command):**
115
>
116
> Component | `gcloud --monitoring=` | `monitoringConfig` API enum
117
> -------------- | ---------------------- | ---------------------------
118
> System | `SYSTEM` | `SYSTEM_COMPONENTS`
119
> API server | `API_SERVER` | `APISERVER`
120
> Controller mgr | `CONTROLLER_MANAGER` | `CONTROLLER_MANAGER`
121
122
```bash
123
# Enable golden path monitoring and control-plane logging suite
124
gcloud container clusters update {cluster_name} --region {region} \
125
--monitoring=SYSTEM,API_SERVER,SCHEDULER,CONTROLLER_MANAGER,STORAGE,POD,DEPLOYMENT,STATEFULSET,DAEMONSET,HPA,JOBSET,CADVISOR,KUBELET,DCGM \
126
--logging=SYSTEM,WORKLOAD,API_SERVER,SCHEDULER,CONTROLLER_MANAGER \
127
--quiet
128
129
# Enable Managed Prometheus and Dataplane V2 flow/policy observability
130
gcloud container clusters update {cluster_name} --region {region} \
131
--enable-managed-prometheus \
132
--enable-dataplane-v2-flow-observability \
133
--quiet
134
```
135
136
## Core GKE Metrics & Alerting Baseline
137
138
Explicitly name **Google Cloud Monitoring** when proposing dashboards and
139
alerts, and cover cluster/node CPU and memory capacity, pod restarts
140
(`CrashLoopBackOff`), volume space exhaustion, and API server latency
141
(`apiserver_request_duration_seconds`). Direct control-plane VM CPU/RAM metrics
142
are not publicly exposed — read
143
[Control-Plane Metrics, Storage, Webhooks & Capacity](references/control-plane-metrics-and-storage.md)
144
whenever asked about control-plane VM CPU/memory or deep control-plane metrics.
145
146
Metric | Source | Use / Alert Threshold
147
------------------------------------------------ | ------------------ | ---------------------
148
`apiserver_request_duration_seconds` | API Server (GMP) | Control-plane latency (Alert: P99 > 5s)
149
`scheduler_scheduling_attempt_duration_seconds` | Scheduler (GMP) | Current GKE scheduling latency (`scheduler_schedule_attempts_total{result="error"} > 0`)
150
`container_cpu_usage_seconds_total` | cAdvisor (Node) | Worker-node container CPU usage
151
`container_memory_working_set_bytes` | cAdvisor (Node) | Worker-node container memory usage
152
`kubernetes.io/node/cpu/core_usage_time` | Cloud Monitoring | Node CPU usage (`kubernetes.io/node/memory/used_bytes` for memory)
153
`kube_pod_status_phase` | kube-state-metrics | Pod lifecycle phase (requires deploying GMP or self-managed kube-state-metrics)
154
`kube_pod_container_status_restarts_total` | kube-state-metrics | Pod crash loops (Alert: > 5 in 10m; requires kube-state-metrics)
155
`kube_node_status_condition` | kube-state-metrics | Node readiness (`condition="Ready", status!="True"`; or `kubernetes.io/node/status_condition`)
156
`kubelet_volume_stats_used_bytes / capacity` | Kubelet | PVC capacity utilization (Alert: > 85%)
157
`DCGM_FI_DEV_GPU_UTIL` | DCGM (GMP) | GPU utilization (Alert: > 95% sustained)
158
159
## Live Resource Usage & Cloud Logging Queries
160
161
Use `kubectl top` for live usage (no MCP or `gcloud` equivalent):
162
163
```bash
164
kubectl top pods --all-namespaces --sort-by=cpu
165
kubectl top nodes
166
kubectl top pods --containers -n {namespace}
167
```
168
169
Use `gcloud logging read` (or Cloud Logging Log Explorer) with LQL filters:
170
171
```bash
172
# Control-plane component logs (requires API_SERVER / SCHEDULER / CONTROLLER_MANAGER enabled)
173
gcloud logging read 'resource.type="k8s_control_plane_component" AND resource.labels.cluster_name="{cluster_name}"' --project {project_id} --limit 50 --quiet
174
175
# Container errors: resource.type="k8s_container" AND resource.labels.container_name="{container_name}" AND severity>=ERROR
176
# OOMKilled events: resource.type="k8s_event" AND jsonPayload.reason="OOMKilling"
177
# FailedScheduling: resource.type="k8s_event" AND jsonPayload.reason="FailedScheduling"
178
# Cloud Audit Logs: resource.type="k8s_cluster" AND logName:"cloudaudit.googleapis.com"
179
# Dataplane V2 network policy / packet drop logs: logName:"policy_action" AND jsonPayload.disposition="DENY"
180
```
181
182
## Distributed Tracing, Profiling & Recent Additions
183
184
- **Cloud Trace & OpenTelemetry**: Deploy the OpenTelemetry Collector
185
(`googlecloud` exporter with Workload Identity) or enable **Managed
186
OpenTelemetry for GKE (Preview)** on GKE 1.34.1-gke.2178000+ (`gcloud beta
187
container clusters update {cluster_name} --region {region}
188
--managed-otel-scope=COLLECTION_AND_INSTRUMENTATION_COMPONENTS`).
189
- **Cloud Profiler**: Continuous low-overhead production CPU/memory profiling.
190
- **PSI (Pressure Stall Information) metrics**: cAdvisor
191
`container_pressure_{cpu,memory,io}_{waiting,stalled}_seconds_total` via GMP
192
`ClusterNodeMonitoring` (GKE 1.35+).
193
194
## Supporting Links
195
196
- [GKE System Metrics](https://docs.cloud.google.com/monitoring/api/metrics_kubernetes)
197
- [GKE Control-Plane Metrics](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/control-plane-metrics)
198
- [GKE Control-Plane Logs](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/view-logs#control_plane_logs)
199
- [Google Cloud Managed Service for Prometheus](https://cloud.google.com/stackdriver/docs/managed-prometheus)
200
- [Troubleshoot Managed Service for Prometheus](https://docs.cloud.google.com/stackdriver/docs/managed-prometheus/troubleshooting.md.txt)
201
- [Rule Evaluation (Rules / ClusterRules / GlobalRules)](https://docs.cloud.google.com/stackdriver/docs/managed-prometheus/rules-managed.md.txt)
202
- [Cloud Logging Query Language (LQL)](https://cloud.google.com/logging/docs/view/logging-query-language)
203
- [Google Cloud Monitoring Alerts](https://cloud.google.com/monitoring/alerts)
204

© Google LLC · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…