Skip to main content

Google Compute Engine

Monitoring Connector Assets​

Monitored Objects​

The Monitoring Connector Google Compute Engine collects metrics for:

  • Cpu
  • Diskio
  • Network

Discovery rules​

The Centreon Monitoring Connector Google Compute Engine includes a Host Discovery provider to automatically discover virtual machines for a given Google Cloud Project.

This provider is named Google Compute Engine:

image

Note that the key file must be deployed on the Poller(s) expected to discover GCP assets.

More information about the Host Discovery module is available in the Centreon documentation: Host Discovery

Collected Metrics​

For all collected metrics, we can choose the aggregation: average, minimum, maximum and total.

Metric nameDescriptionUnit
instance_name~aggregation#computeengine.cpu.utilization.percentageUtilization of allocated CPU%
instance_name~aggregation#computeengine.cpu.reserved_cores.countNumber of vCPUs reserved on the host of the instance

Prerequisites​

Google Cloud Configuration​

Configure a service account key (download its private key as a JSON file) for which the following privileges have to be granted:

Google ScopeDescription
https://www.googleapis.com/auth/cloud-platformView and manage your data across Google Cloud Platform services

How to create a service account key: https://developers.google.com/identity/protocols/oauth2/service-account

Setup​

  1. Install the Centreon Plugin on every Poller:
yum install centreon-plugin-Cloud-Gcp-Compute-ComputeEngine-Api
  1. On the Centreon Web interface in Configuration > Monitoring Connector Manager, install the Google Compute Engine Monitoring Connector

Host configuration​

  • Add a new Host and apply the Cloud-Gcp-Compute-ComputeEngine-custom Host Template

Once the template applied, some Macros have to be configured:

MandatoryNameDescription
XGCPKEYFILEPATHService account key json file
XGCPSCOPEENDPOINTGoogle Scope. Default: https://www.googleapis.com/auth/cloud-platform
XGCPDIMENSIONNAMEThe name of the dimension to filter on. Default: resource.labels.instance_id
XGCPDIMENSIONOPERATORDefine the type of filter match to use. Default: equals
XGCPDIMENSIONVALUEID of the instance you want to monitor.
PROXYURLConfigure proxy URL
GCPEXTRAOPTIONSAny extra option you may want to add to every command_line (eg. a --verbose flag)
DUMMYSTATUSHost state. Default is OK, do not modify it until you know what you are doing
DUMMYOUTPUTHost check output. Default is 'This is a dummy check'. Customize it with your own if needed

Service account key file must be stored on Centreon Poller. centreon-engine user account must have read privileges on that file.

FAQ​

How to test the Plugin and what are the main options for?​

Once the plugin installed, log into your Centreon Poller CLI using the centreon-engine user account and test the Plugin by running the following command:

/usr/lib/centreon/plugins/centreon_gcp_compute_computeengine_api.pl \
--plugin=cloud::google::gcp::compute::computeengine::plugin \
--mode=cpu \
--key-file=/var/lib/centreon-engine/centreon-dev-6e5531fc9e82.json \
--dimension-name='metric.labels.instance_name' \
--dimension-operator='equals' \
--dimension-value='instance-centreon1-drb5' \
--aggregation='average' \
--warning-utilization='90' \
--critical-utilization='95' \
--verbose

Expected command output is shown below:

OK: Instance 'instance-centreon1-drb5' aggregation 'average' metrics cpu utilization: 1.04 %, cpu reserved cores: 0.20 | 'instance-centreon1-drb5~average#computeengine.cpu.utilization.percentage'=1.04%;0:90;0:95;0;100 'instance-centreon1-drb5~average#computeengine.cpu.reserved_cores.count'=0.20;;;;
Checking 'instance-centreon1-drb5'
aggregation 'average' metrics cpu utilization: 1.04 %, cpu reserved cores: 0.20

The command above monitors cpu usage of a Google Compute Engine instance (--plugin=cloud::google::gcp::compute::computeengine::plugin --mode=cpu) identified by the name instance-centreon1-drb5 (--dimension-name='metric.labels.instance_name' --dimension-operator='equals' --dimension-value='instance-centreon1-drb5').

This command would trigger a WARNING alarm if cpu utilization is more than 90% (--warning-utilization='90') and a CRITICAL alarm for more than 95% (--critical-utilization='95').

All the options as well as all the available thresholds can be displayed by adding the --help parameter to the command:

/usr/lib/centreon/plugins/centreon_gcp_compute_computeengine_api.pl \
--plugin=cloud::google::gcp::compute::computeengine::plugin \
--mode=cpu \
--help

Why do I get the following result UNKNOWN: No metrics. Check your options or use --zeroed option to set 0 on undefined values ?​

This command result means that Google Cloud does not have any value for the requested period.

This result can be overriden by adding the --zeroed option in the command. This will force a value of 0 when no metric has been collected and will prevent the UNKNOWN error message.