쿼리 빌더를 사용하여 쿼리를 작성할 수도 있습니다. 네트워크 정책 로그를 쿼리하려면 로그 이름 드롭다운 목록에서 policy-action을 선택합니다. 사용 가능한 로그가 없으면 드롭다운 목록에 policy-action이 표시되지 않습니다.
네트워크 정책 로그에 대한 로컬 액세스
노드의 파일 시스템에 액세스할 수 있으면 로컬 파일 /var/log/network/policy_action.log*의 각 노드에서 네트워크 정책 로그를 사용할 수 있습니다. 현재 로그 파일이 10MB에 도달하면 노드가 로그 파일을 순환합니다. 최대 5개의 이전 로그 파일이 저장됩니다.
[[["이해하기 쉬움","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(UTC)"],[],[],null,["# Use network policy logging\n==========================\n\nThis page explains how to enable network policy logging in an\nGKE cluster and how to export logs.\n\nOverview\n--------\n\n[Network policies](https://kubernetes.io/docs/concepts/services-networking/network-policies/)\nare Pod-level firewalls; they specify the network traffic that Pods are allowed\nto send and receive. Network policy logs record network policy events. You can\nlog all events or you can choose to log events based on the following criteria:\n\n- Allowed connections.\n- Denied connections.\n- Connections allowed by specific policies.\n- Connections denied to Pods in specific namespaces.\n\nEnabling logging\n----------------\n\nNetwork policy logging is not enabled by default. For information on enabling\nlogging and selecting which events to log, see\n[Using network policy logging](/kubernetes-engine/docs/how-to/network-policy-logging)\nin the Google Kubernetes Engine documentation.\n\nAccessing logs\n--------------\n\nNetwork policy logs are automatically uploaded to [Cloud Logging](/logging/docs).\nYou can access logs through the Logs Explorer or with the Google Cloud CLI. You can also\n[export logs from Cloud Logging](/logging/docs/export) to the sink of your choice. \n\n### gcloud\n\n gcloud logging read --project \"\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e\" 'resource.type=\"k8s_node\" \\\n resource.labels.location=\"\u003cvar translate=\"no\"\u003eCLUSTER_LOCATION\u003c/var\u003e\" \\\n resource.labels.cluster_name=\"azureClusters/\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\" \\\n logName=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e/logs/policy-action\"'\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e: your Google Cloud project\n- \u003cvar translate=\"no\"\u003eCLUSTER_LOCATION\u003c/var\u003e: the Google Cloud location your cluster is managed from\n- \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of your cluster\n\n### Cloud Logging\n\n1. Go to the **Logs Explorer** page in Google Cloud console.\n\n [Go to Logs Explorer](https://console.cloud.google.com/logs/query)\n2. Click **Query builder**.\n\n3. Use the following query to find all network policy log records:\n\n resource.type=\"k8s_node\"\n resource.labels.location=\"\u003cvar translate=\"no\"\u003eCLUSTER_LOCATION\u003c/var\u003e\"\n resource.labels.cluster_name=\"azureClusters/\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\"\n logName=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e/logs/policy-action\"\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eCLUSTER_LOCATION\u003c/var\u003e: the Google Cloud location your cluster is managed from\n - \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of your cluster.\n - \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e: your Google Cloud project.\n\nTo learn how to use the Logs Explorer, see\n[Using the Logs Explorer](/logging/docs/view/logs-explorer-interface).\n\nYou can also build a query using the **Query builder** . To query for network\npolicy logs, select **policy-action** in the **Log name** drop-down list. If\nthere are no logs available, **policy-action** does not appear in the drop-\ndown list.\n\n### Local access to network policy logs\n\nIf you have access to a node's file system, network policy logs are available on\neach node in the local file `/var/log/network/policy_action.log*`. Nodes\nrotate log files when the current log file reaches 10 MB. Up to five previous\nlog files are stored.\n\nWhat's next\n-----------\n\n- Learn [how to configure network policy logging](/kubernetes-engine/docs/how-to/network-policy-logging)"]]