Prepare and test your skills
Prepare and test your skills
A comprehensive monitoring strategy in Google Cloud uses Cloud Monitoring (opens in a new tab) to collect and aggregate metrics, logs, and traces from infrastructure and applications into one observable system. Cloud Monitoring automatically ingests system metrics, events, and metadata from most Google Cloud services and can serve as a backend for open-source tools to provide a single pane of glass. Numeric metric data stored in a project is visualized in charts and dashboards and evaluated by alerting policies that notify operators when criteria are met. The metrics scope of a project controls which time-series data can be charted or monitored, and by default the scope is limited to time-series data stored by that project alone.
Metric collection (opens in a new tab) in Cloud Monitoring combines automatic system telemetry with agents and instrumentation to cover gaps in visibility. Different sources capture different layers, from hypervisor-reported utilization to in-VM operating system details to business-specific application behavior. Choosing the right source depends on where the workload runs and whether the needed signal already exists or must be defined.
| Metric source | What it captures | How it is collected |
|---|---|---|
| System metrics | Service health, such as more than 25 unique metrics per Compute Engine virtual machine (VM) instance | Automatically collected and stored by Cloud Monitoring |
| Ops Agent metrics | CPU, disk, memory, swap, plus third-party telemetry such as Apache, Nginx, MySQL, Redis, MongoDB, and PostgreSQL on Compute Engine | Ops Agent installed on Linux and Windows VMs, with configurable third-party plugins |
| Prometheus metrics | Application and Kubernetes telemetry, including third-party workloads on Google Kubernetes Engine (GKE) | Google Cloud Managed Service for Prometheus, or Ops Agent with Prometheus receiver or OpenTelemetry Protocol (OTLP) receiver |
| User-defined and external metrics | Application-specific performance and failure signals defined by the team | Instrumentation with vendor-neutral OpenTelemetry or the Cloud Monitoring API, plus supported open-source and third-party libraries |
| Log-based metrics | Numeric information derived from logs written to Cloud Logging, such as error counts and total log entries received | Google-defined metrics created automatically, plus user-defined metrics such as counts of 404 Not Found errors |
The project whose scope includes additional projects can chart time-series data stored by those other projects, which enables cross-project aggregation without moving the underlying data. For application code, OpenTelemetry is recommended over vendor-specific APIs because the same instrumentation can collect logs, metrics, and traces and export them to any vendor, including Google Cloud. Custom metrics created through the API or OpenTelemetry capture combined conditions that no single built-in metric describes, such as an aggregated workflow duration or a business key performance indicator (KPI).
Health exposure makes system health observable so traffic can be routed away from unhealthy resources. Health checks typically use a pull model where the checker pulls data from an application endpoint to determine service status. When a load balancer is associated with a group of VM instances, its health check defines how the load balancer communicates with the VMs to evaluate whether particular instances should continue to receive traffic.
Load-balancer health checks also drive autohealing for managed instance groups, where traffic flows from the load balancer to healthy VMs while unhealthy machines are re-created and removed from service. If external traffic is load-balanced through a GKE ingress resource, GKE automatically creates appropriate health checks for the load balancer. Inside the cluster, Kubernetes liveness and readiness probes help the orchestrator decide how to manage pods and requests, so applications on Kubernetes should expose endpoints for those probes. End-to-end monitoring complements these fine-grained checks by testing externally visible behavior the way a user sees it, which reveals whether critical actions complete within thresholds and uncovers errors or latency that lower-level checks might miss.
Proactive validation in Cloud Monitoring uses synthetic monitors to test availability, consistency, and performance of services, web pages, and APIs. An uptime check probes HTTP, HTTPS, and TCP endpoints for responsiveness and generates a notification when an endpoint fails to respond. A broken-link checker crawls a web page and notifies operators when broken links are detected, and both monitor types can be managed through the console, API, Google Cloud CLI, or Terraform.
Key metrics are the small set of descriptive signals that together indicate scaling needs, saturation, or unhealthy services. No single metric usually indicates whether to scale an app or whether a service is unhealthy, so effective strategies combine multiple factors into custom metrics that reflect real workflows. App-level metrics are especially important because they capture aggregated conditions, such as time to execute a query or a sequence of service calls, that built-in infrastructure metrics cannot see.
These four golden signals from the Site Reliability Engineering book guide monitoring of user-facing distributed systems. Tolerance for outliers also shapes metric choice because an average or median can hide wide imbalances across operations or shards. Strategies should therefore evaluate the metric distribution, where the 99th percentile is often more informative than the average for detecting tail latency and uneven load.
Service-level objectives (SLOs) in Cloud Monitoring turn collected metrics into target levels of performance or reliability for a service. Service monitoring defines SLOs based on Cloud Monitoring metrics, and alerting policies on SLOs warn when the service is in danger of violating an objective, such as through burn-rate alerting. Dashboards then track SLOs and KPIs over time so teams can see trends, identify outliers, and correlate metric data with logs and events.
Google Cloud-managed dashboards are created automatically as resources are instantiated or applications are registered with App Hub, showing curated health, log, metric, and open-alert information for applications, services, and workloads. When managed views are insufficient, custom dashboards control exactly what data appears and in what format, and charts built in Metrics Explorer can compare current data to previous data, display outliers and percentiles, and show multiple metrics before being saved to a dashboard. Custom dashboards can display charts and tables of metric data, log data and error groups, alerting-policy charts, alert information, text, and events such as a reboot or crash.
Alerting policies define the metric query and the criteria that trigger notification through channels such as email, Cloud Mobile App, PagerDuty, or Slack. Each notification links to an incident, which is a persistent record storing status, links to logs, a chart of recorded metric data, labels, and duration for troubleshooting. Many Google Cloud integrations provide recommended or pre-configured alerts where operators only specify who should be notified, which reduces setup effort while preserving consistent coverage.
Metric retention in Cloud Monitoring balances short-term investigation against long-term analysis. Cloud Monitoring retains metrics for several weeks to support real-time health checks and investigation of recent problems. Historical records beyond that window support data-driven architecture refinement, identification of bottlenecks and interdependencies after outages, validation of tests, and analysis of scaling during high-traffic promotional events over quarters or years.
Exam tip: Cloud Monitoring retains metrics for several weeks by default, so export metrics for multi-quarter or multi-year analysis rather than relying on built-in retention.
Long-term storage depends on exporting metrics through solutions such as Cloud Monitoring metric export. GKE observability (opens in a new tab) extends the same strategy to clusters and workloads with infrastructure and application views, including Overview, CPU, memory, cAdvisor, kubelet, control plane, Kubernetes events, startup latency, ephemeral and persistent storage, workload state, and GPU, Tensor Processing Unit (TPU), and NVIDIA Data Center GPU Manager (DCGM) utilization. Application performance views show per-second request rate grouped by operation, error rates grouped by operation and response code, 50th and 95th percentile latency by operation, and CPU and memory as a percentage of requested amount. High CPU or memory request utilization, rising container restarts, many unschedulable pods, sustained 100% GPU utilization, or high Cloud Logging and Managed Service for Prometheus ingestion point to over-provisioning, crashes, insufficient resources, bottlenecks, or rising observability cost that can be reduced through filtering and ingestion controls.
Optimize Resource Allocation and Cost Based on Performance Data is the practice of using utilization and performance signals to match resources to actual demand while staying within budget. Performance data flows from workloads to Cloud Monitoring (opens in a new tab) for visibility, to Recommender (opens in a new tab) for rightsizing guidance, and to cost tools for budget control, and decisions then flow back to compute, memory, and storage allocations. Over-provisioning wastes spending on idle capacity, while under-provisioning creates bottlenecks that degrade latency, throughput, and user experience. Continuous tuning across this loop keeps efficiency, performance, and scalability in balance as demand changes.
Right-sizing is the continuous process of adjusting machine types, Pod requests and limits, and storage capacity to match observed usage patterns. Cloud Monitoring provides real-time visibility into CPU utilization, memory usage, network traffic, disk I/O, and application response times, which lets teams track trends and spot inefficiencies. Recommender analyzes that utilization history to produce intelligent suggestions, such as idle VM recommendations, idle resource recommendations, and machine-type recommendations for Compute Engine instances and managed instance groups. Custom metrics extend this loop to application-specific signals, and alerting policies notify administrators when predefined thresholds are met so allocation can be corrected before cost or performance drifts.
Proactive right-sizing depends on correlating utilization with performance rather than cutting resources blindly. Teams compare resource signals against latency, error rates, and throughput to determine whether a workload can move to a less expensive shape without harming user experience. Logs reveal system events, errors, and warnings, while traces show how requests flow through services and where round-trip time accumulates between dependencies. Caching, database indexing and query optimization, and code profiling then reduce the resource footprint that must be provisioned, so the same performance can be delivered with smaller or fewer resources.
Autoscaling dynamically adjusts capacity based on workload fluctuations so applications have resources when needed and release them when demand falls. Autoscaling policies evaluate metrics such as CPU utilization, memory usage, queue depth, request rate, and latency, and the control plane adds or removes capacity only after a threshold or demand signal is met. For sudden peak events, manual scale-up and pre-warming of virtual machines, pre-loaded caches, and serverless components are still recommended because reactive autoscaling may not catch up with the velocity of event traffic. Cloud Load Balancing does not require pre-warming, which differs from backend VMs, caches, and serverless concurrency that can suffer cold starts.
Google Cloud divides autoscaling responsibility by platform, with each platform owning a different scaling unit:
| Platform | Scaling unit | Scaling signal and control |
|---|---|---|
| Compute Engine managed instance groups (MIGs) | Group of VMs managed as a single entity | Policy defines minimum and maximum VMs plus conditions such as adding VMs when CPU exceeds a threshold and removing them when it drops |
| Google Kubernetes Engine (GKE) | Nodes, Pods, and node pools in a cluster | Combined autoscalers adjust infrastructure and workload replicas from Pod demand and usage patterns |
| Cloud Run | Serverless container instances | Built-in autoscaler scales instance count up with incoming traffic and down to reduce cost when traffic falls |
GKE autoscaling combines four cooperating tools that work together to optimize utilization, protect performance, and simplify management:
Exam tip: Choose Horizontal Pod Autoscaler to change replica count for load spikes, Vertical Pod Autoscaler to correct oversized or undersized requests and limits, and manual pre-warming when traffic will arrive faster than autoscaling can react.
Cost-optimization recommendations turn performance and inventory data into specific savings actions without breaking reliability targets. Active Assist (opens in a new tab) generates insights for idle resources, over-provisioned machine types, and cost-related GKE optimization metrics, including detailed GKE cost allocation breakdowns that attribute spend to workloads. Decommissioning unneeded resources, rightsizing over-provisioned instances, migrating self-managed systems to managed services such as GKE, and scheduling low-priority work onto cheaper capacity all reduce waste identified through observability. Deriving daily or weekly demand patterns from monitoring data also enables proactive scale-up before known peaks and scale-down afterward, rather than relying only on reactive thresholds.
Discount and pricing choices depend on workload predictability, duration, and tolerance for interruption:
Pricing models and features change over time, so teams regularly review alternatives such as BigQuery slot commitments for analytics, always-allocated CPUs in Cloud Run for predictable traffic, and networking designs that lower egress and load-balancer data-transfer costs. Cloud Billing and Cost Management tools enforce the budget boundary through budgets, alerts, anomaly detection, and reports that track spending, forecast trends, and flag spikes. Exporting billing data to BigQuery enables custom SQL attribution by label, project, or time period, including unit costs such as cost per inference or per training job.
Cost attribution makes performance-driven decisions accountable by linking every resource to its owner and purpose. Tags and labels categorize resources by project, department, team, environment, model, dataset, or use case, and a consistent labeling policy enforced with automation such as Terraform keeps billing data analyzable. Custom dashboards in Cloud Monitoring and interactive reports in Looker visualize key performance indicators (KPIs) such as utilization, latency, error budgets, and business outcomes, while filtered reports isolate trends by time period or resource type. Regular reviews of tags, dashboards, and reports ensure decisions use current data as architectures, traffic, and prices evolve.
Sustained optimization follows an iterative feedback loop where monitoring informs action and action is validated against business goals:
This loop connects capacity planning inputs — historical CPU, memory, and network patterns, growth projections, quotas for instances and APIs, and disaster recovery (DR) failover headroom — to concrete scaling and purchasing actions. Alert thresholds on KPIs must be selective enough to avoid fatigue yet sensitive enough to trigger prompt correction for accuracy drops, latency breaches, and cost anomalies. Shared cost reports, scheduled summaries, and automated notifications then distribute those insights to the teams that own the workloads and can act on them.
Analyzing and diagnosing performance bottlenecks is the practice of correlating metrics, traces, logs, and profiles to distinguish resource contention, distributed latency, and inefficient code. Google Cloud Observability (opens in a new tab) provides the unified platform for collecting, analyzing, and visualizing those signals from Google Cloud services, applications, and external sources. An advanced diagnosis moves from broad health signals to request-level latency and then to line-level resource cost, so each layer confirms the root cause found by the previous layer.
Correlated observability means the same incident can be viewed as resource metrics, request traces, log events, and code profiles at once. Cloud Monitoring (opens in a new tab) collects availability, performance, latency, and resource-utilization metrics, while traces show the flow of requests through the application and logs record system events, errors, and warnings. Cloud Profiler adds continuous CPU usage and memory-allocation data attributed to source code. Correlating the three prevents misdiagnosis, such as scaling infrastructure when the real problem is a single hot function or a slow downstream call.
The three core application signals divide diagnostic work by question answered:
| Tool | Primary signal | Bottleneck it reveals |
|---|---|---|
| Cloud Monitoring | Resource and response-time metrics over time | Resource contention and saturation |
| Cloud Trace | Distributed request traces and inter-service timing | Latency location across services |
| Cloud Profiler | Statistical CPU and memory attribution to code | Inefficient code paths |
A disciplined diagnosis follows this order across distributed systems:
Cloud Monitoring is the integrated monitoring service that provides real-time visibility into resource utilization, performance characteristics, and overall health of resources. Contention appears when demand exceeds provisioned capacity, so monitor CPU utilization, memory usage, network traffic, disk I/O, and application response times together with business-specific metrics:
Historical analysis separates transient spikes from structural under-provisioning. Exporting and analyzing usage data in BigQuery exposes trends, seasonal variations such as holiday shopping or end-of-quarter sales, planned events such as launches, and growth in users or features. Recommender (opens in a new tab) and Active Assist analyze utilization data into rightsizing insights, including idle virtual machine (VM) identification, managed instance group machine-type recommendations, Google Kubernetes Engine (GKE) cost allocation and optimization metrics, and VMware Engine utilization reviews. Correlate utilization with performance before downgrading resources, so cost reduction does not reintroduce latency, and use custom metrics and alerts on application-relevant thresholds to trigger timely right-sizing.
Exam tip: Cloud Trace shows where time is spent as a request moves between services, while Cloud Profiler shows which code consumes CPU and memory inside a service — use Trace to find the slow service, then Profiler to find the expensive function.
Cloud Trace isolates latency by recording the detailed flow of requests through distributed applications. Each trace breaks a user request into spans for service hops, revealing which downstream call, database query, or API dependency dominates total latency. Round-trip time between services is especially diagnostic because it exposes queuing, network delay, and synchronous dependency chains that aggregate metrics hide. When combined with Cloud Logging, which provides storage, search, and analysis of log events, the same trace identifier links slow spans to errors, warnings, retries, and timeouts in the affected services.
Effective correlation depends on capturing sufficient granularity without retaining excessive observability data. Collect logs, traces, and metrics at levels that support root-cause analysis, then control export and retention cost by avoiding unnecessary high-cardinality or long-retention data. Third-party integrations can extend this foundation with advanced analytics, machine learning-powered anomaly detection, and incident management, but the diagnostic logic remains the same: start from the slow user-facing request, drill into the slowest span, and confirm the failure mode in logs before changing code or capacity.
Cloud Profiler is a statistical, low-overhead profiler that continuously gathers CPU usage and memory-allocation information from production applications. Low overhead matters because profiling runs continuously in production, so profiles reflect real traffic patterns rather than synthetic tests. Profiler attributes resource consumption to application source code, illuminating which functions and call paths consume the most resources under actual load. Supported runtimes include Go, Java, Python, and Node.js, with data sent to the Google Cloud project for centralized analysis.
Profiler analysis centers on comparison over time rather than a single snapshot. A flame graph visualizes the stack where CPU and memory accumulate, focusing tools narrow the view to suspect packages or functions, profile comparison shows before-and-after effects of a code change, and the history view reveals regressions and long-term trends. This makes Profiler decisive when Monitoring shows adequate headroom yet response time remains high: the bottleneck is not contention for CPU or memory, but inefficient execution within the allocated resources, such as repeated database queries, uncached API calls, or allocation-heavy loops.
Performance and load testing confirm whether a suspected bottleneck reproduces under controlled demand. Load testing simulates realistic traffic patterns, while stress testing pushes the system to its limits to expose performance limitations that do not appear at normal volume. Cloud Load Balancing and load-testing services generate real-world traffic shapes, revealing how the system behaves under peak, sustained, and spike conditions. If slowdowns appear only during high traffic, the evidence points toward capacity, autoscaling policy, or contention rather than a constant code defect.
Remediation then maps directly to the diagnosed cause. Caching stores frequently accessed data in memory to reduce repeated database queries or API calls, database optimization uses indexing and query optimization to improve database operation performance, and code profiling guides rewrites of resource-heavy paths identified by Profiler. Capacity actions include adjusting virtual machine or container counts, tuning web server and database configuration, managing quotas for compute, storage, and API requests, and applying autoscaling driven by CPU utilization, memory usage, or queue depth. Regular retesting and continuous monitoring close the loop by verifying that response times improve without over-provisioning.
Choose Horizontal Pod Autoscaler to change replica count for load spikes, Vertical Pod Autoscaler to correct oversized or undersized requests and limits, and manual pre-warming when traffic will arrive faster than autoscaling can react. Cluster Autoscaler adds nodes when Pods cannot schedule for lack of resources and Node Auto-Provisioning automatically creates optimized node pools that match pending workload requirements.
Cloud Trace isolates which service hop adds latency across distributed requests, while Cloud Profiler attributes CPU and memory cost to specific functions inside a service. Use Trace to find the slow service, then Profiler to find the expensive function, with Profiler supporting Go, Java, Python, and Node.js applications.
Cloud Monitoring retains metrics for several weeks by default to support real-time health checks and investigation of recent problems. Export metrics through solutions such as Cloud Monitoring metric export for multi-quarter or multi-year analysis rather than relying on built-in retention.
Your enterprise operates a distributed microservices architecture deployed across Compute Engine virtual machines, Google Kubernetes Engine (GKE) clusters, and Cloud Run services located in multiple Google Cloud projects. You need to implement a centralized observability strategy in Google Cloud Monitoring to collect and aggregate metrics, logs, and distributed traces from both infrastructure and applications to track Service-Level Objectives (SLOs) and application key performance indicators (KPIs) through unified dashboards.
Which strategy aligns with Google Cloud recommended best practices?
Last updated