Installing the Ops Agent on individual VMs Stay organized with collections Save and categorize content based on your preferences.
The Ops Agent collects logs and metrics on Compute Engine instances, sendingyour logs to Cloud Logging and your metrics to Cloud Monitoring.
Before you begin
To install the agent, ensure that you have the following:
Asupported VM instance in aGoogle Cloud project.
Credentials on the VM instance that authorize communication withCloud Logging and Cloud Monitoring. Compute Engine VM instancesgenerally have the correct credentials by default. If you are running very oldCompute Engine instances or if you created Compute Engineinstances without the default credentials, then you might not have the propercredentials. You must complete theAuthorize the Ops Agent procedures.
Ensure that youenable the services for boththe Cloud Logging API and Cloud Monitoring API.
Ensure your VM doesn't have the legacyCloud Loggingagent orCloud Monitoring agentinstalled on it. This can cause ingestion of duplicate logs or a conflict inmetrics ingestion. In addition, this agent uses new configuration files thatare not compatible with the old agents.
If you have the old agents installed, save thecustom configuration files forthe Cloud Monitoring agentand thecustom configuration files for the Cloud Loggingagent, and complete theuninstall steps for the Cloud Monitoringagent and theuninstall steps forthe Cloud Logging agent.
For users with VMs that don't have access to remote package repositories,refer to theVMs without remote package accesssection for more information.
Install the agent automatically during VM creation
For more information, seeInstall the Ops Agent during VM creation.
Install the agent from the command line
Note: First verify that all conditions are met in theBefore youbegin section.To install the agent using the command line, use the following instructions.
Install the latest version of the agent
To install the latest version of the agent, complete the following steps.
Linux
Open a terminal connection to your VM instance using SSH or a similar tooland ensure you have
sudoaccess.Change to a directory you have write access to, for example your homedirectory.
Download and run the agent-installation script by using the followingcommands:
curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.shsudo bash add-google-cloud-ops-agent-repo.sh --also-installAfter it is installed, the agent is started automatically.
Windows
Connect to your instance using RDP or a similar tool and login to Windows.
Open a PowerShell terminal with administrator privileges by right-clicking thePowerShell icon and selectingRun as Administrator.
Run the following PowerShell commands:
(New-Object Net.WebClient).DownloadFile("https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.ps1", "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1")Invoke-Expression "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1 -AlsoInstall"
Installing a specific version of the agent
To install a specific version of the agent, complete the following steps.
Linux
Open a terminal connection to your VM instance using SSH or a similar tooland ensure you have
sudoaccess.Change to a directory you have write access to, for example your homedirectory.
Download the agent installation script:
curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.shWhen running the
add-google-cloud-ops-agent-repo.shscript, you can also set thefollowing flags:--verbose: Turns on verbose logging during the script execution.--also-install: Installs the agent after adding the agent packagerepository.--version: Sets the agent version for the script to install.For version information, seeList all agent versions.--uninstall: Uninstalls the agent.--remove-repo: Removes the corresponding agent package repository afterinstalling or uninstalling the agent.--dry-run: Triggers only a dry run of the script execution and prints outthe commands that it is supposed to execute.
--uninstall-standalone-logging-agent: Uninstalls the legacyLogging agent (StackdriverLogging).--uninstall-standalone-monitoring-agent: Uninstalls the legacyMonitoring agent (StackdriverMonitoring).
See the script comments for more information and example usage.
Add the agent's package repository and install the agent:
To list the available agent versions, seeList all agent versions.
For production environments, you might want to pin to a major version toavoid installing major versions that might include backward incompatiblechanges. To pin to a major version, run:
sudo bash add-google-cloud-ops-agent-repo.sh --also-install \ --version=MAJOR_VERSION.*.*For example, to pin to the 1.x.x of theagent, run:
sudo bash add-google-cloud-ops-agent-repo.sh --also-install \ --version=1.*.*To install a specific version of the agent, run:
sudo bash add-google-cloud-ops-agent-repo.sh --also-install \ --version=MAJOR_VERSION.MINOR_VERSION.PATCH_VERSION
You can delete the installation script after it runs successfully.
To verify that the agent is working as expected, run:
sudo systemctl status google-cloud-ops-agent"*"Verify that the components "Logging Agent" and "Metrics Agent" are running.
If you have trouble with the installation, refer to theTroubleshooting page.
Windows
Connect to your instance using RDP or a similar tool and login to Windows.
Open a PowerShell terminal with administrator privileges by right-clicking thePowerShell icon and selectingRun as Administrator.
Download the agent installation script:
(New-Object Net.WebClient).DownloadFile("https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.ps1", "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1")When running the
add-google-cloud-ops-agent-repo.ps1script, you can also set thefollowing flags:-Verbose: Turns on verbose logging during the script execution.-AlsoInstall: Installs the agent after adding the agent packagerepository.-Version: Sets the agent version for the script to install.For version information, seeList all agent versions.-Uninstall: Uninstalls the agent.-RemoveRepo: Removes the corresponding agent package repository afterinstalling or uninstalling the agent.-WhatIf: Triggers only a dry run of the script execution and prints outthe commands that it is supposed to execute.-UninstallStandaloneLoggingAgent: Uninstalls the legacyLogging agent (StackdriverLogging).-UninstallStandaloneMonitoringAgent: Uninstalls the legacyMonitoring agent (StackdriverMonitoring).
See the script comments for more information and example usage.
Add the agent's package repository and install the agent:
To list the available agent versions, seeList all agent versions.
For production environments, you might want to pin to a major version toavoid installing major versions that might include backward incompatiblechanges. To pin to a major version, run:
Invoke-Expression "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1 -AlsoInstall -VersionMAJOR_VERSION.*.*"For example, to pin to the 1.x.x of the agent, run:
Invoke-Expression "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1 -AlsoInstall -Version 1.*.*"To install a specific version of the agent, run:
Invoke-Expression "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1 -AlsoInstall -Versionversion-number"For example:
Invoke-Expression "${env:UserProfile}\add-google-cloud-ops-agent-repo.ps1 -AlsoInstall -Version 1.0.1"
You can delete the installation script after it runs successfully.
To verify that the agent is working as expected, run:
Get-Service google-cloud-ops-agentThe status of the agent should be
Running.
If you have trouble with the installation, refer to theTroubleshooting page.
Install the agent by using the Google Cloud console
Note: First verify that all conditions are met in theBefore youbegin section.You can install the Ops Agent on one or more Compute Engine VMs by using theGoogle Cloud console from the Cloud Monitoring or Compute Engine pages.
Cloud Monitoring
In the Google Cloud console, go to theVM Instances page:
If you use the search bar to find this page, then select the result whose subheading isMonitoring.
TheList view on theInventory tab on the dashboard lists all VMs andincludes a status column for your agent, as shown in the following screenshot:

TheAgent column reports the following values:
Not detected: Either you don't have an agent installed or it isnot running. If you aren't sure if you've installed an agent, then youcanquery for the installed version. If you've installedthe agent, then you canrestart the agent.If you've installed and started the Ops Agent but the status remainsNot detected, then the agent might not have started correctly oris unable to send metrics.
To troubleshoot start-up problems, seeAgent is installed but notrunning.To troubleshoot metric-ingestion problems, seeTroubleshoot dataingestion. The generalagent-diagnostics scriptandhealth checksmight also be helpful.
Ops Agent: You are running the Ops Agent.If you don't see a green checkmark beside the entry, then there is anagent upgrade available, based on the detected operating system of your VM.
When you hover over the Ops Agent indicator in the table, you see informationabout the version of the Ops Agent. If you are running an older version, youalso see a recommendation to upgrade your agent.
Pending: The Ops Agent is being installed or upgraded.
If the agent installation remainsPending for more than 10 minutes,then there might be a problem in applying the Ops Agent OS policy orstarting the agent. For troubleshootinginformation, seeAgent diagnostics tool for automatic installation policies.
Agent installation failed: Installation of the Ops Agent failed.For troubleshooting information, seeAgentfails toinstall.
Not Collecting Telemetry: Installation of the Ops Agent succeeded, butthe agent isn't yet sending telemetry.
It usually takes about 10 minutes fortelemetry to flow from a new agent. You can refresh the page to update thestatus. If this status persists for longer than 10 minutes, it mightindicate a problem with the ingestion of the telemetry. For more information,seeAgent is installed but notrunning.
Legacy Agent: You are running the legacy Monitoring or theLogging agent.SeeMigrating from the legacy agents to theOps Agentfor information on transitioning to the Ops Agent.
Not applicable: This VM is not a supported platform for running the agent.
VM Stopped: The VM is not running, so the agent's status is not known.
You can install the Ops Agent by doing the following:
- Select the VM instances on which you want to install agents.
- Click theInstall/Update Ops Agent option on theInstances table.
You can also install or update the Ops Agent fromtheVM Details page for a specific VM.
When possible, the agent is installed by using an Ops Agent OS policy.For more information, seeManage VMs covered by the Ops Agent OS policy.Ops Agent OS policies aren't supported on all versions of all operatingsystems. In this case, clickingInstall/Update Ops Agent providesa series of commands to run in Cloud Shell.
The Ops Agent collects both metrics and logs by default. You can changethis default behavior byconfiguring the Ops Agent.
Compute Engine
In the Google Cloud console, go to theVM instances page:
If you use the search bar to find this page, then select the result whose subheading isCompute Engine.
Click the name of the VM on which you want to install the agent.
Click theObservability tab.
ClickInstall Ops Agent.
When possible, the agent is installed by using an Ops Agent OS policy.For more information, seeManage VMs covered by the Ops Agent OS policy.Ops Agent OS policies aren't supported on all versions of all operatingsystems. In this case, clickingInstall/Update Ops Agent providesa series of commands to run in Cloud Shell.
The Ops Agent collects both metrics and logs by default. You can changethis default behavior byconfiguring the Ops Agent.
If the agent installation remainsPending for more than 10 minutes,then there might be a problem in applying the Ops Agent OS policy orstarting the agent. For troubleshootinginformation, seeAgent diagnostics tool for automatic installation policies.
Verify that the Ops Agent is running
To verify that the Ops Agent is running, you can use either of the following:
VM Instances dashboard:This dashboard lets you view the agent installation status across your VM fleet.However, the status might be inaccurate if the VM lacks necessary access scopesor if the associated service account has insufficient IAM roles.
gcpdiag:gcpdiag provides more reliable and robust information aboutagent status than theVM Instances dashboard,verifying both agent installation and transmission of telemetry from the VM.Using gcpdiag has someprerequisites,it provides a better way to monitor agent status.
UseVM Instances dashboard
In the Google Cloud console, go to theVM Instances page:
If you use the search bar to find this page, then select the result whose subheading isMonitoring.
TheList view on theInventory tab on the dashboard lists all VMs andincludes a status column for your agent.
TheAgent column reports the following values:
Not detected: Either you don't have an agent installed or it isnot running. If you aren't sure if you've installed an agent, then youcanquery for the installed version. If you've installedthe agent, then you canrestart the agent.If you've installed and started the Ops Agent but the status remainsNot detected, then the agent might not have started correctly oris unable to send metrics.
To troubleshoot start-up problems, seeAgent is installed but notrunning.To troubleshoot metric-ingestion problems, seeTroubleshoot dataingestion. The generalagent-diagnostics scriptandhealth checksmight also be helpful.
Ops Agent: You are running the Ops Agent.If you don't see a green checkmark beside the entry, then there is anagent upgrade available, based on the detected operating system of your VM.
When you hover over the Ops Agent indicator in the table, you see informationabout the version of the Ops Agent. If you are running an older version, youalso see a recommendation to upgrade your agent.
Pending: The Ops Agent is being installed or upgraded.
If the agent installation remainsPending for more than 10 minutes,then there might be a problem in applying the Ops Agent OS policy orstarting the agent. For troubleshootinginformation, seeAgent diagnostics tool for automatic installation policies.
Agent installation failed: Installation of the Ops Agent failed.For troubleshooting information, seeAgentfails toinstall.
Not Collecting Telemetry: Installation of the Ops Agent succeeded, butthe agent isn't yet sending telemetry.
It usually takes about 10 minutes fortelemetry to flow from a new agent. You can refresh the page to update thestatus. If this status persists for longer than 10 minutes, it mightindicate a problem with the ingestion of the telemetry. For more information,seeAgent is installed but notrunning.
Legacy Agent: You are running the legacy Monitoring or theLogging agent.SeeMigrating from the legacy agents to theOps Agentfor information on transitioning to the Ops Agent.
Not applicable: This VM is not a supported platform for running the agent.
VM Stopped: The VM is not running, so the agent's status is not known.
Use gcpdiag
For information about using gcpdiag, seeVerify agent status by using gcpdiag.
Optional tasks
This section describes how to perform common maintenance tasks.
Configure an HTTP proxy
If you use an HTTP proxy for proxying requests to the Logging andMonitoring APIs, do the following:
Linux
Edit the following configuration file (create the file if it doesn't alreadyexist):
/etc/systemd/system.confAdd the following to the file:
DefaultEnvironment="HTTP_PROXY=http://proxy-ip:proxy-port" "HTTPS_PROXY=http://proxy-ip:proxy-port" "NO_PROXY=http://metadata.google.internal" # Skip proxy for the local Metadata Server.Reload the environment variables:
sudosystemctldaemon-reloadRestart the agent by running the following command on your VM instance:
sudo systemctl restart google-cloud-ops-agent"*"
Windows
If you use an HTTP proxy, run the following command from anadministrator command prompt. This sets the
HTTP_PROXYandHTTPS_PROXYenvironment variables so that the agent can send data using outbound HTTPS:setx HTTP_PROXY http://proxy-ip:proxy-port /msetx HTTPS_PROXY http://proxy-ip:proxy-port /msetx no_proxy "metadata.google.internal,169.254.169.254" /m
Determine the agent version
To determine the version of the Ops Agent on your system,run the following commands on your VM instance:
Google Cloud console
To see the version of your Ops Agent on a VM:
Locate the entry for the VM in theInstances table in theMonitoringVM Instances page. For navigation information,seeInstall the agent by using the Google Cloud console.
Hover over theOps Agent indicator in the table entry.
CENTOS / RHEL
Run the following command on Red Hat or CentOS Linux:
rpm --query --queryformat '%{NAME} %{VERSION} %{RELEASE} %{ARCH}\n' google-cloud-ops-agentDEBIAN / UBUNTU
Run the following command on Debian or Ubuntu:
dpkg-query--show--showformat'${Package}${Version}${Architecture}${Status}\n'google-cloud-ops-agentSLES / SUSE
Run the following command on SUSE:
rpm --query --queryformat '%{NAME} %{VERSION} %{RELEASE} %{ARCH}\n' google-cloud-ops-agentWINDOWS
Run the following command on Windows:
googet installed google-cloud-ops-agentRestart the agent
You must restart the Ops Agent to pick up changes inconfiguration files. To restart the agent, use the following instructions.
LINUX
Run the following command on your instance:
sudo systemctl restart google-cloud-ops-agentWindows
Connect to your instance using RDP or a similar tool and login to Windows.
Open a PowerShell terminal with administrator privileges by right-clicking thePowerShell icon and selectingRun as Administrator.
Run the following PowerShell command:
Restart-Service google-cloud-ops-agent -ForceUpgrade the agent
To upgrade the Ops Agent to the latest release, use thefollowing instructions:
Note: If you upgraded your instance's Linux operating system to a new majorrelease, then you should firstremove the agent and thenre-install it using the procedures on this page, instead ofcompleting these upgrade procedures.Google Cloud console
You can upgrade the Ops Agent by using Cloud Monitoring installationinstructions. For more information, seeInstall the agent by using theGoogle Cloud console.
Linux
To upgrade the agent to the latest version, run the following command:
sudo bash add-google-cloud-ops-agent-repo.sh --also-installTo upgrade the agent to the latest point release of a specific major version,run the following command:
sudo bash add-google-cloud-ops-agent-repo.sh --also-install \ --version=MAJOR_VERSION.*.*Windows
To upgrade to the latest agent release:
Connect to your instance using RDP or a similar tool and login to Windows.
Open a PowerShell terminal with administrator privileges by right-clicking thePowerShell icon and selectingRun as Administrator.
Note: If you're upgrading your agent from a version earlier than 2.0.3 toversion 2.0.3 or later, the upgrade removes the old config file. If youcustomized your agent configuration, be sure to save a backup of yourconfiguration file before upgrading, and then to apply the necessarychanges to the configuration file after the upgrade.Copy-Item -Path "C:\Program Files\Google\Cloud Operations\Ops Agent\config\config.yaml" -Destination "C:\Program Files\Google\Cloud Operations\Ops Agent\config\config.bak"Run the following PowerShell commands to remove your installed agent and to run theinstallation command:
googet -noconfirm remove google-cloud-ops-agentgooget -noconfirm install google-cloud-ops-agent
List all agent versions
To list the available versions of the agent, run the following command:
CENTOS / RHEL
List the available versions of the agent:
sudo yum list --showduplicates google-cloud-ops-agentDEBIAN / UBUNTU
List the available versions of the agent:
sudo apt-cache madison google-cloud-ops-agentSLES / SUSE
List the available versions of the agent:
sudo zypper search -s google-cloud-ops-agentWINDOWS
List the available versions of the agent:
googet available google-cloud-ops-agentUninstall the agent
To remove the Ops Agent and its configuration files, use thefollowing instructions.
Note: If the Ops Agent was installed during VM creation, seeManage VMs covered by Ops Agent OS policy.After you uninstall the agent, the Google Cloud console might take up to onehour to report this change.
Linux
Run the following command:
sudo bash add-google-cloud-ops-agent-repo.sh --uninstallOptionally, to remove the repository in addition to uninstalling the agent,append--remove-repo to the previous command.
Windows
To uninstall the Ops Agent, follow the following steps:
Connect to your instance using RDP or a similar tool and login to Windows.
Open a PowerShell terminal with administrator privileges by right-clicking thePowerShell icon and selectingRun as Administrator.
Run the following PowerShell command:
googet -noconfirm remove google-cloud-ops-agent
VMs without remote package access
Installing the Ops Agentrequires access toremote package repositories, for both the agent package and (on Linux) itsdependencies.
If you are usingVPC-SC or a private network,the network configuration might also affect your ability to install agentdependencies from upstream repositories. The agent packages themselves areaccessible by usingPrivate GoogleAccess. This can be configuredfollowingEnable Private GoogleAccess.
If your VM host's security policy denies access to remote package repositories,we recommend creating acustom VMimage with theagent pre-installed and disabling package management in that image.
What's next
Learn about whatlogs the agent sends to Cloud Logging using itsdefault configuration.
For information on viewing your logs, seeUsing theLogs Explorer.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.