Compute Host Events Troubleshooting

Compute Host Events Troubleshooting

Investigates why a Compute Engine VM unexpectedly rebooted, stopped or was preempted, using audit log queries and maintenance checks, then suggests mitigations.

Skill files2 files

references/

SKILL.md484 lines
1
---
2
name: compute-host-events-troubleshooting
3
description: >-
4
Investigates, diagnoses, and mitigates Google Compute Engine virtual
5
machine (VM) host events, including planned infrastructure maintenance
6
(migrateOnHostMaintenance, terminateOnHostMaintenance), physical host hardware
7
errors (hostError), guest OS terminations (guestTerminate), and Spot or
8
Preemptible VM preemptions (compute.instances.preempted) using shutdown-script
9
metadata. Use ONLY when an existing Compute Engine VM unexpectedly reboots,
10
stops, crashes, is preempted, or becomes unresponsive due to physical host
11
maintenance, hardware errors, or Local SSD recovery. DO NOT read or use for
12
creating new standalone VMs, Managed Instance Group (MIG) autoscaler scale-out
13
or scale-in failures, Google Kubernetes Engine (GKE) clusters, application OOM
14
debugging, or VPC firewall issues.
15
metadata:
16
version: "1.0.0"
17
category: Compute
18
---
19
20
# Compute Engine VM Host Events & Infrastructure Crash Troubleshooting
21
22
This skill diagnoses unexpected Google Compute Engine VM restarts,
23
terminations, and unresponsiveness caused by infrastructure host events
24
(`compute.instances.hostError`, `compute.instances.migrateOnHostMaintenance`,
25
`compute.instances.terminateOnHostMaintenance`, `compute.instances.preempted`,
26
`compute.instances.automaticRestart`) or guest-OS-initiated shutdowns
27
(`compute.instances.guestTerminate`). It provides authoritative Cloud Audit Log
28
queries, Log Analytics `_Required._AllLogs` SQL aggregations, upcoming
29
maintenance window checks, and host scheduling remediations.
30
31
> **MCP Tools:** `get_instance_basic_info`, `list_instances`,
32
> `list_instance_attached_disks`, `start_instance`, `stop_instance`,
33
> `reset_instance`, `delete_instance`, `get_zone_operation`
34
35
## Usage Attribution
36
37
**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you
38
MUST read and follow the instructions in
39
[Usage Attribution](references/attribution.md).
40
41
---
42
43
## Prerequisites & Environment Setup
44
45
Any host or project modifications (installing or updating `gcloud`, configuring
46
the Compute Engine MCP server, enabling APIs or Log Analytics, mutating VM
47
scheduling/metadata, creating log-based metrics, or deleting resources) must be
48
explicitly approved by the user before execution.
49
50
1. **Google Cloud SDK**: Verify `gcloud` is installed (`gcloud --version`). If
51
missing or outdated, ask the user for approval before installing via
52
[Install the gcloud CLI](https://docs.cloud.google.com/sdk/docs/install-sdk.md.txt).
53
2. **Compute Engine MCP Server & Capability Boundary**:
54
- The Compute Engine MCP server
55
([Use the Compute Engine MCP server](https://docs.cloud.google.com/compute/docs/use-compute-engine-mcp.md.txt))
56
exposes zonal VM discovery and lifecycle tools (`get_instance_basic_info`,
57
`list_instances`, `list_instance_attached_disks`, `start_instance`,
58
`stop_instance`, `reset_instance`, `delete_instance`,
59
`get_zone_operation`, requiring `roles/mcp.toolUser`).
60
- **Critical Routing Rule**: `get_instance_basic_info` returns a reduced
61
`InstanceBasicInfo` projection (`name`, `id`, `status`, `machine_type`,
62
`create_time`, `guest_accelerators`) that **omits `scheduling` and
63
`resourceStatus.upcomingMaintenance`**, and Compute Engine MCP does **not**
64
expose tools for Cloud Logging queries, serial console output,
65
`set-scheduling`, `perform-maintenance`, or instance metadata updates.
66
Always route full scheduling inspection, upcoming maintenance checks,
67
serial port output, audit log queries, and scheduling/metadata mutations to
68
`gcloud` (or Compute Engine / Cloud Logging REST APIs).
69
3. **Authentication**:
70
- Local CLI: `gcloud auth login`
71
- Application Default Credentials: `gcloud auth application-default login`
72
- Service Accounts: Set `GOOGLE_APPLICATION_CREDENTIALS` to your service
73
account credentials path.
74
4. **Project, Region & Billing**:
75
```sh
76
gcloud config set project {project_id}
77
gcloud config set compute/region {region}
78
gcloud config set compute/zone {zone}
79
```
80
*Note: An active billing account attachment is required (even when evaluating
81
Free Tier eligible resources). If no region is specified, default to
82
`us-central1` (`us-central1-a`), and check
83
[Google Cloud locations](https://cloud.google.com/about/locations) for
84
regional hardware availability.*
85
5. **API Enablement**:
86
```sh
87
gcloud services enable compute.googleapis.com logging.googleapis.com monitoring.googleapis.com
88
```
89
6. **Required IAM Roles**:
90
- **Read-Only Diagnostics**: `roles/compute.viewer` (instance scheduling and
91
serial console output), `roles/logging.viewer` (or
92
`roles/logging.privateLogViewer` to read `system_event` and `activity`
93
audit logs), and `roles/logging.viewAccessor` for Log Analytics queries in
94
Cloud Logging (plus `roles/bigquery.jobUser` and
95
`roles/bigquery.dataViewer` when querying a linked Log Analytics dataset
96
from BigQuery Studio or `bq`).
97
- **Remediation & MCP**: `roles/compute.instanceAdmin.v1` (to run
98
`set-scheduling`, `perform-maintenance`, `add-metadata`, or
99
`remove-metadata`), `roles/logging.configWriter` (to create log-based
100
metrics), and `roles/mcp.toolUser` (for Compute Engine MCP calls).
101
102
---
103
104
## Diagnostic Workflow: Classify the Termination Event
105
106
When a user reports an unexpected VM reboot, stop, or crash, run targeted Cloud
107
Logging queries against `cloudaudit.googleapis.com/system_event` (Compute Engine
108
infrastructure events) and `cloudaudit.googleapis.com/activity`
109
(caller-initiated API stops/resets). Always pass `--freshness=7d` (or a window
110
covering the incident timestamp) because `gcloud logging read` defaults
111
`--freshness` to `1d` and silently returns zero rows for incidents older than 24
112
hours. See
113
[Troubleshooting VM shutdowns and reboots](https://docs.cloud.google.com/compute/docs/troubleshooting/troubleshooting-reboots.md.txt).
114
115
### Key Distinction: `hostError` vs. Planned Maintenance vs. `preempted`
116
117
- **`compute.instances.hostError` (Unplanned Hardware/Hypervisor Crash)**:
118
Indicates an unexpected hardware or hypervisor failure on the physical server
119
hosting the VM. If `scheduling.automaticRestart` is `true`
120
(`--restart-on-failure`), Compute Engine automatically restarts the VM on a
121
healthy physical host (typically within **3 to 5.5 minutes** from detection on
122
standard VMs, logging `compute.instances.automaticRestart`). On VMs with
123
attached Local SSDs, Compute Engine logs `compute.instances.hostError` with
124
`operation.first="true"` when Local SSD recovery begins and
125
`operation.last="true"` when recovery completes or reaches
126
`scheduling.localSsdRecoveryTimeout`.
127
- **`compute.instances.migrateOnHostMaintenance` /
128
`compute.instances.terminateOnHostMaintenance` (Planned Infrastructure
129
Maintenance)**: Compute Engine logs these exact `system_event` method names
130
(along with `compute.instances.upcomingMaintenance` notifications) during
131
scheduled hardware or hypervisor updates. Depending on `onHostMaintenance`,
132
the VM either transparently live-migrates (`MIGRATE` ->
133
`compute.instances.migrateOnHostMaintenance`) or terminates (`TERMINATE` ->
134
`compute.instances.terminateOnHostMaintenance`, followed by
135
`compute.instances.automaticRestart` if `automaticRestart: true`).
136
- **`compute.instances.preempted` (Spot / Preemptible VM Reclaimed)**: Indicates
137
Compute Engine reclaimed capacity from a Spot VM or Preemptible VM.
138
139
### 1. Query Infrastructure Host Events & Caller Stops in Cloud Logging
140
141
Run this `gcloud logging read` command to determine whether `{vm_name}`
142
experienced a physical host error, planned maintenance, Spot preemption, MIG
143
recreation, or an external caller-initiated API stop/reset:
144
145
```sh
146
gcloud logging read 'resource.type="gce_instance" AND (log_id("cloudaudit.googleapis.com/system_event") OR log_id("cloudaudit.googleapis.com/activity")) AND protoPayload.methodName=~"(compute\.instances\.(hostError|migrateOnHostMaintenance|terminateOnHostMaintenance|preempted|automaticRestart|upcomingMaintenance|guestTerminate|repair.*)|v1\.compute\.instances\.(stop|reset|delete|performMaintenance|simulateMaintenanceEvent))" AND protoPayload.resourceName:"{vm_name}"' \
147
--project={project_id} \
148
--freshness=7d \
149
--limit=25 \
150
--format="table(timestamp, logName.basename(), protoPayload.methodName, protoPayload.authenticationInfo.principalEmail, operation.first, operation.last, protoPayload.status.message)"
151
```
152
153
### 2. Check Specifically for Guest OS Initiated Terminations (`guestTerminate`)
154
155
If the VM stopped without a `hostError`, maintenance termination, preemption, or
156
user-initiated `v1.compute.instances.stop` Admin Activity log, check whether the
157
shutdown was initiated **from inside the Guest OS** (`sudo shutdown -h now`,
158
`poweroff`, `systemctl poweroff`, or an internal watchdog script):
159
160
```sh
161
gcloud logging read 'resource.type="gce_instance" AND log_id("cloudaudit.googleapis.com/system_event") AND protoPayload.methodName="compute.instances.guestTerminate" AND protoPayload.resourceName:"{vm_name}"' \
162
--project={project_id} \
163
--freshness=7d \
164
--limit=20 \
165
--format="yaml(timestamp, protoPayload.methodName, protoPayload.authenticationInfo.principalEmail, protoPayload.status)"
166
```
167
168
- **Critical `guestTerminate` Attribution Nuance**: Because
169
`compute.instances.guestTerminate` is a `system_event` generated when the
170
guest ACPI power-off reaches the hypervisor, Compute Engine **always records
171
its generic built-in system principal in
172
`protoPayload.authenticationInfo.principalEmail`** — it **never** identifies
173
which Linux/Windows user, cron job, or script inside the VM ran
174
`shutdown`/`poweroff` (whereas external caller-initiated
175
`v1.compute.instances.stop`, `reset`, or `delete` entries in
176
`cloudaudit.googleapis.com/activity` record the external IAM user or service
177
account in `principalEmail`).
178
- **How to Find the In-Guest Culprit**: Inspect the VM's serial console output
179
and guest OS logs from the previous boot (`journalctl -b -1`,
180
`/var/log/syslog` or `/var/log/messages`, `/var/log/auth.log`, and `last -x
181
shutdown reboot`):
182
```sh
183
gcloud compute instances get-serial-port-output {vm_name} --project={project_id} --zone={zone} --port=1
184
```
185
186
### 3. Log Analytics SQL Query: Aggregate Host Events Across the Project
187
188
Compute Engine host events (`hostError`, `migrateOnHostMaintenance`,
189
`terminateOnHostMaintenance`, `preempted`, `automaticRestart`,
190
`guestTerminate`) are `cloudaudit.googleapis.com/system_event` logs. By default,
191
Cloud Logging's `_Default` sink **excludes** `system_event` logs and routes them
192
exclusively to the **`_Required`** log bucket.
193
194
> **Prerequisites for `_Required._AllLogs` SQL**:
195
> 1. Upgrade the **`_Required`** bucket to **Log Analytics** (seek user approval
196
> first):
197
> ```sh
198
> gcloud logging buckets update _Required --project={project_id} --location=global --enable-analytics
199
> ```
200
> 2. In Log Analytics `_AllLogs` schemas, `resource.labels` has BigQuery type
201
> **`JSON`** (not `STRUCT`). Always extract fields with
202
> `JSON_VALUE(resource.labels.zone)` and
203
> `JSON_VALUE(resource.labels.instance_id)` — grouping directly on raw `JSON`
204
> expressions fails with `Grouping by expressions of type JSON is not
205
> allowed`.
206
207
```sql
208
SELECT
209
JSON_VALUE(resource.labels.zone) AS zone,
210
JSON_VALUE(resource.labels.instance_id) AS instance_id,
211
REGEXP_EXTRACT(proto_payload.audit_log.resource_name, r'[^/]+$') AS vm_name,
212
proto_payload.audit_log.method_name AS event_type,
213
COUNT(*) AS event_count
214
FROM `{project_id}.global._Required._AllLogs`
215
WHERE
216
resource.type = 'gce_instance'
217
AND timestamp >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
218
AND proto_payload.audit_log.method_name IN (
219
'compute.instances.hostError',
220
'compute.instances.migrateOnHostMaintenance',
221
'compute.instances.terminateOnHostMaintenance',
222
'compute.instances.preempted',
223
'compute.instances.automaticRestart',
224
'compute.instances.guestTerminate'
225
)
226
GROUP BY zone, instance_id, vm_name, event_type
227
ORDER BY event_count DESC;
228
```
229
230
### 4. Inspect Upcoming Scheduled Host Maintenance & Trigger Early Maintenance
231
232
For instances that emit advance maintenance notifications (such as `A4X Max`,
233
`A4X`, `A4`, `A3`, `A2`, `G4`, `G2` GPU instances, bare metal `-metal`
234
instances, `H4D` / Cloud RDMA instances, `X4` instances, storage-optimized `Z3`
235
/ `Z4D` / `Z4M` Local SSD instances, or Cloud TPU nodes), inspect upcoming
236
maintenance via `gcloud` or the in-guest metadata server. See
237
[Monitor and plan for a host maintenance event](https://docs.cloud.google.com/compute/docs/instances/monitor-plan-host-maintenance-event.md.txt)
238
and
239
[Get live migration notices from the metadata server](https://docs.cloud.google.com/compute/docs/metadata/getting-live-migration-notice.md.txt):
240
241
```sh
242
# 1. Check a single instance for scheduling policy and upcoming maintenance (Compute Engine API):
243
gcloud compute instances describe {vm_name} --project={project_id} --zone={zone} \
244
--format="yaml(name, scheduling, resourceStatus.upcomingMaintenance)"
245
246
# 2. List upcoming maintenance windows across all instances in the project:
247
gcloud compute instances list --project={project_id} \
248
--format="table(name, zone.basename(), resourceStatus.upcomingMaintenance.type, resourceStatus.upcomingMaintenance.windowStartTime, resourceStatus.upcomingMaintenance.windowEndTime, resourceStatus.upcomingMaintenance.canReschedule, resourceStatus.upcomingMaintenance.maintenanceStatus)"
249
250
# 3. Query from inside the Guest OS via the Metadata Server:
251
curl -s "http://metadata.google.internal/computeMetadata/v1/instance/upcoming-maintenance?alt=json" \
252
-H "Metadata-Flavor: Google"
253
```
254
255
- **API vs. Metadata Server JSON Field Name Difference**:
256
- In `gcloud` / Compute Engine REST (`resourceStatus.upcomingMaintenance`) and
257
Cloud Logging, the maintenance classification field is named **`type`**
258
(`SCHEDULED` or `UNSCHEDULED`), alongside `maintenanceStatus` (`PENDING` or
259
`ONGOING`), `canReschedule` (`true` or `false`), `windowStartTime`,
260
`windowEndTime`, and `latestWindowStartTime`.
261
- When querying `/computeMetadata/v1/instance/upcoming-maintenance?alt=json`
262
inside the guest OS, returns `"NONE"` when no maintenance is scheduled, or a
263
JSON object where the classification property is named **`maintenanceType`**
264
(e.g., `"maintenanceType": "SCHEDULED"`).
265
- **Manually Trigger Host Maintenance Early (`perform-maintenance`)**:
266
- **Preconditions**: Check `canReschedule` and `maintenanceStatus` first. You
267
can run `perform-maintenance` when `canReschedule` is `true` (and
268
`maintenanceStatus` is `PENDING` when an active notice exists, or on
269
supported machine series before a notice is posted to reset the maintenance
270
cycle). If an active notice reports `canReschedule: false` or
271
`maintenanceStatus: ONGOING`, manual triggering is rejected by the API.
272
- **Immediate Impact**: Confirm with the user before running —
273
`perform-maintenance` starts host maintenance **immediately** (terminating
274
and optionally restarting `TERMINATE`-policy instances right away). See
275
[Simulate or trigger a host maintenance event](https://docs.cloud.google.com/compute/docs/instances/trigger-host-maintenance-event.md.txt):
276
277
```sh
278
gcloud compute instances perform-maintenance {vm_name} --project={project_id} --zone={zone}
279
```
280
281
---
282
283
## Actionable Remediation & Hardening Rules
284
285
*Required IAM Role*: Modifying instance scheduling or metadata requires
286
`roles/compute.instanceAdmin.v1`. Always obtain user confirmation before
287
executing mutating commands.
288
289
### Case A: Preventing Downtime During Planned Maintenance (`MIGRATE` Policy)
290
291
If a live-migration-capable VM (such as an `N2`, `N2D`, `C3`, `C3D`, `C4`, or
292
`N4` instance; note that standard `E2` VMs **only** support `MIGRATE` during
293
host maintenance events and disallow `TERMINATE`) logged
294
`compute.instances.terminateOnHostMaintenance` during routine host maintenance,
295
its `scheduling.onHostMaintenance` policy was set to `TERMINATE` instead of
296
`MIGRATE`.
297
298
- **Fix**: Enable Live Migration (`--maintenance-policy=MIGRATE`) and Automatic
299
Restart (`--restart-on-failure`, which sets REST
300
`scheduling.automaticRestart: true`; use `--no-restart-on-failure` to
301
disable). Per
302
[Set VM host maintenance policy](https://docs.cloud.google.com/compute/docs/instances/setting-vm-host-options.md.txt),
303
`gcloud compute instances set-scheduling` updates `onHostMaintenance`,
304
`automaticRestart` (except on running CSEK-encrypted VMs),
305
`hostErrorTimeoutSeconds`, and `localSsdRecoveryTimeout` **in-place on a
306
running VM** without stopping or rebooting it *(note: although the
307
`gcloud compute instances set-scheduling --help` / REST
308
`instances.setScheduling` reference docstring contains a legacy note stating
309
the method requires a stopped `TERMINATED` instance, stopping the VM first is
310
only required when changing `--provisioning-model` / `--preemptible` or
311
updating `automaticRestart` on CSEK-encrypted VMs)*:
312
313
```sh
314
gcloud compute instances set-scheduling {vm_name} \
315
--project={project_id} \
316
--zone={zone} \
317
--maintenance-policy=MIGRATE \
318
--restart-on-failure
319
```
320
321
- **VM Families & Configurations That Do Not Support Live Migration (Always
322
Clarify)**:
323
Whenever recommending `--maintenance-policy=MIGRATE`, explicitly note which VM
324
configurations **cannot** live-migrate and instead require
325
`--maintenance-policy=TERMINATE` paired with `--restart-on-failure` (except
326
Spot/Preemptible VMs, which require `TERMINATE` with
327
`--no-restart-on-failure`), and note that standard **`E2`** VMs only support
328
`MIGRATE`:
329
- **Spot VMs (`provisioningModel: SPOT`) and legacy Preemptible VMs**
330
- **GPU-attached VMs** (`A4X Max`, `A4X`, `A4`, `A3`, `A2`, `G4`, `G2`, and
331
`N1` with attached GPUs; note that `N2` does not support attached GPUs)
332
- **Cloud TPU VMs** and **Bare Metal Instances** (`*-metal`)
333
- **Instances with a Cloud RDMA network interface** (such as `H4D` and `Z4M`
334
with Cloud RDMA)
335
- **`X4` and `X5` memory-optimized instances**
336
- **Large Local SSD Configurations** (`Z3` instances with > 18,000 GiB of
337
Local SSD, and `Z4D` / `Z4M` instances with > 42,000 GiB of Local SSD)
338
339
### Case B: Faster Recovery from Unresponsive Hosts (`--host-error-timeout-seconds`)
340
341
If an application experiences prolonged unresponsiveness before Compute Engine's
342
default host watchdog declares a `hostError`, shorten the detection timeout via
343
`--host-error-timeout-seconds`:
344
345
- **Constraints**: Must be specified in **30-second increments**. Valid range is
346
**`90` to `300` seconds in `gcloud`** (`90` to `330` seconds via Compute
347
Engine REST `instances.setScheduling`). Unsupported on **Sole-Tenant** VMs and
348
**Spot / Preemptible** VMs. Updates dynamically on a running VM (see
349
[Set VM host maintenance policy](https://docs.cloud.google.com/compute/docs/instances/setting-vm-host-options.md.txt)):
350
351
```sh
352
gcloud compute instances set-scheduling {vm_name} --project={project_id} --zone={zone} --host-error-timeout-seconds=90
353
```
354
355
### Case C: Customizing Local SSD Recovery Timeout (`--local-ssd-recovery-timeout`)
356
357
When a `hostError` strikes a VM with attached **Local SSDs**, Compute Engine
358
attempts to recover data from the failed host's NVMe drives while the VM stays
359
offline, logging `compute.instances.hostError` with `operation.first="true"`
360
when recovery begins and `operation.last="true"` when recovery completes or
361
reaches `scheduling.localSsdRecoveryTimeout`.
362
363
- **Valid Range, Defaults & Trade-off**: Valid values are **`0` to `168` hours
364
(up to 7 days)** in **1-hour increments** (see
365
[About host maintenance](https://docs.cloud.google.com/compute/docs/instances/host-maintenance-overview.md.txt)):
366
- **Defaults by Machine Series**:
367
- **`168` hours (7 days)**: `Z4M` bare metal and `Z3` bare metal
368
(`z3-highmem-192-highlssd-metal`) instances
369
- **`6` hours**: `Z4D`, `Z4M`, and `Z3` VMs
370
- **`1` hour**: All other instance types
371
- **Stateless Scratch / Cache Local SSDs**: Set
372
`--local-ssd-recovery-timeout=0` to **skip NVMe data recovery and restart
373
the VM immediately** with blank Local SSDs.
374
- **Stateful Local SSD Data**: Increase `--local-ssd-recovery-timeout` (up to
375
`168` hours, e.g., `--local-ssd-recovery-timeout=24`) to give Compute Engine
376
more time to recover attached Local SSD data before restarting.
377
378
```sh
379
# Fast restart (0 hours wait) for stateless cache/scratch Local SSD workloads:
380
gcloud compute instances set-scheduling {vm_name} --project={project_id} --zone={zone} --local-ssd-recovery-timeout=0
381
```
382
383
### Case D: Handling Spot / Preemptible VM Preemptions (`compute.instances.preempted`)
384
385
When `compute.instances.preempted` appears in Cloud Logging, Compute Engine
386
reclaimed a **Spot VM** or **Preemptible VM** by sending an **ACPI G2 Soft Off**
387
signal.
388
389
1. **Best-Effort Preemption Window**: The ACPI shutdown window provides **up to
390
30 seconds on a best-effort basis** (not guaranteed under severe physical
391
capacity emergencies), so keep checkpointing scripts fast and idempotent and
392
persist critical state continuously. See
393
[Spot VMs](https://docs.cloud.google.com/compute/docs/instances/create-use-spot.md.txt).
394
2. **Attach a `shutdown-script` & Check the Metadata Server**: Query
395
`http://metadata.google.internal/computeMetadata/v1/instance/preempted` with
396
header `Metadata-Flavor: Google` (`TRUE` during preemption vs. `FALSE` on
397
normal shutdown):
398
399
```sh
400
gcloud compute instances add-metadata {vm_name} \
401
--project={project_id} \
402
--zone={zone} \
403
--metadata=shutdown-script='#!/bin/bash
404
PREEMPTED=$(curl -s "http://metadata.google.internal/computeMetadata/v1/instance/preempted" -H "Metadata-Flavor: Google")
405
if [ "$PREEMPTED" = "TRUE" ]; then
406
echo "Spot VM preemption detected; flushing checkpoints..."
407
# Insert fast (<20s), idempotent checkpoint or drain command here
408
fi'
409
```
410
411
3. **Safe Rollback of Test Shutdown Metadata (Always Include)**:
412
```sh
413
gcloud compute instances remove-metadata {vm_name} --project={project_id} --zone={zone} --keys=shutdown-script
414
```
415
416
### Case E: VM Lifecycle Events Dashboard & High-Availability SAP Workloads
417
418
1. **`GCE VM Lifecycle Events Monitoring` Dashboard (`vm-lifecycle-events`
419
Log-Based Metric)**:
420
To populate the pre-generated **`GCE VM Lifecycle Events Monitoring`**
421
dashboard in Cloud Monitoring (**Monitoring > Dashboards > Dashboard List**),
422
create the `vm-lifecycle-events` counter metric using `--config-from-file` so
423
the required `method` `STRING` label extractor on `protoPayload.methodName`
424
is included (`gcloud logging metrics create --log-filter` alone omits label
425
extractors):
426
```yaml
427
# Save as vm-lifecycle-events-metric.yaml:
428
name: vm-lifecycle-events
429
description: "Count of Compute Engine VM lifecycle and host events by method"
430
filter: >-
431
resource.type="gce_instance" AND
432
(log_id("cloudaudit.googleapis.com/activity") OR log_id("cloudaudit.googleapis.com/system_event")) AND
433
operation.first="true"
434
metricDescriptor:
435
metricKind: DELTA
436
valueType: INT64
437
unit: "1"
438
labels:
439
- key: method
440
valueType: STRING
441
description: "Compute Engine lifecycle or host event method"
442
labelExtractors:
443
method: >-
444
REGEXP_EXTRACT(protoPayload.methodName, "(recreateInstance|hostError|automaticRestart|guestTerminate|terminateOnHostMaintenance|preempted|insert|stop|delete|reset|start)")
445
```
446
```sh
447
gcloud logging metrics create vm-lifecycle-events --project={project_id} --config-from-file=vm-lifecycle-events-metric.yaml
448
```
449
2. **SAP Workloads (HANA / NetWeaver)**:
450
If the impacted VM runs **SAP HANA** or **SAP NetWeaver**, verify automatic
451
Pacemaker cluster failover to the secondary node in Cloud Monitoring using
452
the **SAP HANA Availability**
453
(`google_agent_for_sap.agent-for-sap-hana-availability-monitoring`) or **SAP
454
NetWeaver Availability**
455
(`google_agent_for_sap.agent-for-sap-netweaver-availability-monitoring`)
456
dashboards.
457
458
---
459
460
## Verification, Rollback & Cleanup
461
462
1. **Verify Updated Scheduling Policy**:
463
```sh
464
gcloud compute instances describe {vm_name} --project={project_id} --zone={zone} \
465
--format="yaml(scheduling, resourceStatus.upcomingMaintenance)"
466
```
467
2. **Remove Test Shutdown Metadata**:
468
```sh
469
gcloud compute instances remove-metadata {vm_name} --project={project_id} --zone={zone} --keys=shutdown-script
470
```
471
3. **Teardown Temporary Test VMs**: Delete any temporary test VMs when finished
472
(omitting `--quiet` on manual commands so interactive confirmation prevents
473
accidental disk loss):
474
```sh
475
gcloud compute instances delete {vm_name} --project={project_id} --zone={zone} --delete-disks=all
476
```
477
4. **Pricing Reference**: Read-only troubleshooting queries create no billable
478
VM resources (user-defined log-based metrics and Log Analytics queries on
479
linked BigQuery datasets follow standard Cloud Monitoring and BigQuery
480
pricing). Consult [Google Cloud pricing](https://cloud.google.com/pricing)
481
and [Compute Engine pricing](https://cloud.google.com/compute/all-pricing)
482
for current Standard vs. Spot regional rates rather than hardcoded dollar
483
figures.
484

© 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…