Backup de templates Zabbix 7.0.31

This commit is contained in:
HalbeBruno
2026-09-28 18:15:44 -03:00
commit b64daea4da
356 changed files with 728750 additions and 0 deletions
@@ -0,0 +1,466 @@
zabbix_export:
version: '7.0'
template_groups:
- uuid: c2c162144c2d4c5491c8801193af4945
name: Templates/Cloud
templates:
- uuid: b43a7c5f1d1d43d28e2eb8f0a9f6f16f
template: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
name: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
description: |
Get GCP Cloud SQL PostgreSQL monitoring for read-only replicas 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-2
groups:
- name: Templates/Cloud
items:
- uuid: c67dd812c7784948bad5dfa0d9a6cc66
name: 'Flush location lag'
type: DEPENDENT
key: gcp.cloudsql.pgsql.repl.flush_location
delay: '0'
units: B
description: 'Flush location replication lag in bytes.'
preprocessing:
- type: JSONPATH
parameters:
- $.flush_location
master_item:
key: gcp.cloudsql.pgsql.repl.metrics.get
tags:
- tag: component
value: replication
- uuid: 2b8b51f0266049ffbfb7ece2f944fb68
name: 'Number of log archival failures'
type: DEPENDENT
key: gcp.cloudsql.pgsql.repl.log_archive_failure_count
delay: '0'
description: 'Number of failed attempts for archiving replication log files.'
preprocessing:
- type: JSONPATH
parameters:
- $.log_archive_failure_count
master_item:
key: gcp.cloudsql.pgsql.repl.metrics.get
tags:
- tag: component
value: replication
- uuid: 4657c4bb904b437598b68410e47f7194
name: 'Number of log archival successes'
type: DEPENDENT
key: gcp.cloudsql.pgsql.repl.log_archive_success_count
delay: '0'
description: 'Number of failed attempts for archiving replication log files.'
preprocessing:
- type: JSONPATH
parameters:
- $.log_archive_success_count
master_item:
key: gcp.cloudsql.pgsql.repl.metrics.get
tags:
- tag: component
value: replication
- uuid: cb9c5aff913e4deeb29dfa1a20b5ff04
name: 'Replica metrics get'
type: SCRIPT
key: gcp.cloudsql.pgsql.repl.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/replication/',
pgsql_path = 'cloudsql.googleapis.com/database/postgresql/replication/',
obj = {},
base_paths = ['network_lag', 'replica_lag', 'log_archive_failure_count', 'log_archive_success_count'];
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));
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;
};
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',
metric_raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
metric_keys = getField(metric_raw, 'timeSeriesDescriptor.pointDescriptors'),
metric_values = getField(metric_raw, 'timeSeriesData.0.pointData.0.values'),
re = /(^t_\d+\.value\.)/g;
for (i in metric_keys) {
var value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
for (v in value_types) {
if (typeof metric_values[i][value_types[v]] !== 'undefined') {
obj[getField(metric_keys[i], 'key').replace(re, '')] = metric_values[i][value_types[v]];
}
}
}
var state_raw = getHttpData(url, params.token, { query: base_path + 'state' + filter }),
state_keys = getField(state_raw, 'timeSeriesDescriptor.pointDescriptors'),
state_tsd = getField(state_raw, 'timeSeriesData');
for (i in state_keys) {
var state_key = getField(state_keys[i], 'key').replace(/value\./g, '');
obj[state_key] = 'undefined';
for (t in state_tsd) {
if (getField(state_tsd[t], 'pointData.0.values.' + i + '.boolValue') == true) {
obj[state_key] = getField(state_tsd[t], 'labelValues.3.stringValue');
break;
}
}
}
var lag_raw = getHttpData(url, params.token, { query: pgsql_path + 'replica_byte_lag' + '| within ' + params.time_window + " | filter replica_name = '" + params.database_id + "'" }),
lag_tsd = getField(lag_raw, 'timeSeriesData');
for (t in lag_tsd) {
obj[getField(lag_tsd[t], 'labelValues.3.stringValue')] = getField(lag_tsd[t], 'pointData.0.values.0.int64Value');
}
return JSON.stringify(obj);
description: 'PostgreSQL replica 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 Replica"}'
- name: token
value: '{$GCP.AUTH.TOKEN}'
tags:
- tag: component
value: raw
- uuid: e43272210c45425d871d70a5bb91cdd1
name: 'Network lag'
type: DEPENDENT
key: gcp.cloudsql.pgsql.repl.network_lag
delay: '0'
units: s
description: 'Indicates time taken from primary binary log to IO thread on replica.'
preprocessing:
- type: JSONPATH
parameters:
- $.network_lag
master_item:
key: gcp.cloudsql.pgsql.repl.metrics.get
tags:
- tag: component
value: replication
- uuid: 7d74736aa2804c899de35634bc072edf
name: 'Replay location lag'
type: DEPENDENT
key: gcp.cloudsql.pgsql.repl.replay_location
delay: '0'
units: B
description: 'Replay location replication lag in bytes.'
preprocessing:
- type: JSONPATH
parameters:
- $.replay_location
master_item:
key: gcp.cloudsql.pgsql.repl.metrics.get
tags:
- tag: component
value: replication
- uuid: 192e0bb3ac744f8eb38a760ee3f7c623
name: 'Replication lag'
type: DEPENDENT
key: gcp.cloudsql.pgsql.repl.replica_lag
delay: '0'
units: s
description: 'Number of seconds the read replica is behind its primary (approximation).'
preprocessing:
- type: JSONPATH
parameters:
- $.replica_lag
master_item:
key: gcp.cloudsql.pgsql.repl.metrics.get
tags:
- tag: component
value: replication
- uuid: 379c8bc0cfe847d1819ab96aceee5efe
name: 'Sent location lag'
type: DEPENDENT
key: gcp.cloudsql.pgsql.repl.sent_location
delay: '0'
units: B
description: 'Sent location replication lag in bytes.'
preprocessing:
- type: JSONPATH
parameters:
- $.sent_location
master_item:
key: gcp.cloudsql.pgsql.repl.metrics.get
tags:
- tag: component
value: replication
- uuid: a7f785dbe4954d77a82e6384620b5d6e
name: 'Replication state'
type: DEPENDENT
key: gcp.cloudsql.pgsql.repl.state
delay: '0'
description: |
The current serving state of replication.
This metric is only available for the MySQL/PostgreSQL instances.
valuemap:
name: 'Replication state'
preprocessing:
- type: JSONPATH
parameters:
- $.state
- type: JAVASCRIPT
parameters:
- |
const idx = [
'Running',
'Syncing',
'Unsynced',
'Stopped',
'Error',
].indexOf(value);
return idx !== -1 ? idx : 10;
master_item:
key: gcp.cloudsql.pgsql.repl.metrics.get
tags:
- tag: component
value: replication
- tag: component
value: status
- uuid: 10af15bc71ed446eb4e614c2cb6029d5
name: 'Write location lag'
type: DEPENDENT
key: gcp.cloudsql.pgsql.repl.write_location
delay: '0'
units: B
description: 'Write location replication lag in bytes.'
preprocessing:
- type: JSONPATH
parameters:
- $.write_location
master_item:
key: gcp.cloudsql.pgsql.repl.metrics.get
tags:
- tag: component
value: replication
tags:
- tag: class
value: cloud
- tag: target
value: cloudsql
- tag: target
value: gcp
- tag: target
value: google-cloud-platform
- tag: target
value: postgresql
- tag: target
value: replica
macros:
- 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 Replica", e.g. {$HTTP.TLS.VERIFY:"GCP Cloud SQL PostgreSQL Replica"}.'
dashboards:
- uuid: acb71f4a818d43e0b045ba87c2daa989
name: 'PostgreSQL replica'
pages:
- name: 'PostgreSQL replica'
widgets:
- type: graph
width: '36'
height: '5'
fields:
- type: GRAPH
name: graphid.0
value:
host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
name: 'GCP Cloud SQL PostgreSQL: WAL archiving'
- type: STRING
name: reference
value: AAAAA
- type: graph
x: '36'
width: '36'
height: '5'
fields:
- type: GRAPH
name: graphid.0
value:
host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
name: 'GCP Cloud SQL PostgreSQL: Lags'
- type: STRING
name: reference
value: AAAAB
valuemaps:
- uuid: af111e6b9e5a47cd9c3933b8ce35076c
name: 'Replication state'
mappings:
- value: '0'
newvalue: Running
- value: '1'
newvalue: Syncing
- value: '2'
newvalue: Unsynced
- value: '3'
newvalue: Stopped
- value: '4'
newvalue: Error
- value: '10'
newvalue: Unknown
graphs:
- uuid: 30fe61bafae64ae6b29dacd68e9a6b3b
name: 'GCP Cloud SQL PostgreSQL: Lags'
graph_items:
- color: 199C0D
item:
host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
key: gcp.cloudsql.pgsql.repl.network_lag
- sortorder: '1'
color: F63100
item:
host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
key: gcp.cloudsql.pgsql.repl.replica_lag
- sortorder: '2'
color: 00611C
item:
host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
key: gcp.cloudsql.pgsql.repl.flush_location
- sortorder: '3'
color: F7941D
item:
host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
key: gcp.cloudsql.pgsql.repl.replay_location
- sortorder: '4'
color: FC6EA3
item:
host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
key: gcp.cloudsql.pgsql.repl.sent_location
- sortorder: '5'
color: 6C59DC
item:
host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
key: gcp.cloudsql.pgsql.repl.write_location
- uuid: e96be84efaf7445fbfd8cf707b585fe7
name: 'GCP Cloud SQL PostgreSQL: WAL archiving'
graph_items:
- color: 199C0D
item:
host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
key: gcp.cloudsql.pgsql.repl.log_archive_failure_count
- sortorder: '1'
color: F63100
item:
host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
key: gcp.cloudsql.pgsql.repl.log_archive_success_count