Available solutions
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
- Enable the
Stackdriver Monitoring APIfor the GCP project you wish to monitor.
Refer to the vendor documentation.
- Create a service account in Google Cloud console for the project you have to monitor.
Refer to the vendor documentation.
- Create and download the service account key in JSON format.
Refer to the vendor documentation.
- 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.
- Copy the
project_id,private_key_id,private_key,client_emailfrom 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:
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
|
| Authorization errors check | A list of errors from API requests. |
Dependent item | gcp.auth.err.check Preprocessing
|
| Cloud SQL instances get | GCP Cloud SQL: Instances get. |
Dependent item | gcp.cloudsql.instances.get Preprocessing
|
| Cloud SQL instances total | GCP Cloud SQL instances total count. |
Dependent item | gcp.cloudsql.instances.total Preprocessing
|
| MSSQL instances count | GCP Cloud SQL MSSQL instances count. |
Dependent item | gcp.cloudsql.instances.mssql_count Preprocessing
|
| MySQL instances count | GCP Cloud SQL MySQL instances count. |
Dependent item | gcp.cloudsql.instances.mysql_count Preprocessing
|
| PostgreSQL instances count | GCP Cloud SQL PostgreSQL instances count. |
Dependent item | gcp.cloudsql.instances.pgsql_count Preprocessing
|
| GCE instances total | GCP Compute Engine instances total count. |
Dependent item | gcp.gce.instances.total Preprocessing
|
| Regular GCE instances count | GCP Compute Engine: Regular instances count. |
Dependent item | gcp.gce.instances.regular_count Preprocessing
|
| Container-optimized GCE instances count | GCP Compute Engine: count of instances with Container-Optimized OS used. |
Dependent item | gcp.gce.instances.cos_count Preprocessing
|
| Project quotas get | GCP Compute Engine resource quotas available for the particular project. |
Dependent item | gcp.gce.quotas.get Preprocessing
|
Triggers
| Name | Description | Expression | Severity | Dependencies and additional info |
|---|---|---|---|---|
| GCP: Authorization has failed | GCP: Authorization has failed. |
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
|
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
|
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
|
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
|
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
|
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
|
| 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
|
| 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
|
| 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
|
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 |
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 |
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 Compute Engine: The usage percentage for the |
last(/GCP by HTTP/gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]) >= {$GCP.GCE.QUOTA.PUSED.MIN.CRIT:"{#GCE.QUOTA.NAME}"} |
Average | Manual close: Yes |