[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-19 UTC."],[],[],null,["This document describes how to disable the Cloud Monitoring API for a Google Cloud project, and how to prevent the Ops Agent and the legacy Monitoring agent from collecting process metrics. You might want to disable the Cloud Monitoring API, for example, when you want to prevent ingestion of chargeable metrics into a Google Cloud project.\n\n\u003cbr /\u003e\n\nDisable collection of all metrics **Caution:** We don't recommend that you disable the Cloud Monitoring API. When you disable the Cloud Monitoring API for a Google Cloud project, you lose the ability to monitor the resources and services in that Google Cloud project.\n\nTo prevent the collection of all metrics, disable the Cloud Monitoring API: \n\nConsole\n\n1. In the Google Cloud console, select the Google Cloud project,\n and then go to the **APIs \\& Services** page:\n\n [Go to APIs \\& Services](https://console.cloud.google.com/apis)\n2. Select **Cloud Monitoring API**.\n\n3. Click **Disable API**.\n\ngcloud\n\nRun the following command to disable the Cloud Monitoring API in your\ncurrent project: \n\n```\ngcloud services disable monitoring.googleapis.com\n```\n\nFor information about disabling an API by using Google Cloud CLI,\nsee [Enabling and Disabling Services](/service-usage/docs/enable-disable#gcloud).\n\n\u003cbr /\u003e\n\nDisable collection of process metrics\n\nThere are multiple ways you can disable the collection of these metrics\nby the Ops Agent (versions 2.0.0 and higher) and\nby the legacy Monitoring agent on Linux.\n\nThe agents run only on Compute Engine VMs and, for the Monitoring agent,\nAmazon Elastic Compute Cloud (EC2) VMs; these procedures apply only to\nthose platforms.\n\nYou can't disable collection by the Ops Agent if you are running versions\nless than 2.0.0 or the legacy Monitoring agent on Windows.\nIf you want to disable collection of these metrics on Windows, we recommend\nthat you upgrade to the Ops Agent version 2.0.0 or\nhigher. For more information, see [Installing the Ops Agent](/monitoring/agent/ops-agent/install-index).\n\nThe general procedure looks like this:\n\n1. Connect to the VM.\n\n2. Make a copy of the existing configuration file as a back up. Store\n the back-up copy outside the agent's configuration directory, so the\n agent doesn't attempt to load both files. For example, the following command\n makes a copy of the configuration file for the Monitoring agent on Linux:\n\n ```\n cp /etc/stackdriver/collectd.conf BACKUP_DIR/collectd.conf.bak\n ```\n3. Change the configuration using one of the options described in the\n following:\n\n - [Ops Agent on Linux or Windows](#disable-oagent)\n - [Monitoring agent on Linux](#disable-magent)\n4. Restart the agent, to pick up the new configuration:\n\n - Monitoring agent: `sudo service stackdriver-agent restart`\n - Ops Agent: `sudo service google-cloud-ops-agent restart`\n5. Verify that the process metrics are no longer being collected for this VM:\n\n 1. In the Google Cloud console, go to the\n *leaderboard* **Metrics explorer** page:\n\n [Go to **Metrics explorer**](https://console.cloud.google.com/monitoring/metrics-explorer)\n\n \u003cbr /\u003e\n\n If you use the search bar to find this page, then select the result whose subheading is\n **Monitoring**.\n 2. In the toolbar of the\n query-builder pane, select the button whose name is either\n *code* **MQL** or *code* **PromQL**.\n\n 3. Verify that **PromQL** is selected\n in the **Language** toggle. The language toggle is in the same toolbar that\n lets you format your query.\n\n 4. For a `gce_instance` resource, enter the following query, replacing\n \u003cvar translate=\"no\"\u003eVM_NAME\u003c/var\u003e with the name of this VM:\n\n ```\n rate({\"agent.googleapis.com/processes/cpu_time\", monitored_resource=\"gce_instance\", metadata_system_name=\"VM_NAME\"}[1m])\n ```\n\n For an `aws_ec2_instance` resource, replace `gce_instance` in the\n query.\n 5. Click **Run Query**.\n\nOps Agent on Linux or Windows **Note:** This procedure applies only to Ops Agent versions 2.0.0 and higher; you can't disable process metrics on earlier versions.\n\nThe location of the configuration file for the Ops Agent depends on the\noperating system:\n\n- For Linux: `/etc/google-cloud-ops-agent/config.yaml`\n- For Windows: `C:\\Program Files\\Google\\Cloud Operations\\Ops\n Agent\\config\\config.yaml`\n\nTo disable the collection of all process metrics by the Ops Agent,\nadd the following to your `config.yaml` file: \n\n```\nmetrics:\n processors:\n metrics_filter:\n type: exclude_metrics\n metrics_pattern:\n - agent.googleapis.com/processes/*\n```\n\nThis excludes process metrics from collection in the `metrics_filter`\nprocessor that applies to the default pipeline in the `metrics` service.\n\nFor more information about configuration options for the Ops Agent, see\n[Configuring the Ops Agent](/monitoring/agent/ops-agent/configuration).\n\nMonitoring agent on Linux\n\nYou have the following options for disabling the collection of process\nmetrics with the legacy Monitoring agent:\n\n- [Modify the agent's configuration file](#edit-config).\n- [Replace the agent's configuration file](#replace-config).\n\nThe following sections describe each option and list the benefits and risks\nassociated with that option.\n\nModify the agent's configuration file\n\nWith this option, you directly edit the agent's main configuration file,\n`/etc/stackdriver/collectd.conf`, to remove the sections\nthat enable the collection of the process metrics.\n\nProcedure\n\nThere are three groups of deletions you need to make to the\n`collectd.conf` file:\n\n1. Delete the following `LoadPlugin` directive and plugin configuration:\n\n LoadPlugin processes\n\n \u003cPlugin \"processes\"\u003e\n ProcessMatch \"all\" \".*\"\n Detail \"ps_cputime\"\n Detail \"ps_disk_octets\"\n Detail \"ps_rss\"\n Detail \"ps_vm\"\n \u003c/Plugin\u003e\n\n2. Delete the following `PostCacheChain` directive and the configuration\n of the `PostCache` chain:\n\n PostCacheChain \"PostCache\"\n\n \u003cChain \"PostCache\"\u003e\n \u003cRule \"processes\"\u003e\n \u003cMatch \"regex\"\u003e\n Plugin \"^processes$\"\n Type \"^(ps_cputime|disk_octets|ps_rss|ps_vm)$\"\n \u003c/Match\u003e\n \u003cTarget \"jump\"\u003e\n Chain \"MaybeThrottleProcesses\"\n \u003c/Target\u003e\n Target \"stop\"\n \u003c/Rule\u003e\n\n \u003cRule \"otherwise\"\u003e\n \u003cMatch \"throttle_metadata_keys\"\u003e\n OKToThrottle false\n HighWaterMark 5700000000 # 950M * 6\n LowWaterMark 4800000000 # 800M * 6\n \u003c/Match\u003e\n \u003cTarget \"write\"\u003e\n Plugin \"write_gcm\"\n \u003c/Target\u003e\n \u003c/Rule\u003e\n \u003c/Chain\u003e\n\n3. Delete the `MaybeThrottleProcesses` chain used by the `PostCache` chain:\n\n \u003cChain \"MaybeThrottleProcesses\"\u003e\n \u003cRule \"default\"\u003e\n \u003cMatch \"throttle_metadata_keys\"\u003e\n OKToThrottle true\n TrackedMetadata \"processes:pid\"\n TrackedMetadata \"processes:command\"\n TrackedMetadata \"processes:command_line\"\n TrackedMetadata \"processes:owner\"\n \u003c/Match\u003e\n \u003cTarget \"write\"\u003e\n Plugin \"write_gcm\"\n \u003c/Target\u003e\n \u003c/Rule\u003e\n \u003c/Chain\u003e\n\nBenefits and risks\n\n- Benefits\n - You reduce the resources consumed by the agent, because the metrics are never collected.\n - If you have made other changes to your `collectd.conf` file, you might be able to easily preserve those changes.\n- Risks\n - You must use the `root` account to edit this configuration file.\n - You risk introducing typographical errors into the file.\n\nReplace the agent's configuration file\n\nWith this option, you replace the agent's main configuration file\nwith a pre-edited version that has the relevant sections removed for you.\n\nProcedure\n\n1. Download the pre-edited file, `collectd-no-process-metrics.conf`,\n from the GitHub repository to the `/tmp` directory, and then do the\n following:\n\n cd /tmp && curl -sSO https://raw.githubusercontent.com/Stackdriver/agent-packaging/master/collectd-no-process-metrics.conf\n\n2. Replace the existing `collectd.conf` file with the pre-edited file:\n\n cp /tmp/collectd-no-process-metrics.conf /etc/stackdriver/collectd.conf\n\nBenefits and risks\n\n- Benefits\n - You reduce resources consumed by the agent because the metrics are never collected.\n - You don't have to manually edit the file as `root`.\n - Configuration-management tools can easily replace a file.\n- Risks\n - If you have made other changes to the `collectd.conf` file, you have to merge those changes into the replacement file.\n\nTroubleshooting\n\nThe procedures described in this document are changes to the configuration\nof the agent, so the following problems are most likely:\n\n- Insufficient privilege to edit the configuration files. Configuration files must be edited from the `root` account.\n- Introduction of typographical errors into the configuration file, if you edit it directly.\n\nFor information on resolving other problems, see [Troubleshooting the\nMonitoring agent](/monitoring/agent/monitoring/troubleshooting).\n\nMonitoring agent on Windows\n\nYou can't disable the collection of process metrics by the legacy Monitoring agent\nrunning on Windows VMs. This agent is not configurable.\nIf you want to disable collection of these metrics on Windows, we recommend\nthat you upgrade to the Ops Agent version 2.0.0 or\nhigher. For more information, see [Installing the Ops Agent](/monitoring/agent/ops-agent/install-index).\n\nIf you are running the Ops Agent, see\n[Ops Agent on Linux or Windows](#disable-oagent)."]]