[[["容易理解","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-22 (世界標準時間)。"],[],[],null,["# Cloud logging\n\nThis document describes how GKE on AWS integrates with\nCloud Logging and shows you how to access your logs.\n\nOverview\n--------\n\nGKE on AWS supports Cloud Logging for workloads\nand for system components running on control plane and node pool nodes.\n\nGKE on AWS includes a\n[Fluentbit](https://fluentbit.io/)-based logging agent. On the\ncontrol plane nodes, the logging agent runs as a system component; on the\nnode pool nodes, it runs as a Daemonset. Data collected by the\nlogging agents can be managed and deleted like any other metric and log\ndata, as described in\n[Cloud Logging](/logging/docs/reference/tools/gcloud-logging#deleting_logs)\ndocumentation.\n\n\u003cbr /\u003e\n\nWhat data is collected\n----------------------\n\nGKE on AWS logs the following information:\n\n- Logs for system components on each of the control plane replica.\n- Logs for system services on each of the node pool nodes.\n- Optionally, logs for workloads\n\nEnable workload logging\n-----------------------\n\nTo enable workload logging, you must create a new Kubernetes cluster, version\n1.22 or later.\n\nBy default, when you create a cluster GKE on AWS enables system\nlogging. To enable workload logging, you must create a\ncluster with the `--logging` flag. You can choose to enable logging for system\ncomponents, workloads, or both.\n\nFor example, to enable both system and workload logging on a new cluster,\nfollow the instructions\nto [create a cluster](/kubernetes-engine/multi-cloud/docs/aws/how-to/create-cluster), but\ninclude the `--logging` flag in your `gcloud` command: \n\n```sh,devsite-disable-click-to-copy\ngcloud container aws clusters create CLUSTER_NAME\n...\n--logging=SYSTEM,WORKLOAD\n```\n\nor to [update an existing cluster](/kubernetes-engine/multi-cloud/docs/aws/how-to/update-cluster): \n\n```sh,devsite-disable-click-to-copy\ngcloud container aws clusters update CLUSTER_NAME\n...\n--logging=SYSTEM,WORKLOAD\n```\n\nAccess your logs\n----------------\n\nThere are several ways to access your GKE on AWS 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 on AWS:\n\nWhen GKE on AWS 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#### Control Plane logs\n\nControl plane logs use the `k8s_control_plane_component` resource type. These\ninclude logs from system components running on the control plane replicas, such\nas\n[`kube-apiserver`](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/).\n\n\n#### Node logs\n\nNode logs fall under the `k8s_node` resource type. These include logs from\ncritical system component running on the worker nodes, such as\n[`kubelet`](https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet)\nand [`containerd`](https://containerd.io/).\n\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 on AWS.\nSpecifically, containers running in the following namespaces are included:\n\n- `kube-system`\n\n\u003c!-- --\u003e\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 on AWS 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 `kube-apiserver` on control plane nodes for an\nAWS cluster \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: \n\n resource.type=\"k8s_control_plane_component\"\n resource.labels.cluster_name=\"awsClusters/\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\"\n resource.labels.component_name=\"apiserver\"\n\nExample 2: Get the logs of `kubelet` on worker nodes for an AWS\ncluster \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: \n\n resource.type=\"k8s_node\"\n resource.labels.cluster_name=\"awsClusters/\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\"\n log_name=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/kubelet\"\n\nExample 3: Get the logs of the `cilium-agent` container for an\nAWS cluster \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: \n\n resource.type=\"k8s_container\"\n resource.labels.cluster_name=\"awsClusters/\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\"\n resource.labels.container_name=\"cilium-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)"]]