1---2name: cloud-monitoring3description: Cloud Monitoring4---56# Cloud Monitoring78## When to Use9- Setting up observability for GCP services10- Designing SLO/SLI framework and error budgets11- Troubleshooting production issues with logs and traces12- Preparing for GCP Professional Cloud DevOps Engineer exam1314## Core Jobs1516### 1. Observability Stack17| Tool | Purpose |18|------|---------|19| **Cloud Monitoring** | Metrics, dashboards, alerting, uptime checks |20| **Cloud Logging** | Log ingestion, storage, search, routing |21| **Error Reporting** | Auto-groups errors from logs; shows frequency/trend |22| **Cloud Trace** | Distributed tracing; latency analysis across services |23| **Cloud Profiler** | CPU and memory profiling for production code |2425### 2. SLO/SLI Design26- **SLI** — what you measure (e.g., % of requests < 200ms)27- **SLO** — target for the SLI (e.g., 99.9% of requests < 200ms)28- **Error budget** — allowed failures = 1 - SLO (e.g., 0.1% = 43.8 min/month)29- Create SLOs in Cloud Monitoring with time-series data30- Alert on **error budget burn rate** (not raw error rate)3132### 3. Alerting Policies33- **Condition** — metric threshold, absence, or rate of change34- **Notification channels** — email, PagerDuty, Slack, Pub/Sub, Cloud Functions35- **Alert duration** — condition must be true for N minutes before firing36- Avoid alert fatigue: alert on symptoms (slow SLO burn) not causes (high CPU)3738### 4. Log-Based Metrics39- Create custom metrics from log entries matching a filter40- Counter metric: count occurrences of matching log entries41- Distribution metric: extract numeric value from log field (e.g., latency)42- Use for: custom application metrics without SDK instrumentation4344### 5. Uptime Checks45- HTTP/HTTPS/TCP checks from multiple global locations46- Alert if check fails from N locations47- Use for: external SLA monitoring, health check dashboards4849## Key Concepts50- **Workspace** — Cloud Monitoring scope; can monitor multiple projects51- **Log sink** — route logs to BigQuery/GCS/Pub/Sub for long-term storage/analysis52- **Log exclusions** — reduce logging costs by excluding verbose/low-value logs53- **Structured logging** — JSON logs; query specific fields in Log Explorer5455## Checklist56- [ ] SLO defined for each user-facing service?57- [ ] Alerts on error budget burn rate (not raw metrics)?58- [ ] Log-based metrics for custom application events?59- [ ] Uptime checks configured for external endpoints?60- [ ] Log sinks to BigQuery for audit/compliance logs?61- [ ] Traces enabled for all services in a request path?6263## Output Format64- 🔴 **Critical** — no alerting on user-facing SLOs, no structured logging (hard to query)65- 🟡 **Warning** — alerts on CPU/memory (causes) instead of latency/errors (symptoms)66- 🟢 **Suggestion** — error budget burn rate alerts, Cloud Profiler for production optimization6768## Exam Tips69- SLI = metric; SLO = target; Error budget = 1 - SLO (allowed downtime)70- Alert on **burn rate** (how fast error budget is consumed) not raw error rate71- Log-based metrics = create Cloud Monitoring metrics from log entries (no SDK needed)72- Cloud Trace = distributed tracing; find slow span in a microservice call chain73- Error Reporting auto-detects exceptions from logs (no explicit integration usually needed)74- LOG_ID filter = filter specific audit log types in Cloud Logging