Filter pengecualian memungkinkan Anda mengontrol volume log Google Kubernetes Engine (GKE) yang diserap oleh Cloud Logging sekaligus tetap menyediakan logging panjang untuk proses debug. Anda dapat menggunakan filter pengecualian untuk mengecualikan entri log yang cocok agar tidak diserap oleh Cloud Logging atau agar tidak dirutekan ke tujuan sink.
Entri log dikecualikan setelah diterima oleh
Logging API, sehingga entri log ini menggunakan
kuota entries.write API. Anda tidak dapat mengurangi
jumlah panggilan API entries.write dengan
mengecualikan entri log.
Entri log yang dikecualikan tidak tersedia di Logs Explorer atau di Error Reporting.
Jika ingin menggunakan Google Cloud CLI untuk tugas ini,
instal lalu
lakukan inisialisasi
gcloud CLI. Jika sebelumnya Anda telah menginstal gcloud CLI, dapatkan versi terbaru dengan menjalankan gcloud components update.
Pastikan Anda memiliki project Google Cloud dengan log yang dapat Anda lihat di Logs Explorer.
Izin
Pastikan Anda memiliki salah satu peran IAM berikut untuk project Google Cloud sumber tempat Anda merutekan log.
Izin yang terdapat dalam peran ini memungkinkan Anda membuat, menghapus, atau
mengubah sink. Untuk informasi tentang cara menetapkan peran IAM, lihat Panduan kontrol akses Logging.
Menambahkan filter pengecualian
Langkah-langkah berikut menjelaskan cara menambahkan filter pengecualian Cloud Logging yang mengecualikan log dari penyerapan ke bucket Cloud Logging Default.
Temukan baris dengan sink _Default, luaskan
opsi more_vertActions, lalu klik Edit sink.
Di Choose logs to filter out of sink, untuk Build an exclusion filter,
klik addAdd exclusion.
Masukkan nama untuk filter pengecualian Anda.
Di bagian Build an exclusion filter, masukkan kriteria filter.
Misalnya, Anda dapat mengecualikan entri log untuk cluster, atau entri log
tertentu untuk penampung.
Mengecualikan semua entri log dari cluster tertentu:
resource.labels.cluster_name="CLUSTER_NAME"
Kecualikan entri log dengan keparahan logDEFAULT, DEBUG, INFO, atau NOTICE untuk penampung tertentu di
cluster tertentu:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-03-13 UTC."],[],[],null,["# Control log ingestion\n\n[Autopilot](/kubernetes-engine/docs/concepts/autopilot-overview) [Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\n[Exclusion filters](/logging/docs/routing/overview#exclusions) let you\ncontrol the volume of Google Kubernetes Engine (GKE) 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 a\n[sink](/logging/docs/routing/overview#sinks).\n\nCreate exclusion filters by using the [Logging query language](/logging/docs/view/logging-query-language).\n\nLog entries are excluded after they are received by the\nLogging API and therefore these log entries consume\n[`entries.write` API quota](/logging/quotas#api-limits). You can't reduce\nthe number of [`entries.write` API calls](/logging/quotas#log-limits) by\nexcluding log entries.\n\nExcluded log entries aren't available in the Logs Explorer or in\nError Reporting.\n\nFor information about viewing ingestion data, see\n[View detailed usage in Metrics Explorer](/stackdriver/estimating-bills#metric-exp-usage).\n\nBefore you begin\n----------------\n\nBefore you start, make sure that you have performed the following tasks:\n\n- Enable the Google Kubernetes Engine API.\n[Enable Google Kubernetes Engine API](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com)\n- If you want to use the Google Cloud CLI for this task, [install](/sdk/docs/install) and then [initialize](/sdk/docs/initializing) the gcloud CLI. If you previously installed the gcloud CLI, get the latest version by running `gcloud components update`. **Note:** For existing gcloud CLI installations, make sure to set the `compute/region` [property](/sdk/docs/properties#setting_properties). If you use primarily zonal clusters, set the `compute/zone` instead. By setting a default location, you can avoid errors in the gcloud CLI like the following: `One of [--zone, --region] must be supplied: Please specify location`. You might need to specify the location in certain commands if the location of your cluster differs from the default that you set.\n\n\u003c!-- --\u003e\n\n- Verify that you have a Google Cloud project with logs that you can see in the [Logs Explorer](/logging/docs/view/logs-explorer-summary).\n\n### Permissions\n\nVerify that you have one of the following IAM roles for the\nsource 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\nThe permissions contained in these roles let you create, delete, or\nmodify sinks. For information on setting IAM roles, see the\nLogging [Access control guide](/logging/docs/access-control).\n\nAdd an exclusion filter\n-----------------------\n\nThe following steps describe how to add a Cloud Logging exclusion filter\nthat excludes 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, enter the filter criteria.\n For example, you can exclude log entries for a cluster, or specific log\n entries for a container.\n\n Exclude all log entries from a specific cluster: \n\n resource.labels.cluster_name=\"\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\"\n\n Exclude log entries with the [log severity](/logging/docs/reference/v2/rest/v2/LogEntry#logseverity)\n `DEFAULT`, `DEBUG`, `INFO`, or `NOTICE` for a specific container in\n a specific cluster: \n\n resource.type=\"k8s_container\"\n resource.labels.container_name=\"\u003cvar translate=\"no\"\u003eCONTAINER_NAME\u003c/var\u003e\"\n resource.labels.cluster_name=\"\u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\"\n severity=(DEFAULT OR DEBUG OR INFO OR NOTICE)\n\n6. Click **Update sink**.\n\nThe `_Default` sink is now configured to exclude logs with the filter you added.\n\nWhat's next\n-----------\n\n- Learn more about [exclusion filters](/logging/docs/routing/overview#exclusions)."]]