Prepare and test your skills

Prepare and test your skills

Deploying and managing the Ops Agent (opens in a new tab) across compute environments means installing, verifying, and maintaining one agent that collects telemetry from virtual machines (VMs). The Ops Agent runs on Compute Engine instances and Bare Metal Solution servers and combines logs, metrics, and traces in a single process. Data flows from the Ops Agent on each VM to Cloud Logging (opens in a new tab) for logs and to Cloud Monitoring (opens in a new tab) for metrics. The Ops Agent uses Fluent Bit for high-throughput logging and the OpenTelemetry Collector for metrics and traces.
What the Ops Agent collects is system logs and system metrics by default with no extra configuration. Log data flows from the VM where the Ops Agent runs to Cloud Logging, and metric data flows from the same VM to Cloud Monitoring. The Ops Agent replaces the legacy Logging agent and Monitoring agent, which use incompatible configuration files. The Ops Agent and a legacy agent must not run on the same VM because that causes duplicate logs and conflicting metrics.
Compute Engine VM runs Ops Agent with Fluent Bit sending logs to Cloud Logging and OpenTelemetry Collector sending metrics and traces to Cloud Monitoring.
Prerequisites for installation ensure the VM can authenticate to Google Cloud and reach the observability services. The VM must run a supported Linux or Windows operating system on Compute Engine, and its service account must be able to write telemetry. By default this is the Compute Engine service account with Logs Writer (roles/logging.logWriter) and Monitoring Metric Writer (roles/monitoring.metricWriter). The project must have the Cloud Logging API and Cloud Monitoring API enabled, legacy agents must be removed, and VMs without access to remote package repositories need a separate offline installation path.
Automatic installation during VM creation uses VM Manager and OS Config to attach an OS policy that installs the Ops Agent. Creating the VM this way requires Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1) plus OSPolicyAssignment Editor (roles/osconfig.osPolicyAssignmentEditor) to create the OS policy assignment. The ordered workflow in the Google Cloud console for a Compute Engine (opens in a new tab) VM is:
Command-line installation on individual VMs adds the Google package repository to the VM and installs the Ops Agent package. The agent starts automatically after installation, and for production the install should pin to a major version such as 2.*.* or 1.*.* to avoid an automatic upgrade to a breaking major version. On Linux, connect over SSH with sudo access, then download and run the setup script:
sudo access.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, adding --version=MAJOR_VERSION.*.* when pinning is needed.On Windows, connect over RDP, open PowerShell as Administrator, then download and run the setup script:
add-google-cloud-ops-agent-repo.ps1 from https://dl.google.com/cloudagents/.-AlsoInstall, adding -Version MAJOR_VERSION.*.* when pinning is needed.Fleet installation with automated policies manages the Ops Agent across new and existing VMs from one OS Config agent policy. With one policy an administrator can govern a fleet of Linux VMs, ensuring installation and optional auto-upgrade without touching each machine. The same automation can be started from the console, the gcloud CLI, or another automation tool for individual VM installation (opens in a new tab) or for a fleet. From the Monitoring VM Instances inventory list, select one or more VMs and choose Install/Update Ops Agent, or open a single VM details page and choose Install Ops Agent from the Observability tab. When the operating system version does not support an OS policy, the console instead provides commands to run in Cloud Shell.
Exam tip: Do not run the Ops Agent on a VM that still has a legacy Logging or Monitoring agent installed — remove the legacy agents first to avoid duplicate logs and metric conflicts.
Verifying agent health confirms that telemetry flows from the VM to Cloud Logging and Cloud Monitoring. On Linux, sudo systemctl status google-cloud-ops-agent"*" should show both the Logging Agent and Metrics Agent running. On Windows, Get-Service google-cloud-ops-agent should show a status of Running. The Monitoring VM Instances dashboard also shows an Agent column for each VM:
The upgrade, restart, and uninstall lifecycle keeps the Ops Agent current and recoverable. The installation scripts support flags to list all versions, install a specific version, upgrade to a newer version, restart the service, or uninstall the agent and optionally remove its package repository. Fleet policies can enable auto-upgrade so new and existing VMs stay on the approved version without manual updates on each machine. Lifecycle order matters: install the correct version first, then restart to apply configuration, then verify health, and only uninstall when replacing or removing collection.
Configuring the Ops Agent (opens in a new tab) for monitoring and logging means editing one unified YAML configuration that controls both signals. The Ops Agent collects both metrics and logs by default, and that default behavior can be changed through configuration. Because one agent and one configuration control both signals, operators avoid managing separate logging and monitoring agents with incompatible files. The Ops Agent sends logs to Cloud Logging with Fluent Bit and sends metrics and traces with the OpenTelemetry Collector.
The unified configuration model is a single YAML-based configuration with a single download and installation process. Both metrics and logs are enabled by default, so basic system health begins flowing once the agent runs with valid credentials. Operators change the default only when they need extra sources, different processing, or workload-specific tuning. This single-agent model is what replaces the legacy approach of two agents and two file formats.
The log collection pipeline moves log data from receivers through processors to Cloud Logging. Data flows from the log source to Fluent Bit inside the Ops Agent, then from Fluent Bit to the Cloud Logging API. Standard system logs are collected with no configuration, while other sources and processing require configuration changes. Log receivers supported by the Ops Agent include:
/var/log/syslog and /var/log/messages for Linux and Windows Event LogFlexible log processing supported by the Ops Agent includes:
The metric and trace collection pipeline uses the OpenTelemetry Collector to collect system state on the VM and send it to the Cloud Monitoring API. System metrics are collected with no configuration, so CPU, memory, disk, network, and process activity begin flowing once the agent runs and has credentials. Trace collection flows from an instrumented application through the Ops Agent to observability backends when the agent is configured to collect OpenTelemetry Protocol (OTLP) traces. Additional metric sources collected by the Ops Agent include:
Compatibility, performance, and workload requirements define what the VM, network, and credentials must provide on both sides of the trust boundary. The VM must run a supported Linux or Windows distribution, and the Compute Engine service account must hold Logs Writer (roles/logging.logWriter) and Monitoring Metric Writer (roles/monitoring.metricWriter) to write to Cloud Logging (opens in a new tab) and Cloud Monitoring (opens in a new tab). Both the Cloud Logging API and the Cloud Monitoring API must be enabled, and legacy agents must be removed before the Ops Agent starts. Running the Ops Agent depends on outbound access from the VM to Google Cloud, while local ports must remain free inside the VM. The agent requires access to oauth2.googleapis.com for tokens, monitoring.googleapis.com for metrics, and logging.googleapis.com for logs, plus packages.cloud.google.com and dl.google.com during installation. The agent also depends on TCP ports 20201 and 20202 for inter-process communication inside the VM, and those ports do not need to be open externally. Operators manage performance by keeping default system collection for basic health, adding file paths or third-party integrations for specific applications, and configuring proxy settings (opens in a new tab) where direct outbound access is restricted, because Fluent Bit provides high-throughput logging that uses multi-core architecture with efficient memory and CPU management compared with the legacy Logging Agent.
Exam tip: The Ops Agent collects both logs and metrics by default; do not leave a legacy Logging or Monitoring agent installed, because it causes duplicate logs or conflicting metrics ingestion.
Understanding Ops Agent architecture and capabilities means knowing how one agent collects telemetry on a VM and delivers it to Google Cloud observability services. The Ops Agent is the unified agent that collects monitoring and logging data from VM instances. When the Ops Agent is installed on Compute Engine VMs, metric data flows from the agent on each VM to Cloud Monitoring, and log data flows from the agent to Cloud Logging. This single-agent design replaces the older approach of running separate agents for metrics and logs.
Core capabilities and cloud integration describe what the Ops Agent collects and where that data is used. The Ops Agent collects system metrics, third-party application metrics, and logs from the VM where it runs. System coverage includes cpu, memory, disk, network, interface, processes, swap, and gpu, while application coverage includes widely used software such as Apache Web Server, nginx, MySQL, PostgreSQL, MongoDB, and Redis. The agent transmits data for its supported metric types to Cloud Monitoring, where the metrics can be charted, alerted on, and analyzed. Log collection is validated in Cloud Logging in the Google Cloud console, for example by running a filtering query to confirm that forwarded logs such as gcsfuse trace logs have arrived.
Differences from legacy agents come from the fact that one Ops Agent installation handles both monitoring and logging functions. The legacy Monitoring agent (opens in a new tab) and legacy Logging agent are separate agents that collect similar system and application metrics, but they use different metric lists and different installation paths. You must install the Ops Agent to collect the metric types defined for the Ops Agent, and legacy metric lists are documented separately. Because the metric types differ, the agent installed on the VM determines which metric types are available in Cloud Monitoring.
Exam tip: The Ops Agent and the legacy Monitoring agent collect similar but not identical metrics, so the agent installed on the VM determines which metric types are available in Cloud Monitoring.
The installation and configuration workflow covers fleet-wide installation, user configuration, restart, and validation in Cloud Monitoring and Cloud Logging. Fleet installation can use policy-based automation or third-party configuration tools, while single VMs can be installed manually:
| Installation method | Tools | Scope |
|---|---|---|
| Agent policies | Google Cloud CLI or Terraform | Install and manage agents across a fleet of VMs |
| Automation tools | Ansible role, Chef cookbook, or Puppet module | Install and configure agents across a fleet of Compute Engine VMs |
| Individual installation | Manual install commands | Install the agent on individual VMs |
The automation-tools row depends on fleet installation with automation tools (opens in a new tab), while the agent-policies row depends on policy-based fleet installation (opens in a new tab). After installation, configuration changes follow an ordered workflow:
sudo systemctl restart google-cloud-ops-agent so the Ops Agent on the VM picks up the new configuration.fuse_debug query, to confirm that trace logs were forwarded from the VM to Cloud Logging.The Ops Agent collects system logs and system metrics by default with no extra configuration. Log data flows from the virtual machine where the Ops Agent runs to Cloud Logging and metric data flows from the same virtual machine to Cloud Monitoring. The Ops Agent uses Fluent Bit for high-throughput logging and the OpenTelemetry Collector for metrics and traces.
No, the Ops Agent and a legacy Logging agent or legacy Monitoring agent must not run on the same virtual machine. Running them together causes duplicate logs and conflicting metrics because the Ops Agent replaces the legacy agents and uses incompatible configuration files. Legacy agents must be removed before the Ops Agent starts.
The Compute Engine service account on the virtual machine must be able to write telemetry, by default with Logs Writer (roles/logging.logWriter) and Monitoring Metric Writer (roles/monitoring.metricWriter). The project must have the Cloud Logging API and the Cloud Monitoring API enabled. The virtual machine also requires outbound access to oauth2.googleapis.com for tokens, monitoring.googleapis.com for metrics, and logging.googleapis.com for logs, plus local TCP ports 20201 and 20202 for internal communication.
An administrator manages several Linux Compute Engine instances running latency-sensitive workloads. The Google Cloud Ops Agent is installed across all instances and collects host system metrics (such as CPU, disk, and memory) at the default interval of 60 seconds. To support granular performance troubleshooting, the administrator needs to increase the sampling rate so that host metrics are collected every 30 seconds.
What should the administrator do to implement this change?
Last updated