Crea un'istanza per il monitoraggio e il logging di Ops Agent
Mantieni tutto organizzato con le raccolte Salva e classifica i contenuti in base alle tue preferenze.
Ops Agent raccoglie dati di telemetria per le istanze, che puoi poi utilizzare per la risoluzione dei problemi e l'ottimizzazione delle prestazioni.
Prima di iniziare
Se non l'hai ancora fatto, configura l'autenticazione. L'autenticazione è il processo di verifica dell'identità per poter accedere a Google Cloud servizi e API. Per eseguire codice o esempi da un ambiente di sviluppo locale, puoi autenticarti su Compute Engine selezionando una delle seguenti opzioni:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
Installa Google Cloud CLI. Dopo l'installazione, inizializza Google Cloud CLI eseguendo il seguente comando:
Per ottenere le autorizzazioni necessarie per creare un'istanza per il monitoraggio e la registrazione di Ops Agent, chiedi all'amministratore di concederti i seguenti ruoli IAM nel progetto:
Crea un'istanza per il monitoraggio e il logging di Ops Agent
Puoi creare un'istanza configurata per il monitoraggio e il logging di Ops Agent solo utilizzando la Google Cloud console. Questa sezione descrive brevemente come installare l'Ops Agent durante la creazione di un'istanza. Per ulteriori informazioni, vedi anche Installare Ops Agent durante la creazione dell'istanza.
Nella Google Cloud console, vai alla pagina Crea un'istanza.
Se richiesto, seleziona il progetto e fai clic su Continua.
Viene visualizzata la pagina Crea un'istanza, che mostra il riquadro Configurazione macchina.
Nel riquadro di navigazione, fai clic su Osservabilità. Viene visualizzato il riquadro Osservabilità.
Nella sezione Ops Agent, seleziona la casella di controllo Installa Ops Agent per il monitoraggio e il logging.
Se selezioni questa casella di controllo, VM Manager viene abilitato in modalità con funzionalità limitate e viene creata un'assegnazione di policy del sistema operativo per l'installazione di Ops Agent sull'istanza.
Puoi utilizzare la console Google Cloud , gcloud CLI o uno strumento di automazione per installare l'Ops Agento su un parco risorse di istanze o su singole istanze. Per istruzioni dettagliate, vedi Installare l'agente Ops.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-08-19 UTC."],[[["\u003cp\u003eThe Ops Agent collects telemetry data for instances, aiding in troubleshooting and performance tuning.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication to Google Cloud services and APIs is necessary, and can be done through the Google Cloud console, gcloud CLI, or REST API.\u003c/p\u003e\n"],["\u003cp\u003eCreating an instance for Ops Agent monitoring and logging can be done via the Google Cloud console by enabling the "Install the Ops Agent for Monitoring and Logging" option during instance creation.\u003c/p\u003e\n"],["\u003cp\u003eThe Ops Agent can also be installed on existing instances using the Google Cloud console, gcloud CLI, or an automation tool.\u003c/p\u003e\n"],["\u003cp\u003eTo install the agent, required roles include Compute Instance Admin (v1) and OSPolicyAssignment Editor.\u003c/p\u003e\n"]]],[],null,["*** ** * ** ***\n\nThe [Ops Agent](/stackdriver/docs/solutions/agents/ops-agent) collects telemetry data for instances that you can then use for troubleshooting and performance tuning.\n\nBefore you begin\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n gcloud\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nRequired roles\n\n\nTo get the permissions that\nyou need to create an instance for Ops Agent monitoring and logging,\n\nask your administrator to grant you the\nfollowing IAM roles on the project:\n\n- [Compute Instance Admin (v1)](/iam/docs/roles-permissions/compute#compute.instanceAdmin.v1) (`roles/compute.instanceAdmin.v1`)\n- To install the Ops Agent on the instance: [OSPolicyAssignment Editor](/iam/docs/roles-permissions/osconfig#osconfig.osPolicyAssignmentEditor) (`roles/osconfig.osPolicyAssignmentEditor`)\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nYou might also be able to get\nthe required permissions through [custom\nroles](/iam/docs/creating-custom-roles) or other [predefined\nroles](/iam/docs/roles-overview#predefined).\n\nCreate an instance for the Ops Agent monitoring and logging\n\nYou can create an instance that's configured for Ops Agent monitoring and\nlogging only by using the Google Cloud console. This section briefly describes how\nto install the Ops Agent while creating an instance. For more information, also\nsee [Install Ops Agent during instance creation](/stackdriver/docs/solutions/agents/ops-agent/install-agent-vm-creation).\n\n1. In the Google Cloud console, go to the **Create an instance** page.\n\n [Go to Create an instance](https://console.cloud.google.com/compute/instancesAdd)\n\n If prompted, select your project and click **Continue**.\n\n The **Create an instance** page appears and displays the\n **Machine configuration** pane.\n2. In the navigation pane, click **Observability** . The **Observability**\n pane appears.\n\n3. In the **Ops Agent** section, select the\n **Install the Ops Agent for Monitoring and Logging** checkbox.\n\n Selecting this checkbox enables VM Manager in limited\n capability mode and it creates an OS policy assignment for installing\n Ops Agent on the instance.\n4. Optional: Specify other configuration options. For more information, see\n [Configuration options during instance creation](/compute/docs/instances/instance-creation-overview#new-instance-configuration-options).\n\n5. To create and start the instance, click **Create**.\n\nInstall the Ops Agent on existing instances\n\nYou can use the Google Cloud console, the gcloud CLI, or an automation\ntool to install Ops Agent on a fleet of instances or on individual instances.\nFor detailed instructions, see\n[Install the Ops Agent](/stackdriver/docs/solutions/agents/ops-agent/install-index).\n| **Note:** If you install the Ops Agent, then you might be charged for the metrics and logs that the agent sends to your Google Cloud project. For more information, see [Google Cloud Observability pricing](/stackdriver/pricing).\n\nWhat's next\n\n- Learn how to [check the status of an instance](/compute/docs/instances/instance-life-cycle) to see when it is ready to use.\n- Learn how to [connect to your instance0](/compute/docs/instances/connecting-to-instance)."]]