1618 lines
66 KiB
YAML
1618 lines
66 KiB
YAML
zabbix_export:
|
|
version: '7.0'
|
|
template_groups:
|
|
- uuid: c2c162144c2d4c5491c8801193af4945
|
|
name: Templates/Cloud
|
|
templates:
|
|
- uuid: e74c1e12f82e4d9880a368b53f5e65a4
|
|
template: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
name: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
description: |
|
|
Get GCP Cloud SQL PostgreSQL instances monitoring with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
|
|
This template will be automatically connected to discovered entities with all their required parameters pre-defined.
|
|
|
|
You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
|
|
|
|
Generated by official Zabbix template tool "Templator"
|
|
vendor:
|
|
name: Zabbix
|
|
version: 7.0-3
|
|
groups:
|
|
- name: Templates/Cloud
|
|
items:
|
|
- uuid: 396a555958514890af339f4504a96cc6
|
|
name: 'Reserved CPU cores'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.cpu.reserved_cores
|
|
delay: '0'
|
|
value_type: FLOAT
|
|
description: 'Number of cores reserved for the database.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_reserved_cores
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: cpu
|
|
- uuid: aa2e6d9118ed4b198ed9a28932ea8539
|
|
name: 'CPU usage time'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.cpu.usage_time
|
|
delay: '0'
|
|
value_type: FLOAT
|
|
units: s
|
|
description: 'Cumulative CPU usage time in seconds.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_usage_time
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: cpu
|
|
- uuid: cb7cd1b74e4944d88334f22d25b985fa
|
|
name: 'CPU utilization'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.cpu.utilization
|
|
delay: '0'
|
|
value_type: FLOAT
|
|
units: '%'
|
|
description: 'Current CPU utilization represented as a percentage of the reserved CPU that is currently in use.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_utilization
|
|
- type: MULTIPLIER
|
|
parameters:
|
|
- '100'
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: cpu
|
|
triggers:
|
|
- uuid: 3ca3942121bd41029645a19fd3947416
|
|
expression: 'min(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.cpu.utilization,5m) >= {$CLOUD_SQL.PGSQL.CPU.UTIL.MAX}'
|
|
name: 'GCP PostgreSQL: High CPU utilization'
|
|
opdata: 'Current utilization: {ITEM.LASTVALUE}'
|
|
priority: AVERAGE
|
|
description: 'The CPU utilization is too high. The system might be slow to respond.'
|
|
tags:
|
|
- tag: scope
|
|
value: performance
|
|
- uuid: 27ad9640bf734dd49548c19241cc4838
|
|
name: 'DB engine state'
|
|
type: HTTP_AGENT
|
|
key: gcp.cloudsql.pgsql.db.state
|
|
description: 'GCP Cloud SQL PostgreSQL DB Engine State.'
|
|
valuemap:
|
|
name: 'Database availability'
|
|
preprocessing:
|
|
- type: CHECK_NOT_SUPPORTED
|
|
parameters:
|
|
- '-1'
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.timeSeriesData[0].pointData[0].values[0].int64Value'
|
|
error_handler: DISCARD_VALUE
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 10m
|
|
timeout: '{$GCP.DATA.TIMEOUT}'
|
|
url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
|
|
status_codes: ''
|
|
posts: '{"query":"cloudsql.googleapis.com/database/up | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
|
|
headers:
|
|
- name: Content-Type
|
|
value: application/json
|
|
- name: Authorization
|
|
value: 'Bearer {$GCP.AUTH.TOKEN}'
|
|
request_method: POST
|
|
tags:
|
|
- tag: component
|
|
value: status
|
|
triggers:
|
|
- uuid: f7b0fc21edcf489ab174eb06dee4fabe
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.db.state)=0'
|
|
name: 'GCP PostgreSQL: Database engine is down'
|
|
priority: AVERAGE
|
|
description: |
|
|
Database engine is down.
|
|
If an instance experiences unplanned (non-maintenance) downtime, the instance state will still be RUNNING, but the database engine state metric will report 0.
|
|
dependencies:
|
|
- name: 'GCP PostgreSQL: Failed to get the instance state'
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 10'
|
|
- name: 'GCP PostgreSQL: Instance is in failed state'
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 5'
|
|
- name: 'GCP PostgreSQL: Instance is in maintenance'
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 4'
|
|
- name: 'GCP PostgreSQL: Instance is in suspended state'
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 1'
|
|
- name: 'GCP PostgreSQL: Instance is in unknown state'
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 6'
|
|
- name: 'GCP PostgreSQL: Instance is stopped by the owner'
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 2'
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- uuid: 799cad827e8b44d98b8285b08153842d
|
|
name: 'Disk bytes used'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.disk.bytes_used
|
|
delay: '0'
|
|
units: B
|
|
description: 'Data utilization in bytes.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_bytes_used
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: storage
|
|
- uuid: 470510bf76fb47fbbddfc8c4a711a335
|
|
name: 'Disk size'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.disk.quota
|
|
delay: '0'
|
|
units: B
|
|
description: 'Maximum data disk size in bytes.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_quota
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: storage
|
|
- uuid: f12ba5129c2d435389f4fb6964294381
|
|
name: 'Disk read I/O'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.disk.read_ops_count
|
|
delay: '0'
|
|
description: 'Delta count of data disk read I/O operations.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_read_ops_count
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: storage
|
|
- uuid: e2d6702514b941cb9586cb98786c6a01
|
|
name: 'Disk utilization'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.disk.utilization
|
|
delay: '0'
|
|
value_type: FLOAT
|
|
units: '%'
|
|
description: |
|
|
The fraction of the disk quota that is currently in use.
|
|
Shown as percentage.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_utilization
|
|
- type: MULTIPLIER
|
|
parameters:
|
|
- '100'
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: storage
|
|
triggers:
|
|
- uuid: c4fa1d580ffd4546b82605f94da5d2ba
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.disk.utilization) >= {$CLOUD_SQL.PGSQL.DISK.UTIL.CRIT}'
|
|
name: 'GCP PostgreSQL: Disk space is critically low'
|
|
opdata: 'Current utilization: {ITEM.LASTVALUE}'
|
|
priority: AVERAGE
|
|
description: 'Critical utilization of the disk space.'
|
|
tags:
|
|
- tag: scope
|
|
value: capacity
|
|
- uuid: 186a707ca3194c32a894ae809177a7e2
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.disk.utilization) >= {$CLOUD_SQL.PGSQL.DISK.UTIL.WARN}'
|
|
name: 'GCP PostgreSQL: Disk space is low'
|
|
opdata: 'Current utilization: {ITEM.LASTVALUE}'
|
|
priority: WARNING
|
|
description: 'High utilization of the storage space.'
|
|
dependencies:
|
|
- name: 'GCP PostgreSQL: Disk space is critically low'
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.disk.utilization) >= {$CLOUD_SQL.PGSQL.DISK.UTIL.CRIT}'
|
|
tags:
|
|
- tag: scope
|
|
value: capacity
|
|
- uuid: 8d8d6c13cdb244cb80c03226b7c14a90
|
|
name: 'Disk write I/O'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.disk.write_ops_count
|
|
delay: '0'
|
|
description: 'Delta count of data disk write I/O operations.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_write_ops_count
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: storage
|
|
- uuid: 88fd41960538460ebfd2ed9194677cd1
|
|
name: 'Instance state'
|
|
type: HTTP_AGENT
|
|
key: gcp.cloudsql.pgsql.inst.state
|
|
description: 'GCP Cloud SQL PostgreSQL Current instance state.'
|
|
valuemap:
|
|
name: 'Instance state'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.timeSeriesData[0].pointData[0].values[0].stringValue'
|
|
error_handler: CUSTOM_VALUE
|
|
error_handler_params: '10'
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
const idx = [
|
|
'RUNNING',
|
|
'SUSPENDED',
|
|
'RUNNABLE',
|
|
'PENDING_CREATE',
|
|
'MAINTENANCE',
|
|
'FAILED',
|
|
'UNKNOWN_STATE'
|
|
].indexOf(value);
|
|
return idx !== -1 ? idx : 10;
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 10m
|
|
timeout: '{$GCP.DATA.TIMEOUT}'
|
|
url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
|
|
status_codes: ''
|
|
posts: '{"query":"cloudsql.googleapis.com/database/state | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
|
|
headers:
|
|
- name: Content-Type
|
|
value: application/json
|
|
- name: Authorization
|
|
value: 'Bearer {$GCP.AUTH.TOKEN}'
|
|
request_method: POST
|
|
tags:
|
|
- tag: component
|
|
value: status
|
|
triggers:
|
|
- uuid: 596020e32d0c4193a6626c960b4b5be8
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 10'
|
|
name: 'GCP PostgreSQL: Failed to get the instance state'
|
|
priority: AVERAGE
|
|
description: |
|
|
Failed to get the instance state.
|
|
Check access permissions to GCP API or service account.
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- uuid: 1a2efb6f755444c0bab85d2778018eb1
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 5'
|
|
name: 'GCP PostgreSQL: Instance is in failed state'
|
|
priority: AVERAGE
|
|
description: 'The instance creation failed, or an operation left the instance in an own bad state.'
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- uuid: aad6fb2d86c84e33868aacbf160c3d65
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 4'
|
|
name: 'GCP PostgreSQL: Instance is in maintenance'
|
|
priority: INFO
|
|
description: 'The instance is down for maintenance.'
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- uuid: 959072ed00c4461196bef71618799b82
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 1'
|
|
name: 'GCP PostgreSQL: Instance is in suspended state'
|
|
priority: WARNING
|
|
description: |
|
|
The instance is in suspended state.
|
|
It is not available, for example, due to problems with billing.
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- uuid: 5f1084f744b444f3b803110baf703973
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 6'
|
|
name: 'GCP PostgreSQL: Instance is in unknown state'
|
|
priority: AVERAGE
|
|
description: 'The state of the instance is unknown.'
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- uuid: fb0df2eb001649febb6fc6513e056fcc
|
|
expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 2'
|
|
name: 'GCP PostgreSQL: Instance is stopped by the owner'
|
|
priority: INFO
|
|
description: |
|
|
The instance has been stopped by the owner.
|
|
It is not currently running, but it's ready to be restarted.
|
|
tags:
|
|
- tag: scope
|
|
value: availability
|
|
- uuid: 014d96156a364f2c8eac6a47de3eddfe
|
|
name: 'Memory size'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.memory.quota
|
|
delay: '0'
|
|
units: B
|
|
description: 'Maximum RAM size in bytes.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_quota
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: memory
|
|
- uuid: e73876fa0728402db7688a41938f4a12
|
|
name: 'Memory used by DB engine'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.memory.total_usage
|
|
delay: '0'
|
|
units: B
|
|
description: |
|
|
Total RAM usage in bytes.
|
|
This metric reports the RAM usage of the database process, including the buffer/cache.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_total_usage
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: memory
|
|
- uuid: 2a5daa0300564b97a5e744e576a217cb
|
|
name: 'Memory usage'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.memory.usage
|
|
delay: '0'
|
|
units: B
|
|
description: |
|
|
The RAM usage in bytes.
|
|
This metric reports the RAM usage of the server, excluding the buffer/cache.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_usage
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: memory
|
|
- uuid: 4c524a81bf3b4a6bbc87d23b60c4f74c
|
|
name: 'Memory utilization'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.memory.utilization
|
|
delay: '0'
|
|
value_type: FLOAT
|
|
units: '%'
|
|
description: |
|
|
The fraction of the memory quota that is currently in use.
|
|
Shown as percentage.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_ram_pused
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: memory
|
|
triggers:
|
|
- uuid: bbbdbd9c3c5b407491b359f98e4e3fa9
|
|
expression: 'min(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.memory.utilization,5m) >= {$CLOUD_SQL.PGSQL.RAM.UTIL.MAX}'
|
|
name: 'GCP PostgreSQL: High memory utilization'
|
|
opdata: 'Current utilization: {ITEM.LASTVALUE}'
|
|
priority: HIGH
|
|
description: 'RAM utilization is too high. The system might be slow to respond.'
|
|
tags:
|
|
- tag: scope
|
|
value: performance
|
|
- uuid: 9bf09a42ddd64f7eabf6bbc011eda689
|
|
name: 'Metrics get'
|
|
type: SCRIPT
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
delay: '{$GCP.TIME.WINDOW}'
|
|
history: '0'
|
|
value_type: TEXT
|
|
trends: '0'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var base_path = 'cloudsql.googleapis.com/database/',
|
|
pgsql_path = 'cloudsql.googleapis.com/database/postgresql/',
|
|
obj = {},
|
|
value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
|
|
|
|
function getField(data, path) {
|
|
var steps = path.split('.');
|
|
|
|
for (var i = 0; i < steps.length; i++) {
|
|
var step = steps[i];
|
|
|
|
if (typeof data !== 'object' || typeof data[step] === 'undefined') {
|
|
throw 'Required field "' + path + '" is not present in data received.';
|
|
}
|
|
data = data[step];
|
|
}
|
|
return data;
|
|
}
|
|
|
|
function checkParams(params) {
|
|
['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
|
|
throw 'Required param is not set: ' + field + '.';
|
|
}
|
|
});
|
|
if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
|
|
throw 'Incorrect update interval for parameter time_window. Valid ranges 1m-23h.';
|
|
}
|
|
return params;
|
|
}
|
|
|
|
function getHttpData(url, token, body) {
|
|
var tls = new CTlsConfig(params.tls_verify),
|
|
request = new HttpRequest(tls.options);
|
|
if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
|
|
request.setProxy(params.proxy);
|
|
};
|
|
request.addHeader('Authorization: Bearer ' + token);
|
|
request.addHeader('Content-Type: application/json');
|
|
|
|
var response = request.post(url, JSON.stringify(body));
|
|
|
|
Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (response !== null) {
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from GCP API. Check debug log for more information.';
|
|
}
|
|
}
|
|
|
|
if (typeof response !== 'object' || response === null) {
|
|
throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
|
|
}
|
|
|
|
if (request.getStatus() !== 200) {
|
|
if (typeof (response.error && response.error.message) !== 'undefined') {
|
|
throw response.error.message;
|
|
}
|
|
else {
|
|
throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
|
|
}
|
|
}
|
|
return response;
|
|
};
|
|
|
|
function rawMap(raw, prefix) {
|
|
var keys = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
|
|
values = getField(raw, 'timeSeriesData.0.pointData.0.values'),
|
|
re = /(^t_\d+\.value(_|\.)|_sum$)/g;
|
|
|
|
for (i in keys) {
|
|
var key = getField(keys[i], 'key').replace(re, '');
|
|
|
|
for (v in value_types) {
|
|
if (typeof values[i][value_types[v]] !== 'undefined') {
|
|
if (prefix) {
|
|
obj[prefix + key] = values[i][value_types[v]];
|
|
} else {
|
|
obj[key] = values[i][value_types[v]];
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
function singleMetrics(tsd) {
|
|
result = {};
|
|
for (t in tsd) {
|
|
for (v in value_types) {
|
|
if (typeof tsd[t].pointData[0].values[0][value_types[v]] !== 'undefined') {
|
|
result['pgsql_' + getField(tsd[t], 'labelValues.3.stringValue').toLowerCase()] = tsd[t].pointData[0].values[0][value_types[v]];
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
var params = checkParams(JSON.parse(value)),
|
|
filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
|
|
j_filter = filter + ' | join',
|
|
url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
|
|
base_paths = [
|
|
'cpu/reserved_cores',
|
|
'cpu/usage_time',
|
|
'cpu/utilization',
|
|
'disk/read_ops_count',
|
|
'disk/write_ops_count',
|
|
'memory/quota',
|
|
'memory/total_usage',
|
|
'memory/usage',
|
|
'network/received_bytes_count',
|
|
'network/sent_bytes_count | map ignore [destination]'
|
|
].map(function (path) { return base_path + path; }),
|
|
pgsql_paths = [
|
|
'transaction_id_utilization ' + filter,
|
|
'temp_bytes_written_count' + filter + ' | sum',
|
|
'temp_files_written_count' + filter + ' | sum',
|
|
'num_backends' + filter + ' | sum'
|
|
].map(function (path) { return pgsql_path + path; }).concat(
|
|
['disk/bytes_used', 'disk/utilization', 'disk/quota'].map(function (path) { return base_path + path; })),
|
|
queries = [
|
|
{ name: 'base_', data: { query: '{' + base_paths.join(';') + '}' + j_filter } },
|
|
{ name: 'pgsql_', data: { query: '{' + pgsql_paths.join(';') + '}' + '| within ' + params.time_window + '| join' } }
|
|
];
|
|
|
|
for (q in queries) {
|
|
raw = getHttpData(url, params.token, queries[q].data);
|
|
obj = Object.assign(obj, rawMap(raw, queries[q].name));
|
|
}
|
|
|
|
obj.base_ram_pused = Math.floor((getField(obj, 'base_usage') / getField(obj, 'base_quota')) * 100);
|
|
|
|
var single_paths = ['transaction_id_count', 'vacuum/oldest_transaction_age'],
|
|
single_queries = single_paths.map(function (path) { return { query: pgsql_path + path + filter }; });
|
|
|
|
for (q in single_queries) {
|
|
raw = getHttpData(url, params.token, single_queries[q]);
|
|
Object.assign(obj, singleMetrics(getField(raw, 'timeSeriesData')));
|
|
}
|
|
|
|
return JSON.stringify(obj);
|
|
description: 'PostgreSQL metrics data in raw format.'
|
|
preprocessing:
|
|
- type: CHECK_NOT_SUPPORTED
|
|
parameters:
|
|
- '-1'
|
|
timeout: '{$GCP.DATA.TIMEOUT}'
|
|
parameters:
|
|
- name: database_id
|
|
value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
|
|
- name: project_id
|
|
value: '{$GCP.PROJECT.ID}'
|
|
- name: proxy
|
|
value: '{$GCP.PROXY}'
|
|
- name: time_window
|
|
value: '{$GCP.TIME.WINDOW}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GCP Cloud SQL PostgreSQL"}'
|
|
- name: token
|
|
value: '{$GCP.AUTH.TOKEN}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
- uuid: f2d00c86eedd4a1e8efce7661c3da18d
|
|
name: 'Network: Received bytes'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.network.received_bytes_count
|
|
delay: '0'
|
|
units: B
|
|
description: 'Delta count of bytes received through the network.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_received_bytes_count
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: network
|
|
- tag: component
|
|
value: traffic
|
|
- uuid: dc67deac1a2f4cc993406028d6cc8c3b
|
|
name: 'Network: Sent bytes'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.network.sent_bytes_count
|
|
delay: '0'
|
|
units: B
|
|
description: 'Delta count of bytes sent through the network.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.base_sent_bytes_count
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: network
|
|
- tag: component
|
|
value: traffic
|
|
- uuid: 512c5d8156fb4d5299284f708e64dffc
|
|
name: Connections
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.num_backends
|
|
delay: '0'
|
|
description: |
|
|
The number of the connections to the Cloud SQL PostgreSQL instance.
|
|
Includes connections to the system databases, which aren't visible by default.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_num_backends
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: connections
|
|
- tag: component
|
|
value: network
|
|
- uuid: 88603b1881114551ba23e8f12d5ab47f
|
|
name: 'Oldest prepared transaction age'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.oldest_transaction.prepared
|
|
delay: '0'
|
|
description: |
|
|
Age of the oldest prepared transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
|
|
Empty value when there is no such transaction type.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_prepared
|
|
error_handler: DISCARD_VALUE
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: transactions
|
|
- uuid: 50df8067afcb42a9ac44fe963ee635d2
|
|
name: 'Oldest replica transaction age'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.oldest_transaction.replica
|
|
delay: '0'
|
|
description: |
|
|
Age of the oldest replica transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
|
|
Empty value when there is no such transaction type.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_replica
|
|
error_handler: DISCARD_VALUE
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: transactions
|
|
- uuid: fee3d72f615c479389c5fdb46f32229f
|
|
name: 'Oldest replication slot transaction age'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.oldest_transaction.replication_slot
|
|
delay: '0'
|
|
description: |
|
|
Age of the oldest replication slot transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
|
|
Empty value when there is no such transaction type.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_replication_slot
|
|
error_handler: DISCARD_VALUE
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: transactions
|
|
- uuid: 6d51c4865cd04607986ef4e02bc43fb6
|
|
name: 'Oldest running transaction age'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.oldest_transaction.running
|
|
delay: '0'
|
|
description: |
|
|
Age of the oldest running transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
|
|
Empty value when there is no such transaction type.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_running
|
|
error_handler: DISCARD_VALUE
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: transactions
|
|
- uuid: 75bc8d76a59a465fb66a434e13de107d
|
|
name: 'Data written to temporary'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.temp_bytes_written_count
|
|
delay: '0'
|
|
units: B
|
|
description: 'Total data size (in bytes) written to temporary files by the queries.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_temp_bytes_written_count
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: storage
|
|
- uuid: bd10ec6251c444a79878e82e3ebe9ac0
|
|
name: 'Temporary files used for writing data'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.temp_files_written_count
|
|
delay: '0'
|
|
description: 'Total number of temporary files used for writing data while performing algorithms such as join and sort.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_temp_files_written_count
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: storage
|
|
- uuid: 2498b066f4964aa7be03f4cc43eab95e
|
|
name: 'Assigned transactions'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.transaction_id_count_assigned
|
|
delay: '0'
|
|
description: 'Delta count of assigned transaction IDs.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_assigned
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: transactions
|
|
- uuid: 23d1b88571d347db9672596ec13580cc
|
|
name: 'Frozen transactions'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.transaction_id_count_frozen
|
|
delay: '0'
|
|
description: 'Delta count of frozen transaction IDs.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_frozen
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: transactions
|
|
- uuid: 004042d342d0478ea8f826466353454d
|
|
name: 'Transaction ID utilization'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.pgsql.transaction_id_utilization
|
|
delay: '0'
|
|
value_type: FLOAT
|
|
units: '%'
|
|
description: 'Current utilization represented as a percentage of transaction IDs consumed by the Cloud SQL PostgreSQL instance.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.pgsql_transaction_id_utilization
|
|
- type: MULTIPLIER
|
|
parameters:
|
|
- '100'
|
|
master_item:
|
|
key: gcp.cloudsql.pgsql.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: transactions
|
|
discovery_rules:
|
|
- uuid: 090d05a647384858a8b9efe5502c0a76
|
|
name: 'GCP Cloud SQL PostgreSQL: Databases discovery'
|
|
type: HTTP_AGENT
|
|
key: gcp.cloudsql.pgsql.db.discovery
|
|
delay: 1h
|
|
filter:
|
|
evaltype: AND
|
|
conditions:
|
|
- macro: '{#PGSQL.DB.NAME}'
|
|
value: '{$GCP.CLOUD_SQL.DB.NAME.MATCHES}'
|
|
formulaid: A
|
|
- macro: '{#PGSQL.DB.NAME}'
|
|
value: '{$GCP.CLOUD_SQL.DB.NAME.NOT_MATCHES}'
|
|
operator: NOT_MATCHES_REGEX
|
|
formulaid: B
|
|
description: 'Databases discovery for the particular PostgreSQL instance.'
|
|
item_prototypes:
|
|
- uuid: 997bdb03ba0b437ca2705f28dcc651ed
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Buffer cache blocks read.'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.blocks_read_count_buffer_cache[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Number of buffer cache blocks read by the [{#PGSQL.DB.NAME}] database.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.buffer_cache
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: memory
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: b35c4a888743448688a8c5233ed165e7
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Disk blocks read.'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.blocks_read_count_disk[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Number of disk blocks read by the [{#PGSQL.DB.NAME}] database.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.disk
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: storage
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: 7a1df30ae0c443839fe625142aea61b2
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Metrics raw'
|
|
type: SCRIPT
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
delay: '{$GCP.TIME.WINDOW}'
|
|
history: '0'
|
|
value_type: TEXT
|
|
trends: '0'
|
|
params: |
|
|
const CTlsConfig = function (raw_value) {
|
|
raw_value = String(raw_value).trim().toLowerCase();
|
|
|
|
if (['none', 'peer', 'full'].indexOf(raw_value) === -1) {
|
|
raw_value = 'full';
|
|
}
|
|
|
|
this.options = {
|
|
SSLVerifyPeer: (raw_value === 'peer' || raw_value === 'full'),
|
|
SSLVerifyHost: (raw_value === 'full')
|
|
};
|
|
|
|
this.enabled = (raw_value !== 'none');
|
|
|
|
this.checkURL = function (url) {
|
|
if (this.enabled && !/^https:\/\//i.test(url)) {
|
|
throw 'TLS certificate verification is enabled by {$' + 'HTTP.TLS.VERIFY}, but the URL uses plain HTTP: ' + url +
|
|
'. Use an "https://" URL, or set {$' + 'HTTP.TLS.VERIFY} to `none` to disable verification.';
|
|
}
|
|
|
|
return url;
|
|
};
|
|
}
|
|
|
|
|
|
var base_path = 'cloudsql.googleapis.com/database/postgresql/',
|
|
obj = {};
|
|
|
|
function checkParams(params) {
|
|
['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
|
|
throw 'Required param is not set: ' + field + '.';
|
|
}
|
|
});
|
|
if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
|
|
throw 'Incorrect update interval for parameter time_window. Valid ranges 1m-23h.';
|
|
}
|
|
return params;
|
|
}
|
|
|
|
function getField(data, path) {
|
|
var steps = path.split('.');
|
|
|
|
for (var i = 0; i < steps.length; i++) {
|
|
var step = steps[i];
|
|
|
|
if (typeof data !== 'object' || typeof data[step] === 'undefined') {
|
|
throw 'Required field "' + path + '" is not present in data received.';
|
|
}
|
|
data = data[step];
|
|
}
|
|
return data;
|
|
}
|
|
|
|
function getHttpData(url, token, body) {
|
|
var tls = new CTlsConfig(params.tls_verify),
|
|
request = new HttpRequest(tls.options);
|
|
if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
|
|
request.setProxy(params.proxy);
|
|
};
|
|
request.addHeader('Authorization: Bearer ' + token);
|
|
request.addHeader('Content-Type: application/json');
|
|
|
|
var response = request.post(url, JSON.stringify(body));
|
|
|
|
Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (response !== null) {
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from GCP API. Check debug log for more information.';
|
|
}
|
|
}
|
|
|
|
if (typeof response !== 'object' || response === null) {
|
|
throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
|
|
}
|
|
|
|
if (request.getStatus() !== 200) {
|
|
if (typeof (response.error && response.error.message) !== 'undefined') {
|
|
throw response.error.message;
|
|
}
|
|
else {
|
|
throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
|
|
}
|
|
}
|
|
return response;
|
|
};
|
|
|
|
function singleMetrics(tsd) {
|
|
var result = {};
|
|
|
|
for (i in tsd) {
|
|
result[getField(tsd[i], 'labelValues.4.stringValue')] = getField(tsd[i], 'pointData.0.values.0.int64Value');
|
|
}
|
|
return result;
|
|
}
|
|
|
|
var params = checkParams(JSON.parse(value)),
|
|
filter = ' | within ' + params.time_window + " | filter database_id ='" + params.database_id + "'" + " | filter database ='" + params.database_name + "'",
|
|
j_filter = filter + ' | join',
|
|
url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
|
|
common_paths = ['deadlock_count', 'tuples_returned_count', 'tuples_fetched_count'],
|
|
common_raw = getHttpData(url, params.token, { query: '{' + common_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
|
|
keys = getField(common_raw, 'timeSeriesDescriptor.pointDescriptors'),
|
|
values = getField(common_raw, 'timeSeriesData.0.pointData.0.values'),
|
|
re = /(^t_\d+\.value\.)/g;
|
|
|
|
for (i in keys) {
|
|
var value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
|
|
|
|
for (v in value_types) {
|
|
if (typeof values[i][value_types[v]] !== 'undefined') {
|
|
obj[getField(keys[i], 'key').replace(re, '')] = values[i][value_types[v]];
|
|
}
|
|
}
|
|
}
|
|
|
|
var single_paths = ['transaction_count', 'blocks_read_count', 'tuples_processed_count', 'tuple_size'],
|
|
single_queries = single_paths.map(function (path) { return { query: base_path + path + filter }; });
|
|
|
|
for (q in single_queries) {
|
|
raw = getHttpData(url, params.token, single_queries[q]);
|
|
obj = Object.assign(obj, singleMetrics(getField(raw, 'timeSeriesData')));
|
|
}
|
|
|
|
return JSON.stringify(obj);
|
|
description: 'PostgreSQL metrics in raw format.'
|
|
preprocessing:
|
|
- type: CHECK_NOT_SUPPORTED
|
|
parameters:
|
|
- '-1'
|
|
timeout: '{$GCP.DATA.TIMEOUT}'
|
|
parameters:
|
|
- name: database_id
|
|
value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
|
|
- name: database_name
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- name: project_id
|
|
value: '{$GCP.PROJECT.ID}'
|
|
- name: proxy
|
|
value: '{$GCP.PROXY}'
|
|
- name: time_window
|
|
value: '{$GCP.TIME.WINDOW}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"GCP Cloud SQL PostgreSQL"}'
|
|
- name: token
|
|
value: '{$GCP.AUTH.TOKEN}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: d5632c60593749209a6e681b396f4cc7
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Deadlocks count'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.deadlock_count[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Number of deadlocks detected in the [{#PGSQL.DB.NAME}] database.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.deadlock_count
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: deadlock
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: 6d846507fbc24cbb9fb4ad59167552db
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Committed transactions'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.transaction_count_commit[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Delta count of number of committed transactions to the [{#PGSQL.DB.NAME}] database.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.commit
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: transactions
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: 4751ef5e498e4ce184bd07aadc831d2b
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Rolled-back transactions'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.transaction_count_rollback[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Delta count of number of rolled-back transactions in the [{#PGSQL.DB.NAME}] database.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.rollback
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: transactions
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: a7451a61e0b04be8b1f85b47c44107e2
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Tuples fetched'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.tuples_fetched_count[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Total number of rows fetched as a result of queries to the [{#PGSQL.DB.NAME}] database.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.tuples_fetched_count
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: tuples
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: 7daca0b14f5843669bc5b0823cd4d44f
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Deleted rows processed'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.tuples_processed_count_delete[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Number of tuples(rows) processed for delete operations for the database with the name [{#PGSQL.DB.NAME}].'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.delete
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: tuples
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: 48a7613fa611410b8353d03d87af0f8d
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Inserted rows processed.'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.tuples_processed_count_insert[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Number of tuples(rows) processed for insert operations for the database with the name [{#PGSQL.DB.NAME}].'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.insert
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: tuples
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: e159cc28aec6448b9162f780479f5aab
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Updated rows processed'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.tuples_processed_count_update[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Number of tuples(rows) processed for update operations for the database with the name [{#PGSQL.DB.NAME}].'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.update
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: tuples
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: ee6fad5b2fb44a14a29c7cd662b1f5d2
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Tuples returned'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.tuples_returned_count[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Total number of rows scanned while processing the queries of the [{#PGSQL.DB.NAME}] database.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.tuples_returned_count
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: tuples
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: f7a58601a3384b8ba24c89b3693ddb88
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Dead tuples'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.tuple_size_dead[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Number of live tuples(rows) in the [{#PGSQL.DB.NAME}] database.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.dead
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: tuples
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
- uuid: 16e88225cd41406285b3237ee1e61bb4
|
|
name: 'Database [{#PGSQL.DB.NAME}]: Live tuples'
|
|
type: DEPENDENT
|
|
key: 'gcp.cloudsql.pgsql.tuple_size_live[{#PGSQL.DB.NAME}]'
|
|
delay: '0'
|
|
description: 'Number of live tuples(rows) in the [{#PGSQL.DB.NAME}] database.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.live
|
|
master_item:
|
|
key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
|
|
tags:
|
|
- tag: component
|
|
value: tuples
|
|
- tag: database
|
|
value: '{#PGSQL.DB.NAME}'
|
|
graph_prototypes:
|
|
- uuid: 8ba7dd12152243b4a5a438bd649f96c1
|
|
name: 'GCP Cloud SQL PostgreSQL: Database [{#PGSQL.DB.NAME}]: Tuples'
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: 'gcp.cloudsql.pgsql.tuple_size_dead[{#PGSQL.DB.NAME}]'
|
|
- sortorder: '1'
|
|
color: F63100
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: 'gcp.cloudsql.pgsql.tuple_size_live[{#PGSQL.DB.NAME}]'
|
|
- sortorder: '2'
|
|
color: 00611C
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: 'gcp.cloudsql.pgsql.tuples_processed_count_insert[{#PGSQL.DB.NAME}]'
|
|
- sortorder: '3'
|
|
color: F7941D
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: 'gcp.cloudsql.pgsql.tuples_processed_count_update[{#PGSQL.DB.NAME}]'
|
|
- sortorder: '4'
|
|
color: FC6EA3
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: 'gcp.cloudsql.pgsql.tuples_processed_count_delete[{#PGSQL.DB.NAME}]'
|
|
timeout: '{$GCP.DATA.TIMEOUT}'
|
|
url: 'https://sqladmin.googleapis.com/sql/v1beta4/projects/{$GCP.PROJECT.ID}/instances/{HOST.NAME}/databases'
|
|
headers:
|
|
- name: Content-Type
|
|
value: application/json
|
|
- name: Authorization
|
|
value: 'Bearer {$GCP.AUTH.TOKEN}'
|
|
lld_macro_paths:
|
|
- lld_macro: '{#PGSQL.DB.NAME}'
|
|
path: $.name
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.items
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 3h
|
|
tags:
|
|
- tag: class
|
|
value: cloud
|
|
- tag: target
|
|
value: cloudsql
|
|
- tag: target
|
|
value: gcp
|
|
- tag: target
|
|
value: google-cloud-platform
|
|
- tag: target
|
|
value: postgresql
|
|
macros:
|
|
- macro: '{$CLOUD_SQL.PGSQL.CPU.UTIL.MAX}'
|
|
value: '95'
|
|
description: 'GCP Cloud SQL PostgreSQL instance CPU usage threshold.'
|
|
- macro: '{$CLOUD_SQL.PGSQL.DISK.UTIL.CRIT}'
|
|
value: '90'
|
|
description: 'GCP Cloud SQL PostgreSQL instance critical disk usage threshold.'
|
|
- macro: '{$CLOUD_SQL.PGSQL.DISK.UTIL.WARN}'
|
|
value: '80'
|
|
description: 'GCP Cloud SQL PostgreSQL instance warning disk usage threshold.'
|
|
- macro: '{$CLOUD_SQL.PGSQL.RAM.UTIL.MAX}'
|
|
value: '90'
|
|
description: 'GCP Cloud SQL PostgreSQL instance RAM usage threshold.'
|
|
- macro: '{$GCP.CLOUD_SQL.DB.NAME.MATCHES}'
|
|
value: '.*'
|
|
description: 'The filter to include GCP Cloud SQL PostgreSQL databases by namespace.'
|
|
- macro: '{$GCP.CLOUD_SQL.DB.NAME.NOT_MATCHES}'
|
|
value: CHANGE_IF_NEEDED
|
|
description: 'The filter to exclude GCP Cloud SQL PostgreSQL databases by namespace.'
|
|
- macro: '{$GCP.DATA.TIMEOUT}'
|
|
value: 15s
|
|
description: 'A response timeout for an API.'
|
|
- macro: '{$GCP.PROXY}'
|
|
description: 'Sets HTTP proxy value. If this macro is empty then no proxy is used.'
|
|
- macro: '{$GCP.TIME.WINDOW}'
|
|
value: 5m
|
|
description: |
|
|
Time interval for the data requests.
|
|
Supported usage type:
|
|
1. The default update interval for most of the items.
|
|
2. The minimal time window for the data requested in the Monitoring Query Language REST API request.
|
|
- macro: '{$HTTP.TLS.VERIFY}'
|
|
value: full
|
|
description: 'TLS certificate verification for script items: "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 Cloud SQL PostgreSQL", e.g. {$HTTP.TLS.VERIFY:"GCP Cloud SQL PostgreSQL"}.'
|
|
dashboards:
|
|
- uuid: 21636cfe7d2f4de28d07af09c9812075
|
|
name: 'PostgreSQL instance'
|
|
pages:
|
|
- name: 'PostgreSQL instance'
|
|
widgets:
|
|
- type: graph
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.cpu.usage_time
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAA
|
|
- type: INTEGER
|
|
name: source_type
|
|
value: '1'
|
|
- type: graph
|
|
'y': '5'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: GRAPH
|
|
name: graphid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
name: 'GCP Cloud SQL PostgreSQL: Memory usage'
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAC
|
|
- type: graph
|
|
'y': '10'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.disk.utilization
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAE
|
|
- type: INTEGER
|
|
name: source_type
|
|
value: '1'
|
|
- type: graph
|
|
'y': '15'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: GRAPH
|
|
name: graphid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
name: 'GCP Cloud SQL PostgreSQL: Network traffic'
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAG
|
|
- type: graph
|
|
'y': '20'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: GRAPH
|
|
name: graphid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
name: 'GCP Cloud SQL PostgreSQL: Transactions count'
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAI
|
|
- type: graphprototype
|
|
'y': '25'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: INTEGER
|
|
name: columns
|
|
value: '1'
|
|
- type: GRAPH_PROTOTYPE
|
|
name: graphid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
name: 'GCP Cloud SQL PostgreSQL: Database [{#PGSQL.DB.NAME}]: Tuples'
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAK
|
|
- type: graph
|
|
x: '36'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.cpu.utilization
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAB
|
|
- type: INTEGER
|
|
name: source_type
|
|
value: '1'
|
|
- type: graph
|
|
x: '36'
|
|
'y': '5'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.memory.utilization
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAD
|
|
- type: INTEGER
|
|
name: source_type
|
|
value: '1'
|
|
- type: graph
|
|
x: '36'
|
|
'y': '10'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: GRAPH
|
|
name: graphid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
name: 'GCP Cloud SQL PostgreSQL: Disk read/write operations'
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAF
|
|
- type: graph
|
|
x: '36'
|
|
'y': '15'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.transaction_id_utilization
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAH
|
|
- type: INTEGER
|
|
name: source_type
|
|
value: '1'
|
|
- type: graph
|
|
x: '36'
|
|
'y': '20'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: GRAPH
|
|
name: graphid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
name: 'GCP Cloud SQL PostgreSQL: Transaction age'
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAJ
|
|
- type: graphprototype
|
|
x: '36'
|
|
'y': '25'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: INTEGER
|
|
name: columns
|
|
value: '1'
|
|
- type: ITEM_PROTOTYPE
|
|
name: itemid.0
|
|
value:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: 'gcp.cloudsql.pgsql.deadlock_count[{#PGSQL.DB.NAME}]'
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAL
|
|
- type: INTEGER
|
|
name: source_type
|
|
value: '3'
|
|
valuemaps:
|
|
- uuid: c783556dfa214e73b676ca187648c5df
|
|
name: 'Database availability'
|
|
mappings:
|
|
- value: '0'
|
|
newvalue: Down
|
|
- value: '1'
|
|
newvalue: Up
|
|
- uuid: bc3b08ca201d438689678a29e3575823
|
|
name: 'Instance state'
|
|
mappings:
|
|
- value: '0'
|
|
newvalue: Running
|
|
- value: '1'
|
|
newvalue: Suspended
|
|
- value: '2'
|
|
newvalue: Runnable
|
|
- value: '3'
|
|
newvalue: 'Pending create'
|
|
- value: '4'
|
|
newvalue: Maintenance
|
|
- value: '5'
|
|
newvalue: Failed
|
|
- value: '6'
|
|
newvalue: 'Unknown state'
|
|
- value: '10'
|
|
newvalue: 'Data retrievement error'
|
|
graphs:
|
|
- uuid: e2e4ef0a2c1a43d68ae9f4ee881f070e
|
|
name: 'GCP Cloud SQL PostgreSQL: Disk read/write operations'
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.disk.read_ops_count
|
|
- sortorder: '1'
|
|
color: F63100
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.disk.write_ops_count
|
|
- uuid: 707d5cca2ba349f18088d00ef7657eef
|
|
name: 'GCP Cloud SQL PostgreSQL: Disk usage'
|
|
graph_items:
|
|
- drawtype: BOLD_LINE
|
|
color: 199C0D
|
|
calc_fnc: MIN
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.disk.quota
|
|
- sortorder: '1'
|
|
drawtype: GRADIENT_LINE
|
|
color: F63100
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.disk.bytes_used
|
|
- uuid: 897843c1fef540c2ab033c9bad0e9de1
|
|
name: 'GCP Cloud SQL PostgreSQL: Memory usage'
|
|
graph_items:
|
|
- drawtype: BOLD_LINE
|
|
color: 199C0D
|
|
calc_fnc: MIN
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.memory.quota
|
|
- sortorder: '1'
|
|
drawtype: GRADIENT_LINE
|
|
color: F63100
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.memory.usage
|
|
- uuid: 8a61208f44c94cf5bfcb851c4de6412a
|
|
name: 'GCP Cloud SQL PostgreSQL: Network traffic'
|
|
type: STACKED
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.network.received_bytes_count
|
|
- sortorder: '1'
|
|
color: F63100
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.network.sent_bytes_count
|
|
- uuid: bf09992b7f324703b3d51250e47d37f4
|
|
name: 'GCP Cloud SQL PostgreSQL: Transaction age'
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.oldest_transaction.prepared
|
|
- sortorder: '1'
|
|
color: F63100
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.oldest_transaction.replication_slot
|
|
- sortorder: '2'
|
|
color: 00611C
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.oldest_transaction.replica
|
|
- sortorder: '3'
|
|
color: F7941D
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.oldest_transaction.running
|
|
- uuid: 5c567b9d1ef14fcb93eef332fccbe198
|
|
name: 'GCP Cloud SQL PostgreSQL: Transactions count'
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.transaction_id_count_assigned
|
|
- sortorder: '1'
|
|
color: F63100
|
|
item:
|
|
host: 'GCP Cloud SQL PostgreSQL by HTTP'
|
|
key: gcp.cloudsql.pgsql.transaction_id_count_frozen
|