이 문서에서는 VM 인스턴스를 만들 때 Google Cloud 콘솔에서 운영 에이전트를 자동으로 설치하는 방법을 설명합니다. 설치 프로세스 중에 Compute Engine VM Manager에서 에이전트를 설치하고 필요한 경우 다시 설치하는 운영 에이전트 OS 정책을 만듭니다. VM Manager는 VM에서 운영 에이전트를 실행하는 데 도움을 주며 에이전트가 항상 설치되도록 합니다.
개요
VM Manager는 OS 정책을 사용하여 운영 에이전트 설치를 관리합니다. 구성 정책은 다음 예와 같이 할당 ID라는 매핑을 사용하여 VM에 적용됩니다.
goog-ops-agent-v2-x86-template-1-0-0-ZONE
운영 에이전트 OS 정책의 할당 ID는 다음 구성요소로 구성됩니다.
정책 이름: 'goog-ops-agent'
정책 생성 템플릿: 'v2-x86-template'
템플릿의 버전 문자열. 시간이 지나면서 변경될 수 있는 버전은 '1-0-0'과 같은 값입니다.
할당 ID가 적용되는 영역('us-central1-a'와 같은 값)
VM은 VM 인스턴스의 라벨을 사용하여 할당 ID와 연결됩니다.
Compute Engine VM은 gce_instance 유형의 모니터링 리소스이며 zone 라벨을 포함합니다. Google Cloud 콘솔을 사용하여 운영 에이전트가 설치된 VM을 만들면 VM Manager가 VM에 다른 라벨(예: goog-ops-agent-policy:v2-x86-template-1-0-0)을 추가합니다. 이 라벨은 정책, 템플릿, 버전을 식별합니다.
라벨 키, 정책 식별자: goog-ops-agent-policy
라벨 값, 정책 템플릿, 버전: v2-x86-template-1-0-0
Google Cloud 콘솔에서 VM을 만들 때 모니터링 및 로깅을 위한 운영 에이전트 설치 체크박스를 선택할 수 있습니다. 만들기를 클릭하면 VM Manager에서 VM에 goog-ops-agent-policy:v2-x86-template-1-0-0 라벨을 할당하고 운영 에이전트를 설치합니다. VM이 영역의 첫 번째 VM이면 VM Manager에서 해당 영역의 운영 에이전트 OS 정책 및 운영 에이전트 OS 정책 할당도 만듭니다.
영역에 운영 에이전트 OS 정책 할당이 있어도 운영 에이전트 OS 정책은 다음 특성을 가진 VM을 모니터링합니다.
VM에 goog-ops-agent-policy:v2-x86-template-1-0-0 라벨이 있습니다.
VM이 운영 에이전트 OS 정책 할당과 동일한 영역에 있습니다.
운영 에이전트 OS 정책은 적용되는 VM에 운영 에이전트가 설치되어 있는지 매시간 확인합니다. 운영 에이전트가 설치되지 않은 경우 운영 에이전트 OS 정책에서 에이전트의 최신 버전을 설치합니다.
운영 에이전트의 자동 설치를 사용하여 VM 만들기
VM 생성 중에 운영 에이전트를 자동으로 설치하고 VM에 운영 에이전트 OS 정책 할당을 적용하려면 다음을 수행합니다.
Grant roles to your user account. Run the following command once for each of the following
IAM roles:
roles/osconfig.osPolicyAssignmentEditor
영역의 운영 에이전트 OS 정책 및 운영 에이전트 OS 정책 할당을 만듭니다. 운영 에이전트 OS 정책은 정책 할당의 필드입니다.
VM 메타데이터 라벨 enable-osconfig를 TRUE로 설정하여 패치, OS 정책, OS 인벤토리 관리를 사용 설정합니다.
VM을 만들고 운영 에이전트 OS 정책 라벨을 할당합니다.
운영 에이전트 OS 정책 할당이 이미 존재하는 영역에 VM을 만들고 운영 에이전트를 자동으로 설치하면 VM 생성 프로세스에서 VM을 만들고 운영 에이전트 OS 정책 라벨을 할당합니다.
예시
Google Cloud 프로젝트에 운영 에이전트 OS 정책 할당이 없습니다. us-central1-a 영역에 instance-1 및 instance-2라는 VM 2개를 만듭니다. 그런 다음 us-east1-b 영역에 instance-3 및 instance-4를 만듭니다. instance-1, instance-2, instance-3에는 생성 중에 모니터링 및 로깅을 위한 운영 에이전트 설치 체크박스가 선택되었습니다.
instance-1을 만들면 VM Manager가 us-central1-a 영역의 운영 에이전트 OS 정책과 ID goog-ops-agent-v2-x86-template-1-0-0-us-central1-a를 사용한 OS 정책 할당을 만듭니다.
그런 다음 VM Manager는 instance-1에 정책 라벨을 설정합니다.
instance-2를 만들면 VM Manager가 instance-2에 동일한 정책 라벨을 설정합니다.
instance-3을 만들면 VM Manager가 us-east1-b 영역의 운영 에이전트 OS 정책과 ID goog-ops-agent-v2-x86-template-1-0-0-us-east1-b를 사용한 OS 정책 할당을 만듭니다. 그런 다음 VM Manager가 정책 라벨을 instance-3에 할당합니다.
그러면 운영 에이전트 OS 정책이 운영 에이전트 OS 정책 할당 ID에 따라 다음과 같은 VM에 적용됩니다.
모니터링 및 로깅을 위한 운영 에이전트 설치를 선택하지 않았기 때문에 goog-ops-agent-policy:v2-x86-template-1-0-0 라벨이 없으므로 기본적으로 instance-4에는 적용되지 않습니다. 운영 에이전트 OS 정책을 instance-4에도 적용하려면 기존 VM에 운영 에이전트 OS 정책 적용 범위 추가를 참조하세요.
운영 에이전트 OS 정책이 적용되는 VM에서 운영 에이전트 버전 관리
운영 에이전트 OS 정책은 새 버전의 에이전트가 출시될 때 운영 에이전트를 업데이트하지 않습니다. VM에 운영 에이전트의 어떤 버전이라도 있는 한 정책에서 아무것도 수행하지 않습니다. 운영 에이전트를 제거하면 정책에서 운영 에이전트가 설치되지 않은 것을 감지하고 최신 버전을 설치합니다.
VM을 최신 버전의 운영 에이전트로 업그레이드하려면 현재 실행 중인 버전을 제거하고 운영 에이전트 OS 정책에서 최신 버전을 설치하도록 합니다.
OS 정책은 패키지 설치를 위한 일반 도구입니다. 운영 에이전트가 자동으로 설치된 VM을 만들었기 때문에 기본적으로 VM Manager가 사용 설정되면 VM Manager가 제한 모드로 사용 설정됩니다.
VM Manager 모드와 가격 책정에 대한 자세한 내용은 VM Manager 가격 책정을 참조하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-29(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](/monitoring/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](/monitoring/agent/ops-agent/manage-policies-auto-install#uninstall)\nand then [install a specific version of the agent](/monitoring/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](/monitoring/agent/ops-agent/manage-policies-auto-install)\nand\n[Agent diagnostics tool for automatic installation policies](/monitoring/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](/monitoring/agent/ops-agent/manage-policies-auto-install)."]]