Google Cloud

Google Cloud Platform, offered by Google, is a suite of cloud computing services that runs on the same infrastructure that Google uses internally for its end-user products, such as Google Search, Gmail, file storage, and YouTube.

Available solutions

Zabbix version 7.4 7.2 7.0 6.4 6.0
Source: templates/cloud/gcp

GCP by HTTP

Overview

This template is designed to monitor GCP by HTTP. It works without any external scripts and uses the script item. Currently, the template supports the discovery of Compute Engine instances, Cloud SQL instances (Microsoft SQL Server, MySQL, and PostgreSQL, including replicas), Application Load Balancers, and Cost Monitoring resources.

Included Monitoring Templates

  • GCP Application Load Balancer by HTTP
  • GCP Cost Monitoring by HTTP
  • GCP Compute Engine Instance by HTTP
  • GCP Cloud SQL MSSQL by HTTP
  • GCP Cloud SQL MSSQL Replica by HTTP
  • GCP Cloud SQL MySQL by HTTP
  • GCP Cloud SQL MySQL Replica by HTTP
  • GCP Cloud SQL PostgreSQL by HTTP
  • GCP Cloud SQL PostgreSQL Replica by HTTP

The template additionally supports the collection of Compute Engine project quota metrics.

Requirements

Zabbix version: 7.4 and higher.

Tested versions

This template has been tested on:

  • Google Cloud Platform

Configuration

Zabbix should be configured according to the instructions in the Templates out of the box section.

Setup

  1. Enable the Stackdriver Monitoring API for the GCP project you wish to monitor.

Refer to the vendor documentation.

  1. Create a service account in Google Cloud console for the project you have to monitor.

Refer to the vendor documentation.

  1. Create and download the service account key in JSON format.

Refer to the vendor documentation.

  1. If you want to monitor Cloud SQL services - don't forget to activate the Cloud SQL Admin API.

Refer to the vendor documentation for the details.

  1. Copy the project_id, private_key_id, private_key, client_email from the JSON key file and add them to their corresponding macros {$GCP.PROJECT.ID}, {$GCP.PRIVATE.KEY.ID}, {$GCP.PRIVATE.KEY}, {$GCP.CLIENT.EMAIL} on the template/host.

Additional information:

Make sure that you're creating the service account using the credentials with the `Project Owner/Project IAM Admin/service account Admin` role.

The service account JSON key file can only be downloaded once: regenerate it if the previous key has been lost.

The service account should have `Project Viewer` permissions or granular permissions for the GCP Compute Engine API/GCP Cloud SQL.

You can copy and paste private_key string data from the Service Account JSON key file as is or replace the new line metasymbol (\n) with an actual new line.

Please, refer to the vendor documentation about the service accounts management.

IMPORTANT!!!

 Secret authorization token is defined as a plain text in host prototype settings by default due to Zabbix templates export/import limits: therefore, it is highly recommended to change the user macro `{$GCP.AUTH.TOKEN}` value type to `SECRET` for all host prototypes after the template `GCP by HTTP` import.

 All the instances/quotas/metrics discovered are related to a particular GCP project.
 To monitor several GCP projects - create their corresponding service accounts/Zabbix hosts.

 GCP Access Token is available for 1 hour (3600 seconds) after the generation request.

 To avoid a GCP token inconsistency between Zabbix database and Zabbix server configuration cache, don't set Zabbix server configuration parameter CacheUpdateFrequency to a value over 45 minutes and don't set the update interval for the GCP Authorization item to more than 1 hour (maximum CacheUpdateFrequency value).

Additional information about metrics and used API methods:

Compute Engine

Cloud SQL

Macros used

Name Description Default
{$GCP.PROJECT.ID}

GCP project ID.

{$GCP.CLIENT.EMAIL}

Service account client e-mail.

{$GCP.PRIVATE.KEY.ID}

Service account private key id.

{$GCP.PRIVATE.KEY}

Service account private key data.

{$GCP.AUTH.FREQUENCY}

The update interval for the GCP Authorization item, which also equals to the access token regeneration request frequency.

Check the template documentation notes carefully for more details.

45m
{$GCP.GCE.QUOTA.PUSED.MIN.WARN}

GCP Compute Engine project quota warning utilization threshold.

80
{$GCP.GCE.QUOTA.PUSED.MIN.CRIT}

GCP Compute Engine project quota critical quota utilization threshold.

95
{$GCP.DATA.TIMEOUT}

A response timeout for an API.

15s
{$GCP.PROXY}

Sets HTTP proxy value. If this macro is empty then no proxy is used.

{$HTTP.TLS.VERIFY}

TLS certificate verification for script items and JavaScript preprocessing: "none" - disabled, "peer" - verify the certificate chain and expiration, "full" - full verification. Any other value enables full verification. To override the setting for this template only, define the macro with the context "GCP", e.g. {$HTTP.TLS.VERIFY:"GCP"}.

full
{$GCP.GCE.INST.NAME.MATCHES}

The filter to include GCP Compute Engine instances by namespace.

.*
{$GCP.GCE.INST.NAME.NOT_MATCHES}

The filter to exclude GCP Compute Engine instances by namespace.

CHANGE_IF_NEEDED
{$GCP.GCE.ZONE.MATCHES}

The filter to include GCP Compute Engine instances by zone.

.*
{$GCP.GCE.ZONE.NOT_MATCHES}

The filter to exclude GCP Compute Engine instances by zone.

CHANGE_IF_NEEDED
{$GCP.MYSQL.INST.NAME.MATCHES}

The filter to include GCP Cloud SQL MySQL instances by namespace.

.*
{$GCP.MYSQL.INST.NAME.NOT_MATCHES}

The filter to exclude GCP Cloud SQL MySQL instances by namespace.

CHANGE_IF_NEEDED
{$GCP.MYSQL.ZONE.MATCHES}

The filter to include GCP Cloud SQL MySQL instances by zone.

.*
{$GCP.MYSQL.ZONE.NOT_MATCHES}

The filter to exclude GCP Cloud SQL MySQL instances by zone.

CHANGE_IF_NEEDED
{$GCP.MYSQL.INST.TYPE.MATCHES}

The filter to include GCP Cloud SQL MySQL instances by type (standalone/replica).

.*
{$GCP.MYSQL.INST.TYPE.NOT_MATCHES}

The filter to exclude GCP Cloud SQL MySQL instances by type (standalone/replica).

Set a macro value 'CLOUD_SQL_INSTANCE' to exclude standalone Instances or 'READ_REPLICA_INSTANCE' to exclude read-only Replicas.

CHANGE_IF_NEEDED
{$GCP.PGSQL.INST.NAME.MATCHES}

The filter to include GCP Cloud SQL PostgreSQL instances by namespace.

.*
{$GCP.PGSQL.INST.NAME.NOT_MATCHES}

The filter to exclude GCP Cloud SQL PostgreSQL instances by namespace.

CHANGE_IF_NEEDED
{$GCP.PGSQL.ZONE.MATCHES}

The filter to include GCP Cloud SQL PostgreSQL instances by zone.

.*
{$GCP.PGSQL.ZONE.NOT_MATCHES}

The filter to exclude GCP Cloud SQL PostgreSQL instances by zone.

CHANGE_IF_NEEDED
{$GCP.PGSQL.INST.TYPE.MATCHES}

The filter to include GCP Cloud SQL PostgreSQL instances by type (standalone/replica).

.*
{$GCP.PGSQL.INST.TYPE.NOT_MATCHES}

The filter to exclude GCP Cloud SQL PostgreSQL instances by type (standalone/replica).

Set a macro value 'CLOUD_SQL_INSTANCE' to exclude standalone Instances or 'READ_REPLICA_INSTANCE' to exclude read-only Replicas.

CHANGE_IF_NEEDED
{$GCP.MSSQL.INST.NAME.MATCHES}

The filter to include GCP Cloud SQL MSSQL instances by namespace.

.*
{$GCP.MSSQL.INST.NAME.NOT_MATCHES}

The filter to exclude GCP Cloud SQL MSSQL instances by namespace.

CHANGE_IF_NEEDED
{$GCP.MSSQL.ZONE.MATCHES}

The filter to include GCP Cloud SQL MSSQL instances by zone.

.*
{$GCP.MSSQL.ZONE.NOT_MATCHES}

The filter to exclude GCP Cloud SQL MSSQL instances by zone.

CHANGE_IF_NEEDED
{$GCP.MSSQL.INST.TYPE.MATCHES}

The filter to include GCP Cloud SQL MSSQL instances by type (standalone/replica).

.*
{$GCP.MSSQL.INST.TYPE.NOT_MATCHES}

The filter to exclude GCP Cloud SQL MSSQL instances by type (standalone/replica).

Set a macro value 'CLOUD_SQL_INSTANCE' to exclude standalone Instances or 'READ_REPLICA_INSTANCE' to exclude read-only Replicas.

CHANGE_IF_NEEDED
{$GCP.GCE.QUOTA.MATCHES}

The filter to include GCP Compute Engine project quotas by namespace.

.*
{$GCP.GCE.QUOTA.NOT_MATCHES}

The filter to exclude GCP Compute Engine project quotas by namespace.

CHANGE_IF_NEEDED

Items

Name Description Type Key and additional info
Authorization

Google Cloud Platform REST authorization with service account authentication parameters and temporary-generated RSA-based JWT-token usage.

The necessary scopes are pre-defined.

Returns a signed authorization token with 1 hour lifetime; it is required only once, and is used for all the dependent script items.

Check the template documentation for the details.

Script gcp.authorization
GCE instances get

Get GCP Compute Engine instances.

Dependent item gcp.gce.instances.get

Preprocessing

  • JavaScript: The text is too long. Please see the template.

Authorization errors check

A list of errors from API requests.

Dependent item gcp.auth.err.check

Preprocessing

  • JSON Path: $.error

    ⛔️Custom on fail: Set value to: ``

Cloud SQL instances get

GCP Cloud SQL: Instances get.

Dependent item gcp.cloudsql.instances.get

Preprocessing

  • JavaScript: The text is too long. Please see the template.

Cloud SQL instances total

GCP Cloud SQL instances total count.

Dependent item gcp.cloudsql.instances.total

Preprocessing

  • JSON Path: $.[*].length()

MSSQL instances count

GCP Cloud SQL MSSQL instances count.

Dependent item gcp.cloudsql.instances.mssql_count

Preprocessing

  • JSON Path: $[?(@.db_type =~ 'SQLSERVER')].length()

    ⛔️Custom on fail: Discard value

MySQL instances count

GCP Cloud SQL MySQL instances count.

Dependent item gcp.cloudsql.instances.mysql_count

Preprocessing

  • JSON Path: $[?(@.db_type =~ 'MYSQL')].length()

    ⛔️Custom on fail: Discard value

PostgreSQL instances count

GCP Cloud SQL PostgreSQL instances count.

Dependent item gcp.cloudsql.instances.pgsql_count

Preprocessing

  • JSON Path: $[?(@.db_type =~ 'POSTGRES')].length()

    ⛔️Custom on fail: Discard value

GCE instances total

GCP Compute Engine instances total count.

Dependent item gcp.gce.instances.total

Preprocessing

  • JSON Path: $.[*].length()

    ⛔️Custom on fail: Discard value

Regular GCE instances count

GCP Compute Engine: Regular instances count.

Dependent item gcp.gce.instances.regular_count

Preprocessing

  • JSON Path: $[?(@.i_type == 'regular')].length()

    ⛔️Custom on fail: Discard value

Container-optimized GCE instances count

GCP Compute Engine: count of instances with Container-Optimized OS used.

Dependent item gcp.gce.instances.cos_count

Preprocessing

  • JSON Path: $[?(@.i_type == 'container-optimized')].length()

    ⛔️Custom on fail: Discard value

Project quotas get

GCP Compute Engine resource quotas available for the particular project.

Dependent item gcp.gce.quotas.get

Preprocessing

  • JavaScript: The text is too long. Please see the template.

Triggers

Name Description Expression Severity Dependencies and additional info
GCP: Authorization has failed

GCP: Authorization has failed.
Check the authorization parameters and GCP API availability from a network segment, where Zabbix-server/proxy is located.

length(last(/GCP by HTTP/gcp.auth.err.check)) > 0 Average

LLD rule GCP Compute Engine: Instances discovery

Name Description Type Key and additional info
GCP Compute Engine: Instances discovery

GCP Compute Engine: Instances discovery.

Dependent item gcp.gce.inst.discovery

Preprocessing

  • Discard unchanged with heartbeat: 3h

LLD rule GCP Cloud SQL: PostgreSQL instances discovery

Name Description Type Key and additional info
GCP Cloud SQL: PostgreSQL instances discovery

GCP Cloud SQL: PostgreSQL instances discovery.

Dependent item gcp.cloudsql.pgsql.inst.discovery

Preprocessing

  • Discard unchanged with heartbeat: 3h

LLD rule GCP Cloud SQL: MSSQL instances discovery

Name Description Type Key and additional info
GCP Cloud SQL: MSSQL instances discovery

GCP Cloud SQL: MSSQL instances discovery.

Dependent item gcp.cloudsql.mssql.inst.discovery

Preprocessing

  • Discard unchanged with heartbeat: 3h

LLD rule GCP Cloud SQL: MySQL instances discovery

Name Description Type Key and additional info
GCP Cloud SQL: MySQL instances discovery

GCP Cloud SQL: MySQL instances discovery.

Dependent item gcp.cloudsql.mysql.inst.discovery

Preprocessing

  • Discard unchanged with heartbeat: 3h

LLD rule GCP Compute Engine: Project quotas discovery

Name Description Type Key and additional info
GCP Compute Engine: Project quotas discovery

GCP Compute Engine: Quotas discovery.

Dependent item gcp.gce.quotas.discovery

Preprocessing

  • Discard unchanged with heartbeat: 3h

Item prototypes for GCP Compute Engine: Project quotas discovery

Name Description Type Key and additional info
Quota [{#GCE.QUOTA.NAME}]: Raw data

GCP Compute Engine: Get metrics for [{#GCE.QUOTA.NAME}] quota.

Dependent item gcp.gce.quota.single.raw[{#GCE.QUOTA.NAME}]

Preprocessing

  • JSON Path: $[?(@.metric == "{#GCE.QUOTA.NAME}")].first()

Quota [{#GCE.QUOTA.NAME}]: Usage

GCP Compute Engine: The current usage value for [{#GCE.QUOTA.NAME}] quota.

Dependent item gcp.gce.quota.usage[{#GCE.QUOTA.NAME}]

Preprocessing

  • JSON Path: $.usage

Quota [{#GCE.QUOTA.NAME}]: Limit

GCP Compute Engine: The current limit value for [{#GCE.QUOTA.NAME}] quota.

Dependent item gcp.gce.quota.limit[{#GCE.QUOTA.NAME}]

Preprocessing

  • JSON Path: $.limit

Quota [{#GCE.QUOTA.NAME}]: Percentage used

GCP Compute Engine: Percentage usage for [{#GCE.QUOTA.NAME}] quota.

Dependent item gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]

Preprocessing

  • Check for not supported value: any error

    ⛔️Custom on fail: Discard value

  • JSON Path: $.p_used

Trigger prototypes for GCP Compute Engine: Project quotas discovery

Name Description Expression Severity Dependencies and additional info
GCP: Quota [{#GCE.QUOTA.NAME}] limit has been changed

GCP Compute Engine: The limit for the {#GCE.QUOTA.NAME} quota has been changed.

change(/GCP by HTTP/gcp.gce.quota.limit[{#GCE.QUOTA.NAME}]) <> 0 Info Manual close: Yes
GCP: Quota [{#GCE.QUOTA.NAME}] usage is close to reaching the limit

GCP Compute Engine: The usage percentage for the {#GCE.QUOTA.NAME} quota is close to reaching the limit.

last(/GCP by HTTP/gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]) >= {$GCP.GCE.QUOTA.PUSED.MIN.WARN:"{#GCE.QUOTA.NAME}"} Warning Manual close: Yes
Depends on:
  • GCP: Quota [{#GCE.QUOTA.NAME}] usage is critically close to reaching the limit
GCP: Quota [{#GCE.QUOTA.NAME}] usage is critically close to reaching the limit

GCP Compute Engine: The usage percentage for the {#GCE.QUOTA.NAME} quota is critically close to reaching the limit.

last(/GCP by HTTP/gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]) >= {$GCP.GCE.QUOTA.PUSED.MIN.CRIT:"{#GCE.QUOTA.NAME}"} Average Manual close: Yes

Didn't find integration you need?