Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dokumen ini menjelaskan cara konsol Google Cloud dapat menginstal Agen Operasional secara otomatis untuk Anda saat Anda membuat instance VM. Selama proses penginstalan, VM Manager Compute Engine akan membuat kebijakan OS Agen Operasional yang menginstal agen dan menginstalnya ulang jika diperlukan. VM Manager membantu Anda menjalankan Agen Operasional di VM dan memastikan bahwa agen selalu diinstal.
Ringkasan
VM Manager menggunakan kebijakan OS untuk mengelola penginstalan Agen Operasional. Kebijakan konfigurasi diterapkan ke VM menggunakan pemetaan yang disebut ID penetapan, yang terlihat seperti contoh berikut:
goog-ops-agent-v2-x86-template-1-0-0-ZONE
ID penetapan untuk kebijakan OS Agen Operasional terdiri dari komponen berikut:
Nama kebijakan: "goog-ops-agent"
Template untuk membuat kebijakan: "v2-x86-template"
String versi untuk template. Versi, yang dapat berubah dari waktu ke waktu,
adalah nilai seperti "1-0-0".
Zona tempat ID penetapan berlaku, nilai seperti "us-central1-a".
VM dikaitkan dengan ID tugas menggunakan label pada instance VM.
VM Compute Engine adalah resource yang dipantau dengan jenis
gce_instance
dan menyertakan label zone. Saat Anda menggunakan konsol Google Cloud untuk
membuat VM dengan Agen Operasional yang diinstal, VM Manager akan menambahkan label lain ke VM, yang terlihat seperti goog-ops-agent-policy:v2-x86-template-1-0-0. Label ini mengidentifikasi
kebijakan, template, dan versi:
Kunci label, ID untuk kebijakan: goog-ops-agent-policy
Nilai label, template dan versi kebijakan: v2-x86-template-1-0-0
Saat membuat VM di konsol Google Cloud , Anda dapat memilih kotak centang
Install Ops Agent for Monitoring and Logging. Saat Anda mengklik
Buat, VM Manager akan menetapkan label goog-ops-agent-policy:v2-x86-template-1-0-0 ke VM dan
menginstal Agen Operasional. Jika VM adalah VM pertama di zonanya, maka
VM Manager juga akan membuat kebijakan OS Agen Operasional dan penetapan kebijakan OS Agen Operasional untuk zona tersebut.
Meskipun zona memiliki penetapan kebijakan OS Agen Operasional, kebijakan OS Agen Operasional memantau VM yang memiliki karakteristik berikut:
VM memiliki label goog-ops-agent-policy:v2-x86-template-1-0-0.
VM berada di zona yang sama dengan penetapan kebijakan OS Agen Operasional.
Kebijakan OS Agen Operasional memeriksa setiap jam apakah VM yang dicakup telah menginstal Agen Operasional. Jika Agen Operasional belum diinstal, kebijakan OS Agen Operasional akan menginstal agen versi terbaru.
Membuat VM dengan penginstalan otomatis Agen Operasional
Untuk menginstal Agen Operasional secara otomatis selama pembuatan VM dan menerapkan penetapan kebijakan OS Agen Operasional ke VM, lakukan hal berikut:
Grant roles to your user account. Run the following command once for each of the following
IAM roles:
roles/osconfig.osPolicyAssignmentEditor
Saat Anda menginstal Agen Operasional secara otomatis untuk pertama kalinya di zona,
jika Anda belum mengaktifkan VM Manager untuk Google Cloud project Anda,
maka proses pembuatan VM akan melakukan hal berikut:
Memungkinkan VM Manager beroperasi dalam
mode terbatas.
Membuat kebijakan OS Agen Operasional dan penetapan kebijakan OS Agen Operasional
untuk zona. Kebijakan OS Agen Operasional adalah kolom penetapan kebijakan.
Mengaktifkan Patch, kebijakan OS, dan OS inventory management dengan
menetapkan label metadata VM enable-osconfig ke
TRUE.
Membuat VM dan menetapkan label kebijakan OS Agen Operasional ke VM tersebut.
Jika Anda membuat VM dan menginstal Agen Operasional secara otomatis di zona
tempat penetapan kebijakan OS Agen Operasional sudah ada, maka proses
pembuatan VM akan membuat VM dan menetapkan label kebijakan OS Agen Operasional ke VM tersebut.
Contoh
Project Google Cloud Anda tidak memiliki penetapan kebijakan Ops Agent OS. Anda membuat dua VM, instance-1 dan instance-2 di zona
us-central1-a. Kemudian, Anda
membuat instance-3 dan instance-4 di zona us-east1-b. instance-1, instance-2, dan
instance-3 telah mencentang kotak Install Ops Agent for Monitoring and Logging
selama pembuatan.
Saat Anda membuat instance-1, VM Manager akan membuat kebijakan OS Agen Operasional
untuk zona us-central1-a dan penetapan kebijakan OS
dengan ID goog-ops-agent-v2-x86-template-1-0-0-us-central1-a.
Kemudian, VM Manager akan menetapkan label kebijakan pada instance-1.
Saat Anda membuat instance-2, VM Manager menetapkan
label kebijakan yang sama pada instance-2.
Saat Anda membuat instance-3,
VM Manager akan membuat kebijakan OS Agen Operasional untuk zona us-east1-b
dan penetapan kebijakan OS dengan ID
goog-ops-agent-v2-x86-template-1-0-0-us-east1-b. VM Manager kemudian
menetapkan label kebijakan ke instance-3.
Kebijakan OS Agen Operasional kemudian mencakup VM berikut berdasarkan ID penetapan kebijakan OS Agen Operasional:
Secara default, instance-4 tidak tercakup karena Anda tidak memilih
Instal Agen Operasional untuk Pemantauan dan Logging, sehingga tidak memiliki label
goog-ops-agent-policy:v2-x86-template-1-0-0. Jika Anda juga ingin menerapkan kebijakan OS Agen Operasional ke
instance-4, lihat
Menambahkan cakupan kebijakan OS Agen Operasional ke VM yang ada.
Mengelola versi Agen Operasional di VM yang dicakup oleh kebijakan OS Agen Operasional
Kebijakan OS Ops Agent tidak mengupdate Ops Agent saat versi baru agen dirilis. Selama VM telah menginstal Agen Operasional versi tertentu, kebijakan ini tidak akan berpengaruh. Jika Anda meng-uninstal Agen Operasional, kebijakan akan mendeteksi bahwa Agen Operasional tidak diinstal, lalu menginstal versi terbaru.
Untuk mengupgrade VM ke Agen Operasional versi terbaru, hapus instalasi
versi yang saat ini Anda jalankan dan biarkan kebijakan OS Agen Operasional
menginstal versi terbaru.
Kebijakan OS adalah alat generik untuk menginstal paket. Secara default, saat VM Manager diaktifkan karena Anda telah membuat VM dengan Agen Operasional yang diinstal secara otomatis, VM Manager akan diaktifkan dalam mode terbatas.
Untuk mengetahui informasi tentang mode dan harga VM Manager, lihat
Harga VM Manager.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-18 UTC."],[],[],null,["# Install the Ops Agent during VM creation\n\nThis document describes how the Google Cloud console can automatically install the\nOps Agent for you when you create a VM instance. During the installation\nprocess, the Compute Engine [VM Manager](/compute/docs/vm-manager) creates an\nOps Agent OS policy\nthat installs the agent and reinstalls it when necessary. The\nVM Manager helps you get the Ops Agent running on your VM and ensures\nthat the agent is always installed.\n\nOverview\n--------\n\nThe VM Manager uses OS policies to manage the Ops Agent\ninstallation. A configuration policy is applied to a VM by using a mapping\ncalled an *assignment ID*, which looks like the following example: \n\n```\ngoog-ops-agent-v2-x86-template-1-0-0-ZONE\n```\n\nAn assignment ID for an Ops Agent OS policy consists of the following\ncomponents:\n\n- The name of the policy: \"goog-ops-agent\"\n- A template for creating the policy: \"v2-x86-template\"\n- A version string for the template. The version, which might change over time, is a value like \"\u003cvar translate=\"no\"\u003e1-0-0\u003c/var\u003e\".\n- The zone to which the assignment ID applies, a value like \"us-central1-a\".\n\nA VM is associated with an assignment ID by using the labels on the VM instance.\nA Compute Engine VM is a monitored resource of type\n[`gce_instance`](/monitoring/api/resources#tag_gce_instance)\nand includes a `zone` label. When you use the Google Cloud console to\ncreate a VM with the Ops Agent installed, the VM Manager adds another\nlabel to the VM, which looks like `goog-ops-agent-policy:v2-x86-template-`\u003cvar translate=\"no\"\u003e1-0-0\u003c/var\u003e. This label identifies the\npolicy, template, and version:\n\n- Label key, the identifier for the policy: `goog-ops-agent-policy`\n- Label value, the policy template and version: `v2-x86-template-`\u003cvar translate=\"no\"\u003e1-0-0\u003c/var\u003e\n\nWhen you create a VM in the Google Cloud console, you can select the\n**Install Ops Agent for Monitoring and Logging** checkbox. When you click\n**Create** , VM Manager assigns the VM a label of `goog-ops-agent-policy:v2-x86-template-`\u003cvar translate=\"no\"\u003e1-0-0\u003c/var\u003e and\ninstalls the Ops Agent. If the VM is the first VM in its zone, then\nVM Manager also creates an Ops Agent OS policy and an Ops Agent OS\npolicy assignment for that zone.\n\nWhile a zone has an Ops Agent OS policy assignment, the Ops Agent OS policy\nmonitors VMs that have the following characteristics:\n\n- The VM has the `goog-ops-agent-policy:v2-x86-template-`\u003cvar translate=\"no\"\u003e1-0-0\u003c/var\u003e label.\n- The VM is in the same zone as the Ops Agent OS policy assignment.\n\nThe Ops Agent OS policy checks every hour whether its\ncovered VMs have the Ops Agent installed. If the Ops Agent isn't\ninstalled, then the Ops Agent OS policy installs the latest version\nof the agent.\n\nCreate a VM with automatic installation of the Ops Agent\n--------------------------------------------------------\n\nTo install the Ops Agent automatically during VM creation and apply the\nOps Agent OS policy assignment to the VM, do the following:\n\n1.\n Grant roles to your user account. Run the following command once for each of the following\n IAM roles:\n `roles/osconfig.osPolicyAssignmentEditor`\n\n ```bash\n gcloud projects add-iam-policy-binding PROJECT_ID --member=\"user:\u003cvar translate=\"no\"\u003eUSER_IDENTIFIER\u003c/var\u003e\" --role=ROLE\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: your project ID.\n - \u003cvar translate=\"no\"\u003eUSER_IDENTIFIER\u003c/var\u003e: the identifier for your user account---for example, `myemail@example.com`.\n - \u003cvar translate=\"no\"\u003eROLE\u003c/var\u003e: the IAM role that you grant to your user account.\n2. Follow the steps in [Create a VM instance from a public image](/compute/docs/instances/create-start-instance#publicimage). Before you click **Create** , select the **Install Ops Agent for Monitoring and Logging** checkbox:\n\n | **Note:** When you select the **Install Ops Agent for Monitoring and Logging** checkbox during VM creation, the examples on the tabs in the **Equivalent code** flyout are updated to include the steps for creating the Ops Agent OS policy. There is no REST equivalent for creating an Ops Agent OS policy.\n3. Click **Create** .\n\n When you install the Ops Agent automatically for the first time in a zone,\n if you don't have VM Manager enabled for your Google Cloud project,\n then the VM-creation process does the following:\n 1. Enables VM Manager to operate in [restricted mode](/compute/docs/vm-manager#pricing).\n 2. Creates the Ops Agent OS policy and an Ops Agent OS policy assignment for the zone. The Ops Agent OS policy is a field of the policy assignment.\n 3. Enables Patch, OS policies, and OS inventory management by setting the VM metadata label `enable-osconfig` to `TRUE`.\n 4. Creates the VM and assigns it the Ops Agent OS policy label.\n\n \u003cbr /\u003e\n\n If you create a VM and automatically install the Ops Agent in a zone\n where an Ops Agent OS policy assignment already exists, then the VM-creation\n process creates the VM and assigns it the Ops Agent OS policy label.\n\n \u003cbr /\u003e\n\n \u003cbr /\u003e\n\n\u003cbr /\u003e\n\nExample\n-------\n\nYour Google Cloud project doesn't have any Ops Agent OS\npolicy assignments. You create two VMs, *instance-1* and *instance-2* in the\n`us-central1-a` zone. You\nthen create *instance-3* and *instance-4* in the `us-east1-b` zone. *instance-1* , *instance-2* , and\n*instance-3* had the **Install Ops Agent for Monitoring and Logging** checkbox\nselected during creation.\n\n- When you create *instance-1* , VM Manager creates an Ops Agent OS policy for the `us-central1-a` zone and an OS policy assignment with the ID `goog-ops-agent-v2-x86-template-`\u003cvar translate=\"no\"\u003e1-0-0\u003c/var\u003e`-us-central1-a`. VM Manager then sets the policy label on *instance-1*.\n- When you create *instance-2* , VM Manager sets the same policy label on *instance-2*.\n- When you create *instance-3* , VM Manager creates an Ops Agent OS policy for the `us-east1-b` zone and an OS policy assignment with the ID `goog-ops-agent-v2-x86-template-`\u003cvar translate=\"no\"\u003e1-0-0\u003c/var\u003e`-us-east1-b`. VM Manager then assigns the policy label to *instance-3*.\n\nThe Ops Agent OS policies then cover the following VMs based on the\nOps Agent OS policy assignment IDs:\n\nBy default, *instance-4* isn't covered because you didn't select\n**Install Ops Agent for Monitoring and Logging** , so it doesn't have the\n`goog-ops-agent-policy:v2-x86-template-`\u003cvar translate=\"no\"\u003e1-0-0\u003c/var\u003e label. If you also want to apply the Ops Agent OS policy to\n*instance-4* , then see\n[Add Ops Agent OS policy coverage to an existing VM](/logging/docs/agent/ops-agent/manage-policies-auto-install#add-coverage).\n\nManage Ops Agent versions on VMs covered by the Ops Agent OS policy\n-------------------------------------------------------------------\n\nThe Ops Agent OS policy doesn't update the Ops Agent when new versions of the\nagent are released. As long as the VM has some version of the Ops Agent\ninstalled, the policy does nothing. If you uninstall the Ops Agent, then the\npolicy detects that the Ops Agent isn't installed and then installs the latest\nversion.\n\nTo upgrade your VM to the latest version of the Ops Agent, uninstall the\nversion that you are currently running and let the Ops Agent OS policy\ninstall the latest version.\n\nIf you need to install a previous version of the Ops Agent, you can\n[uninstall the Ops Agent on VMs covered by the Ops Agent OS policy](/logging/docs/agent/ops-agent/manage-policies-auto-install#uninstall)\nand then [install a specific version of the agent](/logging/docs/agent/ops-agent/installation#install-specific-version).\n\nTroubleshooting\n---------------\n\nFor information about troubleshooting agent installation and Ops Agent OS\npolicies, see [Manage VMs covered by the Ops Agent OS policy](/logging/docs/agent/ops-agent/manage-policies-auto-install)\nand\n[Agent diagnostics tool for automatic installation policies](/logging/docs/agent/ops-agent/troubleshoot-find-info#agent_diagnostics_tool_for_automatic_installation_policies).\n\nPricing\n-------\n\nOS policies are generic tools for installing packages. By default, when\nVM Manager is enabled because you've created a VM with the Ops Agent\nautomatically installed, VM Manager is enabled in the limited mode.\nFor information about VM Manager modes and pricing, see\n[VM Manager Pricing](/compute/docs/vm-manager#pricing).\n\nWhat's next\n-----------\n\nFor information about managing VMs covered by the Ops Agent OS policy, see\n[Manage VMs covered by the Ops Agent OS policy](/logging/docs/agent/ops-agent/manage-policies-auto-install)."]]