이 문서에서는 Google Cloud 콘솔을 사용하여 로그 항목을 쿼리, 확인, 분석하는 방법을 설명합니다. 사용 가능한 인터페이스로는 로그 탐색기와 로그 애널리틱스라는 두 가지 인터페이스가 있습니다. 두 인터페이스 중 무엇을 사용하던 로그를 쿼리, 확인, 분석할 수 있지만 두 인터페이스는 사용하는 쿼리 언어와 기능이 다릅니다.
로그 데이터의 문제 해결과 탐색 분석을 위해서는 로그 탐색기를 사용하는 것이 좋습니다. 통계와 트렌드를 생성하려면 로그 애널리틱스를 사용하는 것이 좋습니다.
Logging API 명령어를 실행하여 로그를 쿼리하고 쿼리를 저장할 수 있습니다.
또한 Google Cloud CLI를 사용하여 로그를 쿼리할 수도 있습니다.
로그 탐색기
로그 탐색기는 서비스 및 애플리케이션의 문제를 해결하고 성능을 분석할 수 있도록 설계되었습니다. 예를 들어 히스토그램에 오류율이 표시됩니다. 오류가 급증하거나 흥미로운 사항이 표시되면 해당 로그 항목을 찾아 볼 수 있습니다. 로그 항목이 오류 그룹과 연결되어 있는 경우, 해당 로그 항목에는 오류 그룹에 대한 자세한 정보에 액세스할 수 있는 옵션 메뉴가 주석으로 추가되어 있습니다.
Cloud Logging API, Google Cloud CLI, 로그 탐색기에서 같은 쿼리 언어가 지원됩니다.
로그 탐색기를 사용할 때 쿼리 구성을 간소화하려면 메뉴를 사용하거나, 텍스트를 입력하거나, 경우에 따라 개별 로그 항목의 디스플레이에 포함된 옵션을 사용하여 쿼리를 빌드할 수 있습니다.
로그 탐색기에서는 특정 패턴이 포함된 로그 항목 수 계산과 같은 집계 작업을 지원하지 않습니다.
집계 작업을 수행하려면 로그 버킷에서 분석을 사용 설정한 후 로그 애널리틱스를 사용합니다.
로그 애널리틱스를 사용하면 로그 데이터를 분석하는 쿼리를 실행한 후 쿼리 결과를 보거나 차트로 표시할 수 있습니다. 차트를 사용하면 시간 경과에 따른 로그의 패턴과 추세를 식별할 수 있습니다. 다음 스크린샷은 로그 애널리틱스의 차트 기능을 보여줍니다.
예를 들어 문제를 해결하면서 시간 경과에 따라 특정 URL에 발생한 HTTP 요청의 평균 지연 시간을 알고 싶은 경우를 가정해보세요.
로그 애널리틱스를 사용하도록 로그 버킷을 업그레이드하면 SQL 쿼리를 사용하여 로그 버킷에 저장된 로그를 쿼리할 수 있습니다.
이러한 SQL 쿼리에는 파이프 문법도 포함될 수 있습니다.
로그를 그룹화하고 집계하면 로그 데이터에서 유용한 정보를 얻을 수 있으므로 문제 해결에 소요되는 시간을 줄일 수 있습니다.
로그 애널리틱스를 사용하면 로그 뷰 또는 분석 뷰를 쿼리할 수 있습니다. 로그 뷰에는 LogEntry 데이터 구조에 해당하는 고정 스키마가 있습니다.
분석 뷰의 작성자가 스키마를 결정하므로 분석 뷰의 한 가지 사용 사례는 로그 데이터를 LogEntry 형식에서 더 적합한 형식으로 변환하는 것입니다.
BigQuery를 사용하여 데이터를 쿼리할 수도 있습니다. 예를 들어 BigQuery를 사용하여 로그의 URL을 알려진 악성 URL의 공개 데이터 세트와 비교한다고 가정해 보겠습니다. 로그 데이터를 BigQuery에 표시하려면 로그 애널리틱스를 사용하도록 버킷을 업그레이드한 후 연결된 데이터 세트를 만듭니다.
로그 탐색기를 사용하면 문제를 해결하고 업그레이드된 로그 버킷의 개별 로그 항목을 볼 수 있습니다.
제한사항
로그 애널리틱스를 사용하도록 기존 로그 버킷을 업그레이드하려면 다음 제한사항이 적용됩니다.
로그 애널리틱스를 사용하도록 업그레이드된 로그 버킷에서는 로그 애널리틱스 지원을 삭제할 수 없습니다.
업그레이드가 완료된 후 작성된 로그 항목만 분석에 사용할 수 있습니다.
로그 버킷에 필드 수준 액세스 제어가 구성된 경우 로그 애널리틱스 페이지를 사용하여 로그 뷰를 쿼리할 수 없습니다.
하지만 로그 탐색기 페이지를 통해 쿼리를 실행하고 연결된 BigQuery 데이터 세트를 쿼리할 수 있습니다.
BigQuery는 필드 수준 액세스 제어를 따르지 않으므로 연결된 데이터 세트를 쿼리하면 로그 항목의 모든 필드를 쿼리할 수 있습니다.
다양한 Cloud KMS 키로 구성된 로그 버킷 여러 개를 쿼리하는 경우 다음 제약 조건이 충족되지 않으면 쿼리가 실패합니다.
이전 제약조건이 충족되면 상위 요소의 Cloud KMS 키가 로그 애널리틱스 쿼리에서 생성된 임시 데이터를 암호화합니다.
쿼리가 실행되기 전에 중복 로그 항목이 삭제되지 않습니다. 이 동작은 로그 이름, 타임스탬프, 삽입 ID 필드를 비교하여 중복 항목을 삭제하는 로그 탐색기를 사용하여 로그 항목을 쿼리할 때와 다릅니다. 자세한 내용은 문제 해결: 로그 애널리틱스 결과에 중복 로그 항목이 있음을 참고하세요.
가격 책정
Cloud Logging은 로그를 지원되는 목적지로 라우팅하는 데 비용을 청구하지 않지만 목적지에 요금이 부과될 수 있습니다.
_Required 로그 버킷을 제외하면 Cloud Logging은 로그를 로그 버킷으로 스트리밍하고 로그 버킷의 기본 보관 기간보다 긴 스토리지에 대해 요금을 청구합니다.
Cloud Logging은 로그 복사, 로그 범위 생성 또는 분석 뷰 생성, 로그 탐색기나 로그 애널리틱스 페이지를 통해 실행되는 쿼리에 대해 요금을 부과하지 않습니다.
VPC 흐름 로그 생성 요금은 전송한 후 Cloud Logging에서 Virtual Private Cloud 흐름 로그를 제외할 때 적용됩니다.
로그 애널리틱스를 사용하도록 버킷을 업그레이드한 후 연결된 데이터 세트를 만들면 BigQuery 수집 또는 스토리지 비용이 발생하지 않습니다.
로그 버킷에 연결된 데이터 세트를 만들 때 로그 데이터를 BigQuery로 수집하지 않습니다. 대신 연결된 데이터 세트를 통해 로그 버킷에 저장된 로그 데이터에 대한 읽기 액세스 권한을 얻을 수 있습니다.
BigQuery 분석 요금은 BigQuery Studio 페이지, BigQuery API, BigQuery 명령줄 도구 사용을 포함하여 BigQuery 연결 데이터 세트에서 SQL 쿼리를 실행할 때 적용됩니다.
[[["이해하기 쉬움","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-04-22(UTC)"],[],[],null,["# Query and view log entries\n\nThis document describes how you query, view, and analyze log entries by using\nthe Google Cloud console. There are two interfaces available to you, the\nLogs Explorer and Log Analytics. You can query, view, and analyze\nlogs with both interfaces; however, they use different query languages and they\nhave different capabilities.\nFor troubleshooting and exploration of log data, we recommend using the\nLogs Explorer. To generate insights and trends, we recommend that you\nuse Log Analytics.\nYou can query your logs and save your queries by issuing\n[Logging API](/logging/docs/reference/v2/rest/v2/entries/list) commands.\nYou can also query your logs by using\n[Google Cloud CLI](/logging/docs/api/gcloud-logging#reading_log_entries).\n\nLogs Explorer\n-------------\n\nThe Logs Explorer is designed to help you troubleshoot and analyze the\nperformance of your services and applications. For example, a histogram\ndisplays the rate of errors. If you see a spike in errors or something that\nis interesting, you can locate and view the\ncorresponding log entries. When a log entry is associated with an\n[error group](/error-reporting/docs/grouping-errors), the log entry is\nannotated with a\nmenu of options that let you access more information about the error group.\n\nThe same [query language](/logging/docs/view/logging-query-language) is\nsupported by the Cloud Logging API, the Google Cloud CLI,\nand the Logs Explorer.\nTo simplify query construction when you are using the Logs Explorer, you can\n[build queries](/logging/docs/view/building-queries) by using menus, by\nentering text, and, in some cases, by using options included with the display\nof an individual log entry.\n\nThe Logs Explorer doesn't support aggregate operations,\nlike counting the number of log entries that contain a specific pattern.\nTo perform aggregate operations, enable analytics on the log bucket and then use\nLog Analytics.\n\nFor details about searching and viewing logs with the Logs Explorer, see\n[View logs by using the Logs Explorer](/logging/docs/view/logs-explorer-interface).\n\nLog Analytics\n-------------\n\nUsing Log Analytics, you can run queries that analyze your log data, and\nthen you can view or [chart the query results](/logging/docs/analyze/charts). Charts let\nyou identify patterns and trends in your logs over time. The following\nscreenshot illustrates the charting capabilities in Log Analytics:\n\nFor example, suppose that you are troubleshooting a problem and you want to\nknow the average latency for HTTP requests issued to a specific URL over time.\nWhen a log bucket is upgraded to use Log Analytics, you can write a\n[SQL](/bigquery/docs/reference/standard-sql/query-syntax) query or use the query builder to query logs stored in your log\nbucket.\n\nThese SQL queries can also include [pipe syntax](/bigquery/docs/pipe-syntax-guide).\nBy grouping and aggregating your logs, you can gain insights into your log\ndata which can help you reduce time spent troubleshooting.\n\nLog Analytics lets you query\n[log views](/logging/docs/logs-views) or an\n[analytics view](/logging/docs/analyze/about-analytics-views). Log views have a fixed schema which\ncorresponds to the [`LogEntry`](/logging/docs/reference/v2/rest/v2/LogEntry) data structure.\nBecause the creator of an analytics view determines the schema, one use\ncase for analytics views is to transform log data from the\n`LogEntry` format into a format that is more suitable for you.\n\nYou can also use [BigQuery](/bigquery/docs/introduction)\nto query your data. For example, suppose that you want to use\nBigQuery to compare URLs in your logs with a public dataset of\nknown malicious URLs. To make your log data visible to\nBigQuery, upgrade your bucket to use Log Analytics and then\n[create a linked dataset](/logging/docs/buckets#link-bq-dataset).\n\nYou can continue to troubleshoot issues and view individual log entries in\nupgraded log buckets by using the Logs Explorer.\n\n### Restrictions\n\n- To upgrade an existing log bucket to use Log Analytics, the following\n restrictions apply:\n\n - The log bucket was created at the Google Cloud project level.\n - The log bucket is [unlocked](/logging/docs/buckets#locking-logs-buckets) unless it is the `_Required` bucket.\n - There aren't pending updates to the bucket.\n- Log entries written before a bucket is upgraded aren't immediately available.\n However, when the backfill operation completes, you can analyze these log\n entries. The backfill process might take several hours.\n\n- You can't use the **Log Analytics** page to query log views when the log bucket\n has [field-level access controls](/logging/docs/field-level-acl) configured.\n However, you can issue queries\n through the **Logs Explorer** page, and you can query a\n [linked BigQuery dataset](/logging/docs/buckets#link-bq-dataset).\n Because BigQuery doesn't honor field-level access controls, if you\n query a linked dataset, then you can query all fields in the log entries.\n\n- If you query multiple log buckets that are configured with different\n Cloud KMS keys, then the query fails unless the following\n constraints are met:\n\n - The log buckets are in the same location.\n - A folder or organization that is a parent resource of the log buckets is [configured with a default key](/logging/docs/routing/managed-encryption).\n - The default key is in the same location as the log buckets.\n\n When the previous constraints are satisfied, the parent's Cloud KMS\n key encrypts any temporary data generated by a Log Analytics query.\n- Duplicate log entries aren't removed before a query is run. This behavior\n is different than when you query log entries by using the Logs Explorer,\n which removes duplicate entries by comparing the log names, timestamps, and\n insert ID fields. For more information, see\n [Troubleshoot: There are duplicate log entries in my Log Analytics results](/logging/docs/analyze/troubleshoot#duplicate-analytics).\n\n| **Note:** If your data is managed through an [Assured Workloads environment](/assured-workloads/docs/key-concepts), then this feature might be impacted or restricted. For information, see [Restrictions and limitations in Assured Workloads](/assured-workloads/docs/eu-sovereign-controls-restrictions-limitations#features_logging).\n\nPricing\n-------\n\nCloud Logging doesn't charge to route logs to a\nsupported destination; however, the destination might apply charges.\nWith the exception of the `_Required` log bucket,\nCloud Logging charges to stream logs into log buckets and\nfor storage longer than the default retention period of the log bucket.\n\nCloud Logging doesn't charge for copying logs,\nfor creating [log scopes](/logging/docs/log-scope/create-and-manage)\nor [analytics views](/logging/docs/analyze/about-analytics-views),\nor for queries issued through the\n**Logs Explorer** or **Log Analytics** pages.\n\nFor more information, see the following documents:\n\n- The Cloud Logging sections of the [Google Cloud Observability pricing](https://cloud.google.com/stackdriver/pricing) page.\n- Costs when routing log data to other Google Cloud services:\n\n - [Cloud Storage pricing](https://cloud.google.com/storage/pricing)\n - [BigQuery pricing](https://cloud.google.com/bigquery/pricing#data_ingestion_pricing)\n - [Pub/Sub pricing](https://cloud.google.com/pubsub/pricing)\n- [VPC flow log generation charges](https://cloud.google.com/vpc/network-pricing#network-telemetry) apply when you send and then exclude your Virtual Private Cloud flow logs from Cloud Logging.\n\nThere are no BigQuery ingestion or storage costs when\nyou upgrade a bucket to use Log Analytics and then\ncreate a [linked dataset](/bigquery/docs/analytics-hub-introduction#linked_datasets).\nWhen you create a linked dataset for a log bucket, you don't ingest your\nlog data into BigQuery. Instead, you get read access\nto the log data stored in your log bucket through the linked dataset.\n\nBigQuery analysis charges apply when you run SQL queries on\nBigQuery linked datasets, which includes using the\n**BigQuery Studio** page, the BigQuery API, and the\nBigQuery command-line tool.\n\nBlogs\n-----\n\nFor more information about Log Analytics, see the following blog posts:\n\n- For an overview of Log Analytics, see [Log Analytics in Cloud Logging is now GA](/blog/products/devops-sre/log-analytics-in-cloud-logging-is-now-ga).\n- To learn about creating charts generated by Log Analytics queries and saving those charts to custom dashboards, see [Announcing Log Analytics charts and dashboards in Cloud Logging in\n public preview](/blog/products/management-tools/new-log-analytics-charts-and-dashboards-in-cloud-logging).\n- To learn about analyzing audit logs by using Log Analytics, see [Gleaning security insights from audit logs with Log Analytics](/blog/products/identity-security/gleaning-security-insights-from-audit-logs-with-log-analytics).\n- If you route logs to BigQuery and want to understand the difference between that solution and using Log Analytics, then see [Moving to Log Analytics for BigQuery export users](/blog/products/data-analytics/moving-to-log-analytics-for-bigquery-export-users).\n\nWhat's next\n-----------\n\n- [Create a log bucket and upgrade it to use Log Analytics](/logging/docs/buckets#create_bucket)\n- [Upgrade an existing bucket to use Log Analytics](/logging/docs/buckets#upgrade-bucket)\n- Query and view logs:\n\n - [Log Analytics: Query and analyze logs](/logging/docs/analyze/query-and-view)\n - [Logs Explorer: Query and view logs](/logging/docs/view/logs-explorer-interface)\n- Sample queries:\n\n - [Log Analytics: SQL examples](/logging/docs/analyze/examples)\n - [Logs Explorer: Logging query language examples](/logging/docs/view/query-library)"]]