Install and manage the Ops Agent by using VM Extension Manager policies
Stay organized with collections
Save and categorize content based on your preferences.
You can install and manage the Ops Agent on a fleet of Compute Engine VMs
globally or within a specific zone by using
VM Extension Manager policies.
For example, you can use these policies to perform tasks like the following:
Fleetwide installation: Install the Ops Agent on the following:
All VMs in one or more zones in your Google Cloud project.
All VMs globally (in your Google Cloud project).
A subset of VMs in a zone, identified by labels.
A subset of VMs across zones in your Google Cloud project, identified
by labels.
Version control:
Keep the Ops Agent updated to the latest version.
Pin the Ops Agent version to a specific release.
Configuration management: Apply a custom configuration to the Ops Agent
on all VMs managed by a policy.
With VM Extension Manager, you create policies that declare which
extensions you want to install on VMs. The Ops Agent is one of the available
extensions. VM Extension Manager policies can manage the
Ops Agent version 2.58.0 or newer, when the Ops Agent has
been installed by using VM Extension Manager. These policies
can't manage versions of the Ops Agent earlier than version
2.58.0, Ops Agent instances installed by using other means,
or any version of the legacy Monitoring agent or
Logging agent.
You can create and manage zonal VM extension policies by using the
Google Cloud console or the Google Cloud CLI, gcloud. You can
create and manage global VM extension policies by using gcloud.
Before you begin
Before starting to using VM Extension Manager extension
policies, do the following:
Before attempting to use VM Extension Manager policies to
manage the Ops Agent, verify that your target operating system is compatible
with both the Ops Agent and VM Extension Manager.
VM Extension Manager supports all operating systems supported
by the Ops Agent, except for SUSE Linux Enterprise Server (SLES) and Ubuntu.
For more information about the operating systems supported by the Ops Agent,
see Operating systems.
If your operating system is supported by both the Ops Agent and
VM Extension Manager, then follow the rest of this document.
Enable the APIs required to use the Ops Agent
To use the Ops Agent to write logs and metrics, you must enable the
Cloud Logging API and Cloud Monitoring API on your Google Cloud project.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM
role (roles/serviceusage.serviceUsageAdmin), which
contains the serviceusage.services.enable permission. Learn how to grant
roles.
To get the permissions that
you need to use the Ops Agent to write logs and metrics,
ask your administrator to grant you the
following IAM roles on your service account:
To get the permissions that
you need to create, view, modify, and delete VM extension policies,
ask your administrator to grant you the
following IAM roles on the project:
These predefined roles contain
the permissions required to create, view, modify, and delete VM extension policies. To see the exact permissions that are
required, expand the Required permissions section:
Required permissions
The following permissions are required to create, view, modify, and delete VM extension policies:
To create extension policies:
compute.vmExtensionPolicies.create
To view extension policies:
compute.vmExtensionPolicies.list
To view details of an extension policy:
compute.vmExtensionPolicies.get
To modify extension policies:
compute.vmExtensionPolicies.update
To delete extension policies:
compute.vmExtensionPolicies.delete
You can create and manage VM extension policies by using the Google Cloud console
or the Google Cloud CLI, gcloud. To use gcloud,
you must first install it by performing the following steps:
The extension policies described in this document use the beta command
group.
If you haven't done so already, install the beta component of the
gcloud CLI by running the following command:
gcloud components install beta
To check if you have the beta component installed, run
the following command:
gcloud components list
If you previously installed the beta component, verify that
have the latest version:
gcloud components update
Uninstall any observability agents
Before creating a VM Extension Manager policy to manage
the Ops Agent on a VM, ensure that there are no instances of the Ops Agent
or the legacy Monitoring agent and Logging agent already on the VM. Running the
Ops Agent and the legacy agents on the same VM can cause ingestion of
duplicate logs or conflicts in metrics ingestion.
If you use an extension policy to install the Ops Agent on a VM where another
observability agent is already installed, then the policy installs the agent, but the
agent fails to run because a conflict is detected.
How you remove existing agents depends on how those agents were installed.
Agents installed by a VM Manager OS Config policy, which includes
the following:
Install the Ops Agent by creating VM extension policies
Create VM extension policies to automatically install and manage the
Ops Agent on a fleet of Compute Engine virtual machines (VMs). By defining
a policy, you can ensure that specific extensions, like the Ops Agent, are
installed and maintained on any VMs that match criteria you specify, such as
VM labels.
Policy conflicts and priorities
VM Extension Manager associates a priorty with each new policy,
with lower numbers indicating higher priorities; the default priority is
1000. A VM can be covered by
multiple policies for an extension like the Ops Agent, but only one policy
for the Ops Agent extension is effective on the VM.
VM Extension Manager uses priorities to resolve
conflicts among policies applied to a VM. For more information about the
resolution process, see Policy priority and conflict
resolution.
Policy rollout plans for global policies
VM Extension Manager global policies use a rollout plan to
determine how a policy is distributed to target VMs. There are two types of
rollout plans:
Predefined rollout plans. There are two predefined rollout plans,
chosen by the value used with the
--rollout-predefined-plan
option for gcloud CLI commands.
Slow rollout, which deploys the Ops Agent gradually across different
zones over a period of time. This rollout plan is recommended.
Specify this rollout plan by using the
--rollout-predefined-plan=slow_rollout option.
Fast rollout, which deploys the Ops Agent to all targeted VMs across all
zones and regions immediately.
Specify this rollout plan by using the
--rollout-predefined-plan=fast_rollout
option.
Custom rollout plans, specified by using the
--rollout-custom-plan
option for gcloud CLI commands.
Create custom rollout plans by adding them to the set of rollout plans
in your Google Cloud project; for more information, see the
Compute Engine API method
rolloutPlans.insert.
To create a policy that installs the latest version of the Ops Agent on
all VMs in a zone or globally, and updates the Ops Agent when a new version
is released, do the following:
If you use the search bar to find this page, then select the result whose
subheading is Compute Engine.
Click + Create.
In the Name field, enter a name for the policy.
Optional: In the Description field, enter a description for the policy.
In the Priority field, specify a priority number to resolve conflicts
between policies. Lower numbers indicate higher priority. The default
value is 1000.
In the Zone list, select the zone where you want to apply this policy.
In the Manage extensions section, click Add extension and do the
following:
From the Extension list, select
Google Cloud's Extension for Ops Agent.
From the Version list, select the version to install.
Use version 2.58.0 or newer.
Click Create.
gcloud
To create a zonal or global policy, you can use the gcloud CLI.
If you use the search bar to find this page, then select the result whose
subheading is Compute Engine.
Click + Create.
In the Name field, enter a name for the policy.
Optional: In the Description field, enter a description for the policy.
In the Priority field, specify a priority number to resolve conflicts
between policies. Lower numbers indicate higher priority. The default
value is 1000.
In the Zone list, select the zone where you want to apply this policy.
In the Extensions section, click Add extension and do the
following:
From the Extension list, select
Google Cloud's Extension for Ops Agent.
Leave the Version field blank.
In the Target VM instances section, select the VMs for the policy. To
select VMs with specific labels, click Add labels and add the
key-value pair.
Click Create.
gcloud
To create a zonal or global policy, you can use the gcloud CLI.
Install the Ops Agent with a custom configuration on all VMs
To create a policy that installs the latest version of the Ops Agent on
all VMs in a zone or globally, and provides custom configuration for the
Ops Agent, do the following:
Console
To create a zonal policy, you can use the Google Cloud console.
In the Google Cloud console, go to the Extension policies page:
If you use the search bar to find this page, then select the result whose
subheading is Compute Engine.
Click + Create.
In the Name field, enter a name for the policy.
Optional: In the Description field, enter a description for the policy.
In the Priority field, specify a priority number to resolve conflicts
between policies. Lower numbers indicate higher priority. The default
value is 1000.
In the Zone list, select the zone where you want to apply this policy.
In the Extensions section, click Add extension and do the
following:
From the Extension list, select
Google Cloud's Extension for Ops Agent.
If you provide a custom configuration for the Ops Agent when creating
or updating an extension policy, then the policy deploys the Ops Agent with
the custom configuration. You don't need to manually restart the agent.
The configuration is stored with the extension policy, so don't include
sensitive data like passwords in the configuration. Because the configuration
is stored with the extension policy, modifying the configuration file does
not change the configuration of the agent. You must update the configuration
stored with the policy by using the appropriate
gcloud command:
When you provide a custom configuration for the Ops Agent,
VM Extension Manager copies the configuration to the location
used by the Ops Agent for user-specified configuration
files on the target VM:
Install the Ops Agent on a subset of zones in a Google Cloud project (global only)
To create a global policy that applies to only a subset of zones in a
Google Cloud project, you must use a custom rollout plan that specifies the
zones in which to apply the policy. For information about creating
custom rollout plans, see
About rollout plans.
To specify a set of zones, use the locationSelector.includedLocations field
when creating the rollout plan.
CUSTOM_PLAN_NAME: The name associated with your custom
rollout plan.
Manage the Ops Agent by updating VM extension policies
To change how a policy manages the Ops Agent, update the policy.
When you update a policy, VM Extension Manager rolls out the changes to
all applicable VMs, typically within one minute. If you modify inclusion labels,
then the Ops Agent might be installed on new VMs or uninstalled from existing
VMs based on whether the VMs match the updated labels.
The following sections show how to manage the Ops Agent to do the following:
If you provide a custom configuration for the Ops Agent when creating
or updating an extension policy, then the policy deploys the Ops Agent with
the custom configuration. You don't need to manually restart the agent.
The configuration is stored with the extension policy, so don't include
sensitive data like passwords in the configuration. Because the configuration
is stored with the extension policy, modifying the configuration file does
not change the configuration of the agent. You must update the configuration
stored with the policy by using the appropriate
gcloud command:
When you provide a custom configuration for the Ops Agent,
VM Extension Manager copies the configuration to the location
used by the Ops Agent for user-specified configuration
files on the target VM:
Extend an existing global policy to include new zones (global only)
When VMs are created in new zones after a global policy has been created and
rolled out, VM Extension Manager does not automatically apply the
policy to the VMs in the new zones. To include the VMs in new zones, you
must restart the global policy rollout.
UUID: A universally unique identifier (UUID) that identifies the
retry request. You can use any UUID generator to create one. For more
information, see
Retry a rollout .
Update a global policy to exclude a set of zones (global only)
To update the zones to which a global policy that excludes some zones in a
Google Cloud project, you must use a new custom rollout plan that specifies the
zones in which to apply the policy. For information about creating
custom rollout plans, see
About rollout plans.
To specify a set of zones, use the locationSelector.includedLocations field
when creating the rollout plan.
NEW_CUSTOM_PLAN_NAME: The name associated with your
updated custom rollout plan.
UUID: A universally unique identifier (UUID) that identifies the
retry request. You can use any UUID generator to create one. For more
information, see
Retry a rollout .
Uninstall the Ops Agent by deleting VM extension policies
To uninstall the Ops Agent, delete the VM extension policy that manages
the agent. If another active, lower-priority policy applies to a VM and
also manages the Ops Agent, then the agent remains installed
on that VM based on the lower-priority policy.
VM Extension Manager removes the Ops Agent from all accessible VMs
within one minute of policy deletion. If a VM is inaccessible, then
VM Extension Manager skips deletion of the agent.
If the VM becomes available again, then VM Extension Manager
removes the agent at that time.
For general information about using the
Google Cloud console and the gcloud CLI to retrieve information
about VM extension policies, see
View extension policies.
When the Ops Agent has been installed on the VM and is collecting logs and
metrics, the agent's status is marked with a green checkmark next to the
Ops Agent label.
To determine the version of the installed agent, hover over the Ops Agent
label on the Compute Engine or Monitoring dashboard.
Verify that the Ops Agent is collecting telemetry
If the Ops Agent has been successfully installed and is running correctly,
then it sends metrics to Cloud Monitoring and logs to Cloud Logging.
Restart an Ops Agent installed by an extension policy
When the Ops Agent is installed and managed by
VM Extension Manager, the Ops Agent isn't managed by the
system-management service of the operating system, that is, systemd on Linux
or the Windows Service Manager on Windows. Therefore, Linux systemctl
commands and Windows *-Service commands don't work with an Ops Agent
installed by an extension policy.
To restart an Ops Agent that was installed by an extension policy, do
one of the following:
Recreate the policy.
Delete the policy. Deleting the policy stops and
uninstalls the Ops Agent.
Create a new policy. The new policy installs the
Ops Agent and starts it.
Use a temporary, higher-priority policy. If the original policy
affects a large number of VMs but you only want to restart the Ops Agent
on a small number, add a label to those VMs and configure the new
policy to filter on the label.
For example, if a policy with priority 1000
failed to start the Ops Agent on a VM, you could add a label like
status=failed to the VM. Then create a new policy
with a higher priority, like 500. For example, a Google Cloud CLI
command might look like the following:
After the new policy successfully installs the Ops Agent, delete
the policy and remove the label from the VMs. The Ops Agent remains
installed on the VM because the original policy is still active.
When a gcloud beta compute zone-vm-extension-policies command fails, the response includes
troubleshooting suggestions. Correct any errors in the command
flags or arguments suggested by the error message.
If you see logs containing a string like Failed to install plugin
"ops-agent-plugin" ..., or the query returns no logs, then the
extension policy failed to install the Ops Agent. For next steps, see
Extension policy fails to install the Ops Agent.
If you see logs containing a string like Successfully installed plugin
"ops-agent_nnnnnnnn", then the extension policy successfully installed the
Ops Agent. For next steps, see
Installed Ops Agent is "not detected".
Extension policy fails to install the Ops Agent
An extension policy might be ineffective if one of the following is true:
The guest agent is not installed on the VM. To diagnose and fix this condition,
do the following:
Verify that the VM is using one of the
operating systems
supported for the Compute Engine guest environment.
The Ops Agent can have a status of "not detected" if one of the following
is true:
There are observability agents installed on the VM already. Existing
agents can cause conflicts and must be uninstalled. For more information,
see Uninstall any observability agents.
You provided a custom configuration to the Ops Agent by creating or
updating an extension policy, but the agent status is "not detected".
The problem might be an error in your custom configuration. Use the
guest agent debug logs to look for configuration errors.
If you see logs containing the string The agent config file is not valid,
then the custom configuration for the Ops Agent you provided when
creating or updating the extension policy is invalid.
To fix this problem, do the following:
Correct the configuration by referring to
Configure the Ops Agent.
For information about the structure of an Ops Agent configuration file.
Update the extension policy with the corrected configuration.
Linux systemctl status and Windows Get-Service commands don't work with the Ops Agent
You run a command like sudo systemctl status google-cloud-ops-agent"*"
but it returns no information.
When the Ops Agent is installed and managed by
VM Extension Manager, the Ops Agent isn't managed by the
system-management service of the operating system, that is, systemd on Linux
or the Windows Service Manager on Windows.
To find the status information for an Ops Agent managed by
VM Extension Manager, see the following:
Linux systemctl restart and Windows Restart-Service commands don't work with the Ops Agent
You run a command like sudo systemctl restart google-cloud-ops-agent
but the Ops Agent isn't restarted.
When the Ops Agent is installed and managed by
VM Extension Manager, the Ops Agent isn't managed by the
system-management service of the operating system, that is, systemd on Linux
or the Windows Service Manager on Windows. Therefore, you can't stop or start the Ops Agent manually,
and commands like the following don't work with the Ops Agent:
To stop or restart an Ops Agent managed by VM Extension Manager,
you must uninstall the agent by deleting the extension policy. For more
information about stopping or restarting the Ops Agent, see
Restart an Ops Agent installed by an extension policy.
Additional troubleshooting information
For more information about troubleshooting the creation and use of
VM Extension Manager policies, see Troubleshoot
VM extensions.
For information about the number of extension policies you can create
in a Google Cloud project, see Quota.
Pricing
For information about costs associated with using
VM Extension Manager, see Pricing.
If you install the Ops Agent, then you might be charged for the metrics,
logs, or traces that the agent sends to your Google Cloud project. For pricing
information, see Google Cloud Observability pricing.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-09 UTC."],[],[]]