모니터링과 로깅은 클라우드에서 안정적인 애플리케이션을 실행하는 데 있어 매우 중요합니다. 특히 워크로드에 워크로드가 많거나 작업에 중요하다면 BigQuery 워크로드 또한 마찬가지입니다. 이 문서에서는 BigQuery에 사용할 수 있는 모니터링 데이터의 대략적인 개요를 제공합니다.
모니터링 및 로깅 소스는 샘플링 또는 집계 빈도에 따라 다를 수 있습니다. 예를 들어 정보 스키마 데이터가 Cloud Monitoring 측정항목 데이터보다 높은 세분화 수준으로 사용될 수 있습니다.
이 경우 세분화 수준이 낮은 측정항목의 그래프가 유사한 정보 스키마 통계와 다르게 표시될 수 있습니다. 집계에는 불일치를 완화하는 경향이 있습니다. 모니터링 솔루션을 설계할 때 요구사항을 기준으로 측정항목의 요청 응답 시간, 정밀도, 정확성을 평가합니다.
측정항목
측정항목은 일정한 간격으로 수집되어 분석에 사용할 수 있는 숫자 값입니다. 측정항목을 사용하여 다음을 수행할 수 있습니다.
차트 및 대시보드를 만듭니다.
사람이 개입해야 하는 조건 또는 상황에 대한 알림을 트리거합니다.
이전 실적을 분석합니다.
BigQuery의 경우 사용 가능한 측정항목으로 실행 중인 작업 수, 쿼리 중 스캔한 바이트 수, 쿼리 시간 분포가 있습니다. 쿼리의 측정항목은 쿼리가 성공한 후에만 사용할 수 있으며, 보고되는 데 최대 7분이 소요될 수 있습니다. 실패한 쿼리에 대한 측정항목은 보고되지 않습니다. 샘플링 레이트, 공개 상태, 제한사항을 포함하여 사용 가능한 측정항목의 전체 목록은 Google Cloud 측정항목 아래의 bigquery를 참고하세요.
Cloud Monitoring을 사용하여 BigQuery 측정항목을 보고 차트와 알림을 만들 수 있습니다. 각 측정항목에는 bigquery_dataset, bigquery_project 또는 global와 같은 리소스 유형과 라벨 집합이 포함됩니다. 이 정보를 사용하여 MQL(Monitoring 쿼리 언어)로 쿼리를 작성합니다.
라벨을 사용하여 각 측정항목을 그룹화하거나 필터링할 수 있습니다.
예를 들어 전송 중인 대화형 쿼리 수를 차트로 표시하려면 다음 priority를 interactive와 동일하게 필 MQL 문을 사용합니다.
로그는 특정 이벤트 또는 작업에 대한 응답으로 생성된 텍스트 레코드입니다. BigQuery는 테이블 만들기 또는 삭제, 슬롯 구매, 로드 작업 실행과 같은 작업 로그 항목을 만듭니다. Google Cloud로깅에 대한 자세한 내용은 Cloud Logging을 참조하세요.
로그는 로그 항목의 추가 전용 컬렉션입니다. 예를 들어 projects/PROJECT_ID/logs/my-test-log라는 로그에 자체 로그 항목을 작성할 수 있습니다. BigQuery를 비롯한 여러Google Cloud 서비스에서 감사 로그라는 로그 유형을 만듭니다. 이러한 로그는 다음을 기록합니다.
리소스 생성 또는 수정과 같은 관리 활동
데이터 액세스(예: 리소스에서 사용자가 제공한 데이터 읽기)
사용자 작업이 아니라 Google 시스템에서 생성하는 시스템 이벤트입니다.
감사 로그는 구조화된 JSON 형식으로 작성됩니다.Google Cloud 로그 항목의 기본 데이터 유형은 LogEntry 구조입니다. 이 구조에는 로그 이름, 로그 항목을 생성한 리소스, 타임스탬프(UTC), 기타 기본 정보가 포함됩니다.
로깅된 이벤트의 세부정보는 페이로드 필드라는 하위 필드에 포함됩니다. 감사 로그의 경우 페이로드 필드 이름은 protoPayload입니다. 이 필드의 값은 AuditLog 구조이며, protoPayload.@type 필드가 설정되어 있고 type.googleapis.com/google.cloud.audit.AuditLog를 엽니다.
데이터 세트, 테이블, 작업에 대한 작업의 경우 BigQuery는 두 가지 형식으로 감사 로그를 쓰는데 두 형식 모두 AuditLog 기본 유형을 공유합니다.
이전 형식:
resource.type 필드는 bigquery_resource입니다.
작업에 대한 세부정보는 protoPayload.serviceData 필드에 기록됩니다. 이 필드의 값은 AuditData 구조입니다.
새 형식:
resource.type 필드는 bigquery_project 또는 bigquery_dataset입니다.
bigquery_project 리소스에는 작업에 대한 로그 항목이 있는 반면 bigquery_dataset 리소스에는 스토리지에 대한 로그 항목이 있습니다.
최신 형식의 로그를 사용하는 것이 좋습니다. 자세한 내용은 감사 로그 이전 가이드를 참조하세요.
다음은 실패한 작업을 보여주는 로그 항목의 축약형 예입니다.
{"protoPayload":{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":5,"message":"Not found: Dataset my-project:my-dataset was not found in location US"},"authenticationInfo":{...},"requestMetadata":{...},"serviceName":"bigquery.googleapis.com","methodName":"google.cloud.bigquery.v2.JobService.InsertJob","metadata":{},"resource":{"type":"bigquery_project","labels":{..},},"severity":"ERROR","logName":"projects/my-project/logs/cloudaudit.googleapis.com%2Fdata_access",...}
이러한 뷰에는 작업, 데이터 세트, 테이블, 기타 BigQuery 항목의 메타데이터가 포함됩니다. 예를 들어 특정 기간 동안 실행된 BigQuery 작업에 대한 실시간 메타데이터를 가져온 다음 프로젝트, 사용자, 참조한 테이블, 기타 측정기준별로 결과를 그룹화하거나 필터링할 수 있습니다.
이 정보를 사용하여 BigQuery 워크로드에 대한 더 자세한 분석을 수행하고 다음과 같은 질문에 답할 수 있습니다.
조직의 슬롯과 예약 사용률, 작업 실행과 작업 오류를 보여주는 GitHub의 INFORMATION_SCHEMA 쿼리 예시를 확인할 수 있습니다. 예를 들어 다음 쿼리는 대기중이거나 실행 중인 쿼리 목록을 제공합니다. 이러한 쿼리는 us 리전에서 생성된 후 경과된 시간에 따라 정렬됩니다.
SELECT
creation_time,
project_id,
user_email,
job_id,
job_type,
priority,
state,
TIMESTAMP_DIFF(CURRENT_TIMESTAMP(), start_time,second) as running_time_sec
FROM
`region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE
creation_time BETWEEN TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY) AND CURRENT_TIMESTAMP()
AND state != "DONE"
ORDER BY
running_time_sec DESC
[[["이해하기 쉬움","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-08-26(UTC)"],[[["\u003cp\u003eMonitoring and logging are essential for managing BigQuery workloads, especially for high-volume or mission-critical applications, providing insights into performance and operational status.\u003c/p\u003e\n"],["\u003cp\u003eBigQuery metrics, collected at regular intervals, include job counts, bytes scanned, and query time distributions, although they are only available after successful query completion and may take up to seven minutes to appear.\u003c/p\u003e\n"],["\u003cp\u003eBigQuery logs capture actions like table creation, slot purchases, and job executions, including audit logs for administrative activity, data access, and system events, which are available in older and newer formats with differing resource types.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eINFORMATION_SCHEMA\u003c/code\u003e views in BigQuery offer metadata on jobs, datasets, and tables, enabling detailed analysis of workloads through queries that can track slot utilization, user activity, and streaming errors.\u003c/p\u003e\n"],["\u003cp\u003eCloud monitoring can be used to track metrics and create charts and alerts for different types of resources such as \u003ccode\u003ebigquery_dataset\u003c/code\u003e, \u003ccode\u003ebigquery_project\u003c/code\u003e or \u003ccode\u003eglobal\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Introduction to BigQuery monitoring\n===================================\n\nMonitoring and logging are crucial for running reliable applications in the\ncloud. BigQuery workloads are no exception, especially if your workload\nhas high volumes or is mission critical. This document provides a high-level\noverview of the monitoring data that is available for BigQuery.\n\nMonitoring and logging sources can vary based on the frequency of sampling or\naggregation. For example, information schema data might be available at a\nhigher level of granularity than Cloud Monitoring metrics data.\n\nAs a result, graphs of metrics with lower granularity might appear to diverge\nfrom comparable information schema statistics. Aggregation will tend to smooth\nout the discrepancies. When you design a monitoring solution, assess the\nrequest response time, precision, and accuracy of the metrics against your\nrequirements.\n\nMetrics\n-------\n\nMetrics are numerical values that are collected at regular\nintervals and made available for analysis. You can use metrics to:\n\n- Create charts and dashboards.\n- Trigger alerts for conditions or situations that need human intervention.\n- Analyze historical performance.\n\nIn the case of BigQuery, the available metrics include the number\nof jobs that are running, how many bytes were scanned during a query, and the\ndistribution of query times. The metrics for a query only\nbecome available after the query succeeds and can take up to seven minutes to be\nreported. Metrics for queries that fail are not reported. For a complete list of\navailable metrics including their sample rates, visibility, and limitations, see\n[`bigquery`](/monitoring/api/metrics_gcp_a_b#gcp-bigquery) under\n[Google Cloud metrics](/monitoring/api/metrics_gcp).\n\nUse [Cloud Monitoring](/monitoring/docs) to view BigQuery\nmetrics and create charts and alerts. Each metric has a resource type, either\n`bigquery_dataset`, `bigquery_project`, or `global`, and a set of labels. You\ncan group or filter each metric by using the labels.\n\nFor example, to chart the number of interactive queries in flight, use the\nfollowing PromQL statement, which filters by `priority` equal to `interactive`: \n\n {\"bigquery.googleapis.com/query/count\", monitored_resource=\"global\", priority=\"interactive\"}\n\nThe next example gets the number of load jobs in flight, grouped into 10-minute\nintervals: \n\n avg_over_time({\"bigquery.googleapis.com/job/num_in_flight\",\n monitored_resource=\"bigquery_project\",\n job_type=\"load\"\n }[10m])\n\nFor more information, see\n[Creating charts and alerts for BigQuery](/bigquery/docs/monitoring-dashboard).\n\nLogs\n----\n\nLogs are text records that are generated in response to particular events or\nactions. BigQuery creates log entries for actions such as\ncreating or deleting a table, purchasing slots, or running a load job. For more\ninformation about logging in Google Cloud, see\n[Cloud Logging](/logging/docs).\n\nA log is an append-only collection of log entries. For example, you could write\nyour own log entries to a log named\n`projects/`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`/logs/my-test-log`. Many\nGoogle Cloud services, including BigQuery, create a type of\nlog called [audit logs](/logging/docs/audit). These logs record:\n\n- Administrative activity, such as creating or modifying resources.\n- Data access, such as reading user-provided data from a resource.\n- System events that are generated by Google systems, rather than by user actions.\n\nAudit logs are written in a structured JSON format. The base data type for\nGoogle Cloud log entries is the\n[`LogEntry`](/logging/docs/reference/v2/rest/v2/LogEntry) structure. This\nstructure contains the name of the log, the resource that generated the log\nentry, the timestamp (UTC), and other basic information.\n\nThe details of the logged event are contained in a subfield called the *payload*\nfield. For audit logs, the payload field is named `protoPayload`. The value of\nthis field is an\n[`AuditLog`](/logging/docs/reference/audit/auditlog/rest/Shared.Types/AuditLog)\nstructure, indicated by the value of the `protoPayload.@type` field, which is\nset to `type.googleapis.com/google.cloud.audit.AuditLog`.\n\nFor operations on datasets, tables, and jobs, BigQuery writes\naudit logs in two different formats, although both share the `AuditLog` base\ntype.\n\nIn the older format:\n\n- The `resource.type` field is `bigquery_resource`.\n- Details about the operation are written to the `protoPayload.serviceData` field. The value of this field is an [`AuditData`](/bigquery/docs/reference/auditlogs/rest/Shared.Types/AuditData) structure.\n\nIn the newer format:\n\n- The `resource.type` field is either `bigquery_project` or `bigquery_dataset`. The `bigquery_project` resource has log entries about jobs, while the `bigquery_dataset` resource has log entries about storage.\n- Details about the operation are written to the `protoPayload.metadata` field. The value of this field is a [`BigQueryAuditMetadata`](/bigquery/docs/reference/auditlogs/rest/Shared.Types/BigQueryAuditMetadata) structure.\n\nWe recommend consuming logs in the newer format. For more information, see\n[Audit logs migration guide](/bigquery/docs/reference/auditlogs/migration).\n\nHere is an abbreviated example of a log entry that shows a failed operation: \n\n {\n \"protoPayload\": {\n \"@type\": \"type.googleapis.com/google.cloud.audit.AuditLog\",\n \"status\": {\n \"code\": 5,\n \"message\": \"Not found: Dataset my-project:my-dataset was not found in location US\"\n },\n \"authenticationInfo\": { ... },\n \"requestMetadata\": { ... },\n \"serviceName\": \"bigquery.googleapis.com\",\n \"methodName\": \"google.cloud.bigquery.v2.JobService.InsertJob\",\n \"metadata\": {\n },\n \"resource\": {\n \"type\": \"bigquery_project\",\n \"labels\": { .. },\n },\n \"severity\": \"ERROR\",\n \"logName\": \"projects/my-project/logs/cloudaudit.googleapis.com%2Fdata_access\",\n ...\n }\n\nFor operations on BigQuery Reservations, the `protoPayload` is an\n[`AuditLog`](/logging/docs/reference/audit/auditlog/rest/Shared.Types/AuditLog)\nstructure, and the `protoPayload.request` and `protoPayload.response` fields\ncontain more information. You can find the field definitions in\n[BigQuery Reservation API](/bigquery/docs/reference/reservations/rpc). For more\ninformation, see\n[Monitoring BigQuery Reservations](/bigquery/docs/reservations-monitoring).\n\nBigQuery `INFORMATION_SCHEMA` views\n-----------------------------------\n\n[`INFORMATION_SCHEMA`](/bigquery/docs/information-schema-intro) views are\nanother source of insights in BigQuery, which you can use in\nconjunction with metrics and logs.\n\nThese views contain metadata about jobs, datasets, tables, and other\nBigQuery entities. For example, you can get real-time metadata\nabout which BigQuery jobs ran over a specified time period, and\nthen group or filter the results by project, user, tables referenced, and other\ndimensions.\n\nYou can use this information to perform more detailed analysis about your\nBigQuery workloads, and answer questions like:\n\n- What is the average slot utilization for all queries over the past 7 days for a given project?\n- Which users submitted a batch load job for a given project?\n- What streaming errors occurred in the past 30 minutes, grouped by error code?\n\nIn particular, look at [jobs metadata](/bigquery/docs/information-schema-jobs),\n[streaming metadata](/bigquery/docs/information-schema-streaming), and\n[reservations metadata](/bigquery/docs/information-schema-reservations) to\nget insights into the performance of your BigQuery workloads.\n\nYou can find [example `INFORMATION_SCHEMA` queries on\nGitHub](https://github.com/GoogleCloudPlatform/bigquery-utils/tree/master/dashboards/system_tables)\nthat show an organization's slot and reservation utilization, job execution,\nand job errors. For example, the following query provides a list of\nqueries that are either pending or running. These queries are ordered\nby the length of time since they were created in the `us` region: \n\n```\nSELECT\n creation_time,\n project_id,\n user_email,\n job_id,\n job_type,\n priority,\n state,\n TIMESTAMP_DIFF(CURRENT_TIMESTAMP(), start_time,second) as running_time_sec\n FROM\n `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT\n WHERE\n creation_time BETWEEN TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 DAY) AND CURRENT_TIMESTAMP()\n AND state != \"DONE\"\nORDER BY\n running_time_sec DESC\n```\n\nFor more information, see [Troubleshoot BigQuery performance with\nthese dashboards](https://cloud.google.com/blog/products/data-analytics/troubleshoot-bigquery-performance-with-these-dashboards).\n\nIf you have slot reservations, then in addition to writing your own query, you\ncan use BigQuery Admin Resource Charts to view charts that\ndisplay slot usage, job concurrency, and job run time. For more information, see\n[Monitor health, resource utilization, and jobs](/bigquery/docs/admin-resource-charts).\n\nWhat's next\n-----------\n\n- Learn how to [monitor resource utilization and jobs](/bigquery/docs/admin-resource-charts).\n- Learn how to [create charts and alerts for BigQuery](/bigquery/docs/monitoring-dashboard)."]]