[[["容易理解","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-31 (世界標準時間)。"],[],[],null,["# Install Cloud Logging on CNCF conformant attached clusters\n\nThis document describes how GKE attached clusters integrates with\nCloud Logging and shows you how to access your logs.\n\nOverview\n--------\n\nGKE attached clusters supports Cloud Logging for workloads\nand for system components running on worker nodes.\n\nGKE attached clusters includes a\n[Fluentbit](https://fluentbit.io/)-based logging agent that runs on\nworker nodes as a Daemonset. Data collected by the logging agents can be\nmanaged and deleted like any other metric and log data, as described in\n[Cloud Logging](/logging/docs/reference/tools/gcloud-logging#deleting_logs)\ndocumentation.\n\nBefore you begin\n----------------\n\n1. Fulfill the\n [prerequisites for GKE attached clusters](/kubernetes-engine/multi-cloud/docs/attached/generic/reference/cluster-prerequisites).\n\n2. [Authorize Cloud Logging and Cloud Monitoring](/kubernetes-engine/multi-cloud/docs/attached/generic/how-to/attach-cluster#telemetry-agent-auth)\n to set up permissions for Google Cloud Observability.\n\nWhat data is collected\n----------------------\n\nYou can configure GKE attached clusters to capture any or all of the following\ninformation:\n\n- Logs for workloads\n\nEnable logging\n--------------\n\nIf you don't specify a logging mode when you attach your cluster,\nGKE attached clusters enables system logging by default. For workload\nlogging, your cluster must be at Kubernetes version 1.23 or later.\n\nTo enable workload logging when attaching a cluster, follow the instructions\nto [attach your CNCF conformant cluster](/kubernetes-engine/multi-cloud/docs/attached/generic/how-to/attach-cluster), and\ninclude the optional `--logging` flag in the\n[`gcloud container attached clusters register` command](/sdk/gcloud/reference/container/attached/clusters/register): \n\n```sh,devsite-disable-click-to-copy\ngcloud container attached clusters register CLUSTER_NAME\n...\n--logging=LOGGING_FLAG\n```\n\nTo enable workload logging on a cluster that's already attached, follow the\ninstructions to\n[update your CNCF conformant cluster](/kubernetes-engine/multi-cloud/docs/attached/generic/how-to/update-cluster), and\ninclude the optional `--logging` flag in the\n[`gcloud container attached clusters update` command](/sdk/gcloud/reference/container/attached/clusters/update): \n\n```sh,devsite-disable-click-to-copy\ngcloud container attached clusters update CLUSTER_NAME\n...\n--logging=LOGGING_FLAG\n```\n\nReplace \u003cvar translate=\"no\"\u003eLOGGING_FLAG\u003c/var\u003e with a flag indicating what kind of\nlogging you want to enable:\n\n- `NONE`: disable logging.\n- `SYSTEM`: enable logging of system workloads running in [specific](#system_apps_logs) namespaces.\n- `SYSTEM,WORKLOAD`: enable logging of both system and workload activity on your cluster's worker nodes.\n\n\nAccess your logs\n----------------\n\nThere are several ways to access your GKE attached clusters logs in\nCloud Logging:\n\n- **Logs Explorer** -- You can see your logs directly from the\n [Logs Explorer](https://console.cloud.google.com/logs) by using the\n logging filters to select the Kubernetes resources, such as\n cluster, node, namespace, pod, or container logs.\n\n- **Google Cloud CLI** -- Using the\n [`gcloud logging read`](/logging/docs/reference/tools/gcloud-logging) command,\n select the appropriate cluster, node, pod, and container logs.\n\nUnderstanding your logs\n-----------------------\n\nA log in Cloud Logging is a collection of\n[log entries](/logging/docs/log-entry-data-model), and each log entry\napplies to a certain type of\n[logging resource](/logging/docs/api/v2/resource-list).\n\n### Resource types\n\nThese are the resource types that are specific to GKE attached clusters:\n\nWhen GKE attached clusters writes your cluster's logs, each log entry includes\nthe resource type. Understanding where logs appear makes it easier to find logs\nwhen you need them.\n\n#### System apps logs\n\nSystem apps logs fall under the `k8s_container` resource type. These include\nlogs from pods installed on the worker nodes by GKE attached clusters.\nSpecifically, containers running in the following namespaces are included:\n\n- `gke-connect`\n- `gke-system`\n- `gmp-system`\n- `asm-user-auth`\n- `cnrm-system`\n- `config-management-system`\n- `gatekeeper-system`\n- `gmp-public`\n- `istio-system`\n- `knative-serving`\n\nFind your logs in the Cloud Logging user interface\n--------------------------------------------------\n\nYou can view your logs using the\n[Logs Explorer](/logging/docs/view/logs-explorer-interface) in the\nCloud Logging user interface.\n\n### Logs Explorer\n\nUsing the Query Builder, you can build a query by adding query parameters\nmanually. For example, if you want to explore logs for system workloads, you can\nstart with selecting or searching for the `k8s_container` resource type, and\nthen select the location and cluster name. You can then refine your search by\nfiltering the container or Pod names.\n\nThe Logs Explorer offers an additional way to build your search queries\nusing the **Logs field explorer** . It shows the count of log entries, sorted by\ndecreasing count, for the given log field. Using the **Logs field explorer** is\nparticularly useful for GKE attached clusters logs because it provides an easy\nway to select the Kubernetes values for your resources. For example, you can\nselect logs for a specific cluster, Namespace, Pod name, and container name.\n\nFor more information, see\n[Using the Logs Explorer](/logging/docs/view/logs-explorer-interface).\n\n### Sample queries\n\nThis section includes sample queries that you can make on Logs Explorer.\n\nExample 1: Get the logs of the `gke-connect-agent` container for an\nGoogle Cloud cluster \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: \n\n resource.type=\"k8s_container\"\n resource.labels.cluster_name=\"attachedClusters/\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\"\n resource.labels.container_name=\"gke-connect-agent\"\n\nWhat's next\n-----------\n\n- [Cloud Logging overview](/logging/docs/overview)\n- [Using the Logs Explorer](/logging/docs/view/logs-explorer-interface)\n- [Building queries for Cloud Logging](/logging/docs/view/building-queries)\n- [Create logs-based metrics](/logging/docs/logs-based-metrics)"]]