1756 lines
71 KiB
YAML
1756 lines
71 KiB
YAML
zabbix_export:
|
|
version: '7.0'
|
|
template_groups:
|
|
- uuid: c2c162144c2d4c5491c8801193af4945
|
|
name: Templates/Cloud
|
|
templates:
|
|
- uuid: 024cf4f0711c4c39a4e016858efc5e37
|
|
template: 'AWS Backup Vault by HTTP'
|
|
name: 'AWS Backup Vault by HTTP'
|
|
description: |
|
|
The template is designed to monitor AWS Backup vaults and jobs by HTTP via Zabbix, and it works without any external scripts.
|
|
Don't forget to read the README.md for the correct setup of the template.
|
|
|
|
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: cc5d272814ab457c99127d3d42ca8d54
|
|
name: Age
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.age
|
|
delay: '0'
|
|
units: uptime
|
|
description: 'The age of the vault.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.CreationDate
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- 'return Date.now() / 1000 - value'
|
|
master_item:
|
|
key: aws.backup_vault.data.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: 0a02ff6671484ce4bf32c128aa337f14
|
|
name: 'Get data'
|
|
type: SCRIPT
|
|
key: aws.backup_vault.data.get
|
|
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 AWS = {
|
|
params: {},
|
|
metadata: 'http://169.254.169.254/latest/',
|
|
|
|
getField: function (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 was not found: ' + path;
|
|
}
|
|
|
|
data = data[step];
|
|
}
|
|
|
|
return data;
|
|
},
|
|
|
|
getRoleBaseCredentials: function () {
|
|
AWS.params['auth_type'] = 'role_base';
|
|
var request = new HttpRequest({SSLVerifyPeer: false, SSLVerifyHost: false});
|
|
if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
|
|
request.setProxy(AWS.params.proxy);
|
|
}
|
|
request.addHeader('X-aws-ec2-metadata-token-ttl-seconds: 21600');
|
|
var token = request.put(AWS.metadata + 'api/token');
|
|
|
|
if (request.getStatus() !== 200 || token === null || token === '') {
|
|
throw 'Error getting IMDSv2 session token.';
|
|
}
|
|
request.addHeader('X-aws-ec2-metadata-token: ' + token);
|
|
var IamRoleName = request.get(AWS.metadata + 'meta-data/iam/security-credentials');
|
|
|
|
if (request.getStatus() !== 200 || IamRoleName === null || IamRoleName === '') {
|
|
throw 'Error getting security credentials from instance metadata. Role not found.';
|
|
}
|
|
|
|
credentials = request.get(AWS.metadata + 'meta-data/iam/security-credentials/' + encodeURI(IamRoleName));
|
|
|
|
if (request.getStatus() !== 200 || credentials === null || credentials === '') {
|
|
throw 'Error getting security credentials from instance metadata.';
|
|
}
|
|
|
|
try {
|
|
credentials = JSON.parse(credentials);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from instance metadata. Check debug log for more information.';
|
|
}
|
|
|
|
['AccessKeyId', 'SecretAccessKey', 'Token'].forEach(function (field) {
|
|
if (typeof credentials !== 'object' || typeof credentials[field] === 'undefined' || credentials[field] === '') {
|
|
throw 'Required credentials are not set: "' + field + '".';
|
|
};
|
|
AWS.params[field] = credentials[field];
|
|
});
|
|
},
|
|
|
|
setParams: function (params) {
|
|
AWS.tls = new CTlsConfig(params.tls_verify);
|
|
AWS.params['proxy'] = params.proxy;
|
|
switch (AWS.getField(params, 'auth_type')) {
|
|
case 'role_base':
|
|
AWS.getRoleBaseCredentials();
|
|
break;
|
|
case 'assume_role':
|
|
if (typeof params.metadata_auth === 'undefined' || params.metadata_auth === '' || (params.metadata_auth !== 'true' && params.metadata_auth !== 'false')) {
|
|
throw 'Required param metadata_auth for assume_role is not set or has invalid value: "' + params.metadata_auth + '". Expected "true" or "false".';
|
|
}
|
|
if (params.metadata_auth === 'true') {
|
|
AWS.getRoleBaseCredentials();
|
|
AWS.params['SessionToken'] = AWS.params['Token'];
|
|
AWS.params['auth_type'] = 'assume_role_metadata';
|
|
|
|
['sts_region', 'role_arn'].forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
|
|
throw 'Required param is not set: "' + field + '".';
|
|
}
|
|
AWS.params[field] = params[field];
|
|
});
|
|
}
|
|
|
|
if (params.metadata_auth === 'false') {
|
|
AWS.params['auth_type'] = 'assume_role';
|
|
|
|
['AccessKeyId', 'SecretAccessKey', 'sts_region', 'role_arn'].forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
|
|
throw 'Required param is not set: "' + field + '".';
|
|
}
|
|
AWS.params[field] = params[field];
|
|
});
|
|
}
|
|
|
|
const role_arn_regex = /role\/(.+)$/;
|
|
const match = AWS.params.role_arn.match(role_arn_regex);
|
|
if (!match) {
|
|
throw 'Invalid role ARN format.';
|
|
}
|
|
|
|
const payload = {
|
|
'Action': 'AssumeRole',
|
|
'Version': '2011-06-15',
|
|
'RoleArn': AWS.params.role_arn,
|
|
'RoleSessionName': match[1] + 'Session',
|
|
};
|
|
|
|
credentials = AWS.getField(AWS.request('GET', AWS.params.sts_region, 'sts', AWS.prepareParams(payload)), 'AssumeRoleResponse.AssumeRoleResult.Credentials');
|
|
|
|
['AccessKeyId', 'SecretAccessKey', 'SessionToken'].forEach(function (field) {
|
|
if (typeof credentials !== 'object' || typeof credentials[field] === 'undefined' || credentials[field] === '') {
|
|
throw 'Required credentials are not set: "' + field + '".';
|
|
};
|
|
AWS.params[field] = credentials[field];
|
|
});
|
|
break;
|
|
default:
|
|
AWS.params['auth_type'] = 'access_key';
|
|
['AccessKeyId', 'SecretAccessKey'].forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
|
|
throw 'Required param is not set: "' + field + '".';
|
|
}
|
|
AWS.params[field] = params[field];
|
|
});
|
|
}
|
|
['region', 'vault'].forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
|
|
throw 'Required param is not set: "' + field + '".';
|
|
}
|
|
AWS.params[field] = params[field];
|
|
});
|
|
},
|
|
|
|
sign: function (key, message) {
|
|
var hex = hmac('sha256', key, message);
|
|
|
|
if ((hex.length % 2) === 1) {
|
|
throw 'Invalid length of a hex string!';
|
|
}
|
|
|
|
var result = new Int8Array(hex.length / 2);
|
|
for (var i = 0, b = 0; i < hex.length; i += 2, b++) {
|
|
result[b] = parseInt(hex.substring(i, i + 2), 16);
|
|
}
|
|
|
|
return result;
|
|
},
|
|
|
|
prepareParams: function (params) {
|
|
var result = [];
|
|
|
|
Object.keys(params).sort().forEach(function (key) {
|
|
if (typeof params[key] !== 'object') {
|
|
result.push(key + '=' + encodeURIComponent(params[key]));
|
|
}
|
|
else {
|
|
result.push(prepareObject(key, params[key]));
|
|
}
|
|
});
|
|
|
|
return result.join('&');
|
|
},
|
|
|
|
request: function (method, canonical_uri, region, service, params, data) {
|
|
if (typeof data === 'undefined' || data === null) {
|
|
data = '';
|
|
}
|
|
|
|
var amzdate = (new Date()).toISOString().replace(/\.\d+Z/, 'Z').replace(/[-:]/g, ''),
|
|
date = amzdate.replace(/T\d+Z/, ''),
|
|
host = service + '.' + region + '.amazonaws.com',
|
|
canonical_headers = 'content-encoding:amz-1.0\n' + 'host:' + host + '\n' + 'x-amz-date:' + amzdate + '\n',
|
|
signed_headers = 'content-encoding;host;x-amz-date',
|
|
canonical_request = method + '\n' + canonical_uri + '\n' + params + '\n' + canonical_headers + '\n' + signed_headers + '\n' + sha256(data),
|
|
credential_scope = date + '/' + region + '/' + service + '/' + 'aws4_request',
|
|
request_string = 'AWS4-HMAC-SHA256' + '\n' + amzdate + '\n' + credential_scope + '\n' + sha256(canonical_request),
|
|
key = AWS.sign('AWS4' + AWS.params.SecretAccessKey, date),
|
|
key = AWS.sign(key, region),
|
|
key = AWS.sign(key, service),
|
|
key = AWS.sign(key, 'aws4_request'),
|
|
request = new HttpRequest(AWS.tls.options),
|
|
url = 'https://' + host + canonical_uri + '?' + params;
|
|
|
|
if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
|
|
request.setProxy(AWS.params.proxy);
|
|
}
|
|
|
|
request.addHeader('x-amz-date: ' + amzdate);
|
|
request.addHeader('x-amz-content-sha256:' + sha256(data));
|
|
request.addHeader('Accept: application/json');
|
|
request.addHeader('Content-Type: application/json');
|
|
request.addHeader('Content-Encoding: amz-1.0');
|
|
request.addHeader('Authorization: ' + 'AWS4-HMAC-SHA256 Credential=' + AWS.params.AccessKeyId + '/' + credential_scope + ', ' + 'SignedHeaders=' + signed_headers + ', ' + 'Signature=' + hmac('sha256', key, request_string));
|
|
|
|
if (AWS.params.auth_type === 'role_base' || AWS.params.auth_type === 'assume_role_metadata' || (AWS.params.auth_type === 'assume_role' & !params.includes('AssumeRole'))) {
|
|
request.addHeader('X-Amz-Security-Token: ' + (AWS.params.auth_type === 'role_base' ? AWS.params.Token : AWS.params.SessionToken));
|
|
}
|
|
|
|
Zabbix.log(4, '[ AWS Backup vault ] Sending request: ' + url);
|
|
response = request.get(url);
|
|
Zabbix.log(4, '[ AWS Backup vault ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() !== 200) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
try {
|
|
response = JSON.parse(XML.toJson(response));
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from AWS API. Check debug log for more information.';
|
|
}
|
|
}
|
|
|
|
return response;
|
|
},
|
|
|
|
getVaultData: function () {
|
|
var result = AWS.request('GET', '/backup-vaults/' + AWS.params.vault, AWS.params.region, 'backup', '');
|
|
|
|
if (typeof result !== 'object') {
|
|
throw 'Cannot get backup vault list from AWS API. Check debug log for more information.';
|
|
}
|
|
|
|
if (result === null) {
|
|
return [];
|
|
}
|
|
|
|
return result;
|
|
}
|
|
};
|
|
|
|
try {
|
|
AWS.setParams(JSON.parse(value));
|
|
return JSON.stringify(AWS.getVaultData());
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ AWS Backup vault ] ERROR: ' + error);
|
|
return JSON.stringify({ 'error': error });
|
|
}
|
|
description: |
|
|
Retrieve AWS backup vault metrics.
|
|
More information here: https://docs.aws.amazon.com/aws-backup/latest/devguide/API_BackupVaultListMember.html
|
|
timeout: '{$AWS.DATA.TIMEOUT}'
|
|
parameters:
|
|
- name: AccessKeyId
|
|
value: '{$AWS.ACCESS.KEY.ID}'
|
|
- name: auth_type
|
|
value: '{$AWS.AUTH_TYPE}'
|
|
- name: metadata_auth
|
|
value: '{$AWS.ASSUME.ROLE.AUTH.METADATA}'
|
|
- name: proxy
|
|
value: '{$AWS.PROXY}'
|
|
- name: region
|
|
value: '{$AWS.REGION}'
|
|
- name: role_arn
|
|
value: '{$AWS.ASSUME.ROLE.ARN}'
|
|
- name: SecretAccessKey
|
|
value: '{$AWS.SECRET.ACCESS.KEY}'
|
|
- name: sts_region
|
|
value: '{$AWS.STS.REGION}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"AWS Backup Vault"}'
|
|
- name: vault
|
|
value: '{$AWS.BACKUP_VAULT.NAME}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
- uuid: 4bf53a35af804262a4e0250a01d6c962
|
|
name: 'Jobs: Backup'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.backup.count
|
|
delay: '0'
|
|
description: 'The number of backup jobs in the vault over the last `{$AWS.BACKUP_JOB.PERIOD}` day(s).'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.[?(@.job_type == "backup-job")].length()'
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: b1e841181aac401e927b27dc6bca6736
|
|
name: 'Jobs: Failed backup'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.backup.failed.count
|
|
delay: '0'
|
|
description: 'The number of failed backup jobs in the vault over the last `{$AWS.BACKUP_JOB.PERIOD}` day(s).'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.[?(@.job_type == "backup-job" && @.job_state == "FAILED")].length()'
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: d8ea077804634388bcb15bc99ad9839e
|
|
name: 'Jobs: Copy'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.copy.count
|
|
delay: '0'
|
|
description: 'The number of copy jobs in the vault over the last `{$AWS.BACKUP_JOB.PERIOD}` day(s).'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.[?(@.job_type == "copy-job")].length()'
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
triggers:
|
|
- uuid: 6a5ed839d0d049f58775e46ee86e83ee
|
|
expression: 'change(/AWS Backup Vault by HTTP/aws.backup_vault.job.copy.count)>0'
|
|
recovery_mode: NONE
|
|
name: 'AWS Backup vault: Copy job has appeared'
|
|
opdata: 'Current amount: {ITEM.LASTVALUE1}'
|
|
priority: WARNING
|
|
description: 'New copy job has appeared.'
|
|
manual_close: 'YES'
|
|
tags:
|
|
- tag: scope
|
|
value: notice
|
|
- uuid: a2a8734311c84c05b72738ce0d8192f5
|
|
name: 'Jobs: Failed copy'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.copy.failed.count
|
|
delay: '0'
|
|
description: 'The number of failed copy jobs in the vault over the last `{$AWS.BACKUP_JOB.PERIOD}` day(s).'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.[?(@.job_type == "copy-job" && @.job_state == "FAILED")].length()'
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: 81d17a83dddf4a4292428ae0644d83ca
|
|
name: 'Get jobs'
|
|
type: SCRIPT
|
|
key: aws.backup_vault.job.get
|
|
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 AWS = {
|
|
params: {},
|
|
metadata: 'http://169.254.169.254/latest/',
|
|
|
|
getField: function (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 was not found: ' + path;
|
|
}
|
|
|
|
data = data[step];
|
|
}
|
|
|
|
return data;
|
|
},
|
|
|
|
getRoleBaseCredentials: function () {
|
|
AWS.params['auth_type'] = 'role_base';
|
|
var request = new HttpRequest({SSLVerifyPeer: false, SSLVerifyHost: false});
|
|
if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
|
|
request.setProxy(AWS.params.proxy);
|
|
}
|
|
request.addHeader('X-aws-ec2-metadata-token-ttl-seconds: 21600');
|
|
var token = request.put(AWS.metadata + 'api/token');
|
|
|
|
if (request.getStatus() !== 200 || token === null || token === '') {
|
|
throw 'Error getting IMDSv2 session token.';
|
|
}
|
|
request.addHeader('X-aws-ec2-metadata-token: ' + token);
|
|
var IamRoleName = request.get(AWS.metadata + 'meta-data/iam/security-credentials');
|
|
|
|
if (request.getStatus() !== 200 || IamRoleName === null || IamRoleName === '') {
|
|
throw 'Error getting security credentials from instance metadata. Role not found.';
|
|
}
|
|
|
|
credentials = request.get(AWS.metadata + 'meta-data/iam/security-credentials/' + encodeURI(IamRoleName));
|
|
|
|
if (request.getStatus() !== 200 || credentials === null || credentials === '') {
|
|
throw 'Error getting security credentials from instance metadata.';
|
|
}
|
|
|
|
try {
|
|
credentials = JSON.parse(credentials);
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from instance metadata. Check debug log for more information.';
|
|
}
|
|
|
|
['AccessKeyId', 'SecretAccessKey', 'Token'].forEach(function (field) {
|
|
if (typeof credentials !== 'object' || typeof credentials[field] === 'undefined' || credentials[field] === '') {
|
|
throw 'Required credentials are not set: "' + field + '".';
|
|
};
|
|
AWS.params[field] = credentials[field];
|
|
});
|
|
},
|
|
|
|
setParams: function (params) {
|
|
AWS.tls = new CTlsConfig(params.tls_verify);
|
|
AWS.params['proxy'] = params.proxy;
|
|
switch (AWS.getField(params, 'auth_type')) {
|
|
case 'role_base':
|
|
AWS.getRoleBaseCredentials();
|
|
break;
|
|
case 'assume_role':
|
|
if (typeof params.metadata_auth === 'undefined' || params.metadata_auth === '' || (params.metadata_auth !== 'true' && params.metadata_auth !== 'false')) {
|
|
throw 'Required param metadata_auth for assume_role is not set or has invalid value: "' + params.metadata_auth + '". Expected "true" or "false".';
|
|
}
|
|
if (params.metadata_auth === 'true') {
|
|
AWS.getRoleBaseCredentials();
|
|
AWS.params['SessionToken'] = AWS.params['Token'];
|
|
AWS.params['auth_type'] = 'assume_role_metadata';
|
|
|
|
['sts_region', 'role_arn'].forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
|
|
throw 'Required param is not set: "' + field + '".';
|
|
}
|
|
AWS.params[field] = params[field];
|
|
});
|
|
}
|
|
|
|
if (params.metadata_auth === 'false') {
|
|
AWS.params['auth_type'] = 'assume_role';
|
|
|
|
['AccessKeyId', 'SecretAccessKey', 'sts_region', 'role_arn'].forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
|
|
throw 'Required param is not set: "' + field + '".';
|
|
}
|
|
AWS.params[field] = params[field];
|
|
});
|
|
}
|
|
|
|
const role_arn_regex = /role\/(.+)$/;
|
|
const match = AWS.params.role_arn.match(role_arn_regex);
|
|
if (!match) {
|
|
throw 'Invalid role ARN format.';
|
|
}
|
|
|
|
const payload = {
|
|
'Action': 'AssumeRole',
|
|
'Version': '2011-06-15',
|
|
'RoleArn': AWS.params.role_arn,
|
|
'RoleSessionName': match[1] + 'Session',
|
|
};
|
|
|
|
credentials = AWS.getField(AWS.request('GET', AWS.params.sts_region, 'sts', AWS.prepareParams(payload)), 'AssumeRoleResponse.AssumeRoleResult.Credentials');
|
|
|
|
['AccessKeyId', 'SecretAccessKey', 'SessionToken'].forEach(function (field) {
|
|
if (typeof credentials !== 'object' || typeof credentials[field] === 'undefined' || credentials[field] === '') {
|
|
throw 'Required credentials are not set: "' + field + '".';
|
|
};
|
|
AWS.params[field] = credentials[field];
|
|
});
|
|
break;
|
|
default:
|
|
AWS.params['auth_type'] = 'access_key';
|
|
['AccessKeyId', 'SecretAccessKey'].forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
|
|
throw 'Required param is not set: "' + field + '".';
|
|
}
|
|
AWS.params[field] = params[field];
|
|
});
|
|
}
|
|
['region', 'vault', 'period'].forEach(function (field) {
|
|
if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
|
|
throw 'Required param is not set: "' + field + '".';
|
|
}
|
|
AWS.params[field] = params[field];
|
|
});
|
|
},
|
|
|
|
sign: function (key, message) {
|
|
var hex = hmac('sha256', key, message);
|
|
|
|
if ((hex.length % 2) === 1) {
|
|
throw 'Invalid length of a hex string!';
|
|
}
|
|
|
|
var result = new Int8Array(hex.length / 2);
|
|
for (var i = 0, b = 0; i < hex.length; i += 2, b++) {
|
|
result[b] = parseInt(hex.substring(i, i + 2), 16);
|
|
}
|
|
|
|
return result;
|
|
},
|
|
|
|
prepareParams: function (params) {
|
|
var result = [];
|
|
|
|
Object.keys(params).sort().forEach(function (key) {
|
|
if (typeof params[key] !== 'object') {
|
|
result.push(key + '=' + encodeURIComponent(params[key]));
|
|
}
|
|
else {
|
|
result.push(prepareObject(key, params[key]));
|
|
}
|
|
});
|
|
|
|
return result.join('&');
|
|
},
|
|
|
|
request: function (method, canonical_uri, region, service, params, data) {
|
|
if (typeof data === 'undefined' || data === null) {
|
|
data = '';
|
|
}
|
|
|
|
var amzdate = (new Date()).toISOString().replace(/\.\d+Z/, 'Z').replace(/[-:]/g, ''),
|
|
date = amzdate.replace(/T\d+Z/, ''),
|
|
host = service + '.' + region + '.amazonaws.com',
|
|
canonical_headers = 'content-encoding:amz-1.0\n' + 'host:' + host + '\n' + 'x-amz-date:' + amzdate + '\n',
|
|
signed_headers = 'content-encoding;host;x-amz-date',
|
|
canonical_request = method + '\n' + canonical_uri + '\n' + params + '\n' + canonical_headers + '\n' + signed_headers + '\n' + sha256(data),
|
|
credential_scope = date + '/' + region + '/' + service + '/' + 'aws4_request',
|
|
request_string = 'AWS4-HMAC-SHA256' + '\n' + amzdate + '\n' + credential_scope + '\n' + sha256(canonical_request),
|
|
key = AWS.sign('AWS4' + AWS.params.SecretAccessKey, date),
|
|
key = AWS.sign(key, region),
|
|
key = AWS.sign(key, service),
|
|
key = AWS.sign(key, 'aws4_request'),
|
|
request = new HttpRequest(AWS.tls.options),
|
|
url = 'https://' + host + canonical_uri + '?' + params;
|
|
|
|
if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
|
|
request.setProxy(AWS.params.proxy);
|
|
}
|
|
|
|
request.addHeader('x-amz-date: ' + amzdate);
|
|
request.addHeader('x-amz-content-sha256:' + sha256(data));
|
|
request.addHeader('Accept: application/json');
|
|
request.addHeader('Content-Type: application/json');
|
|
request.addHeader('Content-Encoding: amz-1.0');
|
|
request.addHeader('Authorization: ' + 'AWS4-HMAC-SHA256 Credential=' + AWS.params.AccessKeyId + '/' + credential_scope + ', ' + 'SignedHeaders=' + signed_headers + ', ' + 'Signature=' + hmac('sha256', key, request_string));
|
|
|
|
if (AWS.params.auth_type === 'role_base' || AWS.params.auth_type === 'assume_role_metadata' || (AWS.params.auth_type === 'assume_role' & !params.includes('AssumeRole'))) {
|
|
request.addHeader('X-Amz-Security-Token: ' + (AWS.params.auth_type === 'role_base' ? AWS.params.Token : AWS.params.SessionToken));
|
|
}
|
|
|
|
Zabbix.log(4, '[ AWS Backup vault ] Sending request: ' + url);
|
|
response = request.get(url);
|
|
Zabbix.log(4, '[ AWS Backup vault ] Received response with status code ' + request.getStatus() + ': ' + response);
|
|
|
|
if (request.getStatus() !== 200) {
|
|
throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
|
|
}
|
|
|
|
try {
|
|
response = JSON.parse(response);
|
|
}
|
|
catch (error) {
|
|
try {
|
|
response = JSON.parse(XML.toJson(response));
|
|
}
|
|
catch (error) {
|
|
throw 'Failed to parse response received from AWS API. Check debug log for more information.';
|
|
}
|
|
}
|
|
|
|
return response;
|
|
},
|
|
|
|
listJobs: function () {
|
|
var lld_array = [],
|
|
job_types = [
|
|
'backup-job',
|
|
'copy-job',
|
|
'restore-job'
|
|
],
|
|
created_after = Date.now() / 1000 - AWS.params.period * 86400
|
|
payload = {
|
|
'backupVaultName': AWS.params.vault,
|
|
'createdAfter': created_after
|
|
};
|
|
|
|
job_types.forEach(function (job_type) {
|
|
while (payload.nextToken !== null) {
|
|
var result = AWS.request('GET', '/' + job_type + 's', AWS.params.region, 'backup', AWS.prepareParams(payload));
|
|
|
|
payload.nextToken = result.NextToken;
|
|
|
|
if (typeof result !== 'object') {
|
|
throw 'Cannot get job list from AWS API. Check debug log for more information.';
|
|
}
|
|
|
|
switch (job_type) {
|
|
case 'backup-job': {
|
|
if (typeof result.BackupJobs !== 'object') {
|
|
throw 'Cannot get backup job list from AWS API. Check debug log for more information.';
|
|
}
|
|
result.BackupJobs.forEach(function (job) {
|
|
lld_array.push({
|
|
job_id: AWS.getField(job, 'BackupJobId'),
|
|
job_type: job_type,
|
|
resource_type: AWS.getField(job, 'ResourceType'),
|
|
resource_name: AWS.getField(job, 'ResourceName'),
|
|
job_state: AWS.getField(job, 'State'),
|
|
job_size: AWS.getField(job, 'BackupSizeInBytes')
|
|
});
|
|
});
|
|
break;
|
|
}
|
|
case 'copy-job': {
|
|
if (typeof result.CopyJobs !== 'object') {
|
|
throw 'Cannot get copy job list from AWS API. Check debug log for more information.';
|
|
}
|
|
result.CopyJobs.forEach(function (job) {
|
|
lld_array.push({
|
|
job_id: AWS.getField(job, 'CopyJobId'),
|
|
job_type: job_type,
|
|
resource_type: AWS.getField(job, 'ResourceType'),
|
|
resource_name: AWS.getField(job, 'ResourceName'),
|
|
job_state: AWS.getField(job, 'State'),
|
|
job_size: AWS.getField(job, 'BackupSizeInBytes')
|
|
});
|
|
});
|
|
break;
|
|
}
|
|
case 'restore-job': {
|
|
if (typeof result.RestoreJobs !== 'object') {
|
|
throw 'Cannot get restore job list from AWS API. Check debug log for more information.';
|
|
}
|
|
result.RestoreJobs.forEach(function (job) {
|
|
lld_array.push({
|
|
job_id: AWS.getField(job, 'RestoreJobId'),
|
|
job_type: job_type,
|
|
resource_type: AWS.getField(job, 'ResourceType'),
|
|
resource_name: null,
|
|
job_state: AWS.getField(job, 'Status'),
|
|
job_size: AWS.getField(job, 'BackupSizeInBytes')
|
|
});
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
delete payload.nextToken;
|
|
})
|
|
return lld_array;
|
|
}
|
|
};
|
|
|
|
try {
|
|
AWS.setParams(JSON.parse(value));
|
|
return JSON.stringify(AWS.listJobs());
|
|
}
|
|
catch (error) {
|
|
error += (String(error).endsWith('.')) ? '' : '.';
|
|
Zabbix.log(3, '[ AWS Backup vault ] ERROR: ' + error);
|
|
return JSON.stringify({ 'error': error });
|
|
}
|
|
description: 'Get a list of jobs in the vault.'
|
|
timeout: '{$AWS.DATA.TIMEOUT}'
|
|
parameters:
|
|
- name: AccessKeyId
|
|
value: '{$AWS.ACCESS.KEY.ID}'
|
|
- name: auth_type
|
|
value: '{$AWS.AUTH_TYPE}'
|
|
- name: metadata_auth
|
|
value: '{$AWS.ASSUME.ROLE.AUTH.METADATA}'
|
|
- name: period
|
|
value: '{$AWS.BACKUP_JOB.PERIOD}'
|
|
- name: proxy
|
|
value: '{$AWS.PROXY}'
|
|
- name: region
|
|
value: '{$AWS.REGION}'
|
|
- name: role_arn
|
|
value: '{$AWS.ASSUME.ROLE.ARN}'
|
|
- name: SecretAccessKey
|
|
value: '{$AWS.SECRET.ACCESS.KEY}'
|
|
- name: sts_region
|
|
value: '{$AWS.STS.REGION}'
|
|
- name: tls_verify
|
|
value: '{$HTTP.TLS.VERIFY:"AWS Backup Vault"}'
|
|
- name: vault
|
|
value: '{$AWS.BACKUP_VAULT.NAME}'
|
|
tags:
|
|
- tag: component
|
|
value: raw
|
|
- uuid: fa781abfaa014fcdab62321fc9940ac7
|
|
name: 'Jobs: Restore'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.restore.count
|
|
delay: '0'
|
|
description: 'The number of restore jobs in the vault over the last `{$AWS.BACKUP_JOB.PERIOD}` day(s).'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.[?(@.job_type == "restore-job")].length()'
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
triggers:
|
|
- uuid: 31f7e20621f249138df7aea59df927dc
|
|
expression: 'change(/AWS Backup Vault by HTTP/aws.backup_vault.job.restore.count)>0'
|
|
recovery_mode: NONE
|
|
name: 'AWS Backup vault: Restore job has appeared'
|
|
opdata: 'Current amount: {ITEM.LASTVALUE1}'
|
|
priority: AVERAGE
|
|
description: 'New restore job has appeared.'
|
|
manual_close: 'YES'
|
|
tags:
|
|
- tag: scope
|
|
value: notice
|
|
- uuid: acae9cf0a32c42dead1651fc911afc3b
|
|
name: 'Jobs: Failed restore'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.restore.failed.count
|
|
delay: '0'
|
|
description: 'The number of failed restore jobs in the vault over the last `{$AWS.BACKUP_JOB.PERIOD}` day(s).'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.[?(@.job_type == "restore-job" && @.job_state == "FAILED")].length()'
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: 5a9a604c70844ab8bffe4bf96ceeb761
|
|
name: 'Jobs: Size, avg'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.size.avg
|
|
delay: '0'
|
|
units: B
|
|
description: |
|
|
The average size, in bytes, of a backup (recovery point).
|
|
This value can render differently depending on the resource type as AWS Backup pulls in data information from other AWS services. For example, the value returned may show a value of `0`, which may differ from the anticipated value.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$[?(@.job_size > 0)].job_size.avg()'
|
|
error_handler: DISCARD_VALUE
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: 90600e647d2a40ccbe1ced317c03abb4
|
|
name: 'Jobs: Size, max'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.size.max
|
|
delay: '0'
|
|
units: B
|
|
description: |
|
|
The maximum size, in bytes, of a backup (recovery point).
|
|
This value can render differently depending on the resource type as AWS Backup pulls in data information from other AWS services. For example, the value returned may show a value of `0`, which may differ from the anticipated value.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$[?(@.job_size > 0)].job_size.max()'
|
|
error_handler: DISCARD_VALUE
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: 0ad8090097e64cf3bf28710f423a6164
|
|
name: 'Jobs: Size, min'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.size.min
|
|
delay: '0'
|
|
units: B
|
|
description: |
|
|
The minimum size, in bytes, of a backup (recovery point).
|
|
This value can render differently depending on the resource type as AWS Backup pulls in data information from other AWS services. For example, the value returned may show a value of `0`, which may differ from the anticipated value.
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$[?(@.job_size > 0)].job_size.min()'
|
|
error_handler: DISCARD_VALUE
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: 886b2b55cfbf42d58f01cfad66cc1ad5
|
|
name: 'Jobs: Total'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.total.count
|
|
delay: '0'
|
|
description: 'The total number of jobs in the vault over the last `{$AWS.BACKUP_JOB.PERIOD}` day(s).'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.length()
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: 0faeb1eedbb64fa7848a475fb8da1808
|
|
name: 'Lock date'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.lock.date
|
|
delay: '0'
|
|
units: unixtime
|
|
description: 'The date and time when AWS Backup Vault Lock configuration becomes immutable, meaning it cannot be changed or deleted.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.LockDate
|
|
- type: NOT_MATCHES_REGEX
|
|
parameters:
|
|
- 'null'
|
|
error_handler: CUSTOM_ERROR
|
|
error_handler_params: 'Either the vault is not locked, or the lock date is not specified.'
|
|
master_item:
|
|
key: aws.backup_vault.data.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: 477eb6a9728e4fb4aadd8b9903ef6fb1
|
|
name: 'Lock status'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.lock.status
|
|
delay: '0'
|
|
description: 'Indicates whether AWS Backup Vault Lock is applied to the selected backup vault. When the vault is locked, delete and update operations on recovery points in that vault are prevented.'
|
|
valuemap:
|
|
name: 'AWS Backup vault lock status'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.Locked
|
|
- type: STR_REPLACE
|
|
parameters:
|
|
- 'false'
|
|
- '0'
|
|
- type: STR_REPLACE
|
|
parameters:
|
|
- 'true'
|
|
- '1'
|
|
master_item:
|
|
key: aws.backup_vault.data.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: b886025d57d345298e6739972b328223
|
|
name: 'Lock time remain'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.lock.time_left
|
|
delay: '0'
|
|
units: uptime
|
|
description: 'The remaining time before AWS Backup Vault Lock configuration becomes immutable, meaning it cannot be changed or deleted.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.LockDate
|
|
- type: NOT_MATCHES_REGEX
|
|
parameters:
|
|
- 'null'
|
|
error_handler: CUSTOM_ERROR
|
|
error_handler_params: 'Either the vault is not locked, or the lock date is not specified.'
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
now = Date.now() / 1000;
|
|
if (value > now) {
|
|
return value - now
|
|
} else {
|
|
return 0
|
|
}
|
|
master_item:
|
|
key: aws.backup_vault.data.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: abab51050d0a4fbbb976db8b6fe51494
|
|
name: 'Recovery points'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.recovery_points
|
|
delay: '0'
|
|
description: 'The total number of recovery points in the backup vault.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.NumberOfRecoveryPoints
|
|
- type: NOT_MATCHES_REGEX
|
|
parameters:
|
|
- 'null'
|
|
error_handler: DISCARD_VALUE
|
|
master_item:
|
|
key: aws.backup_vault.data.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: 9d8c6dc0c1dc4b65a2a2edd299bf7855
|
|
name: 'Retention period, max'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.retention.max
|
|
delay: '0'
|
|
units: '!day(s)'
|
|
description: 'The maximum retention period that the vault retains its recovery points.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.MaxRetentionDays
|
|
- type: NOT_MATCHES_REGEX
|
|
parameters:
|
|
- 'null'
|
|
error_handler: CUSTOM_ERROR
|
|
error_handler_params: 'The vault does not have the maximum retention period set.'
|
|
master_item:
|
|
key: aws.backup_vault.data.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: 6bbb460c7630455db019528e2fa4333b
|
|
name: 'Retention period, min'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.retention.min
|
|
delay: '0'
|
|
units: '!day(s)'
|
|
description: 'The minimum retention period that the vault retains its recovery points.'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.MinRetentionDays
|
|
- type: NOT_MATCHES_REGEX
|
|
parameters:
|
|
- 'null'
|
|
error_handler: CUSTOM_ERROR
|
|
error_handler_params: 'The vault does not have the minimum retention period set.'
|
|
master_item:
|
|
key: aws.backup_vault.data.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- uuid: b289382581d741e8b420bf6db3eaf073
|
|
name: State
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.state
|
|
delay: '0'
|
|
description: |
|
|
The current state of the backup vault.
|
|
Possible values are:
|
|
- Unknown
|
|
- Creating
|
|
- Available
|
|
- Failed
|
|
valuemap:
|
|
name: 'AWS Backup vault state'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- $.VaultState
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
const idx = {
|
|
'CREATING': 1,
|
|
'AVAILABLE': 2,
|
|
'FAILED': 3
|
|
};
|
|
|
|
return typeof idx[value] === 'undefined' ? 0 : idx[value];
|
|
master_item:
|
|
key: aws.backup_vault.data.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
discovery_rules:
|
|
- uuid: 1e96003b5bd949f08684cee42c1aa4d7
|
|
name: 'AWS Backup job discovery'
|
|
type: DEPENDENT
|
|
key: aws.backup_vault.job.discovery
|
|
delay: '0'
|
|
filter:
|
|
evaltype: AND
|
|
conditions:
|
|
- macro: '{#AWS.BACKUP_JOB.RESOURCE_NAME}'
|
|
value: '{$AWS.BACKUP_JOB.RESOURCE_NAME.MATCHES}'
|
|
formulaid: A
|
|
- macro: '{#AWS.BACKUP_JOB.RESOURCE_NAME}'
|
|
value: '{$AWS.BACKUP_JOB.RESOURCE_NAME.NOT_MATCHES}'
|
|
operator: NOT_MATCHES_REGEX
|
|
formulaid: B
|
|
- macro: '{#AWS.BACKUP_JOB.RESOURCE_TYPE}'
|
|
value: '{$AWS.BACKUP_JOB.RESOURCE_TYPE.MATCHES}'
|
|
formulaid: C
|
|
- macro: '{#AWS.BACKUP_JOB.RESOURCE_TYPE}'
|
|
value: '{$AWS.BACKUP_JOB.RESOURCE_TYPE.NOT_MATCHES}'
|
|
operator: NOT_MATCHES_REGEX
|
|
formulaid: D
|
|
- macro: '{#AWS.BACKUP_JOB.STATE}'
|
|
value: '{$AWS.BACKUP_JOB.STATE.MATCHES}'
|
|
formulaid: E
|
|
- macro: '{#AWS.BACKUP_JOB.STATE}'
|
|
value: '{$AWS.BACKUP_JOB.STATE.NOT_MATCHES}'
|
|
operator: NOT_MATCHES_REGEX
|
|
formulaid: F
|
|
lifetime: '0'
|
|
description: 'AWS Backup job discovery.'
|
|
item_prototypes:
|
|
- uuid: cc978e4977c94e0ca743757d9d254f14
|
|
name: 'Job state [{#AWS.BACKUP_JOB.RESOURCE_NAME}][{#AWS.BACKUP_JOB.ID}]'
|
|
type: DEPENDENT
|
|
key: 'aws.backup_vault.job.state["{#AWS.BACKUP_JOB.ID}"]'
|
|
delay: '0'
|
|
description: |
|
|
The state of the job.
|
|
Possible values are:
|
|
- Unknown
|
|
- Created
|
|
- Pending
|
|
- Running
|
|
- Aborting
|
|
- Aborted
|
|
- Completed
|
|
- Failed
|
|
- Expired
|
|
- Partial
|
|
valuemap:
|
|
name: 'AWS Backup job state'
|
|
preprocessing:
|
|
- type: JSONPATH
|
|
parameters:
|
|
- '$.[?(@.job_id == "{#AWS.BACKUP_JOB.ID}")].job_state.first()'
|
|
error_handler: DISCARD_VALUE
|
|
- type: JAVASCRIPT
|
|
parameters:
|
|
- |
|
|
const idx = {
|
|
'CREATED': 1,
|
|
'PENDING': 2,
|
|
'RUNNING': 3,
|
|
'ABORTING': 4,
|
|
'ABORTED': 5,
|
|
'COMPLETED': 6,
|
|
'FAILED': 7,
|
|
'EXPIRED ': 8,
|
|
'PARTIAL': 9
|
|
};
|
|
|
|
return typeof idx[value] === 'undefined' ? 0 : idx[value];
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
tags:
|
|
- tag: component
|
|
value: backup_vault
|
|
- tag: job_type
|
|
value: '{#AWS.BACKUP_JOB.TYPE}'
|
|
- tag: resource_name
|
|
value: '{#AWS.BACKUP_JOB.RESOURCE_NAME}'
|
|
- tag: resource_type
|
|
value: '{#AWS.BACKUP_JOB.RESOURCE_TYPE}'
|
|
trigger_prototypes:
|
|
- uuid: d32bba2d26514a2381a18415f26c7591
|
|
expression: 'last(/AWS Backup Vault by HTTP/aws.backup_vault.job.state["{#AWS.BACKUP_JOB.ID}"])=7'
|
|
name: 'AWS Backup vault: Job failed [{#AWS.BACKUP_JOB.ID}]'
|
|
event_name: 'AWS Backup vault: Job type [{#AWS.BACKUP_JOB.TYPE}] for [{#AWS.BACKUP_JOB.RESOURCE_NAME}] with ID [{#AWS.BACKUP_JOB.ID}] has failed.'
|
|
opdata: 'Current status: {ITEM.LASTVALUE1}'
|
|
priority: HIGH
|
|
description: 'Job has failed.'
|
|
manual_close: 'YES'
|
|
tags:
|
|
- tag: scope
|
|
value: notice
|
|
- uuid: 06182df42e5d4777b8506726c2793dee
|
|
expression: 'last(/AWS Backup Vault by HTTP/aws.backup_vault.job.state["{#AWS.BACKUP_JOB.ID}"])=5'
|
|
name: 'AWS Backup vault: Job has been aborted [{#AWS.BACKUP_JOB.ID}]'
|
|
event_name: 'AWS Backup vault: Job type [{#AWS.BACKUP_JOB.TYPE}] for [{#AWS.BACKUP_JOB.RESOURCE_NAME}] with ID [{#AWS.BACKUP_JOB.ID}] has been aborted.'
|
|
opdata: 'Current status: {ITEM.LASTVALUE1}'
|
|
priority: AVERAGE
|
|
description: 'Job has been aborted.'
|
|
manual_close: 'YES'
|
|
tags:
|
|
- tag: scope
|
|
value: notice
|
|
- uuid: e1fb82528ca34849b75200b417036037
|
|
expression: 'last(/AWS Backup Vault by HTTP/aws.backup_vault.job.state["{#AWS.BACKUP_JOB.ID}"])=8'
|
|
name: 'AWS Backup vault: Job has expired [{#AWS.BACKUP_JOB.ID}]'
|
|
event_name: 'AWS Backup vault: Job type [{#AWS.BACKUP_JOB.TYPE}] for [{#AWS.BACKUP_JOB.RESOURCE_NAME}] with ID [{#AWS.BACKUP_JOB.ID}] has expired.'
|
|
opdata: 'Current status: {ITEM.LASTVALUE1}'
|
|
priority: WARNING
|
|
description: 'Job expired.'
|
|
manual_close: 'YES'
|
|
tags:
|
|
- tag: scope
|
|
value: notice
|
|
- uuid: e449b1999f09469bbf71e531afebc26b
|
|
expression: 'last(/AWS Backup Vault by HTTP/aws.backup_vault.job.state["{#AWS.BACKUP_JOB.ID}"])=0'
|
|
name: 'AWS Backup vault: Job is in an unknown state [{#AWS.BACKUP_JOB.ID}]'
|
|
event_name: 'AWS Backup vault: Job type [{#AWS.BACKUP_JOB.TYPE}] for [{#AWS.BACKUP_JOB.RESOURCE_NAME}] with ID [{#AWS.BACKUP_JOB.ID}] is in an unknown state.'
|
|
opdata: 'Current status: {ITEM.LASTVALUE1}'
|
|
priority: WARNING
|
|
description: 'Job is in unknown state.'
|
|
manual_close: 'YES'
|
|
tags:
|
|
- tag: scope
|
|
value: notice
|
|
master_item:
|
|
key: aws.backup_vault.job.get
|
|
lld_macro_paths:
|
|
- lld_macro: '{#AWS.BACKUP_JOB.ID}'
|
|
path: $.job_id
|
|
- lld_macro: '{#AWS.BACKUP_JOB.RESOURCE_NAME}'
|
|
path: $.resource_name
|
|
- lld_macro: '{#AWS.BACKUP_JOB.RESOURCE_TYPE}'
|
|
path: $.resource_type
|
|
- lld_macro: '{#AWS.BACKUP_JOB.STATE}'
|
|
path: $.job_state
|
|
- lld_macro: '{#AWS.BACKUP_JOB.TYPE}'
|
|
path: $.job_type
|
|
preprocessing:
|
|
- type: DISCARD_UNCHANGED_HEARTBEAT
|
|
parameters:
|
|
- 1h
|
|
overrides:
|
|
- name: 'Copy job excludes'
|
|
step: '1'
|
|
filter:
|
|
conditions:
|
|
- macro: '{#AWS.BACKUP_JOB.TYPE}'
|
|
value: '^copy-job&'
|
|
formulaid: A
|
|
operations:
|
|
- operationobject: TRIGGER_PROTOTYPE
|
|
operator: LIKE
|
|
value: 'Job aborted'
|
|
discover: NO_DISCOVER
|
|
- operationobject: TRIGGER_PROTOTYPE
|
|
operator: LIKE
|
|
value: 'Job expired'
|
|
discover: NO_DISCOVER
|
|
- name: 'Restore job excludes'
|
|
step: '2'
|
|
filter:
|
|
conditions:
|
|
- macro: '{#AWS.BACKUP_JOB.TYPE}'
|
|
value: '^restore-job&'
|
|
formulaid: A
|
|
operations:
|
|
- operationobject: TRIGGER_PROTOTYPE
|
|
operator: LIKE
|
|
value: 'Job expired'
|
|
discover: NO_DISCOVER
|
|
- operationobject: TRIGGER_PROTOTYPE
|
|
operator: LIKE
|
|
value: 'Job partially completed'
|
|
discover: NO_DISCOVER
|
|
tags:
|
|
- tag: class
|
|
value: cloud
|
|
- tag: target
|
|
value: aws
|
|
- tag: target
|
|
value: backup_vault
|
|
macros:
|
|
- macro: '{$AWS.ACCESS.KEY.ID}'
|
|
description: 'Access key ID.'
|
|
- macro: '{$AWS.ASSUME.ROLE.ARN}'
|
|
description: 'ARN assume role; add when using the `assume_role` authorization method.'
|
|
- macro: '{$AWS.ASSUME.ROLE.AUTH.METADATA}'
|
|
value: 'false'
|
|
description: 'Add when using the `assume_role` through instance metadata or environment authorization method. Possible values: `false`, `true`.'
|
|
- macro: '{$AWS.AUTH_TYPE}'
|
|
value: access_key
|
|
description: 'Authorization method. Possible values: `access_key`, `assume_role`, `role_base`.'
|
|
- macro: '{$AWS.BACKUP_JOB.PERIOD}'
|
|
value: '7'
|
|
description: 'The number of days over which to retrieve backup jobs.'
|
|
- macro: '{$AWS.BACKUP_JOB.RESOURCE_NAME.MATCHES}'
|
|
value: '.*'
|
|
description: 'Filter of discoverable jobs by resource name.'
|
|
- macro: '{$AWS.BACKUP_JOB.RESOURCE_NAME.NOT_MATCHES}'
|
|
value: CHANGE_IF_NEEDED
|
|
description: 'Filter to exclude discovered jobs by resource name.'
|
|
- macro: '{$AWS.BACKUP_JOB.RESOURCE_TYPE.MATCHES}'
|
|
value: '.*'
|
|
description: 'Filter of discoverable jobs by resource type.'
|
|
- macro: '{$AWS.BACKUP_JOB.RESOURCE_TYPE.NOT_MATCHES}'
|
|
value: CHANGE_IF_NEEDED
|
|
description: 'Filter to exclude discovered jobs by resource type.'
|
|
- macro: '{$AWS.BACKUP_JOB.STATE.MATCHES}'
|
|
value: '.*'
|
|
description: 'Filter of discoverable jobs by state.'
|
|
- macro: '{$AWS.BACKUP_JOB.STATE.NOT_MATCHES}'
|
|
value: CHANGE_IF_NEEDED
|
|
description: 'Filter to exclude discovered jobs by state.'
|
|
- macro: '{$AWS.BACKUP_VAULT.NAME}'
|
|
description: 'AWS backup vault name.'
|
|
- macro: '{$AWS.DATA.TIMEOUT}'
|
|
value: 60s
|
|
description: 'API response timeout.'
|
|
- macro: '{$AWS.PROXY}'
|
|
description: 'Sets the HTTP proxy value. If this macro is empty, no proxy is used.'
|
|
- macro: '{$AWS.REGION}'
|
|
value: us-west-1
|
|
description: 'AWS backup vault region code.'
|
|
- macro: '{$AWS.SECRET.ACCESS.KEY}'
|
|
type: SECRET_TEXT
|
|
description: 'Secret access key.'
|
|
- macro: '{$AWS.STS.REGION}'
|
|
value: us-east-1
|
|
description: 'Region used in assume role 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 "AWS Backup Vault", e.g. {$HTTP.TLS.VERIFY:"AWS Backup Vault"}.'
|
|
dashboards:
|
|
- uuid: 92a5197bbdeb403cabb6dd12eabb7deb
|
|
name: 'AWS Backup vault'
|
|
pages:
|
|
- name: 'Backup vault overview'
|
|
widgets:
|
|
- type: item
|
|
name: 'Vault age'
|
|
width: '26'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'AWS Backup Vault by HTTP'
|
|
key: aws.backup_vault.age
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
- type: item
|
|
name: 'Backup jobs'
|
|
'y': '2'
|
|
width: '13'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'AWS Backup Vault by HTTP'
|
|
key: aws.backup_vault.job.backup.count
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '4'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
- type: itemnavigator
|
|
name: 'Jobs grouped'
|
|
'y': '4'
|
|
width: '28'
|
|
height: '8'
|
|
fields:
|
|
- type: INTEGER
|
|
name: group_by.0.attribute
|
|
value: '3'
|
|
- type: STRING
|
|
name: group_by.0.tag_name
|
|
value: resource_type
|
|
- type: INTEGER
|
|
name: group_by.1.attribute
|
|
value: '3'
|
|
- type: STRING
|
|
name: group_by.1.tag_name
|
|
value: resource_name
|
|
- type: STRING
|
|
name: items.0
|
|
value: 'Job state [*]'
|
|
- type: STRING
|
|
name: reference
|
|
value: DTQLA
|
|
- type: INTEGER
|
|
name: show_lines
|
|
value: '300'
|
|
- type: item
|
|
name: 'Selected job'
|
|
'y': '12'
|
|
width: '28'
|
|
height: '1'
|
|
hide_header: 'YES'
|
|
fields:
|
|
- type: STRING
|
|
name: description
|
|
value: 'Selected job status:'
|
|
- type: INTEGER
|
|
name: desc_h_pos
|
|
value: '0'
|
|
- type: INTEGER
|
|
name: desc_size
|
|
value: '60'
|
|
- type: INTEGER
|
|
name: desc_v_pos
|
|
value: '1'
|
|
- type: STRING
|
|
name: itemid._reference
|
|
value: DTQLA._itemid
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: value_h_pos
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
- type: item
|
|
name: 'Restore jobs'
|
|
x: '13'
|
|
'y': '2'
|
|
width: '13'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'AWS Backup Vault by HTTP'
|
|
key: aws.backup_vault.job.restore.count
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '4'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
- type: item
|
|
name: 'Recovery points'
|
|
x: '26'
|
|
width: '13'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'AWS Backup Vault by HTTP'
|
|
key: aws.backup_vault.recovery_points
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '4'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
- type: item
|
|
name: 'Copy jobs'
|
|
x: '26'
|
|
'y': '2'
|
|
width: '13'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'AWS Backup Vault by HTTP'
|
|
key: aws.backup_vault.job.copy.count
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '4'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
- type: honeycomb
|
|
name: Jobs
|
|
x: '28'
|
|
'y': '4'
|
|
width: '44'
|
|
height: '8'
|
|
fields:
|
|
- type: STRING
|
|
name: items.0
|
|
value: 'Job state [*]'
|
|
- type: STRING
|
|
name: reference
|
|
value: ZMGLG
|
|
- type: INTEGER
|
|
name: secondary_label_units_show
|
|
value: '0'
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: STRING
|
|
name: thresholds.0.color
|
|
value: EC1594
|
|
- type: STRING
|
|
name: thresholds.0.threshold
|
|
value: '0'
|
|
- type: STRING
|
|
name: thresholds.1.color
|
|
value: 6AC8FF
|
|
- type: STRING
|
|
name: thresholds.1.threshold
|
|
value: '1'
|
|
- type: STRING
|
|
name: thresholds.2.color
|
|
value: 6AC8FF
|
|
- type: STRING
|
|
name: thresholds.2.threshold
|
|
value: '2'
|
|
- type: STRING
|
|
name: thresholds.3.color
|
|
value: 00A1FF
|
|
- type: STRING
|
|
name: thresholds.3.threshold
|
|
value: '3'
|
|
- type: STRING
|
|
name: thresholds.4.color
|
|
value: FFD54F
|
|
- type: STRING
|
|
name: thresholds.4.threshold
|
|
value: '4'
|
|
- type: STRING
|
|
name: thresholds.5.color
|
|
value: BF00FF
|
|
- type: STRING
|
|
name: thresholds.5.threshold
|
|
value: '5'
|
|
- type: STRING
|
|
name: thresholds.6.color
|
|
value: 0EC9AC
|
|
- type: STRING
|
|
name: thresholds.6.threshold
|
|
value: '6'
|
|
- type: STRING
|
|
name: thresholds.7.color
|
|
value: FF465C
|
|
- type: STRING
|
|
name: thresholds.7.threshold
|
|
value: '7'
|
|
- type: STRING
|
|
name: thresholds.8.color
|
|
value: BAE37D
|
|
- type: STRING
|
|
name: thresholds.8.threshold
|
|
value: '8'
|
|
- type: item
|
|
name: 'Selected job'
|
|
x: '28'
|
|
'y': '12'
|
|
width: '44'
|
|
height: '1'
|
|
hide_header: 'YES'
|
|
fields:
|
|
- type: STRING
|
|
name: description
|
|
value: '{{ITEM.NAME}.regsub("(Job state \[)(.*)(, )(.*)(\])","Resource: \2, Job ID: \4")}'
|
|
- type: INTEGER
|
|
name: desc_h_pos
|
|
value: '0'
|
|
- type: INTEGER
|
|
name: desc_size
|
|
value: '60'
|
|
- type: INTEGER
|
|
name: desc_v_pos
|
|
value: '1'
|
|
- type: STRING
|
|
name: itemid._reference
|
|
value: ZMGLG._itemid
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '1'
|
|
- type: INTEGER
|
|
name: value_h_pos
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
- type: item
|
|
name: 'Average size'
|
|
x: '39'
|
|
width: '13'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '1'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'AWS Backup Vault by HTTP'
|
|
key: aws.backup_vault.job.size.avg
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '4'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
- type: item
|
|
name: 'Total jobs'
|
|
x: '39'
|
|
'y': '2'
|
|
width: '13'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'AWS Backup Vault by HTTP'
|
|
key: aws.backup_vault.job.total.count
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '4'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
- type: item
|
|
name: 'Lock status'
|
|
x: '52'
|
|
width: '20'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'AWS Backup Vault by HTTP'
|
|
key: aws.backup_vault.lock.status
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: show.1
|
|
value: '4'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
- type: item
|
|
name: 'Vault state'
|
|
x: '52'
|
|
'y': '2'
|
|
width: '20'
|
|
fields:
|
|
- type: INTEGER
|
|
name: decimal_places
|
|
value: '0'
|
|
- type: ITEM
|
|
name: itemid.0
|
|
value:
|
|
host: 'AWS Backup Vault by HTTP'
|
|
key: aws.backup_vault.state
|
|
- type: INTEGER
|
|
name: show.0
|
|
value: '2'
|
|
- type: INTEGER
|
|
name: value_size
|
|
value: '60'
|
|
valuemaps:
|
|
- uuid: 0296c0c525304ea2ad91070346669b42
|
|
name: 'AWS Backup job state'
|
|
mappings:
|
|
- value: '0'
|
|
newvalue: Unknown
|
|
- value: '1'
|
|
newvalue: Created
|
|
- value: '2'
|
|
newvalue: Pending
|
|
- value: '3'
|
|
newvalue: Running
|
|
- value: '4'
|
|
newvalue: Aborting
|
|
- value: '5'
|
|
newvalue: Aborted
|
|
- value: '6'
|
|
newvalue: Completed
|
|
- value: '7'
|
|
newvalue: Failed
|
|
- value: '8'
|
|
newvalue: Expired
|
|
- value: '9'
|
|
newvalue: Partial
|
|
- uuid: b5821fcd5f3444198570b8dfb925ce0a
|
|
name: 'AWS Backup vault lock status'
|
|
mappings:
|
|
- value: '0'
|
|
newvalue: Unlocked
|
|
- value: '1'
|
|
newvalue: Locked
|
|
- uuid: d591fd3704ff4fc3a7e5ee6b206190ad
|
|
name: 'AWS Backup vault state'
|
|
mappings:
|
|
- value: '0'
|
|
newvalue: Unknown
|
|
- value: '1'
|
|
newvalue: Creating
|
|
- value: '2'
|
|
newvalue: Available
|
|
- value: '3'
|
|
newvalue: Failed
|