Disable collection of all metrics
To prevent the collection of all metrics, disable the Cloud Monitoring API:
Console
In the Google Cloud console, select the Google Cloud project, and then go to the APIs & Services page:
Select Cloud Monitoring API.
Click Disable API.
gcloud
Run the following command to disable the Cloud Monitoring API in your current project:
gcloud services disable monitoring.googleapis.com
For information about disabling an API by using Google Cloud CLI, see Enabling and Disabling Services.
Disable collection of process metrics
There are multiple ways you can disable the collection of these metrics by the Ops Agent (versions 2.0.0 and higher) and by the legacy Monitoring agent on Linux.
The agents run only on Compute Engine VMs and, for the Monitoring agent, Amazon Elastic Compute Cloud (EC2) VMs; these procedures apply only to those platforms.
You can't disable collection by the Ops Agent if you are running versions less than 2.0.0 or the legacy Monitoring agent on Windows. If you want to disable collection of these metrics on Windows, we recommend that you upgrade to the Ops Agent version 2.0.0 or higher. For more information, see Installing the Ops Agent.
The general procedure looks like this:
Connect to the VM.
Make a copy of the existing configuration file as a back up. Store the back-up copy outside the agent's configuration directory, so the agent doesn't attempt to load both files. For example, the following command makes a copy of the configuration file for the Monitoring agent on Linux:
cp /etc/stackdriver/collectd.conf BACKUP_DIR/collectd.conf.bak
Change the configuration using one of the options described in the following:
Restart the agent, to pick up the new configuration:
- Monitoring agent:
sudo service stackdriver-agent restart
- Ops Agent:
sudo service google-cloud-ops-agent restart
- Monitoring agent:
Verify that the process metrics are no longer being collected for this VM:
Select Metrics explorer.
Click MQL.
For a
gce_instance
resource, enter the following query, replacing VM_NAME with the name of this VM:fetch gce_instance | metric 'agent.googleapis.com/processes/cpu_time' | filter (metadata.system_labels.name == 'VM_NAME') | align rate(1m) | every 1m
For an
aws_ec2_instance
resource, replacegce_instance
in the query.Click Run Query.
Ops Agent on Linux or Windows
The location of the configuration file for the Ops Agent depends on the operating system:
- For Linux:
/etc/google-cloud-ops-agent/config.yaml
- For Windows:
C:\Program Files\Google\Cloud Operations\Ops Agent\config\config.yaml
To disable the collection of all process metrics by the Ops Agent,
add the following to your config.yaml
file:
metrics: processors: metrics_filter: type: exclude_metrics metrics_pattern: - agent.googleapis.com/processes/*
This excludes process metrics from collection in the metrics_filter
processor that applies to the default pipeline in the metrics
service.
For more information about configuration options for the Ops Agent, see Configuring the Ops Agent.
Monitoring agent on Linux
You have the following options for disabling the collection of process metrics with the legacy Monitoring agent:
The following sections describe each option and list the benefits and risks associated with that option.
Modify the agent's configuration file
With this option, you directly edit the agent's main configuration file,
/etc/stackdriver/collectd.conf
, to remove the sections
that enable the collection of the process metrics.
Procedure
There are three groups of deletions you need to make to the
collectd.conf
file:
Delete the following
LoadPlugin
directive and plugin configuration:LoadPlugin processes <Plugin "processes"> ProcessMatch "all" ".*" Detail "ps_cputime" Detail "ps_disk_octets" Detail "ps_rss" Detail "ps_vm" </Plugin>
Delete the following
PostCacheChain
directive and the configuration of thePostCache
chain:PostCacheChain "PostCache" <Chain "PostCache"> <Rule "processes"> <Match "regex"> Plugin "^processes$" Type "^(ps_cputime|disk_octets|ps_rss|ps_vm)$" </Match> <Target "jump"> Chain "MaybeThrottleProcesses" </Target> Target "stop" </Rule> <Rule "otherwise"> <Match "throttle_metadata_keys"> OKToThrottle false HighWaterMark 5700000000 # 950M * 6 LowWaterMark 4800000000 # 800M * 6 </Match> <Target "write"> Plugin "write_gcm" </Target> </Rule> </Chain>
Delete the
MaybeThrottleProcesses
chain used by thePostCache
chain:<Chain "MaybeThrottleProcesses"> <Rule "default"> <Match "throttle_metadata_keys"> OKToThrottle true TrackedMetadata "processes:pid" TrackedMetadata "processes:command" TrackedMetadata "processes:command_line" TrackedMetadata "processes:owner" </Match> <Target "write"> Plugin "write_gcm" </Target> </Rule> </Chain>
Benefits and risks
- Benefits
- You reduce the resources consumed by the agent, because the metrics are never collected.
- If you have made other changes to your
collectd.conf
file, you might be able to easily preserve those changes.
- Risks
- You must use the
root
account to edit this configuration file. - You risk introducing typographical errors into the file.
- You must use the
Replace the agent's configuration file
With this option, you replace the agent's main configuration file with a pre-edited version that has the relevant sections removed for you.
Procedure
Download the pre-edited file,
collectd-no-process-metrics.conf
, from the GitHub repository to the/tmp
directory, and then do the following:cd /tmp && curl -sSO https://raw.githubusercontent.com/Stackdriver/agent-packaging/master/collectd-no-process-metrics.conf
Replace the existing
collectd.conf
file with the pre-edited file:cp /tmp/collectd-no-process-metrics.conf /etc/stackdriver/collectd.conf
Benefits and risks
- Benefits
- You reduce resources consumed by the agent because the metrics are never collected.
- You don't have to manually edit the file as
root
. - Configuration-management tools can easily replace a file.
- Risks
- If you have made other changes to the
collectd.conf
file, you have to merge those changes into the replacement file.
- If you have made other changes to the
Troubleshooting
The procedures described in this document are changes to the configuration of the agent, so the following problems are most likely:
- Insufficient privilege to edit the configuration files. Configuration
files must be edited from the
root
account. - Introduction of typographical errors into the configuration file, if you edit it directly.
For information on resolving other problems, see Troubleshooting the Monitoring agent.
Monitoring agent on Windows
You can't disable the collection of process metrics by the legacy Monitoring agent running on Windows VMs. This agent is not configurable. If you want to disable collection of these metrics on Windows, we recommend that you upgrade to the Ops Agent version 2.0.0 or higher. For more information, see Installing the Ops Agent.
If you are running the Ops Agent, see Ops Agent on Linux or Windows.