356 lines
14 KiB
YAML
356 lines
14 KiB
YAML
zabbix_export:
|
|
version: '7.0'
|
|
template_groups:
|
|
- uuid: c2c162144c2d4c5491c8801193af4945
|
|
name: Templates/Cloud
|
|
templates:
|
|
- uuid: 54f0ffb538d94a9bb8062df3e63c4cb6
|
|
template: 'GCP Cloud SQL MSSQL Replica by HTTP'
|
|
name: 'GCP Cloud SQL MSSQL Replica by HTTP'
|
|
description: |
|
|
Get GCP Cloud SQL MSSQL 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: e66fe8bb6f924cb088ec57b215fe21d7
|
|
name: 'Bytes sent to replica'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.mssql.repl.bytes_sent_to_replica_count
|
|
delay: '0'
|
|
units: B
|
|
description: |
|
|
Total number of bytes sent to the remote availability replica.
|
|
For an async replica, returns the number of bytes before compression.
|
|
For a sync replica without compression, returns the actual number of bytes.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.bytes_sent_to_replica_count
|
|
master_item:
|
|
key: gcp.cloudsql.mssql.repl.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: replication
|
|
- uuid: 4100432768354e1ca7349a901bccbe85
|
|
name: 'Log apply pending queue'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.mssql.repl.log_apply_pending_queue
|
|
delay: '0'
|
|
description: 'Current number of log blocks that are waiting to be applied to replica.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.log_apply_pending_queue
|
|
master_item:
|
|
key: gcp.cloudsql.mssql.repl.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: replication
|
|
- uuid: d060637548af434e926ed833083d9fa0
|
|
name: 'Log bytes received'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.mssql.repl.log_bytes_received_count
|
|
delay: '0'
|
|
units: B
|
|
description: 'Total size of log records received by the replica.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.log_bytes_received_count
|
|
master_item:
|
|
key: gcp.cloudsql.mssql.repl.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: replication
|
|
- uuid: f0d4c711863f4ca9ad76b0099a66a86d
|
|
name: 'Replica metrics get'
|
|
type: SCRIPT
|
|
key: gcp.cloudsql.mssql.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/sqlserver/replication/',
|
|
obj = {},
|
|
base_paths = [
|
|
'bytes_sent_to_replica_count | map ignore [replica_name]',
|
|
'resent_message_count | map ignore [replica_name]',
|
|
'log_apply_pending_queue',
|
|
'log_bytes_received_count',
|
|
'recovery_queue',
|
|
'redone_bytes_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));
|
|
|
|
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;
|
|
};
|
|
|
|
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_raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
|
|
keys = getField(base_raw, 'timeSeriesDescriptor.pointDescriptors'),
|
|
values = getField(base_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]];
|
|
}
|
|
}
|
|
}
|
|
|
|
return JSON.stringify(obj);
|
|
description: 'MSSQL 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 MSSQL Replica"}'
|
|
- name: token
|
|
value: '{$GCP.AUTH.TOKEN}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
- uuid: 4ec364fea7894df29813b65c2d170367
|
|
name: 'Recovery queue'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.mssql.repl.recovery_queue
|
|
delay: '0'
|
|
units: B
|
|
description: 'Current size of log records in bytes in the replica''s log files that have not been redone.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.recovery_queue
|
|
- type: MULTIPLIER
|
|
parameters:
|
|
- '1024'
|
|
master_item:
|
|
key: gcp.cloudsql.mssql.repl.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: replication
|
|
- uuid: 37c145777926471482ecffd1b6cca792
|
|
name: 'Redone bytes'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.mssql.repl.redone_bytes_count
|
|
delay: '0'
|
|
units: B
|
|
description: 'Total size in bytes of redone log records.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.redone_bytes_count
|
|
master_item:
|
|
key: gcp.cloudsql.mssql.repl.metrics.get
|
|
tags:
|
|
- tag: component
|
|
value: replication
|
|
- uuid: 23911902d27e4fa68435935aeeec28e1
|
|
name: 'Resent messages'
|
|
type: DEPENDENT
|
|
key: gcp.cloudsql.mssql.repl.resent_message_count
|
|
delay: '0'
|
|
description: |
|
|
Total count of Always On messages to resend.
|
|
This includes messages that were attempted to be sent but failed and require resending.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.resent_message_count
|
|
master_item:
|
|
key: gcp.cloudsql.mssql.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: mssql
|
|
- 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 MSSQL Replica", e.g. {$HTTP.TLS.VERIFY:"GCP Cloud SQL MSSQL Replica"}.'
|
|
dashboards:
|
|
- uuid: f50d9889ca3c4f6b91dd9e40902e37fb
|
|
name: 'MSSQL replica'
|
|
pages:
|
|
- name: 'MSSQL replica'
|
|
widgets:
|
|
- type: graph
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: GRAPH
|
|
name: graphid.0
|
|
value:
|
|
host: 'GCP Cloud SQL MSSQL Replica by HTTP'
|
|
name: 'GCP Cloud SQL MSSQL: Replication data'
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAA
|
|
- type: graph
|
|
x: '36'
|
|
width: '36'
|
|
height: '5'
|
|
fields:
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'GCP Cloud SQL MSSQL Replica by HTTP'
|
|
key: gcp.cloudsql.mssql.repl.log_apply_pending_queue
|
|
- type: STRING
|
|
name: reference
|
|
value: AAAAB
|
|
- type: INTEGER
|
|
name: source_type
|
|
value: '1'
|
|
graphs:
|
|
- uuid: 0bfd3e8be20c4b5a88b23f16aff4eb82
|
|
name: 'GCP Cloud SQL MSSQL: Replication data'
|
|
graph_items:
|
|
- color: 199C0D
|
|
item:
|
|
host: 'GCP Cloud SQL MSSQL Replica by HTTP'
|
|
key: gcp.cloudsql.mssql.repl.bytes_sent_to_replica_count
|
|
- sortorder: '1'
|
|
color: F63100
|
|
item:
|
|
host: 'GCP Cloud SQL MSSQL Replica by HTTP'
|
|
key: gcp.cloudsql.mssql.repl.log_bytes_received_count
|
|
- sortorder: '2'
|
|
color: 00611C
|
|
item:
|
|
host: 'GCP Cloud SQL MSSQL Replica by HTTP'
|
|
key: gcp.cloudsql.mssql.repl.redone_bytes_count
|