Select the tab for how you plan to use the samples on this page:
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
After installing the Google Cloud CLI, initialize it by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
After installing the Google Cloud CLI, initialize it by running the following command:
gcloudinit
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
To get the permissions that you need to create an instance for Ops Agent monitoring and logging, ask your administrator to grant you the following IAM roles on the project:
roles/compute.instanceAdmin.v1
)roles/osconfig.osPolicyAssignmentEditor
) For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
You can create an instance that's configured for Ops Agent monitoring and logging only by using the Google Cloud console. This section briefly describes how to install the Ops Agent while creating an instance. For more information, also see Install Ops Agent during instance creation.
In the Google Cloud console, go to the Create an instance page.
If prompted, select your project and click Continue.
The Create an instance page appears and displays the Machine configuration pane.
In the navigation pane, click Observability. The Observability pane appears.
In the Ops Agent section, select the Install the Ops Agent for Monitoring and Logging checkbox.
Selecting this checkbox enables VM Manager in limited capability mode and it creates an OS policy assignment for installing Ops Agent on the instance.
Optional: Specify other configuration options. For more information, see Configuration options during instance creation.
To create and start the instance, click Create.
You can use the Google Cloud console, the gcloud CLI, or an automation tool to install Ops Agent on a fleet of instances or on individual instances. For detailed instructions, see Install the Ops Agent.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-04-17 UTC.