Topic 10 of 10
Section 3.4 ends with diagnostics: finding bottlenecks in applications and queries, and telling whether a problem is yours or Google Cloud's with Personalized Service Health and Cloud Hub.
Contents
| Question | Tool |
|---|---|
| Where does a request spend its time across services? | Cloud Trace |
| Which part of the code uses the most CPU or memory? | Cloud Profiler |
| Which exceptions are failing, and since when? | Error Reporting |
| Which SQL query is slow or loading the database? | Query insights (Cloud SQL, Spanner) |
| Is it a Google Cloud incident? | Personalized Service Health |
| How is everything doing overall? | Cloud Hub |
A distributed tracing system that measures end-to-end request latency and pinpoints which dependency causes delays in a microservices architecture (including generative AI applications). It runs on Compute Engine, GKE, App Engine, Cloud Run, and outside Google Cloud.
A statistical, low-overhead profiler that continuously gathers CPU usage and memory allocation from applications in production and attributes it to the source code that generated it.
Aggregates and displays errors from running services in a centralized interface so you can find new or top errors. Errors are sent by writing them to Cloud Logging with the right format or by calling the Error Reporting API. It requires the logs to be stored in log buckets. For Android and iOS apps Google recommends Firebase Crashlytics.
Query insights detects and diagnoses query performance problems: it shows database load per query, lets you identify a problematic query or tag, and examine a trace from a sample query. It traces the source by model, view, controller, route, user, and host. By default it shows completed queries; active queries are shown in real time.
gcloud sql instances patch my-instance --insights-config-query-insights-enabled
| Capability | Enterprise | Enterprise Plus |
|---|---|---|
| Metrics retention | 7 days | 30 days |
| Maximum query length | 4500 bytes | 100 KB |
| Query plans per minute | 20 | 200 |
| Wait events, index advisor, terminate sessions, AI assistance | No | Yes |
The Cloud SQL for PostgreSQL index advisor periodically analyzes your regular queries and recommends new indexes with their CREATE INDEX command, estimated size, and query impact. It requires Enterprise Plus edition with Enterprise Plus query insights; it doesn't work on read replicas. Role to view recommendations: roles/cloudsql.viewer.
In addition, Cloud SQL Enterprise Plus recommenders detect instances that would benefit from near-zero maintenance downtime or data cache.
Detects and diagnoses query and DML performance problems: it checks whether inefficient queries cause high CPU usage and identifies the responsible query or request tag. It works in regional and multi-region configurations, has no additional cost, and keeps data for up to 30 days.
Identifies the Google Cloud service health events relevant to your projects (incidents and their status per product and location). It's the primary channel for incident information about your projects; the public Cloud Service Health dashboard is general.
| Access | What for |
|---|---|
| Service Health dashboard | Active and past incidents for your projects or organization, also on mobile |
| Service Health API | Get events and their details per project or organization |
| Alerts | Log-based notifications: new incidents, updates, or incidents for specific products or locations |
| Logs | Events are logged in Cloud Logging and can be exported |
Organization views aggregate incidents across all projects. Permission to list events: servicehealth.events.list.
A centralized view of operations data for your applications and resources, by project or by App Hub application.
| Page | What it shows |
|---|---|
| Health & troubleshooting | Open Cloud Monitoring alerts, active Google Cloud incidents, and health metrics |
| Deployments | Failed Application Design Center deployments and available updates |
| Security & compliance | Critical and high Security Command Center findings and compliance frameworks |
| Optimization | Total cost and trend, most expensive resources, and expensive ones with low utilization |
| Quotas & reservations | Quotas above 90% usage, forecasted Compute Engine usage, and reservations |
| Maintenance | Upcoming, in-progress, and completed maintenance; some can be rescheduled |
| Support | Open support cases and your support package |
| Situation | Answer | Why |
|---|---|---|
| Find out which microservice adds latency to a request | Cloud Trace | End-to-end latency for each hop. |
| Discover which function in the code uses the most CPU in production | Cloud Profiler | Continuous, low-overhead profiling. |
| See an app's new and most frequent errors, grouped | Error Reporting | Aggregates errors from running services. |
| Find the query that overloads a Cloud SQL for PostgreSQL instance | Query insights | Database load per query, tag, and plan. |
| Get index recommendations for Cloud SQL for PostgreSQL | Index advisor | Requires Enterprise Plus and Enterprise Plus query insights. |
| Know whether a Google Cloud incident affects your projects and get alerts | Personalized Service Health | Dashboard, API, alerts, and event logs. |
| See alerts, incidents, near-exhausted quotas, and maintenance on one page | Cloud Hub | Centralized operations view. |
| Find out whether inefficient queries cause high CPU in Spanner | Spanner query insights | No extra cost; 30 days of data. |
❓ Cloud Trace or Cloud Profiler to see which service delays a request?
Cloud Trace. Profiler measures CPU and memory consumption inside a service's code.
❓ Is Cloud Profiler only for test environments?
No. It's designed for production: its overhead is usually under 0.5%.
❓ Is index advisor available in Cloud SQL Enterprise edition?
No. It requires Enterprise Plus with Enterprise Plus query insights, and it doesn't work on read replicas.
❓ Do you need to instrument Cloud Run to see HTTP request latency in Trace?
Not for the basics: Cloud Run and Cloud Run functions send HTTP request latency automatically.
❓ Does the public Cloud Service Health dashboard tell you which incidents affect your projects?
Not in the same way. Personalized Service Health shows events relevant to your projects and supports alerts.
❓ How long does Cloud Trace keep spans?
30 days in the _Trace bucket.
Did you get this topic?
Test what you just learned
Users notice that checkout in a microservices app on GKE takes 4 seconds. You need to know which of the six services involved in the request causes the delay. What do you use?
Original questions, each with a full explanation.
Start a mock exam