제외 필터를 사용하면 디버깅을 위해 상세 로깅을 계속 수행하는 동안 Cloud Logging에서 수집한 Dataflow 로그의 볼륨을 제어할 수 있습니다. 제외 필터를 사용하여 일치하는 로그 항목이 Cloud Logging에서 수집되거나 싱크 대상으로 라우팅되지 않도록 제외할 수 있습니다.
Logging 쿼리 언어를 사용하여 제외 필터를 만듭니다.
Logging 쿼리 언어를 사용하면 선택한 Google Cloud 리소스(예: 프로젝트 또는 폴더)에 있는 모든 로그 항목의 하위 집합을 지정할 수 있습니다.
제외 필터를 사용하면 Dataflow 로그 수집으로 인해 발생하는 Cloud Logging 비용을 줄일 수 있습니다. Cloud Logging의 로그 수집 가격에 대한 자세한 내용은 Cloud Logging 가격 책정 요약을 참조하세요.
제외 필터의 작동 방식과 제한사항에 대한 자세한 내용은 Cloud Logging 문서의 제외 필터를 참조하세요.
Dataflow 작업은 여러 로그 유형을 내보냅니다.
이 페이지에서는 Dataflow 작업 로그 및 작업자 로그를 필터링하는 방법을 보여줍니다.
로그 제외 필터 만들기
이 예시에서는 _Default Cloud Logging 싱크에서 제외 필터를 만듭니다. 이 필터는 DEFAULT, DEBUG, INFO, NOTICE 심각도 Dataflow 로그가 모두 Cloud Logging에 수집되지 않도록 제외합니다. WARNING, ERROR, CRITICAL, ALERT, EMERGENCY 심각도 로그는 계속 캡처됩니다. 지원되는 로그 수준에 대한 자세한 내용은 LogSeverity를 참조하세요.
시작하기 전에
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Google Cloud CLI, Google Cloud 콘솔 또는 Google CloudAPI를 통해 싱크 전에 라우팅 대상을 만들어야 합니다. 모든 조직의 모든 Google Cloud 프로젝트에 대상을 만들 수 있습니다. 대상을 만들기 전에 싱크의 서비스 계정에 대상에 쓸 수 있는 권한이 있는지 확인합니다.
제외 필터 추가
다음 단계에서는 Dataflow 로그에 Cloud Logging 제외 필터를 추가하는 방법을 설명합니다. 이 제외 필터는 debug 문자열로 끝나지 않는 Dataflow 작업에서 심각도가 DEFAULT, DEBUG, INFO, NOTICE인 Dataflow 로그 항목을 모두 선택합니다. 필터는 이러한 로그가 Default Cloud Logging 버킷에서 수집되지 않도록 제외합니다.
작업 로그 패널에 로그가 표시되지 않고 DEFAULT, DEBUG, INFO 또는NOTICE 로그가 작업자 로그 패널에 표시되지 않는지 확인합니다.
제외 필터 우회
Dataflow 작업 이름(job_name)은 생성된 Dataflow 로그를 캡처해야 하는 시나리오의 우회 메커니즘을 제공하는 데 사용됩니다. 이 우회를 사용하여 실패한 작업을 다시 실행하고 모든 로그 정보를 캡처할 수 있습니다.
이 시나리오에서 만든 필터는 job_name 필드가 debug 문자열로 끝나는 경우 모든 로그 항목을 유지합니다. 제외 필터를 우회하고 Dataflow 작업의 모든 로그를 표시하려면 작업 이름에 debug를 추가합니다. 예를 들어 제외 필터를 우회하려면 작업 이름 dataflow-job-debug를 사용할 수 있습니다.
로그 수 비교
제외 필터가 있는 로그와 없는 로그의 볼륨을 비교하려면 작업 이름에 debug가 추가된 작업과 그렇지 않은 작업을 각각 하나씩 실행합니다. 시스템 정의 로그 기반 측정항목 로그 바이트를 사용하여 수집 데이터를 보고 비교합니다. 수집 데이터 보기에 대한 자세한 내용은 측정항목 탐색기에서 수집 데이터 보기를 참조하세요.
외부 대상 만들기
선택적으로 제외 필터를 만든 후 추가 Cloud Logging 싱크를 만들 수 있습니다. 이 싱크를 사용하여 전체 Dataflow 로그 세트를 BigQuery, Pub/Sub 또는 Splunk 등 지원되는 외부 대상으로 리디렉션할 수 있습니다.
이 시나리오에서 외부 로그는 로그 탐색기에 저장되지 않지만 외부 대상에서 사용할 수 있습니다. 외부 대상을 사용하면 로그 탐색기에 로그를 저장하여 발생하는 비용을 더 세밀하게 제어할 수 있습니다.
Cloud Logging이 로그를 라우팅하는 방식을 제어하는 단계는 싱크 구성 및 관리를 참조하세요.
외부 대상에 모든 Dataflow 로그를 캡처하려면 싱크에 포함할 로그 선택 패널의 포함 필터 빌드 필드에 다음 필터 표현식을 입력합니다.
resource.type="dataflow_step"
Cloud Logging에서 지원되는 대상으로 라우팅한 로그 항목을 찾으려면 싱크 대상에서 로그 보기를 참조하세요.
심각도별로 Dataflow 로그 메시지 추적
사용자 정의 로그 기반 측정항목에는 제외 필터가 적용되지 않습니다.
이 측정항목은 지정된 필터와 일치하는 로그 항목 수를 세거나 일치하는 로그 항목에 있는 특정 값을 기록합니다.
심각도를 기반으로 Dataflow 로그 메시지 수를 추적하려면 Dataflow 로그에 대한 로그 기반 측정항목을 만들면 됩니다. 로그 메시지가 수집에서 제외되는 경우에도 로그가 추적됩니다.
사용자 정의 로그 기반 측정항목에 대한 요금이 청구됩니다. 가격 정보는 요금이 부과되는 측정항목을 참조하세요.
사용자 정의 로그 기반 측정항목을 구성하려면 카운터 측정항목 만들기를 참조하세요.
Dataflow 로그를 추적하려면 필터 선택 섹션의 빌드 필터 상자에서 다음 텍스트를 입력하세요.
[[["이해하기 쉬움","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)"],[[["\u003cp\u003eExclusion filters in Cloud Logging allow users to manage the volume of Dataflow logs ingested, reducing costs while maintaining detailed logs for debugging.\u003c/p\u003e\n"],["\u003cp\u003eThese filters use the Logging query language to specify which log entries to exclude from being ingested or routed to a sink, based on criteria like log severity and Dataflow job name.\u003c/p\u003e\n"],["\u003cp\u003eBy default, a sample exclusion filter can prevent \u003ccode\u003eDEFAULT\u003c/code\u003e, \u003ccode\u003eDEBUG\u003c/code\u003e, \u003ccode\u003eINFO\u003c/code\u003e, and \u003ccode\u003eNOTICE\u003c/code\u003e severity Dataflow logs from being captured, while retaining \u003ccode\u003eWARNING\u003c/code\u003e and higher severity logs.\u003c/p\u003e\n"],["\u003cp\u003eA bypass mechanism using \u003ccode\u003edebug\u003c/code\u003e in the Dataflow job name enables the capture of all log entries for specific jobs, useful for debugging failed jobs.\u003c/p\u003e\n"],["\u003cp\u003eUsers can create an external sink to route all Dataflow logs to destinations like BigQuery, Pub/Sub, or Splunk, providing more control over log storage and costs, and log based metrics can be used to track logs regardless if they are excluded or not.\u003c/p\u003e\n"]]],[],null,["# Control Dataflow log ingestion\n\n[Exclusion filters](/logging/docs/routing/overview#exclusions) let you\ncontrol the volume of Dataflow logs ingested by Cloud Logging while\nstill making verbose logging available for debugging. You can use exclusion\nfilters to exclude matching log entries from being ingested\nby Cloud Logging or from being routed to the destination of the [sink](/logging/docs/routing/overview#sinks).\nCreate exclusion filters by using the [Logging query language](/logging/docs/view/logging-query-language).\nLogging query language lets you specify a subset of all log entries in\nyour selected Google Cloud resource, such as a project or a folder.\n\nBy using exclusion filters, you can reduce the Cloud Logging\ncosts incurred by Dataflow log ingestion. For more information about log ingestion pricing for\nCloud Logging, see the [Cloud Logging pricing summary](/stackdriver/pricing).\nFor more details about how exclusion filters work and their limitations, see\n[Exclusion filters](/logging/docs/routing/overview#exclusions) in the\nCloud Logging documentation.\n\nDataflow jobs emit multiple [log types](/logging#log-types).\nThis page demonstrates how to filter Dataflow job logs and worker logs.\n\nCreate log exclusion filters\n----------------------------\n\nThis example creates an exclusion filter on the\n[`_Default` Cloud Logging sink](/logging/docs/routing/overview#sinks). The\nfilter excludes all `DEFAULT`, `DEBUG`, `INFO`, and `NOTICE` severity Dataflow\nlogs from being ingested into Cloud Logging. `WARNING`,\n`ERROR`, `CRITICAL`, `ALERT`, and `EMERGENCY` severity logs are still captured. For more information about\nsupported log levels, see\n[LogSeverity](/logging/docs/reference/v2/rest/v2/LogEntry#logseverity).\n\n### Before you begin\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n### Permissions\n\nAs you get started, ensure the following:\n\n- You have a Google Cloud project with logs that you can see in the\n [Logs Explorer](/logging/docs/view/logs-explorer-summary).\n\n- You have one of the following IAM roles for the source\n Google Cloud project from which you're routing logs.\n\n - **Owner** (`roles/owner`)\n - **Logging Admin** (`roles/logging.admin`)\n - **Logs Configuration Writer** (`roles/logging.configWriter`)\n\n The permissions contained in these roles let you create, delete, or\n modify sinks. For information on setting IAM roles, see the\n Logging [Access control guide](/logging/docs/access-control).\n- You have a resource in a [supported destination](#supported-destinations) or\n can create one.\n\n You need to create the routing destination before the sink, through\n either Google Cloud CLI, Google Cloud console, or the Google Cloud\n APIs. You can create the destination in any Google Cloud project in any\n organization. Before you create the destination, make sure the service\n account from the sink has [permissions to write to the destination](#dest-auth).\n\n### Add an exclusion filter\n\nThe following steps demonstrate how to add a Cloud Logging exclusion filter\nto your Dataflow logs. This exclusion filter selects all Dataflow\nlog entries with the severity `DEFAULT`, `DEBUG`, `INFO`, and `NOTICE` from jobs\nthat have a Dataflow job name that does not end in the string `debug`. The filter\nexcludes these logs from ingestion into the `Default` Cloud Logging bucket.\n\n1. In the Google Cloud console, go to the **Logs Router** page:\n\n [Go to Logs Router](https://console.cloud.google.com/logs/router)\n2. Find the row with the `_Default` sink, expand the\n more_vert\n **Actions** option, and then click **Edit sink**.\n\n3. In **Choose logs to filter out of sink** , for **Build an exclusion filter** ,\n click add **Add exclusion**.\n\n4. Enter a name for your exclusion filter.\n\n5. In the **Build an exclusion filter** section, paste the following text into\n the box:\n\n resource.type=\"dataflow_step\" AND\n labels.\"dataflow.googleapis.com/job_name\"!~\".*debug\" AND\n severity=(DEFAULT OR DEBUG OR INFO OR NOTICE)\n\n - The first line selects all log entries generated by the Dataflow service.\n - The second line selects all log entries where the `job_name` field does not end with the string `debug`.\n - The third line selects all log entries with the severity `DEFAULT`, `DEBUG`, `INFO`, or `NOTICE`.\n6. Click **Update sink**.\n\nTest your exclusion filter\n--------------------------\n\nYou can verify that the filter is working correctly by running a sample\nDataflow job and then viewing the logs.\n\nAfter your job starts running, to view job logs, complete the following steps:\n\n1. In the Google Cloud console, go to the Dataflow **Jobs** page.\n\n [Go to Jobs](https://console.cloud.google.com/dataflow/jobs)\n\n A list of Dataflow jobs appears along with their status.\n2. Select a job.\n\n3. On the **Job details** page, in the **Logs** panel, click\n *segment* **Show**.\n\n4. Verify that no logs appear in the **Job logs** panel and that no `DEFAULT`,\n `DEBUG`, `INFO`, or `NOTICE` logs appear in the **Worker logs** panel.\n\nBypass the exclusion filter\n---------------------------\n\nThe Dataflow job name (`job_name`) is used to provide a bypass mechanism for\nscenarios where the generated Dataflow logs need to be captured. You can\nuse this bypass to rerun a failed job and capture all the log information.\n\nThe filter created in this scenario retains all log entries when the `job_name` field\nends with the string `debug`. When you want to bypass the exclusion filter and display all logs for a\nDataflow job, append `debug` to the job name. For example, to bypass the exclusion filter, you\ncould use the job name `dataflow-job-debug`.\n\nCompare log counts\n------------------\n\nIf you want to compare the volume of logs ingested with and without the exclusion\nfilter, run one job with `debug` appended to the job name and one without. Use\nthe system-defined, logs-based metric\n[Log bytes](/monitoring/api/metrics_gcp_i_o#logging/byte_count) to view and compare\nthe ingestion data. For more information about viewing ingestion data, see\n[View ingestion data in Metrics Explorer](/stackdriver/estimating-bills#metric-exp-usage).\n\nCreate an external destination\n------------------------------\n\nOptionally, after you create the exclusion filter, you can create an additional\nCloud Logging sink. Use this sink to redirect the complete set of\nDataflow logs into a\n[supported external destination](/logging/docs/routing/overview#destinations),\nsuch as BigQuery, Pub/Sub, or Splunk.\n\nIn this scenario, the external logs aren't stored in Logs Explorer but are\navailable in the external destination. Using an external destination gives you\nmore control over the costs incurred by storing logs in Logs Explorer.\n\nFor steps detailing how to control how Cloud Logging routes logs, see\n[Configure and manage sinks](/logging/docs/export/configure_export_v2).\nTo capture all Dataflow logs in an external destination,\nin the **Choose logs to include in sink** panel, in the **Build inclusion filter** field,\nenter the following filter expression: \n\n resource.type=\"dataflow_step\"\n\nTo find log entries that you routed from Cloud Logging to supported\ndestinations, see [View logs in sink destinations](/logging/docs/export/using_exported_logs).\n\nTrack Dataflow log messages by severity\n---------------------------------------\n\nExclusion filters do not apply to\n[user-defined logs-based metrics](/logging/docs/logs-based-metrics#user-metrics).\nThese metrics count the number of log entries that match a given filter or\nrecord particular values within the matching log entries.\nTo track counts of Dataflow log messages based on severity, you can\ncreate a logs-based metric for the Dataflow logs. The logs\nare tracked even when the log messages are excluded from ingestion.\n\nYou're billed for user-defined logs-based metrics. For pricing information, see\n[Chargeable metrics](/stackdriver/pricing#metrics-chargeable).\n\nTo configure user-defined logs-based metrics, see\n[Create a counter metric](/logging/docs/logs-based-metrics/counter-metrics#create_a_counter_metric).\nTo track the Dataflow logs, in the **Filter selection** section,\nin the **Build filter** box, enter the following text: \n\n resource.type=\"dataflow_step\""]]