Pub/Sub와 관련된 모든 감사 로그를 표시하려면 쿼리 편집기 필드에 다음 쿼리를 입력합니다.
protoPayload.serviceName="pubsub.googleapis.com"
그림 1 쿼리를 입력합니다.
쿼리 실행을 클릭합니다.
특정 리소스 및 감사 로그 유형에 대한 감사 로그를 표시하려면 쿼리 빌더 창에서 다음을 수행합니다.
모든 리소스의 경우 감사 로그를 확인할 Google Cloud 리소스를 선택합니다. 예를 들어 Cloud Pub/Sub 주제를 선택한 다음 주제 이름을 선택합니다.
모든 로그 이름에서 확인할 감사 로그 유형을 선택합니다.
예를 들면 다음과 같습니다.
관리자 활동 감사 로그의 경우 activity를 선택합니다.
시스템 이벤트 감사 로그의 경우 system_event를 선택합니다.
쿼리가 자동으로 실행됩니다.
감사 로그를 사용하여 Pub/Sub 문제를 해결하는 방법
조사 중인 구체적인 문제를 파악합니다. 다음은 발생할 수 있는 문제 목록입니다.
주제, 구독, 스냅샷 또는 스키마를 생성, 삭제 또는 수정한 사용자를 식별합니다.
주제 또는 구독 설정의 변경사항을 추적합니다.
주제 또는 구독이 있는지, 현재 상태가 무엇인지 확인합니다.
하지만 감사 로그를 사용하여 메일 게시 및 전송과 관련된 문제를 해결할 수는 없습니다. 메시지 전송 실패, 메시지 중복, 메시지 순서 문제에 대한 로그는 표시되지 않습니다. 또한 감사 로그는 느린 구독자 또는 메시지 확인 관련 문제를 식별하는 데 도움이 되지 않습니다.
메시지 수준 문제를 해결하려면 모니터링 측정항목, 데드 레터 큐, 애플리케이션 로그와 같은 다른 도구를 사용해야 합니다.
문제에 따라 감사 로그를 필터링하는 쿼리를 작성합니다.
예를 들어 구독을 삭제한 사용자를 찾으려면 protoPayload.methodName="google.pubsub.v1.Publisher.DeleteSubscription"로 필터링합니다.
구독 생성 시 발생할 수 있는 오류를 조사하려면 protoPayload.methodName="google.pubsub.v1.Subscriber.CreateSubscription"로 필터링합니다.
로그 항목의 타임스탬프, 사용자, 리소스 이름을 검토하여 이벤트의 순서를 파악하고 이상치를 식별합니다.
Pub/Sub의 감사 로그 쿼리를 구성하는 방법에 관한 자세한 내용은 감사 로깅을 참고하세요.
[[["이해하기 쉬움","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-09-04(UTC)"],[],[],null,["Pub/Sub generates audit logs that capture administrative\nand access activities of Pub/Sub resources. Some examples of\nthese activities include creating a topic, updating a subscription, or\ndeleting a snapshot. You can use these logs for troubleshooting issues\nand ensuring the security of your messaging infrastructure.\n\nHere are some important points to remember regarding audit logs in\nPub/Sub:\n\n- Pub/Sub audit logs use the service name `pubsub.googleapis.com`.\n\n- Pub/Sub has different types of logs. These include the following:\n\n - Admin activity logs record actions like creating, deleting, or updating\n topics and subscriptions.\n\n - Data access logs record actions like retrieving a topic or listing\n subscriptions.\n\n - System event logs record events like removing inactive\n subscriptions.\n\n- Pub/Sub does not log message operations like publishing,\n subscribing, or acknowledging messages.\n\nFor more information about audit logs for\nPub/Sub, see [Audit logging](/pubsub/docs/audit-logging).\n\nView Pub/Sub audit logs\n\n**Logs Explorer** provides a centralized location to access all your log data\nwithin Google Cloud. You can use **Logs Explorer** to view Pub/Sub logs.\n\n1. Get the required permissions to view **Logs Explorer**.\n\n For more information, see [Before you begin](/logging/docs/view/logs-explorer-interface#before-you-begin).\n2. In the Google Cloud console, go to the **Logs Explorer** page.\n\n [Go to Logs Explorer](https://console.cloud.google.com/logs)\n3. Select an existing Google Cloud project, folder, or organization.\n\n4. To display all audit logs related to Pub/Sub, enter the\n following query into the query-editor field:\n\n protoPayload.serviceName=\"pubsub.googleapis.com\"\n\n **Figure 1** Enter a query.\n5. Click **Run query**.\n\n6. To display the audit logs for a specific resource and audit log type,\n in the Query builder pane, do the following:\n\n 1. For **All resources** , select the Google Cloud resource whose\n audit logs you want to see. For example, select **Cloud Pub/Sub Topic** and then\n select the topic name.\n\n 2. For **All log names**, select the audit log type that you want to see.\n\n For example:\n - For Admin activity audit logs, select enter `activity`.\n\n - For System event audit logs, select `system_event`.\n\nThe query runs automatically.\n\nHow to use audit logs to troubleshoot Pub/Sub issues\n\n1. Determine the specific problem that you're investigating. Here is a list of\n potential issues:\n\n - Identify who created, deleted, or modified topics, subscriptions, snapshots,\n or schemas.\n\n - Track changes to topic or subscription settings.\n\n - Verify if a topic or subscription exists and its current status.\n\n However, you cannot use audit logs to troubleshoot issues related to message\n publishing and delivery. You won't find logs for message delivery failures,\n message duplication, or message ordering problems. Audit logs also won't help\n you identify slow subscribers or issues with message acknowledgments.\n For troubleshooting message-level issues, you'll need to rely on other tools\n like monitoring metrics, dead-letter queues, and application logs.\n2. Based on the issue, construct a query to filter the audit logs.\n For example, to find out who deleted a subscription, filter by\n `protoPayload.methodName=\"google.pubsub.v1.Publisher.DeleteSubscription\"`.\n\n To investigate a potential error with creating a subscription, filter by\n `protoPayload.methodName=\"google.pubsub.v1.Subscriber.CreateSubscription\"`.\n3. Examine the timestamps, principals, and resource names in the log entries\n to understand the sequence of events and identify any anomalies.\n\nFor more information on how to construct an audit log query for\nPub/Sub, see [Audit logging](/pubsub/docs/audit-logging)."]]