Installing the Cloud Monitoring agent

The Cloud Monitoring agent gathers system and application metrics from your VM instances and sends them to Monitoring. You can also configure the Monitoring agent to monitor third-party applications.

This guide explains how to install the Cloud Monitoring agent for Monitoring on Compute Engine and Amazon Elastic Compute Cloud (EC2) VMs. Using the agent is optional but recommended. Monitoring can access some metrics from the VM's hypervisor without the agent, including CPU utilization, some disk traffic metrics, network traffic, and uptime.

On instances running Microsoft Windows, the agent records CPU utilization and memory, pagefile, and volume usage. If you are running IIS or SQL server, the agent collects metrics from those services by default.

Before you begin

To install the agent, ensure that you have the following:

  • A supported VM instance in a Google Cloud project or Amazon Web Services (AWS) account.

    • A minimum of 250 MiB of resident (RSS) memory is recommended to run the Monitoring agent.
  • A Workspace monitoring the AWS account containing the VM instance. For pricing information, go to Pricing for the Google Cloud operations suite.

  • Credentials on the VM instance that authorize communication with Cloud Logging or Cloud Monitoring. Compute Engine VM instances generally have the correct credentials by default. If either of the following scenarios applies to you, then you might not have the proper credentials and must complete the Authorizing the agent procedures:

    • Running AWS EC2 VM instances, you must install authorization credentials on your VMs before installing the agent.

    • Running very old Compute Engine instances or Compute Engine instances created without the default credentials.

    To check if you have the proper credentials, run the Verifying Compute Engine credentials procedures.

Google Cloud projects for AWS EC2 VM instances

When the documentation refers to the Google Cloud project associated with your VM instance, for EC2 VM instances, this phrase refers to the AWS connector project linked to your AWS account.

When you connect your AWS account to a Workspace, the AWS connector project is created. The connector project has the following attributes:

  • A name that begins AWS Link

  • An ID that begins with aws-

    This ID is the Google Cloud project associated with your VM instance.

Refer to the Workspace page for more information about AWS connector projects.

VMs without remote package access

Installing the Monitoring agent requires access to remote package repositories, for both the agent package and (on Linux) its dependencies. If your VM host's security policy denies access to remote package repositories, we recommend creating a custom VM image with the agent pre-installed and disabling package management in that image.

Installing on Linux and Windows

To install the agent on VM instances running Linux or Microsoft Windows, use the following instructions.

AMAZON LINUX AMI / CENTOS / RHEL

  1. Open a terminal connection to your VM instance using SSH or a similar tool.

  2. Add the agent's package repository:

    curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
    sudo bash add-monitoring-agent-repo.sh
    

  3. To install the latest version of the agent, run:

    sudo yum install -y stackdriver-agent
    sudo service stackdriver-agent start
    
    1. For production environments, you might want to pin to a major version to avoid pulling in major versions that might include backward incompatible changes. To pin to a major version, run:

      sudo yum install -y stackdriver-agent-[MAJOR_VERSION].*
      sudo service stackdriver-agent start
      

      For example, to pin to the 5.x.x version of the agent, run:

      sudo yum install -y stackdriver-agent-5.*
      sudo service stackdriver-agent start
      
    2. You also have the option of installing a specific version of the agent by running the following command:

      sudo yum install -y stackdriver-agent-[VERSION_NUMBER]
      sudo service stackdriver-agent start
      

      To show all available versions of the agent, run:

      sudo yum list -y stackdriver-agent
      

You can delete the installation script after it runs successfully.

DEBIAN / UBUNTU

  1. Open a terminal connection to your VM instance using SSH or a similar tool.

  2. Add the agent's package repository:

    curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
    sudo bash add-monitoring-agent-repo.sh
    sudo apt-get update
    

  3. To install the latest version of the agent, run:

    sudo apt-get install stackdriver-agent
    sudo service stackdriver-agent start
    
    1. For production environments, you might want to pin to a major version to avoid pulling in major versions that might include backward incompatible changes. To pin to a major version, run:

      sudo apt-get install 'stackdriver-agent=[MAJOR_VERSION].*'
      sudo service stackdriver-agent start
      

      For example, to pin to the 5.x.x version of the agent, run:

      sudo apt-get install 'stackdriver-agent=5.*'
      sudo service stackdriver-agent start
      
    2. You also have the option of installing a specific version of the agent by running the following command:

      sudo apt-get install stackdriver-agent=[VERSION_NUMBER]
      sudo service stackdriver-agent start
      

      To show all available versions of the agent, run:

      sudo apt-cache madison stackdriver-agent
      

You can delete the installation script after it runs successfully.

SLES / SUSE

  1. Open a terminal connection to your VM instance using SSH or a similar tool.

  2. Add the agent's package repository:

    curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
    sudo bash add-monitoring-agent-repo.sh
    

  3. To install the latest version of the agent, run:

    sudo zypper install stackdriver-agent
    sudo service stackdriver-agent start
    
    1. For production environments, you might want to pin to a major version to avoid pulling in major versions that might include backward incompatible changes. To pin to a major version, run:

      sudo zypper install 'stackdriver-agent<[MAJOR_VERSION].0.0'
      sudo service stackdriver-agent start
      

      For example, to pin to the 5.x.x version of the agent, run:

      sudo zypper install 'stackdriver-agent<6.0.0'
      sudo service stackdriver-agent start
      
    2. You also have the option of installing a specific version of the agent by running the following command:

      sudo zypper install stackdriver-agent=[VERSION_NUMBER]
      sudo service stackdriver-agent start
      

      To show all available versions of the agent, run:

      sudo zypper search -s stackdriver-agent
      

You can delete the installation script after it runs successfully.

WINDOWS

To install the agent on a VM instance running Windows, perform the following steps:

  1. Open a terminal connection to your instance using RDP or a similar tool and login to Windows.

  2. Open a PowerShell terminal, then run the following PowerShell commands. You don't need administrator privileges.

    cd $env:UserProfile;
    (New-Object Net.WebClient).DownloadFile("https://repo.stackdriver.com/windows/StackdriverMonitoring-GCM-46.exe", ".\StackdriverMonitoring-GCM-46.exe")
    .\StackdriverMonitoring-GCM-46.exe
    

    Alternatively, you can browse to the following URL to download and run the agent's installer:

    https://repo.stackdriver.com/windows/StackdriverMonitoring-GCM-46.exe

    To install the agent silently, append the /S option to the invocation of the installer:

    .\StackdriverMonitoring-GCM-46.exe /S
    

    In “silent” mode use the /D option to specify the installation directory, for example:

    .\StackdriverMonitoring-GCM-46.exe /S /D="C:\the operations suite\Monitoring\"
    

    You can delete the installer when it completes successfully.

Optional tasks

This section describes how to perform common maintenance tasks.

Configuring an HTTP proxy

If you use an HTTP proxy, do the following:

LINUX

  1. Edit the following configuration file:

    • For agent versions 6.0.0 and higher, edit:

      /etc/default/stackdriver-agent
      
    • For agent versions earlier than 6.0.0, edit the appropriate file for your OS:

      For Debian and Ubuntu, edit:

      /etc/default/stackdriver-agent
      

      For CentOS and SLES, edit:

      /etc/default/stackdriver-collectd
      
  2. Add the following lines:

     export http_proxy="http://<PROXY_IP>:<PROXY_PORT>"
     export https_proxy="http://<PROXY_IP>:<PROXY_PORT>"
     export no_proxy=169.254.169.254  # Skip proxy for the local Metadata Server.
    
  3. Restart the Monitoring agent by running the following command on your VM instance.

     sudo service stackdriver-agent restart
    

WINDOWS

  1. If you use an HTTP proxy, run the following command from an administrator command prompt. This sets the HTTP_PROXY and HTTPS_PROXY environment variables so that the agent can send data to Monitoring using outbound HTTPS:

    setx HTTP_PROXY http://<PROXY_IP>:<PROXY_PORT> /m
    setx HTTPS_PROXY http://<PROXY_IP>:<PROXY_PORT> /m
    setx no_proxy 169.254.169.254 /m
    

Determining the agent version

To determine the version of the Monitoring agent on your system, run the following commands on your VM instance:

AMAZON LINUX AMI / CENTOS / RHEL

Run the following command Amazon Linux, Red Hat, or CentOS Linux:

rpm --query --queryformat '%{NAME} %{VERSION} %{RELEASE} %{ARCH}\n' \
     stackdriver-agent

DEBIAN / UBUNTU

Run the following command on Debian or Ubuntu:

dpkg-query --show --showformat \
    '${Package} ${Version} ${Architecture} ${Status}\n' \
     stackdriver-agent

SLES / SUSE

Run the following command on SUSE:

rpm --query --queryformat '%{NAME} %{VERSION} %{RELEASE} %{ARCH}\n' \
     stackdriver-agent

WINDOWS

There is presently no way to determine the version of the Monitoring agent running on Windows.

Restarting the agent

You must restart the Monitoring agent to pick up changes in configuration files. To restart the agent, use the following instructions.

LINUX

Run the following command on your instance:

 sudo service stackdriver-agent restart

WINDOWS

Requires administrator privileges: To restart the agent, run the following commands on your VM instance in PowerShell:

Restart-Service -Name StackdriverMonitoring

Upgrading the agent

To upgrade the Monitoring agent to the latest release, use the following instructions:

AMAZON LINUX AMI / CENTOS / RHEL

Run the following command on Amazon Linux, Red Hat, or CentOS Linux:

sudo yum update stackdriver-agent

DEBIAN / UBUNTU

Run the following commands on Debian or Ubuntu:

sudo apt-get update
sudo apt-get install stackdriver-agent

SLES / SUSE

Run the following command on SUSE:

sudo zypper update stackdriver-agent

WINDOWS

To upgrade to the latest agent release, install the newest agent as described in Installing on Windows on this page. The installer prompts you to uninstall the previous version of the agent.

Uninstalling the agent

To remove the Monitoring agent and its configuration files, use the following instructions.

AMAZON LINUX AMI / CENTOS / RHEL

Run the following command on Amazon Linux, Red Hat, or CentOS Linux:

sudo yum remove stackdriver-agent

DEBIAN / UBUNTU

Run the following command on Debian or Ubuntu:

sudo apt-get purge stackdriver-agent

SLES / SUSE

Run the following command on SUSE Linux:

sudo zypper remove stackdriver-agent

WINDOWS

In the Windows Control Panel, choose Uninstall a program. You should see the Monitoring agent in the list of programs that you can uninstall.

Troubleshooting

If you have trouble with the installation, refer to the Troubleshooting page.