Topic 8 of 10
Exam section 3.4 asks you to monitor resources: create alerts from metrics, configure custom metrics, install the Ops Agent, use Managed Service for Prometheus, and rely on Gemini Cloud Assist and Active Assist. Logging is covered in the next article.
Contents
Cloud Monitoring collects, stores, and analyzes metrics. Metrics for most Google Cloud services are collected automatically, with nothing to install.
| Metric type | Where it comes from |
|---|---|
| System metrics | Generated by Google Cloud services |
| Agent metrics | The Ops Agent on Compute Engine VMs, including apps such as Apache, Nginx, MongoDB, or PostgreSQL |
| User-defined | Created with the Cloud Monitoring API or libraries such as OpenTelemetry |
| Prometheus | Managed Service for Prometheus, or the Ops Agent with the Prometheus or OTLP receiver |
| Log-based | Numeric information derived from Cloud Logging entries |
Chart and alert queries are built from menus, with PromQL, or with Monitoring filter expressions. Metrics Explorer lets you explore time series quickly and save charts to a dashboard.
By default, a project only sees its own metrics. The metrics scope defines which projects (and AWS accounts) a project can chart and monitor. The project that hosts it is the scoping project, which stores the alerting policies, uptime checks, dashboards, and groups.
Recommended practice
Use a new project, or one without resources, as the scoping project. If it has its own VMs, their metrics mix with those of the monitored projects and you have to filter every chart and alert.
An alerting policy describes when to alert and who to notify. When the data meets the condition, Monitoring creates an alert (a persistent record with status, links to logs, and a chart) and sends notifications. When the condition is no longer met, it closes the alert and notifies you.
Metric-based
Evaluate Monitoring time series.
Log-based
Notify you when a specific message appears in a log entry.
SQL-based
Evaluate the results of a SQL query on logs (in preview).
| Condition | Met when… |
|---|---|
| Metric threshold | The value is above or below a threshold for a retest window |
| Metric absence | A time series has no data for a retest window (maximum 24 hours) |
| Forecasted value | The threshold is predicted to be crossed within the forecast window (1 hour to 7 days) |
| PromQL | A PromQL expression: ratios, several metrics, or dynamic thresholds |
gcloud monitoring snoozes create --display-name="Maintenance Week" \ --criteria-policies="projects/my-project/alertPolicies/12345" \ --start-time="2026-11-01T03:00:00Z" --end-time="2026-11-01T07:00:00Z"
Email, Cloud Mobile App, PagerDuty, SMS, Slack, webhooks, and Pub/Sub. A policy can have several channels.
User-defined (custom)
custom.googleapis.com/ prefix.Log-based
gcloud logging metrics create high_severity_count \ --description="Number of high severity log entries" \ --log-filter="severity > WARNING"
User-defined log-based metrics are calculated from both included and excluded logs; system ones only from included logs.
It's the primary agent for collecting telemetry from Compute Engine VMs: logs, metrics, and traces in a single process. It uses Fluent Bit for logs and the OpenTelemetry Collector for metrics and traces. It's configured with a YAML file.
roles/logging.logWriter and roles/monitoring.metricWriter. The Cloud Logging and Cloud Monitoring APIs must be enabled.curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh sudo bash add-google-cloud-ops-agent-repo.sh --also-install
A managed, multi-cloud service for Prometheus and OpenTelemetry metrics, with no Prometheus servers to run. You query it with PromQL, so existing Grafana dashboards and alerts keep working. It uses the same backend as Cloud Monitoring (Monarch) and keeps data for 24 months at no extra cost.
| Collection mode | When |
|---|---|
| Managed | An operator for Kubernetes (GKE and others). Recommended for all Kubernetes environments |
| Self-deployed | You manage Prometheus as usual, with Google's drop-in replacement binary |
| OpenTelemetry Collector | One agent for metrics, logs, and traces in any environment |
| Ops Agent | Compute Engine VMs |
On Cloud Run you use a Prometheus or OpenTelemetry sidecar.
Public uptime checks send periodic HTTP, HTTPS, or TCP requests from several locations worldwide to a URL, VM, App Engine app, Kubernetes service, Cloud Run revision, or EC2 instance. When you create one you can add an alerting policy. For resources on a private network there are private uptime checks.
roles/monitoring.editor.Google Cloud creates managed dashboards for your resources automatically. Custom dashboards show metric charts, logs, error groups, alerts, text, and events; you can import them from Grafana or install them from templates.
Gemini Cloud Assist
Active Assist
Before applying a recommendation
Google warns that someone in your organization should assess its impact: applying recommendations without review can affect performance or reliability or remove required permissions. If you apply them without human review, have a rollback process in place.
| Situation | Answer | Why |
|---|---|---|
| Notify the team when a VM's CPU is above 80% for 5 minutes | Alerting policy with a metric-threshold condition | Condition + notification channel. |
| See VM memory usage and Apache logs | Install the Ops Agent | Collects system metrics and third-party logs. |
| An operations team must see metrics from 20 projects in one place | Metrics scope in a scoping project with no resources | This is the recommended practice. |
| Count how often "payment failed" appears in logs and alert on it | Log-based metric (counter) plus an alert on it | Only counts entries from when it's created. |
| Alert if a disk will reach 80% within the next 24 hours | Forecasted metric-value condition | Forecast window from 1 hour to 7 days. |
| Silence alerts during a maintenance window | Create a snooze | Policies can't be limited to certain hours. |
| Monitor GKE workloads with PromQL without running Prometheus servers | Managed Service for Prometheus with managed collection | Recommended for Kubernetes; keeps 24 months. |
| Find idle VMs to cut costs | Active Assist recommendations (idle VM recommender) | Cost category. |
❓ Do you need to install anything to see a VM's CPU in Cloud Monitoring?
No. System metrics from Google Cloud services are collected automatically. The Ops Agent adds operating system metrics, such as memory, and application logs.
❓ Does a newly created log-based metric include yesterday's logs?
No. It only counts entries received after it was created.
❓ Can you configure an alerting policy to work only during business hours?
No. It's always evaluated; to pause it for a specific period, create a snooze.
❓ Is a single Slack channel enough for critical alerts?
Not recommended. Slack, PagerDuty, webhooks, and Mobile App share a single point of failure; add email or Pub/Sub.
❓ Where are the alerts and dashboards of a multi-project metrics scope stored?
In the scoping project, which ideally has no resources of its own.
❓ Can you run the Ops Agent alongside the legacy Logging agent?
You shouldn't: it causes duplicate logs or metric conflicts. Uninstall the legacy agents.
Did you get this topic?
Test what you just learned
You want an alert when memory usage on a group of Linux VMs goes above 90%. Metrics Explorer shows no memory metric for those VMs. What do you do first?