Cloud SQL은 데이터베이스 성능을 모니터링, 식별, 문제 해결하기 위해 XEvents 사용을 지원합니다. 이를 위해 XEvent 세션을 만들고 XEvent 출력 파일을 읽습니다. 인스턴스에서 또는 Cloud Storage 버킷에서 XEvent 파일을 다운로드하여 XEvent 출력 파일을 읽을 수 있습니다.
시작하기 전에
XEvent 파일을 Cloud Storage 버킷에 업로드하려면 Google Cloud 계정에서 버킷을 만듭니다.
권장사항
리전 간 큰 파일을 전송하지 않도록 방지하려면 다음 중 하나를 수행하는 것이 좋습니다.
멀티 리전 Cloud Storage 버킷 만들기
인스턴스와 동일한 리전에서 대상 Cloud Storage 버킷 설정
XEvents를 사용하기 전에 스토리지 자동 증가를 사용 설정합니다. XEvent 출력 파일은 총 크기 및 보관 간격에 따라 상당한 디스크 공간이 필요할 수 있습니다.
너무 많은 XEvent 파일이 장시간 보관되지 않도록 방지하려면 Cloud Storage 버킷에 대해 데이터 보관 정책을 설정합니다.
SSMS UI를 사용하여 XEvent 세션을 만들었지만 입력 값의 일부 상자가 표시되지 않는 경우 XEvent 세션 만들기 창의 크기를 조절합니다.
이벤트가 대상으로 전송되기 전에 이벤트 디스패치 큐에 남아 있을 수 있는 최대 시간(초)을 지정합니다.
최소 1초
최대 30초
MAX_EVENT_SIZE
각 이벤트의 최대 크기(바이트)를 설정합니다.
최소 4MB
최대 8MB
XEvent 세션 구성 매개변수
다음 매개변수를 커스텀 플래그로 사용하여 XEvent 세션을 구성할 수 있습니다.
매개변수
설명
cloud sql xe bucket name
XEvent 세션 출력을 업로드할 Cloud Storage 버킷을 지정합니다. 지정되지 않은 경우 Cloud SQL은 XEvent 세션 출력 데이터를 Cloud Storage에 업로드하지 않습니다.
cloud sql xe output total disk size (mb)
모든 XEvent 세션의 출력을 위해 예약할 디스크 공간을 지정합니다. 지정하지 않으면 Cloud SQL에서 기본 디스크 공간인 512MB를 사용합니다. XEvent 출력 파일이 cloud sql xe output total disk size (mb) 값보다 더 많은 디스크 공간을 사용하면 Cloud SQL은 디스크에서 이러한 파일을 삭제합니다.
cloud sql xe file retention (mins)
XEvent 세션의 파일 대상으로 생성된 파일의 인스턴스에 대한 보관 기간을 분 단위로 지정합니다. 지정하지 않으면 Cloud SQL은 기본값인 7일을 사용합니다.
cloud sql xe upload interval (mins)
Cloud Storage에 업로드되는 XEvent 파일의 업로드 간격을 지정합니다. 지정하지 않으면 Cloud SQL에서 기본값인 10분을 사용합니다.
Cloud Storage 버킷에서 XEvent 출력 파일을 읽으려면 버킷에서 SQL Server 인스턴스로 파일을 다운로드합니다. 다음 인스턴스 중 하나에서 다운로드할 수 있습니다.
Compute Engine Windows 인스턴스
Compute Engine Linux 인스턴스
SQL Server를 실행하는 다른 유형의 인스턴스
그런 다음 버킷의 XEvent 출력 파일을 로컬 디스크와 같이 해당 인스턴스에 액세스할 수 있는 위치로 전송합니다. 그런 다음 XEvent 출력 파일에서 정보를 반환하기 위해 서버에 대해 VIEW SERVER STATE 권한이 있는 계정으로 sys.fn_xe_file_target_read_file 함수를 실행합니다. 권한에 대한 자세한 내용은 권한을 참조하세요.
[[["이해하기 쉬움","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-09(UTC)"],[],[],null,["# Analyze database performance with Extended Events\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis page describes how to use [Extended Events (XEvents)](https://learn.microsoft.com/en-us/sql/relational-databases/extended-events/extended-events?view=sql-server-ver16)\non your instances.\n\nCloud SQL supports using XEvents for monitoring, identifying, and troubleshooting the\nperformance of your database. To do this, you create XEvent sessions and read XEvent output files. You can read the XEvent output files either on the instance or by downloading the XEvent files from a Cloud Storage bucket.\n\nBefore you begin\n----------------\n\nIf you want to upload your XEvent files to a Cloud Storage bucket, then [create a bucket](/storage/docs/creating-buckets) in your Google Cloud account.\n| **Note:** You need to manage log retention in the Cloud Storage bucket. For information about adding a retention policy to specify a retention period, see [Retention policies and retention policy locks](/storage/docs/bucket-lock).\n\nBest practices\n--------------\n\n- To avoid transferring large files across regions, we recommend that you do one of the following:\n - Create multi-regional Cloud Storage buckets\n - Set up the destination Cloud Storage bucket in the same region as the instance\n- Before using XEvents, enable [automatic storage increases](/sql/docs/sqlserver/instance-settings#automatic-storage-increase-2ndgen). XEvent output files, depending on their total size and retention intervals, might need significant disk space.\n- To avoid retaining too many XEvent files for a long time, set up a data retention policy for your Cloud Storage bucket.\n- If you create an XEvent session by using the SSMS UI, but some boxes for input values don't appear, then resize the **Create XEvent Session** window.\n\nHow to create XEvent sessions\n-----------------------------\n\nXEvents is enabled on your instances automatically.\n\nUse the [`CREATE EVENT SESSION`](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-event-session-transact-sql?view=sql-server-ver16)\ncommand to define new XEvent sessions. You also can use the user interface of\n[SQL Server Management Studio (SSMS)](https://learn.microsoft.com/en-us/sql/ssms/sql-server-management-studio-ssms?view=sql-server-ver15) to create XEvent sessions.\n\nCloud SQL enforces the following parameters for all XEvent sessions:\n\n### XEvent session configuration parameters\n\nYou can configure XEvent sessions by using the following parameters as custom flags:\n\nFor more information about setting these flags, see [Configure database flags](/sql/docs/sqlserver/flags).\n\nHow to read XEvent session output files\n---------------------------------------\n\nYou can read XEvent session output files from either a Cloud SQL instance or a Cloud Storage bucket.\n\n### Read XEvent output files from an instance\n\nTo retrieve the data from an XEvent file that an XEvent session creates, use the [`sys.fn_xe_file_target_read_file`](https://learn.microsoft.com/en-us/sql/relational-databases/system-functions/sys-fn-xe-file-target-read-file-transact-sql?view=sql-server-ver16) function.\n\nHere's an example: \n\n SELECT * FROM sys.fn_xe_file_target_read_file('/var/opt/mssql/xevents/filename*, NULL, NULL, NULL);\n\n### Read XEvent output files from a bucket\n\nTo read XEvent output files from a Cloud Storage bucket, download the files from the bucket to a SQL Server instance. You can download from one of the following instances:\n\n- A Compute Engine Windows instance\n- A Compute Engine Linux instance\n- Another type of instance that runs SQL Server\n\nThen, transfer the XEvent output files from the bucket to a location accessible to\nthat instance, such as its local disk. Next, to return information from the XEvent\noutput file, run the [`sys.fn_xe_file_target_read_file`](https://learn.microsoft.com/en-us/sql/relational-databases/system-functions/sys-fn-xe-file-target-read-file-transact-sql?view=sql-server-ver16) function with an account that has the\n`VIEW SERVER STATE` permission on the server. For more information about permissions, see\n[Permissions](https://learn.microsoft.com/en-us/sql/relational-databases/security/permissions-database-engine?view=sql-server-ver16#sql-server-permissions.).\n\nMonitoring metrics\n------------------\n\nYou can monitor the following xevent-related operations as part of the\n[Cloud SQL metrics](/sql/docs/sqlserver/admin-api/metrics),\navailable through\n[Metrics Explorer](https://cloud.google.com/monitoring/charts/metrics-explorer):\n\n- **database/sqlserver/xevents_upload_count**: indicates the total of the successful and failed xevent file upload attempts. Check this metric to monitor if your uploads were successful.\n- **database/sqlserver/xevents_size.**: indicates how much disk space is used by xevent files stored on the instance, in bytes.\n\nMonitor XEvent sessions\n-----------------------\n\nYou can monitor XEvent session-related activities through the `xevents.log` file for the following operations:\n\n- The XEvent output files removed from the disk, which were not uploaded to Cloud Storage and were occupying disk space higher than the value associated with `cloud sql xe output total disk size (mb)`.\n- The XEvent output files removed from the disk, which were not uploaded to Cloud Storage and are older than the value associated with `cloud sql xe file retention`.\n\nConsiderations for read replicas\n--------------------------------\n\nThis section contains information about XEvent sessions for new and existing read replicas.\n\n### For new read replicas\n\n- All XEvent session configuration parameters that are passed through database flags on the original instance are available on the newly created read replica.\n- All XEvent sessions present on the original instance when the read replicas are created are available on the read replica. Note that XEvent sessions on the read replica need to be started manually, unless they're configured to start automatically. For more information, see [How to create XEvent sessions](#how_to_create_xevent_sessions).\n- If you clone a primary instance, then any database flags that appear on the primary instance are propagated to the cloned instance. Also, you must grant permissions to the service account of the cloned instance to access the Cloud Storage bucket again.\n\n### For existing read replicas\n\n- XEvent session configuration parameters passed through database flags to the original instance aren't propagated to read replicas.\n- XEvent sessions created on the original instance aren't propagated to read replicas.\n\n| **Note:** If an XEvent session is created on a read replica, but the replica is recreated after the session is created, then the session no longer appears on the replica."]]