Files
templates-default/GCP_Compute_Engine_Instance_by_HTTP.yaml
T

1547 lines
60 KiB
YAML

zabbix_export:
version: '7.0'
template_groups:
- uuid: c2c162144c2d4c5491c8801193af4945
name: Templates/Cloud
templates:
- uuid: 6d2443db49e54d59a82b9b525f2424ef
template: 'GCP Compute Engine Instance by HTTP'
name: 'GCP Compute Engine Instance by HTTP'
description: |
Discover GCP Compute Engine instances by HTTP with script item usage.
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: 3de05ba490644a62ba4a700ffe439c98
name: 'Guest visible vCPUs'
type: DEPENDENT
key: gcp.gce.cpu.guest_visible_vcpus
delay: '0'
value_type: FLOAT
description: |
Number of vCPUs visible inside the guest.
For many GCE machine types, the number of vCPUs visible inside the guest is equal to the `compute.googleapis.com/instance/cpu/reserved_cores` metric.
For shared-core machine types, the number of guest-visible vCPUs differs from the number of reserved cores.
For example, e2-small instances have two vCPUs visible inside the guest and 0.5 fractional vCPUs reserved.
Therefore, for an e2-small instance, `compute.googleapis.com/instance/cpu/guest_visible_vcpus` has a value of 2 and `compute.googleapis.com/instance/cpu/reserved_cores` has a value of 0.5.
preprocessing:
- type: JSONPATH
parameters:
- $.guest_visible_vcpus
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: cpu
- uuid: 2fa7a2aa15a242cc826248ebe96bb173
name: 'Reserved vCPUs'
type: DEPENDENT
key: gcp.gce.cpu.reserved_cores
delay: '0'
value_type: FLOAT
description: 'Number of vCPUs reserved on the host of the instance.'
preprocessing:
- type: JSONPATH
parameters:
- $.reserved_cores
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: cpu
- uuid: f6c9c633f514416189ba85d2015251ba
name: 'Scheduler wait time'
type: DEPENDENT
key: gcp.gce.cpu.scheduler_wait_time
delay: '0'
value_type: FLOAT
units: s
description: |
Wait time is the time a vCPU is ready to run, but unexpectedly not scheduled to run.
The wait time returned here is the accumulated value for all vCPUs.
The time interval for which the value was measured is returned by Monitoring in whole seconds as start_time and end_time.
This metric is only available for VMs that belong to the e2 family or to overcommitted VMs on sole-tenant nodes.
preprocessing:
- type: JSONPATH
parameters:
- $.scheduler_wait_time
error_handler: DISCARD_VALUE
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: cpu
- uuid: daf4d0d23ccf4633aad6405bd1f09dc3
name: 'CPU usage time'
type: DEPENDENT
key: gcp.gce.cpu.usage_time
delay: '0'
value_type: FLOAT
units: s
description: |
Delta vCPU usage for all vCPUs, in vCPU-seconds.
To compute the per-vCPU utilization fraction, divide this value by (end-start)*N, where end and start define this value's time interval and N is `compute.googleapis.com/instance/cpu/reserved_cores` at the end of the interval.
This value is reported by the hypervisor for the VM and can differ from `agent.googleapis.com/cpu/usage_time`, which is reported from inside the VM.
preprocessing:
- type: JSONPATH
parameters:
- $.usage_time
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: cpu
- uuid: 666cd3e9f21d4ede9d4bcc16bc95347c
name: 'CPU utilization'
type: DEPENDENT
key: gcp.gce.cpu.utilization
delay: '0'
value_type: FLOAT
units: '%'
description: |
Fractional utilization of allocated CPU on this instance.
This metric is reported by the hypervisor for the VM and can differ from `agent.googleapis.com/cpu/utilization`, which is reported from inside the VM.
preprocessing:
- type: JSONPATH
parameters:
- $.utilization
- type: MULTIPLIER
parameters:
- '100'
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: cpu
triggers:
- uuid: fb8e28649b4947e9a11d891e3126a3a1
expression: 'min(/GCP Compute Engine Instance by HTTP/gcp.gce.cpu.utilization,15m) >= {$GCE.CPU.UTIL.MAX}'
name: 'GCP Compute Engine Instance: High CPU utilization'
event_name: 'GCP Compute Engine Instance: High CPU utilization (over {$GCE.CPU.UTIL.MAX}% for 15m)'
priority: AVERAGE
description: 'The CPU utilization is too high. The system might be slow to respond.'
manual_close: 'YES'
tags:
- tag: scope
value: performance
- uuid: 4bdd3662247749a69bb59e6643ba7b9a
name: 'Disks get'
type: SCRIPT
key: gcp.gce.disks.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 = 'compute.googleapis.com/instance/disk/',
base_paths = ['read_ops_count', 'read_bytes_count', 'write_bytes_count', 'write_ops_count'];
function checkParams(params) {
['project_id', 'time_window', 'instance_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;
};
var params = checkParams(JSON.parse(value)),
j_filter = ' | within ' + params.time_window + " | filter instance_id = '" + params.instance_id + "'" + ' | join',
url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
metrics = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
time_series = getField(raw, 'timeSeriesData'),
arr = [];
for (t in time_series) {
data = {
disk_name: getField(time_series[t], 'labelValues.3.stringValue'),
device_type: getField(time_series[t], 'labelValues.4.stringValue'),
storage_type: getField(time_series[t], 'labelValues.6.stringValue'),
metrics: {}
};
for (i in metrics) {
re = /(^t_\d+\.value(_|\.))/g;
data['metrics'][getField(metrics[i], 'key').replace(re, '')] = getField(time_series[t], 'pointData.0.values.' + i + '.int64Value');
}
arr.push(data);
}
return JSON.stringify(arr);
description: 'Disk entities and metrics related to a particular instance.'
preprocessing:
- type: CHECK_NOT_SUPPORTED
parameters:
- '-1'
timeout: '{$GCP.DATA.TIMEOUT}'
parameters:
- name: instance_id
value: '{HOST.HOST}'
- 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 Compute Engine Instance"}'
- name: token
value: '{$GCP.AUTH.TOKEN}'
tags:
- tag: component
value: raw
- uuid: e1cd503d86f7487db023e2fd3cea5385
name: 'Firewall: Dropped bytes'
type: DEPENDENT
key: gcp.gce.firewall.dropped_bytes_count
delay: '0'
units: B
description: 'Count of incoming bytes dropped by the firewall.'
preprocessing:
- type: JSONPATH
parameters:
- $.dropped_bytes_count
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: firewall
- tag: component
value: network
- uuid: 25002706c5164c43a345a8ce594615c7
name: 'Firewall: Dropped packets'
type: DEPENDENT
key: gcp.gce.firewall.dropped_packets_count
delay: '0'
description: 'Count of incoming packets dropped by the firewall.'
preprocessing:
- type: JSONPATH
parameters:
- $.dropped_packets_count
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: firewall
- tag: component
value: network
- uuid: 3f82955d43694b25b1e96c9b8f4f6ffb
name: 'Instance state'
type: HTTP_AGENT
key: gcp.gce.instance.state
description: 'GCP Compute Engine instance state.'
valuemap:
name: 'Instance state'
preprocessing:
- type: JSONPATH
parameters:
- $.status
error_handler: CUSTOM_VALUE
error_handler_params: '10'
- type: JAVASCRIPT
parameters:
- |
const idx = [
'RUNNING',
'PROVISIONING',
'STAGING',
'STOPPING',
'REPAIRING',
'TERMINATED',
'SUSPENDING',
'SUSPENDED'
].indexOf(value);
return idx !== -1 ? idx : 10;
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 10m
timeout: '{$GCP.DATA.TIMEOUT}'
url: 'https://compute.googleapis.com/compute/v1/projects/{$GCP.PROJECT.ID}/zones/{$GCE.INSTANCE.ZONE}/instances/{HOST.NAME}'
status_codes: ''
headers:
- name: Content-Type
value: application/json
- name: Authorization
value: 'Bearer {$GCP.AUTH.TOKEN}'
tags:
- tag: component
value: status
triggers:
- uuid: 96abd48a3e684e1b9b95fdd96d095188
expression: 'last(/GCP Compute Engine Instance by HTTP/gcp.gce.instance.state) = 10'
name: 'GCP Compute Engine Instance: Failed to get the instance state'
priority: AVERAGE
description: |
Failed to get the instance state.
Check access permissions to GCP API or service account.
manual_close: 'YES'
tags:
- tag: scope
value: availability
- uuid: 1223f00a5e4b4bc8aa9e8ec08253c4cc
expression: 'last(/GCP Compute Engine Instance by HTTP/gcp.gce.instance.state) = 7'
name: 'GCP Compute Engine Instance: Instance is in suspended state'
priority: INFO
description: 'The VM is in a suspended state. You can resume the VM or delete it.'
manual_close: 'YES'
tags:
- tag: scope
value: availability
- tag: scope
value: notice
- uuid: d2144e2277ec458c80d2b948364f1924
expression: 'last(/GCP Compute Engine Instance by HTTP/gcp.gce.instance.state) = 4'
name: 'GCP Compute Engine Instance: The instance is in repairing state'
priority: WARNING
description: |
The VM is being repaired.
Repairing occurs when the VM encounters an internal error or the underlying machine is unavailable due to maintenance.
During this time, the VM is unusable.
manual_close: 'YES'
tags:
- tag: scope
value: availability
- uuid: 4a010c2b1e6f4ec88dbbe97255b9bac4
expression: 'last(/GCP Compute Engine Instance by HTTP/gcp.gce.instance.state) = 5'
name: 'GCP Compute Engine Instance: The instance is in terminated state'
priority: AVERAGE
description: 'The VM is stopped. You stopped the VM, or the VM encountered a failure.'
manual_close: 'YES'
tags:
- tag: scope
value: availability
- uuid: f075482578ec475385cdfc57346d1570
name: 'Instance uptime'
type: DEPENDENT
key: gcp.gce.instance.uptime
delay: '0'
value_type: FLOAT
units: s
description: 'Elapsed time since the VM was started, in seconds.'
preprocessing:
- type: JSONPATH
parameters:
- $.uptime_total
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: uptime
- uuid: 744f3f821847473d9cef1236580bda38
name: 'Integrity: Early boot validation status'
type: DEPENDENT
key: gcp.gce.integrity.early_boot_validation_status
delay: '0'
description: |
The validation status of early boot integrity policy.
Empty value if integrity monitoring isn't enabled.
valuemap:
name: 'Integrity validation status'
preprocessing:
- type: JSONPATH
parameters:
- $.early_boot_validation_status
error_handler: DISCARD_VALUE
- type: JAVASCRIPT
parameters:
- |
const idx = [
'passed',
'failed',
'unknown',
].indexOf(value);
return idx !== -1 ? idx : "";
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: security
- uuid: aa334c3a0faf4f36bcbbf51d87ef9186
name: 'Integrity: Late boot validation status'
type: DEPENDENT
key: gcp.gce.integrity.late_boot_validation_status
delay: '0'
description: |
The validation status of late boot integrity policy.
Empty value if integrity monitoring isn't enabled.
valuemap:
name: 'Integrity validation status'
preprocessing:
- type: JSONPATH
parameters:
- $.late_boot_validation_status
error_handler: DISCARD_VALUE
- type: JAVASCRIPT
parameters:
- |
const idx = [
'passed',
'failed',
'unknown',
].indexOf(value);
return idx !== -1 ? idx : "";
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: security
- uuid: 1b14fefa6b0f4abc98f6ddf3164074b3
name: 'Memory usage percentage'
type: DEPENDENT
key: gcp.gce.memory.ram_pused
delay: '0'
value_type: FLOAT
units: '%'
description: |
Memory usage Percentage.
This metric is only available for VMs that belong to the e2 family; returns empty value for different instance types.
preprocessing:
- type: JSONPATH
parameters:
- $.ram_pused
error_handler: DISCARD_VALUE
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: memory
triggers:
- uuid: fa918889bcb84d3886254f00f0df288c
expression: 'min(/GCP Compute Engine Instance by HTTP/gcp.gce.memory.ram_pused,15m) >= {$GCE.RAM.UTIL.MAX}'
name: 'GCP Compute Engine Instance: High memory utilization'
event_name: 'GCP Compute Engine Instance: High memory utilization (over {$GCE.RAM.UTIL.MAX}% for 15m)'
priority: AVERAGE
description: 'RAM utilization is too high. The system might be slow to respond.'
tags:
- tag: scope
value: performance
- uuid: 10d63d2c01dc481380bf386af7af7f97
name: 'Memory size'
type: DEPENDENT
key: gcp.gce.memory.ram_size
delay: '0'
units: B
description: |
Total VM memory size.
This metric is only available for VMs that belong to the e2 family; returns empty value for different instance types.
preprocessing:
- type: JSONPATH
parameters:
- $.ram_size
error_handler: DISCARD_VALUE
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: memory
- uuid: 20dc9e49a60d46b4b6d855eb74a60d5e
name: 'Memory used'
type: DEPENDENT
key: gcp.gce.memory.ram_used
delay: '0'
units: B
description: |
Memory currently used in the VM.
This metric is only available for VMs that belong to the e2 family; returns empty value for different instance types.
preprocessing:
- type: JSONPATH
parameters:
- $.ram_used
error_handler: DISCARD_VALUE
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: memory
- uuid: b043128882254e9492c7436521bf994a
name: 'VM swap in'
type: DEPENDENT
key: gcp.gce.memory.swap_in_bytes_count
delay: '0'
units: B
description: |
The amount of memory read into the guest from its own swap space.
This metric is only available for VMs that belong to the e2 family; returns empty value for different instance types.
preprocessing:
- type: JSONPATH
parameters:
- $.swap_in_bytes_count
error_handler: DISCARD_VALUE
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: memory
- uuid: 7166423bbcf0456ab0fcc7c852d89125
name: 'VM swap out'
type: DEPENDENT
key: gcp.gce.memory.swap_out_bytes_count
delay: '0'
units: B
description: |
The amount of memory written from the guest to its own swap space.
This metric is only available for VMs that belong to the e2 family; returns empty value for different instance types.
preprocessing:
- type: JSONPATH
parameters:
- $.swap_out_bytes_count
error_handler: DISCARD_VALUE
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: memory
- uuid: 723fbff060ab41a39322bc0d6d8b1f84
name: 'Metrics get'
type: SCRIPT
key: gcp.gce.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 = 'compute.googleapis.com/',
value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'],
re = /(^t_\d+\.value\.)/g,
obj = {},
base_paths = [
'instance/uptime_total',
'firewall/dropped_packets_count',
'firewall/dropped_bytes_count',
'instance/cpu/guest_visible_vcpus',
'instance/cpu/reserved_cores',
'instance/cpu/usage_time',
'instance/cpu/utilization',
'mirroring/mirrored_bytes_count',
'mirroring/mirrored_packets_count'
],
e2_paths = [
'instance/cpu/scheduler_wait_time',
'instance/memory/balloon/ram_size',
'instance/memory/balloon/ram_used',
'instance/memory/balloon/swap_in_bytes_count',
'instance/memory/balloon/swap_out_bytes_count',
],
net_paths = [
'instance/network/received_packets_count',
'instance/network/received_bytes_count',
'instance/network/sent_bytes_count',
'instance/network/sent_packets_count'
],
integrity_paths = [
'instance/integrity/late_boot_validation_status',
'instance/integrity/early_boot_validation_status'
];
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 getFieldBool(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') {
return false;
}
data = data[step];
}
return true;
}
function queryMap(array, path, filter) {
var query_params = '{' + array.map(function (element) { return path + element; }).join(';') + '}';
return { query: query_params + filter }
}
function checkParams(params) {
['project_id', 'time_window', 'instance_id', 'token', 'machine_type', 'integrity'].forEach(function (field) {
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '' || params[field].match(/^\{\$.*\}$/)) {
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.';
}
if (params.integrity !== 'true' && params.integrity !== 'false') {
throw 'Incorrect integrity state definition type. Valid definitions: true/false';
}
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 nestedMap(raw) {
var ids = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
ltsd = getField(raw, 'timeSeriesData'),
result = {};
for (i in ids) {
var id = getField(ids[i], 'key').replace(re, '');
result[id] = {};
for (t in ltsd) {
for (v in value_types) {
if (getFieldBool(ltsd[t], 'pointData.0.values.' + [i] + '.' + [value_types[v]])) {
['stringValue', 'boolValue'].forEach(function (type) {
if (getFieldBool(ltsd[t], 'labelValues.4.' + [type])) {
result[id][ltsd[t].labelValues[4][type]] = ltsd[t].pointData[0].values[i][value_types[v]];
}
});
}
}
}
}
return result;
}
var params = checkParams(JSON.parse(value));
if (params.machine_type.match(/e2.*/)) {
base_paths = base_paths.concat(e2_paths);
}
var filter = ' | within ' + params.time_window + " | filter instance_id = '" + params.instance_id + "'",
j_filter = filter + ' | join',
url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
raw = getHttpData(url, params.token, queryMap(base_paths, base_path, j_filter)),
keys = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
values = getField(raw, 'timeSeriesData.0.pointData.0.values');
for (i in keys) {
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]];
}
}
}
if (params.machine_type.match(/e2.*/)) {
obj.ram_pused = Math.floor((getField(obj, 'ram_used') / getField(obj, 'ram_size')) * 100);
}
var mirr_raw = getHttpData(url, params.token, { query: base_path + 'mirroring/dropped_packets_count' + filter }),
tsd = getField(mirr_raw, 'timeSeriesData');
for (t in tsd) {
for (v in value_types) {
if (getFieldBool(tsd[t], 'pointData.0.values.0.' + [value_types[v]])) {
obj[getField(tsd[t], 'labelValues.3.stringValue')] = getField(tsd[t], 'pointData.0.values.0.' + [value_types[v]]);
}
}
}
var net_metrics = getHttpData(url, params.token, queryMap(net_paths, base_path, j_filter));
Object.assign(obj, nestedMap(net_metrics));
if (params.integrity === 'true') {
integrity_metrics = getHttpData(url, params.token, queryMap(integrity_paths, base_path, j_filter));
var keys = getField(integrity_metrics, 'timeSeriesDescriptor.pointDescriptors'),
tsd = getField(integrity_metrics, 'timeSeriesData');
for (i in keys) {
var key = getField(keys[i], 'key').replace(re, '');
obj[key] = 'undefined';
for (t in tsd) {
if (getField(tsd[t], 'pointData.0.values.' + i + '.int64Value') == 1) {
obj[key] = getField(tsd[t], 'labelValues.4.stringValue');
break;
}
}
}
}
return JSON.stringify(obj);
description: 'GCP Compute Engine metrics get in raw format.'
preprocessing:
- type: CHECK_NOT_SUPPORTED
parameters:
- '-1'
timeout: '{$GCP.DATA.TIMEOUT}'
parameters:
- name: instance_id
value: '{HOST.HOST}'
- name: integrity
value: '{$GCE.INTEGRITY.STATE}'
- name: machine_type
value: '{$GCE.MACHINE.TYPE}'
- 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 Compute Engine Instance"}'
- name: token
value: '{$GCP.AUTH.TOKEN}'
tags:
- tag: component
value: raw
- uuid: faf1c3ccbcc24b9eb52be355f2f782e6
name: 'Network: Received bytes'
type: DEPENDENT
key: gcp.gce.network.lb.received_bytes_count.false
delay: '0'
units: B
description: 'Count of bytes received from the network without load-balancing.'
preprocessing:
- type: JSONPATH
parameters:
- $.received_bytes_count.false
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: 91ef1b33d7ae479999302cdec227eb3e
name: 'Network: Received bytes: Load-balanced'
type: DEPENDENT
key: gcp.gce.network.lb.received_bytes_count.true
delay: '0'
units: B
description: |
Whether traffic was received by an L3 loadbalanced IP address assigned to the VM.
Traffic that is externally routed to the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric.
The value is empty when load-balancing is not used.
preprocessing:
- type: JSONPATH
parameters:
- $.received_bytes_count.true
error_handler: DISCARD_VALUE
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: 84dec0cb32ea434a9d6f29f402d337a0
name: 'Network: Received packets'
type: DEPENDENT
key: gcp.gce.network.lb.received_packets_count.false
delay: '0'
description: 'Count of packets received from the network without load-balancing.'
preprocessing:
- type: JSONPATH
parameters:
- $.received_packets_count.false
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: 148fe8aaa01e4863bbe2ca4c0226ce80
name: 'Network: Received packets: Load-balanced'
type: DEPENDENT
key: gcp.gce.network.lb.received_packets_count.true
delay: '0'
description: |
Whether traffic was received by an L3 loadbalanced IP address assigned to the VM.
Traffic that is externally routed to the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric.
The value is empty when load-balancing is not used.
preprocessing:
- type: JSONPATH
parameters:
- $.received_packets_count.true
error_handler: DISCARD_VALUE
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: b8ea22b00a254ee5a2484fd833421b12
name: 'Network: Sent bytes'
type: DEPENDENT
key: gcp.gce.network.lb.sent_bytes_count.false
delay: '0'
units: B
description: 'Count of bytes sent over the network without load-balancing.'
preprocessing:
- type: JSONPATH
parameters:
- $.sent_bytes_count.false
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: 77bd252194764837bc71b031e4d7e2b8
name: 'Network: Sent bytes: Load-balanced'
type: DEPENDENT
key: gcp.gce.network.lb.sent_bytes_count.true
delay: '0'
units: B
description: |
Whether traffic was received by an L3 loadbalanced IP address assigned to the VM.
Traffic that is externally routed to the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric.
The value is empty when load-balancing is not used.
preprocessing:
- type: JSONPATH
parameters:
- $.sent_bytes_count.true
error_handler: DISCARD_VALUE
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: 44032903b7da4d72b2dff35e81e787d3
name: 'Network: Sent packets'
type: DEPENDENT
key: gcp.gce.network.lb.sent_packets_count.false
delay: '0'
description: 'Count of packets sent over the network without load-balancing.'
preprocessing:
- type: JSONPATH
parameters:
- $.sent_packets_count.false
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: 2aef5ad0f3704550b4920ce36614b52d
name: 'Network: Sent packets: Load-balanced'
type: DEPENDENT
key: gcp.gce.network.lb.sent_packets_count.true
delay: '0'
description: |
Whether traffic was received by an L3 loadbalanced IP address assigned to the VM.
Traffic that is externally routed to the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric.
The value is empty when load-balancing is not used.
preprocessing:
- type: JSONPATH
parameters:
- $.sent_packets_count.true
error_handler: DISCARD_VALUE
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: 199fb1f4278848138ef8cfd8fc3e07ee
name: 'Network: Mirrored bytes'
type: DEPENDENT
key: gcp.gce.network.mirrored_bytes_count
delay: '0'
units: B
description: 'The count of mirrored bytes.'
preprocessing:
- type: JSONPATH
parameters:
- $.mirrored_bytes_count
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: f0add3d3853d4d8c9993b1603fd7b542
name: 'Network: Mirrored packets'
type: DEPENDENT
key: gcp.gce.network.mirrored_packets_count
delay: '0'
description: 'The count of mirrored packets.'
preprocessing:
- type: JSONPATH
parameters:
- $.mirrored_packets_count
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: 6ca64c0fa39e4587a2987cd607058b54
name: 'Network: Mirrored packets dropped: Invalid'
type: DEPENDENT
key: gcp.gce.network.mirr_dropped_packets.invalid
delay: '0'
description: |
The count of mirrored packets dropped.
Reason - invalid.
preprocessing:
- type: JSONPATH
parameters:
- $.invalid
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: 3cf438aa0225428385d30c5be30ea3e6
name: 'Network: Mirrored packets dropped: Out of quota'
type: DEPENDENT
key: gcp.gce.network.mirr_dropped_packets.out_of_quota
delay: '0'
description: |
The count of mirrored packets dropped.
Reason - out of quota.
preprocessing:
- type: JSONPATH
parameters:
- $.out_of_quota
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
- uuid: 5303badcf26641f1af85366fbaecdd77
name: 'Network: Mirrored packets dropped: Unknown'
type: DEPENDENT
key: gcp.gce.network.mirr_dropped_packets.unknown
delay: '0'
description: |
The count of mirrored packets dropped.
Reason - unknown.
preprocessing:
- type: JSONPATH
parameters:
- $.unknown
master_item:
key: gcp.gce.metrics.get
tags:
- tag: component
value: network
- tag: component
value: traffic
discovery_rules:
- uuid: 260e06bfe28e46f4a726dd4a6d7fa523
name: 'GCP Compute Engine: Physical disks discovery'
type: DEPENDENT
key: gcp.gce.phys.disks.discovery
delay: '0'
filter:
evaltype: AND
conditions:
- macro: '{#GCE.DISK.DEV_TYPE}'
value: '{$GCE.DISK.DEV_TYPE.MATCHES}'
formulaid: A
- macro: '{#GCE.DISK.DEV_TYPE}'
value: '{$GCE.DISK.DEV_TYPE.NOT_MATCHES}'
operator: NOT_MATCHES_REGEX
formulaid: B
- macro: '{#GCE.DISK.NAME}'
value: '{$GCE.DISK.NAME.MATCHES}'
formulaid: C
- macro: '{#GCE.DISK.NAME}'
value: '{$GCE.DISK.NAME.NOT_MATCHES}'
operator: NOT_MATCHES_REGEX
formulaid: D
- macro: '{#GCE.DISK.STOR_TYPE}'
value: '{$GCE.DISK.STOR_TYPE.MATCHES}'
formulaid: E
- macro: '{#GCE.DISK.STOR_TYPE}'
value: '{$GCE.DISK.STOR_TYPE.NOT_MATCHES}'
operator: NOT_MATCHES_REGEX
formulaid: F
description: 'GCP Compute Engine: Physical disks discovery.'
item_prototypes:
- uuid: dda10a0535c04fdb92092efeff020b2c
name: 'Disk [{#GCE.DISK.NAME}]: Read bytes'
type: DEPENDENT
key: 'gcp.gce.disk.read_bytes_count[{#GCE.DISK.NAME}]'
delay: '0'
units: B
description: 'Count of bytes read from [{#GCE.DISK.NAME}] disk.'
preprocessing:
- type: JSONPATH
parameters:
- $.read_bytes_count
master_item:
key: 'gcp.gce.quota.single.raw[{#GCE.DISK.NAME}]'
tags:
- tag: component
value: storage
- tag: device-type
value: '{#GCE.DISK.DEV_TYPE}'
- tag: disk
value: '{#GCE.DISK.NAME}'
- tag: storage-type
value: '{#GCE.DISK.STOR_TYPE}'
- uuid: e166d3dfeb404111bcd143415070a0af
name: 'Disk [{#GCE.DISK.NAME}]: Read operations'
type: DEPENDENT
key: 'gcp.gce.disk.read_ops_count[{#GCE.DISK.NAME}]'
delay: '0'
description: 'Count of read IO operations from [{#GCE.DISK.NAME}] disk.'
preprocessing:
- type: JSONPATH
parameters:
- $.read_ops_count
master_item:
key: 'gcp.gce.quota.single.raw[{#GCE.DISK.NAME}]'
tags:
- tag: component
value: storage
- tag: device-type
value: '{#GCE.DISK.DEV_TYPE}'
- tag: disk
value: '{#GCE.DISK.NAME}'
- tag: storage-type
value: '{#GCE.DISK.STOR_TYPE}'
- uuid: cf21b2bf6dc74ed28bc55a2c567b3dae
name: 'Disk [{#GCE.DISK.NAME}]: Write bytes'
type: DEPENDENT
key: 'gcp.gce.disk.write_bytes_count[{#GCE.DISK.NAME}]'
delay: '0'
units: B
description: 'Count of bytes written to {#GCE.DISK.NAME}] disk.'
preprocessing:
- type: JSONPATH
parameters:
- $.write_bytes_count
master_item:
key: 'gcp.gce.quota.single.raw[{#GCE.DISK.NAME}]'
tags:
- tag: component
value: storage
- tag: device-type
value: '{#GCE.DISK.DEV_TYPE}'
- tag: disk
value: '{#GCE.DISK.NAME}'
- tag: storage-type
value: '{#GCE.DISK.STOR_TYPE}'
- uuid: 602255b7df004129b5a3e0e1d2fba920
name: 'Disk [{#GCE.DISK.NAME}]: Write operations'
type: DEPENDENT
key: 'gcp.gce.disk.write_ops_count[{#GCE.DISK.NAME}]'
delay: '0'
description: 'Count of write IO operations to [{#GCE.DISK.NAME}] disk.'
preprocessing:
- type: JSONPATH
parameters:
- $.write_ops_count
master_item:
key: 'gcp.gce.quota.single.raw[{#GCE.DISK.NAME}]'
tags:
- tag: component
value: storage
- tag: device-type
value: '{#GCE.DISK.DEV_TYPE}'
- tag: disk
value: '{#GCE.DISK.NAME}'
- tag: storage-type
value: '{#GCE.DISK.STOR_TYPE}'
- uuid: 7fc27a6630664e2fbac8fe64ac40985a
name: 'Disk [{#GCE.DISK.NAME}]: Raw data'
type: DEPENDENT
key: 'gcp.gce.quota.single.raw[{#GCE.DISK.NAME}]'
delay: '0'
history: '0'
value_type: TEXT
trends: '0'
description: 'Data in raw format for the disk with the name [{#GCE.DISK.NAME}].'
preprocessing:
- type: JSONPATH
parameters:
- '$[?(@.disk_name == "{#GCE.DISK.NAME}")].metrics.first()'
master_item:
key: gcp.gce.disks.get
tags:
- tag: component
value: raw
- tag: component
value: storage
- tag: disk
value: '{#GCE.DISK.NAME}'
graph_prototypes:
- uuid: 9af0456af3d74041b678ceeccbc036fc
name: 'GCP Compute Engine: Disk [{#GCE.DISK.NAME}]: Read/Write bytes'
graph_items:
- color: 199C0D
item:
host: 'GCP Compute Engine Instance by HTTP'
key: 'gcp.gce.disk.read_bytes_count[{#GCE.DISK.NAME}]'
- sortorder: '1'
color: F63100
item:
host: 'GCP Compute Engine Instance by HTTP'
key: 'gcp.gce.disk.write_bytes_count[{#GCE.DISK.NAME}]'
- uuid: 542185ffc8b3485f8955b63c46a50b83
name: 'GCP Compute Engine: Disk [{#GCE.DISK.NAME}]: Read/Write operations'
graph_items:
- color: 199C0D
item:
host: 'GCP Compute Engine Instance by HTTP'
key: 'gcp.gce.disk.read_ops_count[{#GCE.DISK.NAME}]'
- sortorder: '1'
color: F63100
item:
host: 'GCP Compute Engine Instance by HTTP'
key: 'gcp.gce.disk.write_ops_count[{#GCE.DISK.NAME}]'
master_item:
key: gcp.gce.disks.get
lld_macro_paths:
- lld_macro: '{#GCE.DISK.DEV_TYPE}'
path: $.device_type
- lld_macro: '{#GCE.DISK.NAME}'
path: $.disk_name
- lld_macro: '{#GCE.DISK.STOR_TYPE}'
path: $.storage_type
preprocessing:
- type: DISCARD_UNCHANGED_HEARTBEAT
parameters:
- 3h
tags:
- tag: class
value: cloud
- tag: target
value: compute-engine
- tag: target
value: gce
- tag: target
value: gcp
- tag: target
value: google-cloud-platform
macros:
- macro: '{$GCE.CPU.UTIL.MAX}'
value: '95'
description: 'GCP Compute Engine instance CPU utilization threshold.'
- macro: '{$GCE.DISK.DEV_TYPE.MATCHES}'
value: '.*'
description: 'The filter to include GCP Compute Engine disks by device type.'
- macro: '{$GCE.DISK.DEV_TYPE.NOT_MATCHES}'
value: CHANGE_IF_NEEDED
description: 'The filter to exclude GCP Compute Engine disks by device type.'
- macro: '{$GCE.DISK.NAME.MATCHES}'
value: '.*'
description: 'The filter to include GCP Compute Engine disks by namespace.'
- macro: '{$GCE.DISK.NAME.NOT_MATCHES}'
value: CHANGE_IF_NEEDED
description: 'The filter to exclude GCP Compute Engine disks by namespace.'
- macro: '{$GCE.DISK.STOR_TYPE.MATCHES}'
value: '.*'
description: 'The filter to include GCP Compute Engine disks by storage type.'
- macro: '{$GCE.DISK.STOR_TYPE.NOT_MATCHES}'
value: CHANGE_IF_NEEDED
description: 'The filter to exclude GCP Compute Engine disks by storage type.'
- macro: '{$GCE.RAM.UTIL.MAX}'
value: '90'
description: 'GCP Compute Engine instance RAM utilization threshold.'
- 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 Compute Engine Instance", e.g. {$HTTP.TLS.VERIFY:"GCP Compute Engine Instance"}.'
dashboards:
- uuid: b8b09f6833ec4ea78c4ac7d15cdb0cc5
name: Hardware
pages:
- name: Hardware
widgets:
- type: graph
width: '36'
height: '5'
fields:
- type: GRAPH
name: graphid.0
value:
host: 'GCP Compute Engine Instance by HTTP'
name: 'GCP Compute Engine: CPU usage'
- type: STRING
name: reference
value: AAAAA
- type: graph
'y': '5'
width: '24'
height: '5'
fields:
- type: GRAPH
name: graphid.0
value:
host: 'GCP Compute Engine Instance by HTTP'
name: 'GCP Compute Engine: Memory usage'
- type: STRING
name: reference
value: AAAAC
- type: graphprototype
'y': '10'
width: '36'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: GRAPH_PROTOTYPE
name: graphid.0
value:
host: 'GCP Compute Engine Instance by HTTP'
name: 'GCP Compute Engine: Disk [{#GCE.DISK.NAME}]: Read/Write bytes'
- type: STRING
name: reference
value: AAAAF
- type: graph
'y': '15'
width: '72'
height: '5'
fields:
- type: GRAPH
name: graphid.0
value:
host: 'GCP Compute Engine Instance by HTTP'
name: 'GCP Compute Engine: Network traffic'
- type: STRING
name: reference
value: AAAAH
- type: graph
x: '24'
'y': '5'
width: '24'
height: '5'
fields:
- type: ITEM
name: itemid.0
value:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.memory.ram_pused
- type: STRING
name: reference
value: AAAAD
- type: INTEGER
name: source_type
value: '1'
- type: graph
x: '36'
width: '36'
height: '5'
fields:
- type: ITEM
name: itemid.0
value:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.cpu.utilization
- type: STRING
name: reference
value: AAAAB
- type: INTEGER
name: source_type
value: '1'
- type: graphprototype
x: '36'
'y': '10'
width: '36'
height: '5'
fields:
- type: INTEGER
name: columns
value: '1'
- type: GRAPH_PROTOTYPE
name: graphid.0
value:
host: 'GCP Compute Engine Instance by HTTP'
name: 'GCP Compute Engine: Disk [{#GCE.DISK.NAME}]: Read/Write operations'
- type: STRING
name: reference
value: AAAAG
- type: graph
x: '48'
'y': '5'
width: '24'
height: '5'
fields:
- type: GRAPH
name: graphid.0
value:
host: 'GCP Compute Engine Instance by HTTP'
name: 'GCP Compute Engine: Memory swapping'
- type: STRING
name: reference
value: AAAAE
valuemaps:
- uuid: d5f19327f8b74b44a40950d9d4f9410f
name: 'Instance state'
mappings:
- value: '0'
newvalue: Running
- value: '1'
newvalue: Provisioning
- value: '2'
newvalue: Staging
- value: '3'
newvalue: Stopping
- value: '4'
newvalue: Repairing
- value: '5'
newvalue: Terminated
- value: '6'
newvalue: Suspending
- value: '7'
newvalue: Suspended
- value: '10'
newvalue: 'Data retrievement error'
- uuid: 1e17bce361f9486dae764fc195561703
name: 'Integrity validation status'
mappings:
- value: '0'
newvalue: Passed
- value: '1'
newvalue: Failed
- value: '2'
newvalue: Unknown
graphs:
- uuid: aa6edbd13ec74ee4b30de2c68823e6aa
name: 'GCP Compute Engine: CPU usage'
graph_items:
- color: 199C0D
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.cpu.scheduler_wait_time
- sortorder: '1'
color: F63100
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.cpu.usage_time
- uuid: a87f4b9849e34f96b7026f4abc8499a1
name: 'GCP Compute Engine: Memory swapping'
graph_items:
- color: 199C0D
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.memory.swap_in_bytes_count
- sortorder: '1'
color: F63100
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.memory.swap_out_bytes_count
- uuid: 5aef2c89a0fa41cd889d87a618cc10bd
name: 'GCP Compute Engine: Memory usage'
graph_items:
- drawtype: BOLD_LINE
color: 199C0D
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.memory.ram_size
- sortorder: '1'
drawtype: GRADIENT_LINE
color: F63100
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.memory.ram_used
- uuid: c1c8ebb71d9542ea8b59cef775a6bd65
name: 'GCP Compute Engine: Network traffic'
type: STACKED
graph_items:
- color: 199C0D
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.firewall.dropped_bytes_count
- sortorder: '1'
color: F63100
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.network.lb.received_bytes_count.false
- sortorder: '2'
color: 00611C
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.network.lb.received_bytes_count.true
- sortorder: '3'
color: F7941D
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.network.lb.sent_bytes_count.false
- sortorder: '4'
color: FC6EA3
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.network.lb.sent_bytes_count.true
- sortorder: '5'
color: 6C59DC
item:
host: 'GCP Compute Engine Instance by HTTP'
key: gcp.gce.network.mirrored_bytes_count