Container-Optimized OS에는 일부 시스템 및 컨테이너 로그를 Cloud Logging으로 내보내는 로깅 에이전트가 포함됩니다. Container-Optimized OS 101까지는 x86 기반 Container-Optimized OS 이미지가 fluentd 기반으로 컨테이너화된 Logging 에이전트를 사용했습니다. Container-Optimized OS 105부터는 대체 Logging 에이전트 구현인 fluent-bit가 제공되었습니다.
Container-Optimized OS 109부터는 fluent-bit Logging 에이전트가 기본값입니다.
기존 Logging 에이전트인 fluentd는 Container-Optimized OS 113에서 삭제될 예정입니다.
모든 버전의 Arm 기반 Container-Optimized OS 이미지는 fluent-bit Logging 에이전트를 제공합니다.
Logging 에이전트 사용 설정
Logging 에이전트는 기본적으로 사용 중지되어 있습니다. 새 인스턴스를 만들거나 기존 인스턴스를 업데이트하여 이 기능을 사용 설정할 수 있습니다.
액세스 요구사항
Cloud Logging은 적절한 액세스 권한을 부여하는 데 사용할 수 있는 IAM 역할을 제공합니다. 프로젝트의 로그를 보려면 roles/logging.viewer 역할이 있어야 하며 애플리케이션에 로그를 작성할 권한이 있어야 합니다. 이 권한을 부여하려면 애플리케이션의 서비스 계정에 IAM 역할 roles/logging.logWriter를 할당하면 됩니다.
관리 탭에서 메타데이터 섹션으로 스크롤합니다. 키가 google-logging-enabled이고 값이 true인 새 메타데이터 항목을 추가합니다.
필요에 따라 사용 사례에 대한 다른 옵션을 지정합니다. 자세한 내용은 인스턴스 만들기 및 구성을 참조하세요.
만들기를 클릭하여 인스턴스를 만들고 부팅합니다.
gcloud
Logging 에이전트가 사용 설정된 Container-Optimized OS에서 Compute Engine 인스턴스를 실행하려면 gcloud compute instances create 명령어를 사용하고 메타데이터에 google-logging-enabled=true를 포함합니다. 예를 들면 다음과 같습니다.
x86 기반 Container-Optimized OS 105 및 109 이미지는 fluentd(기존) 및 fluent-bit라는 두 가지 Logging 에이전트 구현을 제공합니다.
Container-Optimized OS 105는 기본적으로 fluentd를 사용하고 Container-Optimized OS 109는 기본적으로 fluent-bit를 사용합니다. google-logging-use-fluentbit 메타데이터 항목을 사용하여 기본 동작을 변경할 수 있습니다.
Container-Optimized OS 105에서 fluent-bit Logging 에이전트를 사용하려면 google-logging-use-fluentbit 값을 true로 설정합니다.
Container-Optimized OS 109에서 fluentd Logging 에이전트를 사용하려면 google-logging-use-fluentbit 값을 false로 설정합니다.
Logging 에이전트는 기본적으로 특정 시스템 중요 서비스 및 사용자 애플리케이션 컨테이너에서 Cloud Logging 백엔드로 로그를 전송하도록 구성됩니다. 예를 들어 docker 컨테이너, 선택한 systemd 서비스, 감사 로그, 저널 로그 오류 등의 로그입니다. 전체 기본 로깅 구성에 대한 Container-Optimized OS 특정 구성 소스(x86 이미지 및 Arm 이미지)를
참조하세요.
Container-Optimized OS 105 이하의 x86 이미지에서 Logging 에이전트는 Google Cloud Observability의 컨테이너화된 기존 Logging 에이전트입니다. Logging 에이전트를 시작하는 docker 명령어는 Container-Optimized OS stackdriver-logging systemd 서비스에 대한 소스에 정의되어 있습니다.
실행 중인 컨테이너화된 에이전트 버전은 Container-Optimized OS 소스 app-admin/stackdriver 디렉터리에 정의되어 있습니다.
모든 버전의 ARM 이미지 및 Container-Optimized OS 109 이상의 x86 이미지에서 Logging 에이전트는 fluent-bit라는 기본 제공 OS 패키지입니다.
에이전트는 OS에 기본 제공되며 OS 이미지와 함께 업데이트됩니다.
알려진 제한사항
gcplogs 드라이버와의 호환성
마일스톤 89부터 Container-Optimized OS에 포함된 Logging 에이전트가 사용 설정되고 Docker gcplogs 로깅 드라이버가 하나 이상의 컨테이너에 사용 설정된 경우, 과도한 경우 경고 로그는 포함된 Logging 에이전트에서 출력될 수 있습니다. 이로 인해 로그 노이즈가 발생하거나 Cloud Logging 관련 요금이 증가할 수 있습니다.
해결 방법은 gcplogs를 Docker 로깅 드라이버로 사용하지 않고 Container-Optimized OS에서 구성된 기본 드라이버를 대신 사용하는 것입니다. Container-Optimized OS에 포함된 Logging 에이전트는 컨테이너 로그를 Cloud Logging으로 내보내므로 두 솔루션을 동시에 사용할 필요가 없습니다.
Logging 에이전트 구성 호환성
Logging 에이전트는 x86 기반 Container-Optimized OS 이미지의 fluentd 기반 컨테이너이자 Arm 기반 Container-Optimized OS 이미지의 fluent-bit 바이너리입니다. 두 에이전트의 구성은 호환되지 않습니다. OS 이미지에 내장된 기본 로깅 구성만 사용하는 경우에는 문제가 되지 않습니다. 하지만 커스텀 로깅 구성이 있는 경우 워크로드를 다른 아키텍처 기반의 이미지 또는 Container-Optimized OS의 새 버전으로 마이그레이션할 때 중단이 발생할 수 있습니다.
참조
Google Cloud Observability의 기존 Logging 에이전트 문서 Container-Optimized OS에 포함된 컨테이너화된 Logging 에이전트는 레거시 Logging 에이전트의 일부입니다. 따라서 이 문서에서는 Container-Optimized OS 범위를 벗어나서 보다 일반적으로 에이전트에 대한 컨텍스트를 제공할 수 있습니다.
Google Cloud Observability 문서 Google Cloud Observability 문서 홈페이지이며, 유용한 컨텍스트를 제공할 수 있습니다.
[[["이해하기 쉬움","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-04-21(UTC)"],[[["\u003cp\u003eContainer-Optimized OS uses a logging agent to export system and container logs to Cloud Logging, with fluent-bit being the default agent as of version 109.\u003c/p\u003e\n"],["\u003cp\u003eThe logging agent is disabled by default, but can be enabled during instance creation or by updating an existing instance, using the \u003ccode\u003egoogle-logging-enabled\u003c/code\u003e metadata key.\u003c/p\u003e\n"],["\u003cp\u003eTo use the logging agent outside of Google Kubernetes Engine, you must have the \u003ccode\u003eroles/logging.viewer\u003c/code\u003e role to view logs and grant applications the \u003ccode\u003eroles/logging.logWriter\u003c/code\u003e role to write logs.\u003c/p\u003e\n"],["\u003cp\u003ex86-based Container-Optimized OS versions 105 and 109 offer a choice between the fluentd and fluent-bit logging agents, controllable via the \u003ccode\u003egoogle-logging-use-fluentbit\u003c/code\u003e metadata entry.\u003c/p\u003e\n"],["\u003cp\u003eStarting with milestone 89, avoid using the Docker \u003ccode\u003egcplogs\u003c/code\u003e logging driver with the included logging agent to prevent excessive warning logs and increased Cloud Logging charges, as the built-in agent already handles container log exporting.\u003c/p\u003e\n"]]],[],null,["# Using Cloud Logging with Container-Optimized OS\n\nContainer-Optimized OS includes a logging agent which exports some\nsystem and container logs to Cloud Logging. Up until\nContainer-Optimized OS 101, x86-based Container-Optimized OS images used\na containerized logging agent based on fluentd. Container-Optimized OS 105\nstarted shipping an alternative logging agent implementation, fluent-bit.\nAs of Container-Optimized OS 109, the fluent-bit logging agent is the default.\nThe legacy logging agent, fluentd, will be removed in\nContainer-Optimized OS 113.\n\nAll versions of Arm-based Container-Optimized OS images ship the fluent-bit\nlogging agent.\n| **Note:** Logging is automatically available when you choose Container-Optimized OS as the node image for running your Google Kubernetes Engine clusters. These instructions are for when you are using Container-Optimized OS outside of GKE, such as in Compute Engine.\n\nEnable the logging agent\n------------------------\n\nThe logging agent is disabled by default. You can enable this feature when\ncreating a new instance or by updating an existing instance.\n\n### Access Requirements\n\nCloud Logging provides IAM\n[roles](/logging/docs/access-control#permissions_and_roles)\nthat you can use to grant appropriate access. In order to view your logs in a project,\nyou must have the `roles/logging.viewer` role and applications must have permission\nto write logs. You can grant this permission by assigning the\nIAM role `roles/logging.logWriter` to the service account for an\napplication.\n\nFor more information about permissions and roles, see\n[Predefined roles](/logging/docs/access-control#permissions_and_roles).\n\n### Create an instance with a logging agent enabled\n\n### Console\n\nTo run a Compute Engine instance on Container-Optimized OS with the fluent-bit logging\nagent enabled, perform the following:\n\n1. Open the Compute Engine instance creation page on Google Cloud console.\n\n [Create a new Compute Engine instance](https://console.cloud.google.com/compute/instancesAdd)\n2. Specify a **Name** for your instance.\n\n3. In the **Boot disk** section, select a Container-Optimized OS image.\n\n4. Click on **Management, security, disks, networking, sole tenancy** to\n expand additional options.\n\n5. Under the **Management** tab, scroll to the **Metadata** section. Add a\n new metadata entry, with **Key** as `google-logging-enabled` and **Value**\n as `true`.\n\n6. Optionally, specify any other options for your use case. See\n [Creating and configuring instances](/container-optimized-os/docs/how-to/create-configure-instance)\n for more details.\n\n7. Click **Create** to create and boot the instance.\n\n### gcloud\n\nTo run a Compute Engine instance on Container-Optimized OS with the logging\nagent enabled, use the `gcloud compute instances create` command, and include\n`google-logging-enabled=true` in the metadata. For example: \n\n```\ngcloud compute instances create instance-name \\\n --image image-name \\\n --image-project cos-cloud \\\n --zone compute-zone \\\n --metadata google-logging-enabled=true\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003einstance-name\u003c/var\u003e: the name of your VM instance.\n- \u003cvar translate=\"no\"\u003eimage-name\u003c/var\u003e: the name of the Container-Optimized OS image for the instance. For example, `--image=cos-113-18244-85-29`.\n- \u003cvar translate=\"no\"\u003ecompute-zone\u003c/var\u003e: the [compute zone](/compute/docs/regions-zones#available) for your instance.\n\nFor more information on the `gcloud` command, see the\n[gcloud compute instances create](/sdk/gcloud/reference/compute/instances/create)\nreference documentation.\nFor more details on creating Container-Optimized OS instances, see\n[Creating and configuring instances](/container-optimized-os/docs/how-to/create-configure-instance).\n\n### Selecting the logging agent\n\nx86-based Container-Optimized OS 105 and 109 images ship two implementations\nof the logging agent: fluentd (legacy) and fluent-bit.\nContainer-Optimized OS 105 uses fluentd by default and\nContainer-Optimized OS 109 uses fluent-bit by default. You can use the `google-logging-use-fluentbit`\nmetadata entry to change the default behavior.\n\nTo use fluent-bit logging agent on Container-Optimized OS 105 set\n`google-logging-use-fluentbit` value to `true`.\n\nTo use fluentd logging agent on Container-Optimized OS 109 set\n`google-logging-use-fluentbit` value to `false`.\n\n### Enable the logging agent in project metadata\n\nStarting in [milestone 97](/container-optimized-os/docs/release-notes/m97),\nlogging can be enabled in project metadata: \n\n gcloud compute project-info add-metadata \\\n --metadata google-logging-enabled=true\n\n| **Note:** Metadata flags defined at instance level takes precedence over metadata flags defined at project level.\n\nAccess logs\n-----------\n\n### Console\n\n1. Go to the VM instances page.\n\n [Go to the VM instances page](https://console.cloud.google.com/compute/instances)\n2. Click on the name of the Container-Optimized OS instance you want to access\n logs from.\n\n3. Under the **Logs** section, click Cloud Logging.\n\n4. This opens the Logs Explorer for the given instance. For more information,\n see [Using the Logs Explorer](/logging/docs/view/logs-explorer-interface).\n\n| **Note:** In the query builder, you can filter by log name. Click on **Log name** , and select the given log name. For example, **cos_audit** for Audit logs or **cos_containers** for docker container logs.\n\n### gcloud\n\nTo access logs, use the `gcloud logging read` command. For example: \n\n```\ngcloud logging read \\\n\"resource.type=gce_instance AND resource.labels.instance_id=instance-id\" \\\n --limit 10 \\\n --format json \\\n --freshness 30d\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003einstance-id\u003c/var\u003e: the id of your VM instance.\n\nThis command attempts to read logs from the VM instance with\n\u003cvar translate=\"no\"\u003einstance-id\u003c/var\u003e, limiting to 10 logs, in JSON format, from the last 30\ndays.\n\nFor more information on the `gcloud` command, see the\n[gcloud logging read](/sdk/gcloud/reference/logging/read) reference\ndocumentation.\n\nHow does it work?\n-----------------\n\nThe logging agent is configured by default to send logs from certain system\ncritical services and user application containers to the Cloud Logging\nbackend. For example, logs from docker containers, selected systemd services,\naudit logs, journal log errors, etc. See Container-Optimized OS specific\nconfiguration source ([x86 images](https://cos.googlesource.com/cos/overlays/board-overlays/+/refs/heads/main-R105/project-lakitu/app-admin/stackdriver/files/logging_configs/fluentd-lakitu.conf) and [Arm images](https://cos.googlesource.com/cos/overlays/board-overlays/+/refs/heads/main-R105/project-lakitu/app-admin/fluent-bit/files/fluent-bit.conf))\nfor complete default logging configuration.\n\nFor x86 images of Container-Optimized OS 105 and older, the logging agent is\nGoogle Cloud Observability's containerized legacy Logging agent. The docker command that\nstarts the logging agent is defined in the Container-Optimized OS\n[source for stackdriver-logging systemd service](https://cos.googlesource.com/cos/overlays/board-overlays/+/refs/heads/main-R105/project-lakitu/app-admin/stackdriver/files/stackdriver-logging.service).\nThe version of the containerized agent being run is defined in the Container-Optimized OS\n[source app-admin/stackdriver directory](https://cos.googlesource.com/cos/overlays/board-overlays/+/refs/heads/main-R105/project-lakitu/app-admin/stackdriver/files/env_vars).\n\nFor Arm images of all versions and x86 images for Container-Optimized OS 109 and\nlater, the logging agent is a built-in OS package called\n[fluent-bit](https://cos.googlesource.com/cos/overlays/board-overlays/+/refs/heads/master/project-lakitu/app-admin/fluent-bit).\nThe agent is built into the OS and updated along with the OS images.\n\nKnown Limitations\n-----------------\n\n### Compatibility with `gcplogs` driver\n\nStarting with\n[milestone 89](/container-optimized-os/docs/release-notes#release_schedule),\nif the logging agent included with Container-Optimized OS is enabled and Docker\n`gcplogs` logging driver is enabled for one or more containers, excessive\nwarning logs may be output by the included logging agent. This may create log\nnoise and/or increase Cloud Logging related charges.\n\nA workaround is to not use `gcplogs` as a Docker logging driver, and to\ninstead use the default driver as configured by Container-Optimized OS. Note\nthat the logging agent included with Container-Optimized OS will export\ncontainer logs to Cloud Logging, so using both solutions simultaneously is\nnot necessary.\n\n### Logging agent configuration compatibility\n\nThe logging agent is a fluentd-based container on x86-based\nContainer-Optimized OS images and a fluent-bit binary on Arm-based\nContainer-Optimized OS images. The configurations of the two agents are not\ncompatible. This is not a problem if you only rely on the default logging\nconfiguration built into the OS images. However, if you have a\ncustom logging configuration, you might experience breakage when migrating\nworkloads to images that are based on a different architecture or to a\nnewer version of Container-Optimized OS.\n\nReferences\n----------\n\n- Google Cloud Observability's legacy Logging agent [documentation](/logging/docs/agent/logging). The containerized logging agent included with Container-Optimized OS is a subset of the legacy Logging agent, so this documentation may provide context on the agent more generally, outside of the scope of Container-Optimized OS.\n- Google Cloud Observability [documentation](/products/operations). Homepage for Google Cloud Observability documentation; may be useful for context."]]