Os filtros de exclusão permitem
controlar o volume de registros do Google Kubernetes Engine (GKE) ingeridos pelo Cloud Logging enquanto
ainda disponibiliza o registro detalhado disponível para depuração. É possível usar filtros de exclusão para impedir que as entradas de registro correspondentes sejam ingeridas pelo Cloud Logging ou roteadas para o destino de um coletor.
As entradas de registro são excluídas depois de recebidas pela
API Logging e, portanto, consomem
cota da API entries.write. Não é possível reduzir
o número de chamadas de API entries.write
excluindo entradas de registro.
As entradas de registro excluídas não estão disponíveis no Logs Explorer nem no Error Reporting.
Se você quiser usar a CLI do Google Cloud para essa tarefa,
instale e, em seguida,
inicialize a
CLI gcloud. Se você instalou a gcloud CLI anteriormente, instale a versão
mais recente executando gcloud components update.
Verifique se você tem um projeto do Google Cloud com registros que podem ser vistos no
Explorador de registros.
Permissões
Verifique se você tem um dos seguintes papéis do IAM para o projeto do Google Cloud de origem de onde está roteando registros.
Proprietário (roles/owner)
Administrador do Logging (roles/logging.admin)
Gravador de configuração de registros (roles/logging.configWriter)
As permissões contidas nesses papéis permitem criar, excluir ou modificar coletores. Para informações sobre como definir papéis do IAM, consulte o
Guia de controle de acesso do Logging.
Adicionar um filtro de exclusão
As etapas a seguir descrevem como adicionar um filtro de exclusão do Cloud Logging que exclui os registros da ingestão no bucket do Cloud Logging Default.
No console do Google Cloud, acesse a página do Roteador de registros.
Encontre a linha com o coletor _Default, expanda a opção
more_vertAções e clique em Editar coletor.
Em Escolher registros para filtrar fora do coletor, em Criar um filtro de exclusão,
clique em addAdicionar exclusão.
Insira um nome para seu filtro de exclusão.
Na seção Criar um filtro de exclusão, insira os critérios do filtro.
Por exemplo, é possível excluir entradas de registro de um cluster ou entradas de registro específicas de um contêiner.
Excluir todas as entradas de registro de um cluster específico:
resource.labels.cluster_name="CLUSTER_NAME"
Excluir entradas de registro com a gravidade de registroDEFAULT, DEBUG, INFO ou NOTICE para um contêiner específico em
um cluster específico:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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)."]]