zabbix_export:
  version: '7.4'
  template_groups:
    - uuid: c2c162144c2d4c5491c8801193af4945
      name: Templates/Cloud
  host_groups:
    - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
      name: Applications
    - uuid: 748ad4d098d447d492bb935c907f652f
      name: Databases
    - uuid: 137f19e6e2dc4219b33553b812627bc2
      name: 'Virtual machines'
  templates:
    - uuid: 4e1e9372a5fe4297936210bc4fc4b1c0
      template: 'GCP by HTTP'
      name: 'GCP by HTTP'
      description: |
        Discover GCP Compute Engine/Cloud SQL Instances and Compute Engine project quota metrics.
        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"
      wizard_ready: 'YES'
      readme: |
        ## Overview
        
        This template is designed to monitor Google Cloud Platform (hereinafter - GCP) by Zabbix.
        It works without any external scripts and uses the script item.
        The template currently supports the discovery of [Compute Engine](https://cloud.google.com/compute)/[Cloud SQL](https://cloud.google.com/sql) instances and Compute Engine project quota metrics.
        
        
        ## Setup
        
        1. Enable the `Stackdriver Monitoring API` for the GCP project you wish to monitor.
        >Refer to the [vendor documentation](https://cloud.google.com/monitoring/api/enable-api).
        2. Create a service account in Google Cloud console for the project you have to monitor.
        >Refer to the [vendor documentation](https://cloud.google.com/iam/docs/creating-managing-service-accounts).
        3. Create and download the service account key in JSON format.
        >Refer to the [vendor documentation](https://cloud.google.com/iam/docs/creating-managing-service-account-keys).
        4. If you want to monitor Cloud SQL services - don't forget to activate the Cloud SQL Admin API.
        >Refer to the [vendor documentation](https://cloud.google.com/sql/docs/mysql/admin-api) for the details.
        5. Copy the `project_id`, `private_key_id`, `private_key`, `client_email` from the JSON key file and add them to their corresponding macros `GCP project ID`, `Private key id`, `Private key data`, `Client e-mail` in host wizard configuration fields.
        
        **Additional information**:
        
            Make sure that you're creating the service account using the credentials with the `Project Owner/Project IAM Admin/service account Admin` role.
        
            The service account JSON key file can only be downloaded once: regenerate it if the previous key has been lost.
        
            The service account should have `Project Viewer` permissions or granular permissions for the GCP Compute Engine API/GCP Cloud SQL.
        
            You can copy and paste private_key string data from the Service Account JSON key file as is or replace the new line metasymbol (\n) with an actual new line.
        
        >Please, refer to the [vendor documentation](https://cloud.google.com/iam/docs/manage-access-service-accounts)  about the service accounts management.
        
        **IMPORTANT!!!**
        
             Secret authorization token is defined as a plain text in host prototype settings by default due to Zabbix templates export/import limits: therefore, it is highly recommended to change the user macro `{$GCP.AUTH.TOKEN}` value type to `SECRET` for all host prototypes after the template `GCP by HTTP` import.
        
             All the instances/quotas/metrics discovered are related to a particular GCP project.
             To monitor several GCP projects - create their corresponding service accounts/Zabbix hosts.
        
             GCP Access Token is available for 1 hour (3600 seconds) after the generation request.
        
             To avoid a GCP token inconsistency between Zabbix database and Zabbix server configuration cache, don't set Zabbix server configuration parameter CacheUpdateFrequency to a value over 45 minutes and don't set the update interval for the GCP Authorization item to more than 1 hour (maximum CacheUpdateFrequency value).
        
        Additional information about metrics and used API methods:
        
          [Compute Engine](https://cloud.google.com/monitoring/api/metrics_gcp#gcp-compute)
        
          [Cloud SQL](https://cloud.google.com/monitoring/api/metrics_gcp#gcp-cloudsql)
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: b003e61fbede488a957b6c866ffaa9ba
          name: 'Authorization errors check'
          type: DEPENDENT
          key: gcp.auth.err.check
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
          master_item:
            key: gcp.authorization
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 74c0e16244314ab4a920e32faca50444
              expression: 'length(last(/GCP by HTTP/gcp.auth.err.check)) > 0'
              name: 'GCP: Authorization has failed'
              priority: AVERAGE
              description: |
                GCP: Authorization has failed.
                Check the authorization parameters and GCP API availability from a network segment, where Zabbix-server/proxy is located.
              tags:
                - tag: scope
                  value: availability
        - uuid: 5cc3faa82f404b38b513958f323f3d7d
          name: Authorization
          type: SCRIPT
          key: gcp.authorization
          delay: '{$GCP.AUTH.FREQUENCY}'
          history: '0'
          value_type: TEXT
          params: |
            var auth_url = 'https://oauth2.googleapis.com/token',
            	issued = Math.floor(new Date().getTime() / 1000),
            	expires = issued + 3600,
            	endpoint = 'https://www.googleapis.com/auth/',
            	scopes = ['cloud-platform.read-only', 'monitoring', 'compute.readonly', 'sqlservice.admin'],
            	scope = scopes.map(function (path) { return endpoint + path; }).join(' ');
            
            function base64url(source) {
            	encodedSource = btoa(source);
            	encodedSource = encodedSource.replace(/=+$/, '');
            	encodedSource = encodedSource.replace(/\+/g, '-');
            	encodedSource = encodedSource.replace(/\//g, '_');
            
            	return encodedSource;
            }
            
            function fromHex(hex) {
            	var utf8array = [];
            
            	if (hex.length % 2)
            		throw 'Invalid length of a hex string!';
            	for (var i = 0; i < hex.length; i += 2) {
            		utf8array.push(parseInt(hex.substr(i, 2), 16));
            	}
            	return new Uint8Array(utf8array);
            }
            
            function encodeJWT(headers, payload, secret) {
            	unsignedToken = base64url(JSON.stringify(headers)) + '.' + base64url(JSON.stringify(payload));
            	jwt = unsignedToken + '.' + base64url(fromHex(sign('sha256', secret, unsignedToken)));
            	return jwt;
            }
            
            function exchangeJwtForAccessToken(signed_jwt) {
            
            	var request = new HttpRequest(),
            		params = {
            			grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
            			assertion: signed_jwt
            		}
            	if (typeof script_params.proxy !== 'undefined' && script_params.proxy !== '') {
            		request.setProxy(script_params.proxy);
            	};
            	var response = request.post(auth_url, JSON.stringify(params));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + auth_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.';
            		}
            	}
            
            
            	if (typeof response.access_token !== 'undefined') {
            		return response.access_token;
            	}
            	else {
            		throw 'No access token in the JWT exchange request.';
            	}
            }
            
            function checkParams(params) {
            	['pkey_id', 'private_key', 'email'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	return params;
            }
            
            var script_params = checkParams(JSON.parse(value)),
            	headers = {
            		alg: 'RS256',
            		kid: script_params.pkey_id,
            		typ: 'JWT'
            	},
            	payload = {
            		iss: script_params.email,
            		sub: script_params.email,
            		aud: auth_url,
            		iat: issued,
            		exp: expires,
            		scope: scope
            	};
            
            try {
            	jwt = encodeJWT(headers, payload, script_params.private_key);
            	token = exchangeJwtForAccessToken(jwt);
            	return token;
            }
            catch (err) {
            	return JSON.stringify({ error: err });
            }
          description: |
            Google Cloud Platform REST authorization with service account authentication parameters and temporary-generated RSA-based JWT-token usage.
            The necessary scopes are pre-defined.
            Returns a signed authorization token with 1 hour lifetime; it is required only once, and is used for all the dependent script items.
            Check the template documentation for the details.
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: email
              value: '{$GCP.CLIENT.EMAIL}'
            - name: pkey_id
              value: '{$GCP.PRIVATE.KEY.ID}'
            - name: private_key
              value: '{$GCP.PRIVATE.KEY}'
            - name: proxy
              value: '{$GCP.PROXY}'
          tags:
            - tag: component
              value: raw
        - uuid: 3ac5c859692140c0b686e772efa05032
          name: 'Instances get'
          type: DEPENDENT
          key: gcp.cloudsql.instances.get
          history: '0'
          value_type: TEXT
          description: 'GCP Cloud SQL: Instances get.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var token = value;
                  
                  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 getHttpData(url, token) {
                  	var request = new HttpRequest(),
                  		proxy = '{$GCP.PROXY}';
                  	if (proxy !== '{' + '$GCP.PROXY}' && proxy !== '') {
                  		request.setProxy(proxy);
                  	};
                  	request.addHeader('Authorization: Bearer ' + token);
                  	request.addHeader('Content-Type: application/json');
                  
                  	var response = request.get(url);
                  
                  	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 project = '{$GCP.PROJECT.ID}';
                  
                  if (!project || project === '{' + '$GCP.PROJECT.ID}') {
                  	throw 'Error. Set the \{$GCP.PROJECT.ID\} macro value.';
                  }
                  
                  var inst_raw = getHttpData('https://sqladmin.googleapis.com/sql/v1beta4/projects/' + project + '/instances', token);
                  
                  if (Object.keys(inst_raw).length === 0) {
                  	return '[]';
                  }
                  
                  return JSON.stringify(getField(inst_raw, 'items').map(function (sql_inst) {
                  	obj = {
                  		name: getField(sql_inst, 'name'),
                  		token: value,
                  		zone: getField(sql_inst, 'settings.locationPreference.zone'),
                  		inst_type: getField(sql_inst, 'instanceType'),
                  		tier: getField(sql_inst, 'settings.tier'),
                  		project_id: getField(sql_inst, 'project'),
                  		db_type: getField(sql_inst, 'databaseInstalledVersion')
                  	};
                  
                  	obj.high_availability = (sql_inst.failoverReplica) ? true : false;
                  
                  	if (obj.db_type.match(/SQLSERVER*/)) {
                  		var mssql_audit = getField(sql_inst, 'settings.sqlServerAuditConfig');
                  
                  		obj.audited = (mssql_audit.bucket) ? true : false;
                  	}
                  
                  	if (obj.inst_type === 'READ_REPLICA_INSTANCE') {
                  		obj.master = getField(sql_inst, 'masterInstanceName');
                  	}
                  
                  	if (Array.isArray(sql_inst.ipAddresses)) {
                  		var int_addresses = sql_inst.ipAddresses.filter(function (addr) {
                  			return addr.type === 'PRIVATE';
                  		});
                  
                  		var ext_addresses = sql_inst.ipAddresses.filter(function (addr) {
                  			return addr.type === 'PRIMARY';
                  		});
                  
                  		obj.ip = getFieldBool(int_addresses, '0.ipAddress') ? int_addresses[0].ipAddress : '0.0.0.0';
                  		obj.ext_ip = getFieldBool(ext_addresses, '0.ipAddress') ? ext_addresses[0].ipAddress : '0.0.0.0';
                  	}
                  	else {
                  		obj.ip = '0.0.0.0';
                  		obj.ext_ip = '0.0.0.0';
                  	}
                  
                  	return obj;
                  }));
          master_item:
            key: gcp.authorization
          tags:
            - tag: component
              value: raw
        - uuid: 80687b35246b45ffa1be9d171f686e94
          name: 'MSSQL instances count'
          type: DEPENDENT
          key: gcp.cloudsql.instances.mssql_count
          description: 'GCP Cloud SQL MSSQL instances count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.db_type =~ ''SQLSERVER'')].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: 8ec94dff7a3b47998242d97a18cf0821
          name: 'MySQL instances count'
          type: DEPENDENT
          key: gcp.cloudsql.instances.mysql_count
          description: 'GCP Cloud SQL MySQL instances count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.db_type =~ ''MYSQL'')].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: de284dd30b2d4ecb9f7d0cf3ca80a094
          name: 'PostgreSQL instances count'
          type: DEPENDENT
          key: gcp.cloudsql.instances.pgsql_count
          description: 'GCP Cloud SQL PostgreSQL instances count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.db_type =~ ''POSTGRES'')].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: b926ba1901c5413396c1c071e6e76072
          name: 'Cloud SQL instances total'
          type: DEPENDENT
          key: gcp.cloudsql.instances.total
          description: 'GCP Cloud SQL instances total count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[*].length()'
          master_item:
            key: gcp.cloudsql.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: 58329c9a5b124b1990c94f15266e6edf
          name: 'Container-optimized GCE instances count'
          type: DEPENDENT
          key: gcp.gce.instances.cos_count
          description: 'GCP Compute Engine: count of instances with Container-Optimized OS used.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.i_type == ''container-optimized'')].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: 461e72fb7e104261831455ae3cc87358
          name: 'Instances get'
          type: DEPENDENT
          key: gcp.gce.instances.get
          history: '0'
          value_type: TEXT
          description: 'Get GCP Compute Engine instances.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var token = value;
                  function checkMacro(macro) {
                  	if (!macro || macro.match(/^\{\$.*\}$/)) {
                  		throw 'The GCP project id is not defined. Please, set the value for the \{$GCP.PROJECT.ID\} macro.';
                  	}
                  	return macro;
                  }
                  
                  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 getHttpData(url, token) {
                  	var request = new HttpRequest(),
                  		proxy = '{$GCP.PROXY}';
                  	if (proxy !== '{' + '$GCP.PROXY}' && proxy !== '') {
                  		request.setProxy(proxy);
                  	};
                  	request.addHeader('Authorization: Bearer ' + token);
                  	request.addHeader('Content-Type: application/json');
                  
                  	var response = request.get(url);
                  
                  	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 project = '{$GCP.PROJECT.ID}';
                  
                  if (!project || project === '{' + '$GCP.PROJECT.ID}') {
                  	throw 'Error. Set the \{$GCP.PROJECT.ID\} macro value.';
                  }
                  
                  var result = getHttpData('https://compute.googleapis.com/compute/v1/projects/' + project + '/aggregated/instances', token),
                  	vms_raw = getField(result, 'items'),
                  	keys = Object.keys(vms_raw),
                  	arr = [];
                  
                  for (var i in keys) {
                  	if (typeof vms_raw[keys[i]].instances !== 'undefined') {
                  		var vm_prop = vms_raw[keys[i]].instances.map(function setProp(inst) {
                  			obj = {
                  				id: getField(inst, 'id'),
                  				name: getField(inst, 'name'),
                  				token: value,
                  				zone: keys[i].replace(/zones\//, ''),
                  				m_type: getField(inst, 'machineType').replace(/.*machineTypes\//g, ''),
                  				state: getField(inst, 'status'),
                  				project_id: '{$GCP.PROJECT.ID}',
                  				ip: getField(inst, 'networkInterfaces.0.networkIP'),
                  				integrity: getFieldBool(inst, 'shieldedInstanceConfig.enableIntegrityMonitoring') ? inst.shieldedInstanceConfig.enableIntegrityMonitoring : false
                  			};
                  
                  			obj.ext_ip = getFieldBool(inst, 'networkInterfaces.0.accessConfigs.0.natIP') ? inst.networkInterfaces[0].accessConfigs[0].natIP : '0.0.0.0';
                  			obj.i_type = getFieldBool(inst, 'labels.container-vm') ? 'container-optimized' : 'regular';
                  			return obj;
                  		});
                  		arr = arr.concat(vm_prop);
                  	}
                  }
                  return JSON.stringify(arr);
          master_item:
            key: gcp.authorization
          tags:
            - tag: component
              value: raw
        - uuid: a936207f9d914955b2e2140e953f22f2
          name: 'Regular GCE instances count'
          type: DEPENDENT
          key: gcp.gce.instances.regular_count
          description: 'GCP Compute Engine: Regular instances count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.i_type == ''regular'')].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: 46eaeccd1f43466caadd44440da88568
          name: 'GCE instances total'
          type: DEPENDENT
          key: gcp.gce.instances.total
          description: 'GCP Compute Engine instances total count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[*].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: c4f17331815345bcb0ac6ea98413b2b5
          name: 'Project quotas get'
          type: DEPENDENT
          key: gcp.gce.quotas.get
          history: '0'
          value_type: TEXT
          description: 'GCP Compute Engine resource quotas available for the particular project.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var token = value;
                  
                  function checkMacro(macro) {
                  	if (!macro || macro.match(/^\{\$.*\}$/)) {
                  		throw 'The GCP project id is not defined. Please, set the value for the \{$GCP.PROJECT.ID\} macro.';
                  	}
                  	return macro;
                  }
                  
                  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) {
                  	var request = new HttpRequest(),
                  		proxy = '{$GCP.PROXY}';
                  	if (proxy !== '{' + '$GCP.PROXY}' && proxy !== '') {
                  		request.setProxy(proxy);
                  	};
                  	request.addHeader('Authorization: Bearer ' + token);
                  	request.addHeader('Content-Type: application/json');
                  
                  	var response = request.get(url);
                  
                  	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.';
                  		}
                  	}
                  
                  	if (typeof response.quotas !== 'undefined') {
                  		return response;
                  	} else {
                  		throw 'No quotas array in API response';
                  	}
                  };
                  var project = checkMacro('{$GCP.PROJECT.ID}'),
                  	qts_raw = getHttpData('https://www.googleapis.com/compute/v1/projects/' + project, token),
                  	qts_lst = getField(qts_raw, 'quotas').map(function (qt) {
                  		obj = {
                  			metric: getField(qt, 'metric'),
                  			limit: getField(qt, 'limit'),
                  			usage: getField(qt, 'usage'),
                  			p_used: (qt.usage / qt.limit) * 100
                  		};
                  		return obj;
                  	});
                  
                  return JSON.stringify(qts_lst);
          master_item:
            key: gcp.authorization
          tags:
            - tag: component
              value: raw
      discovery_rules:
        - uuid: f210e8e38c194c65b30e74610ec2b86f
          name: 'GCP Cloud SQL: MSSQL instances discovery'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.inst.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                value: 'SQLSERVER.*'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.MSSQL.INST.NAME.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.MSSQL.INST.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.MSSQL.INST.TYPE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.MSSQL.INST.TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.MSSQL.ZONE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.MSSQL.ZONE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Cloud SQL: MSSQL instances discovery.'
          host_prototypes:
            - uuid: edc6ab9314ed410b8a3cf6bfedff51ab
              host: '{#GCP.PROJECT.ID}-{#CLOUD_SQL.INSTANCE.NAME}'
              name: '{#CLOUD_SQL.INSTANCE.NAME}'
              group_links:
                - group:
                    name: Databases
              templates:
                - name: 'GCP Cloud SQL MSSQL by HTTP'
              macros:
                - macro: '{$CLOUD_SQL.HIGH.AVAILABILITY}'
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                  description: 'GCP Cloud SQL instance high availability definition. Required for metrics filtration.'
                - macro: '{$CLOUD_SQL.MSSQL.AUDITED}'
                  value: '{#MSSQL.AUDITED}'
                  description: 'GCP Cloud SQL MSSQL audit enabled definition. Required for metrics filtration.'
                - macro: '{$GCP.AUTH.TOKEN}'
                  value: '{#GCP.AUTH.TOKEN}'
                  description: 'Google Cloud Platform authorization token.'
                - macro: '{$GCP.PROJECT.ID}'
                  value: '{#GCP.PROJECT.ID}'
                  description: 'GCP Project Id.'
              tags:
                - tag: audit
                  value: '{#MSSQL.AUDITED}'
                - tag: db-version
                  value: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                - tag: high-availability
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                - tag: instance-type
                  value: '{#CLOUD_SQL.INSTANCE.TYPE}'
                - tag: project
                  value: '{#GCP.PROJECT.ID}'
                - tag: service
                  value: cloudsql
                - tag: service
                  value: gcp
                - tag: service
                  value: mssql
                - tag: tier
                  value: '{#CLOUD_SQL.INSTANCE.TIER}'
                - tag: zone
                  value: '{#CLOUD_SQL.INSTANCE.ZONE}'
              custom_interfaces: 'YES'
              interfaces:
                - default: 'NO'
                  ip: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
                  dns: external.ip
                - ip: '{#CLOUD_SQL.INSTANCE.IP}'
                  dns: internal.ip
          master_item:
            key: gcp.cloudsql.instances.get
          lld_macro_paths:
            - lld_macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
              path: $.db_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
              path: $.ext_ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
              path: $.high_availability
            - lld_macro: '{#CLOUD_SQL.INSTANCE.IP}'
              path: $.ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.NAME}'
              path: $.name
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TIER}'
              path: $.tier
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
              path: $.inst_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
              path: $.zone
            - lld_macro: '{#CLOUD_SQL.MASTER}'
              path: $.master
            - lld_macro: '{#GCP.AUTH.TOKEN}'
              path: $.token
            - lld_macro: '{#GCP.PROJECT.ID}'
              path: $.project_id
            - lld_macro: '{#MSSQL.AUDITED}'
              path: $.audited
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          overrides:
            - name: 'MSSQL replica'
              step: '1'
              filter:
                conditions:
                  - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                    value: READ_REPLICA_INSTANCE
                  - macro: '{#CLOUD_SQL.MASTER}'
                    operator: EXISTS
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  tags:
                    - tag: master_instance
                      value: '{#CLOUD_SQL.MASTER}'
                  templates:
                    - name: 'GCP Cloud SQL MSSQL Replica by HTTP'
        - uuid: 3fdd2543936a4587b1bfb5dabb30c1f6
          name: 'GCP Cloud SQL: MySQL instances discovery'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.inst.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                value: 'MYSQL.*'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.MYSQL.INST.NAME.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.MYSQL.INST.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.MYSQL.INST.TYPE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.MYSQL.INST.TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.MYSQL.ZONE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.MYSQL.ZONE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Cloud SQL: MySQL instances discovery.'
          host_prototypes:
            - uuid: 8b2556b881b14b86a98f90a447ae9734
              host: '{#GCP.PROJECT.ID}-{#CLOUD_SQL.INSTANCE.NAME}'
              name: '{#CLOUD_SQL.INSTANCE.NAME}'
              group_links:
                - group:
                    name: Databases
              templates:
                - name: 'GCP Cloud SQL MySQL by HTTP'
              macros:
                - macro: '{$CLOUD_SQL.HIGH.AVAILABILITY}'
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                  description: 'GCP Cloud SQL instance high availability definition.'
                - macro: '{$GCP.AUTH.TOKEN}'
                  value: '{#GCP.AUTH.TOKEN}'
                  description: 'Google Cloud Platform authorization token.'
                - macro: '{$GCP.PROJECT.ID}'
                  value: '{#GCP.PROJECT.ID}'
                  description: 'GCP Project Id.'
              tags:
                - tag: db-version
                  value: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                - tag: high-availability
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                - tag: instance-type
                  value: '{#CLOUD_SQL.INSTANCE.TYPE}'
                - tag: project
                  value: '{#GCP.PROJECT.ID}'
                - tag: service
                  value: cloudsql
                - tag: service
                  value: gcp
                - tag: service
                  value: mysql
                - tag: tier
                  value: '{#CLOUD_SQL.INSTANCE.TIER}'
                - tag: zone
                  value: '{#CLOUD_SQL.INSTANCE.ZONE}'
              custom_interfaces: 'YES'
              interfaces:
                - default: 'NO'
                  ip: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
                  dns: external.ip
                - ip: '{#CLOUD_SQL.INSTANCE.IP}'
                  dns: internal.ip
          master_item:
            key: gcp.cloudsql.instances.get
          lld_macro_paths:
            - lld_macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
              path: $.db_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
              path: $.ext_ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
              path: $.high_availability
            - lld_macro: '{#CLOUD_SQL.INSTANCE.IP}'
              path: $.ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.NAME}'
              path: $.name
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TIER}'
              path: $.tier
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
              path: $.inst_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
              path: $.zone
            - lld_macro: '{#CLOUD_SQL.MASTER}'
              path: $.master
            - lld_macro: '{#GCP.AUTH.TOKEN}'
              path: $.token
            - lld_macro: '{#GCP.PROJECT.ID}'
              path: $.project_id
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          overrides:
            - name: 'MySQL replica'
              step: '1'
              filter:
                conditions:
                  - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                    value: READ_REPLICA_INSTANCE
                  - macro: '{#CLOUD_SQL.MASTER}'
                    operator: EXISTS
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  tags:
                    - tag: master_instance
                      value: '{#CLOUD_SQL.MASTER}'
                  templates:
                    - name: 'GCP Cloud SQL MySQL Replica by HTTP'
        - uuid: 606ba15087894f268f4b626590b7a9d0
          name: 'GCP Cloud SQL: PostgreSQL instances discovery'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.inst.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                value: 'POSTGRES.*'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.PGSQL.INST.NAME.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.PGSQL.INST.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.PGSQL.INST.TYPE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.PGSQL.TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.PGSQL.ZONE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.PGSQL.ZONE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Cloud SQL: PostgreSQL instances discovery.'
          host_prototypes:
            - uuid: 0fbbc550fda448d39aad6d0710f28b6a
              host: '{#GCP.PROJECT.ID}-{#CLOUD_SQL.INSTANCE.NAME}'
              name: '{#CLOUD_SQL.INSTANCE.NAME}'
              group_links:
                - group:
                    name: Databases
              templates:
                - name: 'GCP Cloud SQL PostgreSQL by HTTP'
              macros:
                - macro: '{$CLOUD_SQL.HIGH.AVAILABILITY}'
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                  description: 'GCP Cloud SQL instance high availability definition.'
                - macro: '{$GCP.AUTH.TOKEN}'
                  value: '{#GCP.AUTH.TOKEN}'
                  description: 'Google Cloud Platform authorization token.'
                - macro: '{$GCP.PROJECT.ID}'
                  value: '{#GCP.PROJECT.ID}'
                  description: 'GCP project id.'
              tags:
                - tag: db-version
                  value: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                - tag: high-availability
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                - tag: instance-type
                  value: '{#CLOUD_SQL.INSTANCE.TYPE}'
                - tag: project
                  value: '{#GCP.PROJECT.ID}'
                - tag: service
                  value: cloudsql
                - tag: service
                  value: gcp
                - tag: service
                  value: pgsql
                - tag: tier
                  value: '{#CLOUD_SQL.INSTANCE.TIER}'
                - tag: zone
                  value: '{#CLOUD_SQL.INSTANCE.ZONE}'
              custom_interfaces: 'YES'
              interfaces:
                - default: 'NO'
                  ip: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
                  dns: external.ip
                - ip: '{#CLOUD_SQL.INSTANCE.IP}'
                  dns: internal.ip
          master_item:
            key: gcp.cloudsql.instances.get
          lld_macro_paths:
            - lld_macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
              path: $.db_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
              path: $.ext_ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
              path: $.high_availability
            - lld_macro: '{#CLOUD_SQL.INSTANCE.IP}'
              path: $.ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.NAME}'
              path: $.name
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TIER}'
              path: $.tier
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
              path: $.inst_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
              path: $.zone
            - lld_macro: '{#CLOUD_SQL.MASTER}'
              path: $.master
            - lld_macro: '{#GCP.AUTH.TOKEN}'
              path: $.token
            - lld_macro: '{#GCP.PROJECT.ID}'
              path: $.project_id
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          overrides:
            - name: 'PostgreSQL replica'
              step: '1'
              filter:
                conditions:
                  - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                    value: READ_REPLICA_INSTANCE
                  - macro: '{#CLOUD_SQL.MASTER}'
                    operator: EXISTS
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  tags:
                    - tag: master_instance
                      value: '{#CLOUD_SQL.MASTER}'
                  templates:
                    - name: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
        - uuid: 7d0226eccc5644c89fff10f7ece1c8b4
          name: 'GCP Compute Engine: Instances discovery'
          type: DEPENDENT
          key: gcp.gce.inst.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GCE.INSTANCE.NAME}'
                value: '{$GCP.GCE.INST.NAME.MATCHES}'
              - macro: '{#GCE.INSTANCE.NAME}'
                value: '{$GCP.GCE.INST.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#GCE.INSTANCE.ZONE}'
                value: '{$GCP.GCE.ZONE.MATCHES}'
              - macro: '{#GCE.INSTANCE.ZONE}'
                value: '{$GCP.GCE.ZONE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Compute Engine: Instances discovery.'
          host_prototypes:
            - uuid: cb22d82a12814afb8ba833c649d575c4
              host: '{#GCE.INSTANCE.ID}'
              name: '{#GCE.INSTANCE.NAME}'
              group_links:
                - group:
                    name: 'Virtual machines'
              templates:
                - name: 'GCP Compute Engine Instance by HTTP'
              macros:
                - macro: '{$GCE.INSTANCE.ZONE}'
                  value: '{#GCE.INSTANCE.ZONE}'
                  description: 'Instance zone (location).'
                - macro: '{$GCE.INTEGRITY.STATE}'
                  value: '{#GCE.INTEGRITY.STATE}'
                  description: 'Instance integrity metrics status.'
                - macro: '{$GCE.MACHINE.TYPE}'
                  value: '{#GCE.MACHINE.TYPE}'
                  description: 'Instance machine type.'
                - macro: '{$GCP.AUTH.TOKEN}'
                  value: '{#GCP.AUTH.TOKEN}'
                  description: 'Google Cloud Platform authorization token.'
                - macro: '{$GCP.PROJECT.ID}'
                  value: '{#GCP.PROJECT.ID}'
                  description: 'GCP project id.'
              tags:
                - tag: instance-type
                  value: '{#GCE.INSTANCE.TYPE}'
                - tag: machine-type
                  value: '{#GCE.MACHINE.TYPE}'
                - tag: project
                  value: '{#GCP.PROJECT.ID}'
                - tag: service
                  value: gce
                - tag: service
                  value: gcp
                - tag: zone
                  value: '{#GCE.INSTANCE.ZONE}'
              custom_interfaces: 'YES'
              interfaces:
                - default: 'NO'
                  ip: '{#GCE.INSTANCE.EXT.IP}'
                  dns: external.ip
                - ip: '{#GCE.INSTANCE.IP}'
                  dns: internal.ip
          master_item:
            key: gcp.gce.instances.get
          lld_macro_paths:
            - lld_macro: '{#GCE.INSTANCE.EXT.IP}'
              path: $.ext_ip
            - lld_macro: '{#GCE.INSTANCE.ID}'
              path: $.id
            - lld_macro: '{#GCE.INSTANCE.IP}'
              path: $.ip
            - lld_macro: '{#GCE.INSTANCE.NAME}'
              path: $.name
            - lld_macro: '{#GCE.INSTANCE.TYPE}'
              path: $.i_type
            - lld_macro: '{#GCE.INSTANCE.ZONE}'
              path: $.zone
            - lld_macro: '{#GCE.INTEGRITY.STATE}'
              path: $.integrity
            - lld_macro: '{#GCE.MACHINE.TYPE}'
              path: $.m_type
            - lld_macro: '{#GCP.AUTH.TOKEN}'
              path: $.token
            - lld_macro: '{#GCP.PROJECT.ID}'
              path: $.project_id
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: 1a0dc88bc40d45af90ca761dcb611bf0
          name: 'GCP Compute Engine: Project quotas discovery'
          type: DEPENDENT
          key: gcp.gce.quotas.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GCE.QUOTA.NAME}'
                value: '{$GCP.GCE.QUOTA.MATCHES}'
              - macro: '{#GCE.QUOTA.NAME}'
                value: '{$GCP.GCE.QUOTA.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Compute Engine: Quotas discovery.'
          item_prototypes:
            - uuid: 1e9a772b9a89497ba695079fc480bd0a
              name: 'Quota [{#GCE.QUOTA.NAME}]: Limit'
              type: DEPENDENT
              key: 'gcp.gce.quota.limit[{#GCE.QUOTA.NAME}]'
              description: 'GCP Compute Engine: The current limit value for [{#GCE.QUOTA.NAME}] quota.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.limit
              master_item:
                key: 'gcp.gce.quota.single.raw[{#GCE.QUOTA.NAME}]'
              tags:
                - tag: component
                  value: quota
                - tag: quota
                  value: '{#GCE.QUOTA.NAME}'
              trigger_prototypes:
                - uuid: ac0d8842f0934dcead56d41f328c10d2
                  expression: 'change(/GCP by HTTP/gcp.gce.quota.limit[{#GCE.QUOTA.NAME}]) <> 0'
                  name: 'GCP: Quota [{#GCE.QUOTA.NAME}] limit has been changed'
                  opdata: 'Current limit: {ITEM.VALUE}'
                  priority: INFO
                  description: 'GCP Compute Engine: The limit for the `{#GCE.QUOTA.NAME}` quota has been changed.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: capacity
            - uuid: 6bb3700f7c5c4c51b6a435f5c7d0e315
              name: 'Quota [{#GCE.QUOTA.NAME}]: Percentage used'
              type: DEPENDENT
              key: 'gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]'
              value_type: FLOAT
              units: '%'
              description: 'GCP Compute Engine: Percentage usage for [{#GCE.QUOTA.NAME}] quota.'
              preprocessing:
                - type: CHECK_NOT_SUPPORTED
                  parameters:
                    - '-1'
                - type: JSONPATH
                  parameters:
                    - $.p_used
              master_item:
                key: 'gcp.gce.quota.single.raw[{#GCE.QUOTA.NAME}]'
              tags:
                - tag: component
                  value: quota
                - tag: quota
                  value: '{#GCE.QUOTA.NAME}'
              trigger_prototypes:
                - uuid: ecce0204198d4edda88f84d4f25ba75c
                  expression: 'last(/GCP by HTTP/gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]) >= {$GCP.GCE.QUOTA.PUSED.MIN.WARN:"{#GCE.QUOTA.NAME}"}'
                  name: 'GCP: Quota [{#GCE.QUOTA.NAME}] usage is close to reaching the limit'
                  opdata: 'Usage: {#GCE.QUOTA.USAGE} | Limit: {#GCE.QUOTA.LIMIT} | Percentage {ITEM.VALUE}%'
                  priority: WARNING
                  description: 'GCP Compute Engine: The usage percentage for the `{#GCE.QUOTA.NAME}` quota is close to reaching the limit.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'GCP: Quota [{#GCE.QUOTA.NAME}] usage is critically close to reaching the limit'
                      expression: 'last(/GCP by HTTP/gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]) >= {$GCP.GCE.QUOTA.PUSED.MIN.CRIT:"{#GCE.QUOTA.NAME}"}'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: bc894d5e4f694e428fcb32babe87c204
                  expression: 'last(/GCP by HTTP/gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]) >= {$GCP.GCE.QUOTA.PUSED.MIN.CRIT:"{#GCE.QUOTA.NAME}"}'
                  name: 'GCP: Quota [{#GCE.QUOTA.NAME}] usage is critically close to reaching the limit'
                  opdata: 'Usage: {#GCE.QUOTA.USAGE} | Limit: {#GCE.QUOTA.LIMIT} | Percentage {ITEM.VALUE}%'
                  priority: AVERAGE
                  description: 'GCP Compute Engine: The usage percentage for the `{#GCE.QUOTA.NAME}` quota is critically close to reaching the limit.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: capacity
                    - tag: scope
                      value: notice
            - uuid: a439501636fd49f0aaf3902300d943b8
              name: 'Quota [{#GCE.QUOTA.NAME}]: Raw data'
              type: DEPENDENT
              key: 'gcp.gce.quota.single.raw[{#GCE.QUOTA.NAME}]'
              history: '0'
              value_type: TEXT
              description: 'GCP Compute Engine: Get metrics for [{#GCE.QUOTA.NAME}] quota.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.metric == "{#GCE.QUOTA.NAME}")].first()'
              master_item:
                key: gcp.gce.quotas.get
              tags:
                - tag: component
                  value: raw
                - tag: quota
                  value: '{#GCE.QUOTA.NAME}'
            - uuid: 936c66cc59a240858f67922dcba2cbec
              name: 'Quota [{#GCE.QUOTA.NAME}]: Usage'
              type: DEPENDENT
              key: 'gcp.gce.quota.usage[{#GCE.QUOTA.NAME}]'
              description: 'GCP Compute Engine: The current usage value for [{#GCE.QUOTA.NAME}] quota.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.usage
              master_item:
                key: 'gcp.gce.quota.single.raw[{#GCE.QUOTA.NAME}]'
              tags:
                - tag: component
                  value: quota
                - tag: quota
                  value: '{#GCE.QUOTA.NAME}'
          graph_prototypes:
            - uuid: 45de6eacbed84c82bfe9175fcf84e0c3
              name: 'GCP Compute Engine: Quota [{#GCE.QUOTA.NAME}]: Usage'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'GCP by HTTP'
                    key: 'gcp.gce.quota.usage[{#GCE.QUOTA.NAME}]'
                - sortorder: '1'
                  drawtype: BOLD_LINE
                  color: F63100
                  calc_fnc: MIN
                  item:
                    host: 'GCP by HTTP'
                    key: 'gcp.gce.quota.limit[{#GCE.QUOTA.NAME}]'
          master_item:
            key: gcp.gce.quotas.get
          lld_macro_paths:
            - lld_macro: '{#GCE.QUOTA.LIMIT}'
              path: $.limit
            - lld_macro: '{#GCE.QUOTA.NAME}'
              path: $.metric
            - lld_macro: '{#GCE.QUOTA.USAGE}'
              path: $.usage
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: automation
        - tag: subclass
          value: computing
        - tag: subclass
          value: containers
        - tag: subclass
          value: deploy
        - tag: subclass
          value: security
        - tag: subclass
          value: virtualization
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
      macros:
        - macro: '{$GCP.AUTH.FREQUENCY}'
          value: 45m
          description: |
            The update interval for the GCP Authorization item, which also equals to the access token regeneration request frequency.
            Check the template documentation notes carefully for more details.
          config:
            type: TEXT
            priority: '5'
            label: 'Token update frequency'
            description: 'Update interval for the GCP Authorization item, which also equals to the access token regeneration request frequency.'
        - macro: '{$GCP.CLIENT.EMAIL}'
          description: 'Service account client e-mail.'
          config:
            type: TEXT
            priority: '2'
            label: 'Client e-mail'
            description: 'Service account client e-mail.'
            required: 'YES'
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'A response timeout for an API.'
          config:
            type: TEXT
            priority: '8'
            section_name: Other
            label: 'Response timeout'
            description: 'A response timeout for an API.'
        - macro: '{$GCP.GCE.INST.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Compute Engine instances by namespace.'
          config:
            type: TEXT
            priority: '10'
            section_name: Filters
            label: 'Include GCP Compute Engine namespace filter'
            description: 'Filter to include GCP Compute Engine instances by namespace.'
        - macro: '{$GCP.GCE.INST.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Compute Engine instances by namespace.'
          config:
            type: TEXT
            priority: '11'
            section_name: Filters
            label: 'Exclude GCP Compute Engine namespace filter'
            description: 'Filter to exclude GCP Compute Engine instances by namespace.'
        - macro: '{$GCP.GCE.QUOTA.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Compute Engine project quotas by namespace.'
          config:
            type: TEXT
            priority: '32'
            section_name: Filters
            label: 'Include GCP Compute Engine project quotas by namespace filter'
            description: 'Filter to include GCP Compute Engine project quotas by namespace.'
        - macro: '{$GCP.GCE.QUOTA.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Compute Engine project quotas by namespace.'
          config:
            type: TEXT
            priority: '33'
            section_name: Filters
            label: 'Exclude GCP Compute Engine project quotas by namespace filter'
            description: 'Filter to exclude GCP Compute Engine project quotas by namespace.'
        - macro: '{$GCP.GCE.QUOTA.PUSED.MIN.CRIT}'
          value: '95'
          description: 'GCP Compute Engine project quota critical quota utilization threshold.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'GCP Compute Engine critical utilization threshold'
            description: 'GCP Compute Engine project quota critical quota utilization threshold. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$GCP.GCE.QUOTA.PUSED.MIN.WARN}'
          value: '80'
          description: 'GCP Compute Engine project quota warning utilization threshold.'
          config:
            type: TEXT
            priority: '6'
            section_name: Thresholds
            label: 'GCP Compute Engine warning utilization threshold'
            description: 'GCP Compute Engine project quota warning utilization threshold. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$GCP.GCE.ZONE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Compute Engine instances by zone.'
          config:
            type: TEXT
            priority: '12'
            section_name: Filters
            label: 'Include GCP Compute Engine zone filter'
            description: 'Filter to include GCP Compute Engine instances by zone.'
        - macro: '{$GCP.GCE.ZONE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Compute Engine instances by zone.'
          config:
            type: TEXT
            priority: '13'
            section_name: Filters
            label: 'Exclude GCP Compute Engine zone filter'
            description: 'Filter to exclude GCP Compute Engine instances by zone.'
        - macro: '{$GCP.MSSQL.INST.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL instances by namespace.'
          config:
            type: TEXT
            priority: '26'
            section_name: Filters
            label: 'Include GCP Cloud SQL MSSQL namespace filter'
            description: 'Filter to include GCP Cloud SQL MSSQL instances by namespace.'
        - macro: '{$GCP.MSSQL.INST.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MSSQL instances by namespace.'
          config:
            type: TEXT
            priority: '27'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MSSQL namespace filter'
            description: 'Filter to exclude GCP Cloud SQL MSSQL instances by namespace.'
        - macro: '{$GCP.MSSQL.INST.TYPE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL instances by type (standalone/replica).'
          config:
            type: TEXT
            priority: '30'
            section_name: Filters
            label: 'Include GCP Cloud SQL MSSQL instances by type filter'
            description: 'Filter to include GCP Cloud SQL MSSQL instances by type (standalone/replica).'
        - macro: '{$GCP.MSSQL.INST.TYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: |
            The filter to exclude GCP Cloud SQL MSSQL instances by type (standalone/replica).
            Set a macro value 'CLOUD_SQL_INSTANCE' to exclude standalone Instances or 'READ_REPLICA_INSTANCE' to exclude read-only Replicas.
          config:
            type: TEXT
            priority: '31'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MSSQL instances by type filter'
            description: 'Filter to exclude GCP Cloud SQL MSSQL instances by type (standalone/replica).'
        - macro: '{$GCP.MSSQL.ZONE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL instances by zone.'
          config:
            type: TEXT
            priority: '28'
            section_name: Filters
            label: 'Include GCP Cloud SQL MSSQL zone filter'
            description: 'Filter to include GCP Cloud SQL MSSQL instances by zone.'
        - macro: '{$GCP.MSSQL.ZONE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MSSQL instances by zone.'
          config:
            type: TEXT
            priority: '29'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MSSQL zone filter'
            description: 'Filter to exclude GCP Cloud SQL MSSQL instances by zone.'
        - macro: '{$GCP.MYSQL.INST.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MySQL instances by namespace.'
          config:
            type: TEXT
            priority: '14'
            section_name: Filters
            label: 'Include GCP Cloud SQL MySQL namespace filter'
            description: 'Filter to include GCP Cloud SQL MySQL instances by namespace.'
        - macro: '{$GCP.MYSQL.INST.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MySQL instances by namespace.'
          config:
            type: TEXT
            priority: '15'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MySQL namespace filter'
            description: 'Filter to exclude GCP Cloud SQL MySQL instances by namespace.'
        - macro: '{$GCP.MYSQL.INST.TYPE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MySQL instances by type (standalone/replica).'
          config:
            type: TEXT
            priority: '18'
            section_name: Filters
            label: 'Include GCP Cloud SQL MySQL instances by type filter'
            description: 'Filter to include GCP Cloud SQL MySQL instances by type (standalone/replica).'
        - macro: '{$GCP.MYSQL.INST.TYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: |
            The filter to exclude GCP Cloud SQL MySQL instances by type (standalone/replica).
            Set a macro value 'CLOUD_SQL_INSTANCE' to exclude standalone Instances or 'READ_REPLICA_INSTANCE' to exclude read-only Replicas.
          config:
            type: TEXT
            priority: '19'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MySQL instances by type filter'
            description: 'Filter to exclude GCP Cloud SQL MySQL instances by type (standalone/replica).'
        - macro: '{$GCP.MYSQL.ZONE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MySQL instances by zone.'
          config:
            type: TEXT
            priority: '16'
            section_name: Filters
            label: 'Include GCP Cloud SQL MySQL zone filter'
            description: 'Filter to include GCP Cloud SQL MySQL instances by zone.'
        - macro: '{$GCP.MYSQL.ZONE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MySQL instances by zone.'
          config:
            type: TEXT
            priority: '17'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MySQL zone filter'
            description: 'Filter to exclude GCP Cloud SQL MySQL instances by zone.'
        - macro: '{$GCP.PGSQL.INST.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL PostgreSQL instances by namespace.'
          config:
            type: TEXT
            priority: '20'
            section_name: Filters
            label: 'Include GCP Cloud SQL PostgreSQL namespace filter'
            description: 'Filter to include GCP Cloud SQL PostgreSQL instances by namespace.'
        - macro: '{$GCP.PGSQL.INST.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL PostgreSQL instances by namespace.'
          config:
            type: TEXT
            priority: '21'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL PostgreSQL namespace filter'
            description: 'Filter to exclude GCP Cloud SQL PostgreSQL instances by namespace.'
        - macro: '{$GCP.PGSQL.INST.TYPE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL PostgreSQL instances by type (standalone/replica).'
          config:
            type: TEXT
            priority: '24'
            section_name: Filters
            label: 'Include GCP Cloud SQL PostgreSQL instances by type filter'
            description: 'Filter to include GCP Cloud SQL PostgreSQL instances by type (standalone/replica).'
        - macro: '{$GCP.PGSQL.INST.TYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: |
            The filter to exclude GCP Cloud SQL PostgreSQL instances by type (standalone/replica).
            Set a macro value 'CLOUD_SQL_INSTANCE' to exclude standalone Instances or 'READ_REPLICA_INSTANCE' to exclude read-only Replicas.
          config:
            type: TEXT
            priority: '25'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL PostgreSQL instances by type filter'
            description: 'Filter to exclude GCP Cloud SQL PostgreSQL instances by type (standalone/replica).'
        - macro: '{$GCP.PGSQL.ZONE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL PostgreSQL instances by zone.'
          config:
            type: TEXT
            priority: '22'
            section_name: Filters
            label: 'Include GCP Cloud SQL PostgreSQL zone filter'
            description: 'Filter to include GCP Cloud SQL PostgreSQL instances by zone.'
        - macro: '{$GCP.PGSQL.ZONE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL PostgreSQL instances by zone.'
          config:
            type: TEXT
            priority: '23'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL PostgreSQL zone filter'
            description: 'Filter to exclude GCP Cloud SQL PostgreSQL instances by zone.'
        - macro: '{$GCP.PRIVATE.KEY}'
          type: SECRET_TEXT
          description: 'Service account private key data.'
          config:
            type: TEXT
            priority: '4'
            label: 'Private key data'
            description: 'Service account private key data.'
            required: 'YES'
        - macro: '{$GCP.PRIVATE.KEY.ID}'
          type: SECRET_TEXT
          description: 'Service account private key id.'
          config:
            type: TEXT
            priority: '3'
            label: 'Private key id'
            description: 'Service account private key id.'
            required: 'YES'
        - macro: '{$GCP.PROJECT.ID}'
          description: 'GCP project ID.'
          config:
            type: TEXT
            priority: '1'
            label: 'GCP project ID'
            description: 'Google Cloud Platform project ID.'
            required: 'YES'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty then no proxy is used.'
          config:
            type: TEXT
            priority: '9'
            section_name: Other
            label: 'HTTP proxy'
            description: 'HTTP proxy to use for requests.'
      dashboards:
        - uuid: 71df4601171e471ea74a291242028394
          name: 'Project resources'
          pages:
            - name: 'Project resources'
              widgets:
                - type: item
                  name: 'GCE instances total'
                  width: '24'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.gce.instances.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: item
                  name: 'Cloud SQL total'
                  'y': '5'
                  width: '18'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.cloudsql.instances.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: graphprototype
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'GCP by HTTP'
                        name: 'GCP Compute Engine: Quota [{#GCE.QUOTA.NAME}]: Usage'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: item
                  name: 'Cloud SQL MySQL'
                  x: '18'
                  'y': '5'
                  width: '18'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.cloudsql.instances.mysql_count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: item
                  name: 'GCE regular instances'
                  x: '24'
                  width: '24'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.gce.instances.regular_count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: item
                  name: 'Cloud SQL PostgreSQL'
                  x: '36'
                  'y': '5'
                  width: '18'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.cloudsql.instances.pgsql_count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: graphprototype
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: ITEM_PROTOTYPE
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: 'gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]'
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '3'
                - type: item
                  name: 'GCE COS instances'
                  x: '48'
                  width: '24'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.gce.instances.cos_count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: item
                  name: 'Cloud SQL MSSQL'
                  x: '54'
                  'y': '5'
                  width: '18'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.cloudsql.instances.mssql_count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
    - uuid: 507d70db18554a4e9ee5e09bb29bc85f
      template: 'GCP Cloud SQL MSSQL by HTTP'
      name: 'GCP Cloud SQL MSSQL by HTTP'
      description: |
        Get GCP Cloud SQL MSSQL instances monitoring with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: a8d79cab89864c03a7614bd59f734942
          name: 'Audits size'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.audits_size
          units: B
          description: |
            Tracks the size in bytes of stored SQLServer audit files on an instance.
            Empty value if there are no audits enabled.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_audits_size
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: security
        - uuid: 3026bc61670c496a942a94ab50b614df
          name: 'Audits successfully uploaded'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.audits_upload_count
          description: |
            Tracks the size in bytes of stored SQLServer audit files on an instance.
            Empty value if there are no audits enabled.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_success
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: security
        - uuid: d512c542f5514681acbb11431a0a6f5a
          name: 'Connection resets'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.conn.connection_reset_count
          description: 'Total number of login operations started from the connection pool since the last restart of SQL Server service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_connection_reset_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 300a6cb53fb44176bdf99eba86a976bd
          name: 'Login attempts'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.conn.login_attempt_count
          description: |
            Total number of login attempts since the last restart of SQL Server service.
            This does not include pooled connections.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_login_attempt_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 622c237ed12e44c7b2415676ec23bd2d
          name: Logouts
          type: DEPENDENT
          key: gcp.cloudsql.mssql.conn.logout_count
          description: 'Total number of logout operations since the last restart of SQL Server service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_logout_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 6ba672cbf4c242eb8e6fb80eba4c90d8
          name: 'Processes blocked'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.conn.processes_blocked
          description: 'Current number of blocked processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_processes_blocked
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 38de8ae591854d5fbc4ee4946a2e189a
          name: 'Reserved CPU cores'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.cpu.reserved_cores
          value_type: FLOAT
          description: 'Number of cores reserved for the database.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_reserved_cores
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: cd1f9ab326ac4694b3aeea6cb4ec56ab
          name: 'CPU usage time'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.cpu.usage_time
          value_type: FLOAT
          units: s
          description: 'Cumulative CPU usage time in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage_time
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: 42d51e38b96f472996eff1e0f9d7b931
          name: 'CPU utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: 'Current CPU utilization represented as a percentage of the reserved CPU that is currently in use.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: b8280e45fea8470e9f36f7f08e4a77e1
              expression: 'min(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.cpu.utilization,5m) >= {$CLOUD_SQL.MSSQL.CPU.UTIL.MAX}'
              name: 'GCP MSSQL: High CPU utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: ecdd1774ef744bcb93e8e4094e29772f
          name: 'Databases get'
          type: SCRIPT
          key: gcp.cloudsql.mssql.db.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/sqlserver/transactions/',
            	arr = [],
            	base_paths = [
            		'log_bytes_flushed_count',
            		'transaction_count'
            	];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	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 database_id = '" + params.database_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');
            
            for (t in time_series) {
            	data = {
            		database: getField(time_series[t], 'labelValues.3.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: 'MSSQL databases data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 9806c645a10a4e1d8fbb39eb1d3ac993
          name: 'DB engine state'
          type: HTTP_AGENT
          key: gcp.cloudsql.mssql.db.state
          description: 'GCP Cloud SQL MSSQL DB Engine State.'
          valuemap:
            name: 'Database availability'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].int64Value'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/up | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: b3c7b8e2e38a42fe9d2ae3c84b637e53
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.db.state)=0'
              name: 'GCP MSSQL: Database engine is down'
              priority: AVERAGE
              description: |
                Database engine is down.
                If an instance experiences unplanned (non-maintenance) downtime, the instance state will still be RUNNING, but the database engine state metric will report 0.
              dependencies:
                - name: 'GCP MSSQL: Failed to get the instance state'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 10'
                - name: 'GCP MSSQL: Instance is in failed state'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 5'
                - name: 'GCP MSSQL: Instance is in maintenance'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 4'
                - name: 'GCP MSSQL: Instance is in suspended state'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 1'
                - name: 'GCP MSSQL: Instance is in unknown state'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 6'
                - name: 'GCP MSSQL: Instance is stopped by the owner'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 2'
              tags:
                - tag: scope
                  value: availability
        - uuid: cd6cf3870a514ff59bd1f40987764642
          name: 'Disk bytes used'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.disk.bytes_used
          units: B
          description: 'Data utilization in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_bytes_used
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 86bdbf20c9b4466c9ea00e26cb0f0652
          name: 'Disk size'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.disk.quota
          units: B
          description: 'Maximum data disk size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_quota
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 400a7318203f40928ebf0b023da65848
          name: 'Disk read I/O'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.disk.read_ops_count
          description: 'Delta count of data disk read I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_read_ops_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 1d0c09441d9d4333b7be32c3d69bad47
          name: 'Disk utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.disk.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the disk quota that is currently in use. 
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 2cbc7e3008f24197963df4ea920ab5a8
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.disk.utilization) >= {$CLOUD_SQL.MSSQL.DISK.UTIL.CRIT}'
              name: 'GCP MSSQL: Disk space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'Critical utilization of the disk space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 2569abbb94ca4df38cdd4f9d5a5df9fc
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.disk.utilization) >= {$CLOUD_SQL.MSSQL.DISK.UTIL.WARN}'
              name: 'GCP MSSQL: Disk space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              dependencies:
                - name: 'GCP MSSQL: Disk space is critically low'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.disk.utilization) >= {$CLOUD_SQL.MSSQL.DISK.UTIL.CRIT}'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 819078cd99af46368eb33d76dadf4861
          name: 'Disk write I/O'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.disk.write_ops_count
          description: 'Delta count of data disk write I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_write_ops_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 556c96cf1bf342f99c69dc47813f221e
          name: 'Instance state'
          type: HTTP_AGENT
          key: gcp.cloudsql.mssql.inst.state
          description: 'GCP Cloud SQL MSSQL Current instance state.'
          valuemap:
            name: 'Instance state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].stringValue'
              error_handler: CUSTOM_VALUE
              error_handler_params: '10'
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'RUNNING',
                  	'SUSPENDED',
                  	'RUNNABLE',
                  	'PENDING_CREATE',
                  	'MAINTENANCE',
                  	'FAILED',
                  	'UNKNOWN_STATE'
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/state | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: dff9067ad7de4ab1a4f83c9d482e6b71
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 10'
              name: 'GCP MSSQL: Failed to get the instance state'
              priority: AVERAGE
              description: |
                Failed to get the instance state. 
                Check access permissions to GCP API or service account.
              tags:
                - tag: scope
                  value: availability
            - uuid: 3d7e054340e94b09b085e508b9b76841
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 5'
              name: 'GCP MSSQL: Instance is in failed state'
              priority: AVERAGE
              description: 'The instance creation failed, or an operation left the instance in an own bad state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: dd395fd3003f4fce847cd72309cdf7ec
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 4'
              name: 'GCP MSSQL: Instance is in maintenance'
              priority: INFO
              description: 'The instance is down for maintenance.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 3c080bba511e44aab1139b66f00451ee
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 1'
              name: 'GCP MSSQL: Instance is in suspended state'
              priority: WARNING
              description: |
                The instance is in suspended state. 
                It is not available, for example, due to problems with billing.
              tags:
                - tag: scope
                  value: availability
            - uuid: 378b4d62582d416db7cb7fd6ed099ac9
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 6'
              name: 'GCP MSSQL: Instance is in unknown state'
              priority: AVERAGE
              description: 'The state of the instance is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 72ecba08f6424573a36b816da9695b89
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 2'
              name: 'GCP MSSQL: Instance is stopped by the owner'
              priority: INFO
              description: |
                The instance has been stopped by the owner. 
                It is not currently running, but it's ready to be restarted.
              tags:
                - tag: scope
                  value: availability
        - uuid: a29584de7ab142309f0bb6f57b52af85
          name: 'Buffer cache hit ratio'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.buffer_cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: |
            Current percentage of pages found in the buffer cache without having to read from disk.
            The ratio is the total number of cache hits divided by the total number of cache lookups.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_buffer_cache_hit_ratio
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: f8460bbac21c44a98a31a49daf7f692f
          name: 'Checkpoint pages'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.checkpoint_page_count
          description: 'Total number of pages flushed to disk by a checkpoint or other operation that requires all dirty pages to be flushed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_checkpoint_page_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: cc6a5230c7a2447e8038cdbe52105da4
          name: 'Free list stalls'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.free_list_stall_count
          description: 'Total number of requests that had to wait for a free page.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_free_list_stall_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: d86e328fc5fa4c3d938a4959075299b5
          name: 'Lazy writes'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.lazy_write_count
          description: |
            Total number of buffers written by the buffer manager's lazy writer.
            The lazy writer is a system process that flushes out batches of dirty, aged buffers
            (buffers that contain changes that must be written back to disk before the buffer can be reused for a different page)
            and makes them available to user processes.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_lazy_write_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 2fa0744221884109951ce62d3bb9aaaf
          name: 'Memory grants pending'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.memory_grants_pending
          description: 'Current number of processes waiting for a workspace memory grant.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_memory_grants_pending
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 3dcad151d0c04f8eb0e8e81c00de23c8
          name: 'Page life expectancy'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.page_life_expectancy
          units: s
          description: 'Current number of seconds a page will stay in the buffer pool without references.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_page_life_expectancy
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 4d87a50d490348afbaf751857beb5b61
          name: 'Read page operations'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.page_ops.read
          description: |
            Total number of physical database page reads.
            This metric counts physical page reads across all databases.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_read
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 41654bd730b744acbc0ea6de07c992f3
          name: 'Write age operations'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.page_ops.write
          description: |
            Total number of physical database page writes.
            This metric counts physical page writes across all databases.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_write
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: db943300803847718c52d0d33988d81e
          name: 'Memory size'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.quota
          units: B
          description: 'Maximum RAM size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_quota
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 21b075a5f95d4c93888b7a0766fdcea5
          name: 'Memory used by DB engine'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.total_usage
          units: B
          description: |
            Total RAM usage in bytes. 
            This metric reports the RAM usage of the database process, including the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_total_usage
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 05d1ff573371416dad9ee028247b1cf3
          name: 'Memory usage'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.usage
          units: B
          description: |
            The RAM usage in bytes. 
            This metric reports the RAM usage of the server, excluding the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 4e11944fb7624ffdb02b5d1bb5bedf7a
          name: 'Memory utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the memory quota that is currently in use.
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_ram_pused
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: c5003533f3524b8b868a0c2f86b1fa9b
              expression: 'min(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.memory.utilization,5m) >= {$CLOUD_SQL.MSSQL.RAM.UTIL.MAX}'
              name: 'GCP MSSQL: High memory utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: HIGH
              description: 'RAM utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 6de08b07cecc47a88bde22de5d1b4e5a
          name: 'Metrics get'
          type: SCRIPT
          key: gcp.cloudsql.mssql.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/',
            	mssql_path = 'cloudsql.googleapis.com/database/sqlserver/',
            	obj = {},
            	base_paths = [
            		'cpu/reserved_cores',
            		'cpu/usage_time',
            		'cpu/utilization',
            		'disk/read_ops_count',
            		'disk/write_ops_count',
            		'memory/quota',
            		'memory/total_usage',
            		'memory/usage',
            		'network/connections',
            		'network/received_bytes_count',
            		'network/sent_bytes_count | map ignore [destination]'
            	].map(function (path) { return base_path + path; }),
            	mssql_paths = [
            		'connections/connection_reset_count',
            		'connections/login_attempt_count',
            		'connections/logout_count',
            		'connections/processes_blocked',
            		'memory/buffer_cache_hit_ratio',
            		'memory/checkpoint_page_count',
            		'memory/lazy_write_count',
            		'memory/memory_grants_pending',
            		'memory/page_life_expectancy',
            		'memory/free_list_stall_count',
            		'transactions/batch_request_count',
            		'transactions/forwarded_record_count',
            		'transactions/full_scan_count',
            		'transactions/page_split_count',
            		'transactions/probe_scan_count',
            		'transactions/sql_compilation_count',
            		'transactions/sql_recompilation_count'
            	].map(function (path) { return mssql_path + path; }).concat(
            		['disk/bytes_used', 'disk/utilization', 'disk/quota'].map(function (path) { return base_path + path; })),
            	value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function 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 checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token', 'audited'].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.';
            	}
            	if (params.audited !== 'true' && params.audited !== 'false') {
            		throw 'Incorrect audit definition type. Valid definitions: true/false';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            function rawMap(raw, prefix) {
            	var keys = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            		values = getField(raw, 'timeSeriesData.0.pointData.0.values'),
            		re = /(^t_\d+\.value\.)/g;
            
            	for (i in keys) {
            		var key = getField(keys[i], 'key').replace(re, '');
            
            		for (v in value_types) {
            			if (typeof values[i][value_types[v]] !== 'undefined') {
            				if (prefix) {
            					obj[prefix + key] = values[i][value_types[v]];
            				}
            				else {
            					obj[key] = values[i][value_types[v]];
            				}
            
            			}
            		}
            	}
            	return obj;
            }
            
            function singleMetrics(tsd) {
            	var result = {};
            
            	for (t in tsd) {
            		for (v in value_types) {
            			if (getFieldBool(tsd[t], 'pointData.0.values.0.' + [value_types[v]])) {
            				result['mssql_' + getField(tsd[t], 'labelValues.3.stringValue').toLowerCase()] = tsd[t].pointData[0].values[0][value_types[v]];
            				break;
            			}
            		}
            	}
            	return result;
            }
            
            var params = checkParams(JSON.parse(value));
            
            if (params.audited === 'true') {
            	base_paths.push(mssql_path + 'audits_size');
            };
            
            var filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	queries = [
            		{ name: 'base_', data: { query: '{' + base_paths.join(';') + '}' + j_filter } },
            		{ name: 'mssql_', data: { query: '{' + mssql_paths.join(';') + '}' + j_filter } }
            	];
            
            for (q in queries) {
            	raw = getHttpData(url, params.token, queries[q].data);
            	obj = Object.assign(obj, rawMap(raw, queries[q].name));
            }
            
            obj.base_ram_pused = Math.floor(getField(obj, 'base_usage') / getField(obj, 'base_quota') * 100);
            
            var single_queries = [
            	{ query: mssql_path + 'memory/page_operation_count' + filter }
            ];
            
            if (params.audited === 'true') {
            	single_queries.push({ query: mssql_path + 'audits_upload_count' + filter });
            }
            
            for (q in single_queries) {
            	raw = getHttpData(url, params.token, single_queries[q]);
            	Object.assign(obj, singleMetrics(getField(raw, 'timeSeriesData')));
            }
            
            return JSON.stringify(obj);
          description: 'MSSQL metrics data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: audited
              value: '{$CLOUD_SQL.MSSQL.AUDITED}'
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 393b6117008d4925be9474afc9c7cdf9
          name: Connections
          type: DEPENDENT
          key: gcp.cloudsql.mssql.network.connections
          description: 'Number of connections to the databases on the Cloud SQL instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_connections
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 297744bfcdd84565b828e1c6912beb46
          name: 'Network: Received bytes'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.network.received_bytes_count
          units: B
          description: 'Delta count of bytes received through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_received_bytes_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: b362d14169b34f00ab3fa94b89a1b362
          name: 'Network: Sent bytes'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.network.sent_bytes_count
          units: B
          description: 'Delta count of bytes sent through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_sent_bytes_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 7ee117702e1f40faadd901faa9d333ff
          name: 'Resources get'
          type: SCRIPT
          key: gcp.cloudsql.mssql.resources.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/sqlserver/transactions/',
            	arr = [],
            	base_paths = [
            		'deadlock_count',
            		'lock_wait_count',
            		'lock_wait_time'
            	];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	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 database_id = '" + params.database_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');
            
            for (t in time_series) {
            	data = {
            		resource: getField(time_series[t], 'labelValues.3.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: 'MSSQL resources data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 3c14882329b94b8e88ca5d85e21bb7c8
          name: 'Schedulers get'
          type: SCRIPT
          key: gcp.cloudsql.mssql.schedulers.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/sqlserver/schedulers/',
            	arr = [],
            	base_paths = ['active_workers', 'current_tasks', 'current_workers', 'pending_disk_io', 'runnable_tasks', 'work_queue'];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	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 database_id = '" + params.database_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');
            
            for (t in time_series) {
            	data = {
            		scheduler: getField(time_series[t], 'labelValues.3.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: 'MSSQL schedulers data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 7d2c28a537e44ee284e4b5d186b935d6
          name: 'Batch requests'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.batch_request_count
          description: 'Total number of Transact-SQL command batches received.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_batch_request_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 774cffa1a1f24d778f346bea24926690
          name: 'Forwarded records'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.forwarded_record_count
          description: 'Total number of records fetched through forwarded record pointers.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_forwarded_record_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: f80a924d20c4470496202d3e32261e7d
          name: 'Full scans'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.full_scan_count
          description: |
            Total number of unrestricted full scans.
            These can be either base-table or full-index scans.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_full_scan_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: cd6f91964b7041bb929c6f6f3430cc75
          name: 'Page splits'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.page_split_count
          description: 'Total number of page splits that occur as the result of overflowing index pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_page_split_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 0b431016ca8245dea8e33c252a9a7c9b
          name: 'Probe scans'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.probe_scan_count
          description: 'Total number of probe scans that are used to find at least one single qualified row in an index or base table directly.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_probe_scan_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: bf4eb81de038452cb3af16b4efcdb4c5
          name: 'SQL compilations'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.sql_compilation_count
          description: 'Total number of SQL compilations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_sql_compilation_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 39c350f5d1f94726b03c435e9e5e3110
          name: 'SQL recompilations'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.sql_recompilation_count
          description: 'Total number of SQL recompilations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_sql_recompilation_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
      discovery_rules:
        - uuid: 2dad3e63931942f8937b8720c9477a66
          name: 'Databases discovery'
          type: DEPENDENT
          key: gcp.cloudsql.db.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DB.NAME}'
                value: '{$CLOUD_SQL.MSSQL.DB.NAME.MATCHES}'
              - macro: '{#DB.NAME}'
                value: '{$CLOUD_SQL.MSSQL.DB.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Databases discovery.'
          item_prototypes:
            - uuid: 8f6deafa9efd416797ea58d1fce41c29
              name: 'Database [{#DB.NAME}]: Log bytes flushed'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.db.log_bytes_flushed_count[{#DB.NAME}]'
              units: B
              description: 'Total number of log bytes flushed for the [{#DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.log_bytes_flushed_count
              master_item:
                key: 'gcp.cloudsql.mssql.db.raw[{#DB.NAME}]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DB.NAME}'
            - uuid: b52f757bc2b341e891f60e15795088ca
              name: 'Database [{#DB.NAME}]: Raw data'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.db.raw[{#DB.NAME}]'
              history: '0'
              value_type: TEXT
              description: 'Data in raw format for the [{#DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#DB.NAME}")].metrics.first()'
              master_item:
                key: gcp.cloudsql.mssql.db.get
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DB.NAME}'
            - uuid: 9f8d37a25e1041c087bbea8d670cce46
              name: 'Database [{#DB.NAME}]: Transactions started'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.db.transaction_count[{#DB.NAME}]'
              description: 'Total number of transactions started for the [{#DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.transaction_count
              master_item:
                key: 'gcp.cloudsql.mssql.db.raw[{#DB.NAME}]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DB.NAME}'
          master_item:
            key: gcp.cloudsql.mssql.db.get
          lld_macro_paths:
            - lld_macro: '{#DB.NAME}'
              path: $.database
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: d47a9164fdf54309ab96f48f6dc3c037
          name: 'Resources discovery'
          type: DEPENDENT
          key: gcp.cloudsql.resources.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#RESOURCE.NAME}'
                value: '{$CLOUD_SQL.MSSQL.RES.NAME.MATCHES}'
              - macro: '{#RESOURCE.NAME}'
                value: '{$CLOUD_SQL.MSSQL.RES.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Resources discovery.'
          item_prototypes:
            - uuid: 55bb12000dca46e096045da83a46edea
              name: 'Resource [{#RESOURCE.NAME}]: Deadlocks'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.resource.deadlock_count[{#RESOURCE.NAME}]'
              description: 'Total number of lock requests that resulted in a deadlock for the [{#RESOURCE.NAME}] resource.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.deadlock_count
              master_item:
                key: 'gcp.cloudsql.mssql.resource.raw[{#RESOURCE.NAME}]'
              tags:
                - tag: component
                  value: resource
                - tag: resource
                  value: '{#RESOURCE.NAME}'
            - uuid: 0117dba440f34461959490efaff059e2
              name: 'Resource [{#RESOURCE.NAME}]: Lock waits'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.resource.lock_wait_count[{#RESOURCE.NAME}]'
              description: 'Total number of lock requests that required the caller to wait for the [{#RESOURCE.NAME}] resource.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.lock_wait_count
              master_item:
                key: 'gcp.cloudsql.mssql.resource.raw[{#RESOURCE.NAME}]'
              tags:
                - tag: component
                  value: resource
                - tag: resource
                  value: '{#RESOURCE.NAME}'
            - uuid: 6e8b5646d70b470fa18960c7b43a9aff
              name: 'Resource [{#RESOURCE.NAME}]: Lock wait time'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.resource.lock_wait_time[{#RESOURCE.NAME}]'
              units: s
              description: 'Total time lock requests were waiting for locks for the [{#RESOURCE.NAME}] resource.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.lock_wait_time
              master_item:
                key: 'gcp.cloudsql.mssql.resource.raw[{#RESOURCE.NAME}]'
              tags:
                - tag: component
                  value: resource
                - tag: resource
                  value: '{#RESOURCE.NAME}'
            - uuid: 0cc16595d1e044db947084a44786aaaa
              name: 'Resource [{#RESOURCE.NAME}]: Raw data'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.resource.raw[{#RESOURCE.NAME}]'
              history: '0'
              value_type: TEXT
              description: 'Data in raw format for the [{#RESOURCE.NAME}] resource.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.resource == "{#RESOURCE.NAME}")].metrics.first()'
              master_item:
                key: gcp.cloudsql.mssql.resources.get
              tags:
                - tag: component
                  value: raw
                - tag: resource
                  value: '{#RESOURCE.NAME}'
          master_item:
            key: gcp.cloudsql.mssql.resources.get
          lld_macro_paths:
            - lld_macro: '{#RESOURCE.NAME}'
              path: $.resource
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: 31667d0e9c32458d9c895367b3ca7042
          name: 'Schedulers discovery'
          type: DEPENDENT
          key: gcp.cloudsql.schedulers.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#SCHEDULER.ID}'
                value: '{$CLOUD_SQL.MSSQL.SCHEDULER.ID.MATCHES}'
              - macro: '{#SCHEDULER.ID}'
                value: '{$CLOUD_SQL.MSSQL.SCHEDULER.ID.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Schedulers discovery.'
          item_prototypes:
            - uuid: 67bde61c128e4dfe9e47d8a3a6e3ceec
              name: 'Scheduler [{#SCHEDULER.ID}]: Active workers'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.active_workers[{#SCHEDULER.ID}]'
              description: |
                Current number of active workers associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].
                An active worker is never preemptive, must have an associated task, and is either running, runnable, or suspended.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.active_workers
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: fc5113b2b5f64205ad9d100bd480adea
              name: 'Scheduler [{#SCHEDULER.ID}]: Current tasks'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.current_tasks[{#SCHEDULER.ID}]'
              description: |
                Current number of present tasks associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].
                This count includes tasks that are waiting for a worker to execute them and tasks that are currently waiting or running (in SUSPENDED or RUNNABLE state).
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.current_tasks
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: 6602f8d26a9a46fb8ed74a40d10f36e4
              name: 'Scheduler [{#SCHEDULER.ID}]: Current workers'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.current_workers[{#SCHEDULER.ID}]'
              description: |
                Current number of workers associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].
                It includes workers that are not assigned any task.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.current_workers
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: 2022a85bb7c04e73a75136e55162084a
              name: 'Scheduler [{#SCHEDULER.ID}]: Pending I/O operations'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.pending_disk_io[{#SCHEDULER.ID}]'
              description: |
                Current number of pending I/Os waiting to be completed that are associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].
                Each scheduler has a list of pending I/Os that are checked to determine whether they have been completed every time there is a context switch.
                The count is incremented when the request is inserted.
                This count is decremented when the request is completed.
                This number does not indicate the state of the I/Os.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.pending_disk_io
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: c3e337845c344f4cb0d14a5e7d22cbb7
              name: 'Scheduler [{#SCHEDULER.ID}]: Raw data'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              history: '0'
              value_type: TEXT
              description: 'Data in raw format associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.scheduler == "{#SCHEDULER.ID}")].metrics.first()'
              master_item:
                key: gcp.cloudsql.mssql.schedulers.get
              tags:
                - tag: component
                  value: raw
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: a9852ac0cdcc423fad6b305eb57eedf1
              name: 'Scheduler [{#SCHEDULER.ID}]: Runnable tasks'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.runnable_tasks[{#SCHEDULER.ID}]'
              description: 'Current number of workers that are associated with the scheduler that goes by its ID [{#SCHEDULER.ID}] and have assigned tasks waiting to be scheduled on the runnable queue.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.runnable_tasks
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: eaae59fb97124471b1c7c30c601dba1f
              name: 'Scheduler [{#SCHEDULER.ID}]: Work queue'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.work_queue[{#SCHEDULER.ID}]'
              description: |
                Current number of tasks in the pending queue associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].
                These tasks are waiting for a worker to pick them up.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.work_queue
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
          master_item:
            key: gcp.cloudsql.mssql.schedulers.get
          lld_macro_paths:
            - lld_macro: '{#SCHEDULER.ID}'
              path: $.scheduler
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: mssql
      macros:
        - macro: '{$CLOUD_SQL.MSSQL.CPU.UTIL.MAX}'
          value: '95'
          description: 'GCP Cloud SQL MSSQL instance CPU usage threshold.'
        - macro: '{$CLOUD_SQL.MSSQL.DB.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL databases by namespace.'
        - macro: '{$CLOUD_SQL.MSSQL.DB.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MSSQL databases by namespace.'
        - macro: '{$CLOUD_SQL.MSSQL.DISK.UTIL.CRIT}'
          value: '90'
          description: 'GCP Cloud SQL MSSQL instance critical disk usage threshold.'
        - macro: '{$CLOUD_SQL.MSSQL.DISK.UTIL.WARN}'
          value: '80'
          description: 'GCP Cloud SQL MSSQL instance warning disk usage threshold.'
        - macro: '{$CLOUD_SQL.MSSQL.RAM.UTIL.MAX}'
          value: '90'
          description: 'GCP Cloud SQL MSSQL instance RAM usage threshold.'
        - macro: '{$CLOUD_SQL.MSSQL.RES.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL resources by namespace.'
        - macro: '{$CLOUD_SQL.MSSQL.RES.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MSSQL resources by namespace.'
        - macro: '{$CLOUD_SQL.MSSQL.SCHEDULER.ID.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL schedulers by namespace.'
        - macro: '{$CLOUD_SQL.MSSQL.SCHEDULER.ID.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MSSQL schedulers by namespace.'
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'A response timeout for an API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: 'Time interval for the data requests. Supported usage type: 1. The default update interval for most of the items. 2. The minimal time window for the data requested in the Monitoring Query Language REST API request.'
      dashboards:
        - uuid: 4233430037fc4570b3a5eb3f23ef02e6
          name: 'MSSQL instance'
          pages:
            - name: 'MSSQL instance'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.cpu.usage_time
                    - type: STRING
                      name: reference
                      value: AAAAA
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Memory usage'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.disk.utilization
                    - type: STRING
                      name: reference
                      value: AAAAE
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Transactions'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graph
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Memory workflow'
                    - type: STRING
                      name: reference
                      value: AAAAK
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.cpu.utilization
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.memory.utilization
                    - type: STRING
                      name: reference
                      value: AAAAD
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Disk read/write operations'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.network.connections
                    - type: STRING
                      name: reference
                      value: AAAAH
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.memory.buffer_cache_hit_ratio
                    - type: STRING
                      name: reference
                      value: AAAAJ
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Memory Read/Writes'
                    - type: STRING
                      name: reference
                      value: AAAAL
      valuemaps:
        - uuid: d2aa57a09cbb43e8b53b11316193f013
          name: 'Database availability'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
        - uuid: 1c26d58d111b4689a2e7acd23a38f1ca
          name: 'Instance state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Suspended
            - value: '2'
              newvalue: Runnable
            - value: '3'
              newvalue: 'Pending create'
            - value: '4'
              newvalue: Maintenance
            - value: '5'
              newvalue: Failed
            - value: '6'
              newvalue: 'Unknown state'
            - value: '10'
              newvalue: 'Data retrievement error'
    - uuid: 54f0ffb538d94a9bb8062df3e63c4cb6
      template: 'GCP Cloud SQL MSSQL Replica by HTTP'
      name: 'GCP Cloud SQL MSSQL Replica by HTTP'
      description: |
        Get GCP Cloud SQL MSSQL monitoring for read-only replicas with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: e66fe8bb6f924cb088ec57b215fe21d7
          name: 'Bytes sent to replica'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.bytes_sent_to_replica_count
          units: B
          description: |
            Total number of bytes sent to the remote availability replica.
            For an async replica, returns the number of bytes before compression.
            For a sync replica without compression, returns the actual number of bytes.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.bytes_sent_to_replica_count
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 4100432768354e1ca7349a901bccbe85
          name: 'Log apply pending queue'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.log_apply_pending_queue
          description: 'Current number of log blocks that are waiting to be applied to replica.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.log_apply_pending_queue
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: d060637548af434e926ed833083d9fa0
          name: 'Log bytes received'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.log_bytes_received_count
          units: B
          description: 'Total size of log records received by the replica.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.log_bytes_received_count
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: f0d4c711863f4ca9ad76b0099a66a86d
          name: 'Replica metrics get'
          type: SCRIPT
          key: gcp.cloudsql.mssql.repl.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/sqlserver/replication/',
            	obj = {},
            	base_paths = [
            		'bytes_sent_to_replica_count | map ignore [replica_name]',
            		'resent_message_count | map ignore [replica_name]',
            		'log_apply_pending_queue',
            		'log_bytes_received_count',
            		'recovery_queue',
            		'redone_bytes_count'
            	];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            var params = checkParams(JSON.parse(value)),
            	filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	base_raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
            	keys = getField(base_raw, 'timeSeriesDescriptor.pointDescriptors'),
            	values = getField(base_raw, 'timeSeriesData.0.pointData.0.values'),
            	re = /(^t_\d+\.value\.)/g;
            
            for (i in keys) {
            	var value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            	for (v in value_types) {
            		if (typeof values[i][value_types[v]] !== 'undefined') {
            			obj[getField(keys[i], 'key').replace(re, '')] = values[i][value_types[v]];
            		}
            	}
            }
            
            return JSON.stringify(obj);
          description: 'MSSQL replica metrics data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 4ec364fea7894df29813b65c2d170367
          name: 'Recovery queue'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.recovery_queue
          units: B
          description: 'Current size of log records in bytes in the replica''s log files that have not been redone.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.recovery_queue
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 37c145777926471482ecffd1b6cca792
          name: 'Redone bytes'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.redone_bytes_count
          units: B
          description: 'Total size in bytes of redone log records.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.redone_bytes_count
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 23911902d27e4fa68435935aeeec28e1
          name: 'Resent messages'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.resent_message_count
          description: |
            Total count of Always On messages to resend.
            This includes messages that were attempted to be sent but failed and require resending.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.resent_message_count
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: mssql
        - tag: target
          value: replica
      macros:
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'A response timeout for an API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for the data requests.
            Supported usage type:
            1. The default update interval for most of the items.
            2. The minimal time window for the data requested in the Monitoring Query Language REST API request.
      dashboards:
        - uuid: f50d9889ca3c4f6b91dd9e40902e37fb
          name: 'MSSQL replica'
          pages:
            - name: 'MSSQL replica'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL Replica by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Replication data'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL Replica by HTTP'
                        key: gcp.cloudsql.mssql.repl.log_apply_pending_queue
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '1'
    - uuid: 38456af4aedd4b168ec3fa4ad2acb256
      template: 'GCP Cloud SQL MySQL by HTTP'
      name: 'GCP Cloud SQL MySQL by HTTP'
      description: |
        Get GCP Cloud SQL MySQL instances monitoring with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 83e36c61e8ce4d06a395ea7b06c5877b
          name: 'Reserved CPU cores'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.cpu.reserved_cores
          value_type: FLOAT
          description: 'Number of cores reserved for the database.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_reserved_cores
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: a39ba253dbf24110af48fd49572976fd
          name: 'CPU usage time'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.cpu.usage_time
          value_type: FLOAT
          units: s
          description: 'Cumulative CPU usage time in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage_time
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: df7469e3c76c4286846c27003c9785cc
          name: 'CPU utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: 'Current CPU utilization represented as a percentage of the reserved CPU that is currently in use.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 5bf54c01665549c8a05f49db34c86191
              expression: 'min(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.cpu.utilization,5m) >= {$CLOUD_SQL.MYSQL.CPU.UTIL.MAX}'
              name: 'GCP MySQL: High CPU utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 948dac37023c4efcaf5f830ba5d4fafe
          name: 'DB engine state'
          type: HTTP_AGENT
          key: gcp.cloudsql.mysql.db.state
          description: 'GCP Cloud SQL MySQL DB Engine State.'
          valuemap:
            name: 'Database availability'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].int64Value'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/up | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: a3eff8c422f5427e9b1c6abb9854f73c
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.db.state)=0'
              name: 'GCP MySQL: Database engine is down'
              priority: AVERAGE
              description: |
                Database engine is down.
                If an instance experiences unplanned (non-maintenance) downtime, the instance state will still be RUNNING, but the database engine state metric will report 0.
              dependencies:
                - name: 'GCP MySQL: Failed to get the instance state'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 10'
                - name: 'GCP MySQL: Instance is in failed state'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 5'
                - name: 'GCP MySQL: Instance is in maintenance'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 4'
                - name: 'GCP MySQL: Instance is in suspended state'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 1'
                - name: 'GCP MySQL: Instance is in unknown state'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 6'
                - name: 'GCP MySQL: Instance is stopped by the owner'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 2'
              tags:
                - tag: scope
                  value: availability
        - uuid: 76c37760145d43f3927f1a9548dea8a5
          name: 'Disk bytes used'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.disk.bytes_used
          units: B
          description: 'Data utilization in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_bytes_used
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 464fecbbedd64e988739c93736d2b824
          name: 'Disk size'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.disk.quota
          units: B
          description: 'Maximum data disk size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_quota
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: d426d282d2ee43fe9c9b64dcb6d0c4c9
          name: 'Disk read I/O'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.disk.read_ops_count
          description: 'Delta count of data disk read I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_read_ops_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: b2274d47be5041b493b00fd55172c0e9
          name: 'Disk utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.disk.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the disk quota that is currently in use. 
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: d5ade16fb0494ca6af61100a2e643702
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.disk.utilization) >= {$CLOUD_SQL.MYSQL.DISK.UTIL.CRIT}'
              name: 'GCP MySQL: Disk space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'Critical utilization of the disk space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 3b5c84fee47f4376b19d0738b261c01b
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.disk.utilization) >= {$CLOUD_SQL.MYSQL.DISK.UTIL.WARN}'
              name: 'GCP MySQL: Disk space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              dependencies:
                - name: 'GCP MySQL: Disk space is critically low'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.disk.utilization) >= {$CLOUD_SQL.MYSQL.DISK.UTIL.CRIT}'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 7a44187c6a404defb0dc83fa22f89d96
          name: 'Disk write I/O'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.disk.write_ops_count
          description: 'Delta count of data disk write I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_write_ops_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 5e5b9cdfa7f2455b881cceface136e65
          name: 'InnoDB dirty pages'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_dirty
          description: 'Number of unflushed pages in the InnoDB buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_buffer_pool_pages_dirty
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 75835c8326e6461d8f25fb7d55271f16
          name: 'InnoDB free pages'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_free
          description: 'Number of unused pages in the InnoDB buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_buffer_pool_pages_free
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 080d5304c0e346808bd70b125a27be4b
          name: 'InnoDB total pages'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_total
          description: 'Total number of pages in the InnoDB buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_buffer_pool_pages_total
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 19e259f61fc24e29a189c35121878eb3
          name: 'InnoDB fsync calls'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_data_fsyncs
          description: 'Delta count of InnoDB fsync() calls.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_data_fsyncs
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: storage
        - uuid: c4a4ffa274974041bccbd25643ff9f70
          name: 'InnoDB log fsync calls'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_os_log_fsyncs
          description: 'Delta count of InnoDB fsync() calls to the log file.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_os_log_fsyncs
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: storage
        - uuid: 4a9154e235e84c0d9dbf0abf44479f49
          name: 'InnoDB pages read'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_pages_read
          description: 'Delta count of InnoDB pages read.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_pages_read
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 584714b219034bbebbc24edad36704c9
          name: 'InnoDB pages written'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_pages_written
          description: 'Delta count of InnoDB pages written.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_pages_written
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 71559008ad444772b0b1212f715980ed
          name: 'Instance state'
          type: HTTP_AGENT
          key: gcp.cloudsql.mysql.inst.state
          description: 'GCP Cloud SQL MySQL Current instance state.'
          valuemap:
            name: 'Instance state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].stringValue'
              error_handler: CUSTOM_VALUE
              error_handler_params: '10'
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'RUNNING',
                  	'SUSPENDED',
                  	'RUNNABLE',
                  	'PENDING_CREATE',
                  	'MAINTENANCE',
                  	'FAILED',
                  	'UNKNOWN_STATE'
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/state | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 3b3adc89e0bb45a79a824121f49d2d02
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 10'
              name: 'GCP MySQL: Failed to get the instance state'
              priority: AVERAGE
              description: |
                Failed to get the instance state. 
                Check access permissions to GCP API or service account.
              tags:
                - tag: scope
                  value: availability
            - uuid: 65831fed3d19425c86933db4034ed565
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 5'
              name: 'GCP MySQL: Instance is in failed state'
              priority: AVERAGE
              description: 'The instance creation failed, or an operation left the instance in an own bad state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: fae15d1ab46c418ebfdfdd73fb698b51
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 4'
              name: 'GCP MySQL: Instance is in maintenance'
              priority: INFO
              description: 'The instance is down for maintenance.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 347215d307c8465cad41198f12b5ff68
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 1'
              name: 'GCP MySQL: Instance is in suspended state'
              priority: WARNING
              description: |
                The instance is in suspended state. 
                It is not available, for example, due to problems with billing.
              tags:
                - tag: scope
                  value: availability
            - uuid: 1387f9a2ef194d5bb5d1e548fc4eb8d3
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 6'
              name: 'GCP MySQL: Instance is in unknown state'
              priority: AVERAGE
              description: 'The state of the instance is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 9c66317433a24be985559fdb11907c70
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 2'
              name: 'GCP MySQL: Instance is stopped by the owner'
              priority: INFO
              description: |
                The instance has been stopped by the owner. 
                It is not currently running, but it's ready to be restarted.
              tags:
                - tag: scope
                  value: availability
        - uuid: cc09f5591b0242b3b99199b267a1c527
          name: 'Memory size'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.memory.quota
          units: B
          description: 'Maximum RAM size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_quota
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 13868b9408c9489296531bf1fd927084
          name: 'Memory used by DB engine'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.memory.total_usage
          units: B
          description: |
            Total RAM usage in bytes. 
            This metric reports the RAM usage of the database process, including the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_total_usage
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 995d07fc814f4d12a9c9bdc6bb52481d
          name: 'Memory usage'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.memory.usage
          units: B
          description: |
            The RAM usage in bytes. 
            This metric reports the RAM usage of the server, excluding the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: efe4357a63ec43f799b2303a952c1378
          name: 'Memory utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.memory.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the memory quota that is currently in use.
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_ram_pused
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 82e3af43d3104b4ba641e0be56d11662
              expression: 'min(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.memory.utilization,5m) >= {$CLOUD_SQL.MYSQL.RAM.UTIL.MAX}'
              name: 'GCP MySQL: High memory utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: HIGH
              description: 'RAM utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 682484eaf1db4a239c69566a5cd492e2
          name: 'Metrics get'
          type: SCRIPT
          key: gcp.cloudsql.mysql.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/',
            	mysql_path = 'cloudsql.googleapis.com/database/mysql/',
            	obj = {},
            	base_paths = [
            		'cpu/reserved_cores',
            		'cpu/usage_time',
            		'cpu/utilization',
            		'disk/read_ops_count',
            		'disk/write_ops_count',
            		'memory/quota',
            		'memory/total_usage',
            		'memory/usage',
            		'network/connections',
            		'network/received_bytes_count',
            		'network/sent_bytes_count  | map ignore [destination]'
            	].map(function (path) { return base_path + path; }),
            	mysql_paths = [
            		'innodb_buffer_pool_pages_dirty',
            		'innodb_buffer_pool_pages_free',
            		'innodb_buffer_pool_pages_total',
            		'innodb_data_fsyncs',
            		'innodb_os_log_fsyncs',
            		'innodb_pages_read',
            		'innodb_pages_written',
            		'queries',
            		'questions',
            		'received_bytes_count',
            		'sent_bytes_count',
            		'open_tables',
            		'open_table_definitions'
            	].map(function (path) { return mysql_path + path; }).concat(
            		['disk/bytes_used', 'disk/utilization', 'disk/quota'].map(function (path) { return base_path + path; }));
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            function rawMap(raw, prefix) {
            	var keys = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            		values = getField(raw, 'timeSeriesData.0.pointData.0.values'),
            		re = /(^t_\d+\.value\.)/g;
            
            	for (i in keys) {
            		var key = getField(keys[i], 'key').replace(re, ''),
            			value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            		for (v in value_types) {
            			if (typeof values[i][value_types[v]] !== 'undefined') {
            				if (prefix) {
            					obj[prefix + key] = values[i][value_types[v]];
            				}
            				else {
            					obj[key] = values[i][value_types[v]];
            				}
            
            			}
            		}
            	}
            	return obj;
            }
            
            var params = checkParams(JSON.parse(value)),
            	j_filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'" + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	queries = [
            		{ name: 'base_', data: { query: '{' + base_paths.join(';') + '}' + j_filter } },
            		{ name: 'mysql_', data: { query: '{' + mysql_paths.join(';') + '}' + j_filter } }
            	];
            
            for (q in queries) {
            	raw = getHttpData(url, params.token, queries[q].data);
            	obj = Object.assign(obj, rawMap(raw, queries[q].name));
            }
            
            obj.base_ram_pused = Math.floor(getField(obj, 'base_usage') / getField(obj, 'base_quota') * 100);
            
            return JSON.stringify(obj);
          description: 'MySQL metrics in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 9ddae405a9b343759d03b5b29c469d18
          name: Connections
          type: DEPENDENT
          key: gcp.cloudsql.mysql.network.connections
          description: 'Number of connections to the databases on the Cloud SQL instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_connections
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: d970d8e209df4b2a810c2e59f39fa429
          name: 'Network: Received bytes'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.network.received_bytes_count
          units: B
          description: 'Delta count of bytes received through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_received_bytes_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 977e4e22ebfc4a19a228a8935d9a342c
          name: 'Network: Sent bytes'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.network.sent_bytes_count
          units: B
          description: 'Delta count of bytes sent through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_sent_bytes_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 1d651976f70944acb31cd0430e70d422
          name: 'Open tables'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.open_tables
          description: 'The number of tables that are currently open.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_open_tables
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: tables
        - uuid: 1606766c63bf4aa1ade24a34650eef05
          name: 'Open table definitions'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.open_table_definitions
          description: 'The number of table definitions that are currently cached.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_open_table_definitions
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: tables
        - uuid: 3d3ec2e37bf94fb68c40967b56dfd95c
          name: 'Network: Bytes received by MySQL'
          type: DEPENDENT
          key: gcp.cloudsql.mysql_received_bytes_count
          units: B
          description: 'Delta count of bytes received by MySQL process.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_received_bytes_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: f926beb31be44dc0bfb30c571fac280a
          name: 'Network: Bytes sent by MySQL'
          type: DEPENDENT
          key: gcp.cloudsql.mysql_sent_bytes_count
          units: B
          description: 'Delta count of bytes sent by MySQL process.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_sent_bytes_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: bbdeb595ab1b44d7a332fbf0c2637403
          name: Queries
          type: DEPENDENT
          key: gcp.cloudsql.queries
          description: 'Delta of statements executed by the server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_queries
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: queries
        - uuid: 114fb26dcdc1441c84c150c7809b3400
          name: Questions
          type: DEPENDENT
          key: gcp.cloudsql.questions
          description: 'Delta of statements executed by the server sent by the client.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_questions
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: queries
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: mysql
      macros:
        - macro: '{$CLOUD_SQL.MYSQL.CPU.UTIL.MAX}'
          value: '95'
          description: 'GCP Cloud SQL MySQL instance CPU usage threshold.'
        - macro: '{$CLOUD_SQL.MYSQL.DISK.UTIL.CRIT}'
          value: '90'
          description: 'GCP Cloud SQL MySQL instance critical disk usage threshold.'
        - macro: '{$CLOUD_SQL.MYSQL.DISK.UTIL.WARN}'
          value: '80'
          description: 'GCP Cloud SQL MySQL instance warning disk usage threshold.'
        - macro: '{$CLOUD_SQL.MYSQL.RAM.UTIL.MAX}'
          value: '90'
          description: 'GCP Cloud SQL MySQL instance RAM usage 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.'
      dashboards:
        - uuid: 5932cc56f6f146db8fac121b3817a407
          name: 'MySQL instance'
          pages:
            - name: 'MySQL instance'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        key: gcp.cloudsql.mysql.cpu.usage_time
                    - type: STRING
                      name: reference
                      value: AAAAA
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        name: 'GCP Cloud SQL MySQL: Memory usage'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        key: gcp.cloudsql.mysql.disk.utilization
                    - type: STRING
                      name: reference
                      value: AAAAE
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        name: 'GCP Cloud SQL MySQL: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        name: 'GCP Cloud SQL MySQL: pages'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        key: gcp.cloudsql.mysql.cpu.utilization
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        key: gcp.cloudsql.mysql.memory.utilization
                    - type: STRING
                      name: reference
                      value: AAAAD
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        name: 'GCP Cloud SQL MySQL: Disk read/write operations'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        key: gcp.cloudsql.mysql.network.connections
                    - type: STRING
                      name: reference
                      value: AAAAH
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        name: 'GCP Cloud SQL MySQL: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAJ
      valuemaps:
        - uuid: 8aa36f0f6a0b42a3b5e0eabfb700e8db
          name: 'Database availability'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
        - uuid: 9adad9dad34646d79bcc6c414ddf8afe
          name: 'Instance state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Suspended
            - value: '2'
              newvalue: Runnable
            - value: '3'
              newvalue: 'Pending create'
            - value: '4'
              newvalue: Maintenance
            - value: '5'
              newvalue: Failed
            - value: '6'
              newvalue: 'Unknown state'
            - value: '10'
              newvalue: 'Data retrievement error'
    - uuid: 9d7871c093f9489293421396b9fea668
      template: 'GCP Cloud SQL MySQL Replica by HTTP'
      name: 'GCP Cloud SQL MySQL Replica by HTTP'
      description: |
        Get GCP Cloud SQL MySQL monitoring for read-only replicas with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 17aa9eb4749e46be9b0b0f93ef011fca
          name: 'Last I/O thread error number'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.last_io_errno
          description: 'The error number of the most recent error that caused the I/O thread to stop.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.last_io_errno
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 52c11965a2fc4d37a97ebccc04ee7b80
          name: 'Last SQL thread error number'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.last_sql_errno
          description: 'The error number of the most recent error that caused the SQL thread to stop.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.last_sql_errno
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 470200d2cca348bb8a670a2be3a270e3
          name: 'Replica metrics get'
          type: SCRIPT
          key: gcp.cloudsql.mysql.repl.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/replication/',
            	mysql_path = 'cloudsql.googleapis.com/database/mysql/replication/',
            	raw_metrics,
            	obj = {},
            	base_paths = ['network_lag', 'replica_lag'].map(function (path) { return base_path + path; }),
            	mysql_paths = [
            		'last_io_errno',
            		'last_sql_errno',
            		'slave_io_running',
            		'slave_sql_running'].map(function (path) { return mysql_path + path; }).concat(
            			['network_lag', 'replica_lag'].map(function (path) { return base_path + path; }));
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            var params = checkParams(JSON.parse(value)),
            	filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	metric_raw = getHttpData(url, params.token, { query: '{' + mysql_paths.join(';') + '}' + j_filter }),
            	metric_keys = getField(metric_raw, 'timeSeriesDescriptor.pointDescriptors'),
            	metric_values = getField(metric_raw, 'timeSeriesData.0.pointData.0.values'),
            	re = /(^t_\d+\.value\.)/g;
            
            for (i in metric_keys) {
            	var value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            	for (v in value_types) {
            		if (typeof metric_values[i][value_types[v]] !== 'undefined') {
            			obj[getField(metric_keys[i], 'key').replace(re, "")] = metric_values[i][value_types[v]];
            		}
            	}
            }
            
            var state_raw = getHttpData(url, params.token, { query: base_path + 'state' + filter }),
            	state_keys = getField(state_raw, 'timeSeriesDescriptor.pointDescriptors'),
            	state_tsd = getField(state_raw, 'timeSeriesData');
            
            for (i in state_keys) {
            	var state_key = getField(state_keys[i], 'key').replace(/value\./g, '');
            
            	obj[state_key] = 'undefined';
            	for (t in state_tsd) {
            		if (getField(state_tsd[t], 'pointData.0.values.' + i + '.boolValue') == true) {
            			obj[state_key] = getField(state_tsd[t], 'labelValues.3.stringValue');
            			break;
            		}
            	}
            }
            
            return JSON.stringify(obj);
          description: 'MySQL replication metrics data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: e84ac3a2537848b29024659ab5e3a0e9
          name: 'Network lag'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.network_lag
          units: s
          description: 'Indicates time taken from primary binary log to IO thread on replica.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.network_lag
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: b5f9960de9414975ac48357844a15860
          name: 'Replication lag'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.replica_lag
          units: s
          description: 'Number of seconds the read replica is behind its primary (approximation).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.replica_lag
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 0c093a0416f24afb96fc28a7abb283d4
          name: 'Slave I/O thread running'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.slave_io_running
          description: |
            Indicates whether the I/O thread for reading the primary's binary log is running.
            Possible values are Yes, No and Connecting.
          valuemap:
            name: 'Thread state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.slave_io_running
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'No',
                  	'Yes',
                  	'Connecting',
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 994d92340dd146a381f2e6bbebd1c3f2
          name: 'Slave SQL thread running'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.slave_sql_running
          description: 'Indicates whether the SQL thread for executing events in the relay log is running.'
          valuemap:
            name: 'Thread state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.slave_sql_running
            - type: BOOL_TO_DECIMAL
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 90a9154072164b5c89d715fa77e7e2b0
          name: 'Replication state'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.state
          description: |
            The current serving state of replication.
            This metric is only available for the MySQL/PostgreSQL instances.
          valuemap:
            name: 'Replication state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.state
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'Running',
                  	'Syncing',
                  	'Unsynced',
                  	'Stopped',
                  	'Error',
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
            - tag: component
              value: status
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: mysql
        - tag: target
          value: replica
      macros:
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'A response timeout for an API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for the data requests.
            Supported usage type:
            1. The default update interval for most of the items.
            2. The minimal time window for the data requested in the Monitoring Query Language REST API request.
      dashboards:
        - uuid: 76eda12212f045388bef22cb382eff6b
          name: 'MySQL replica'
          pages:
            - name: 'MySQL replica'
              widgets:
                - type: graph
                  width: '72'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL Replica by HTTP'
                        name: 'GCP Cloud SQL MySQL: Lags'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: item
                  name: 'I/O Thread State'
                  'y': '5'
                  width: '18'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL Replica by HTTP'
                        key: gcp.cloudsql.mysql.repl.slave_io_running
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: 'I/O Thread Error'
                  x: '18'
                  'y': '5'
                  width: '18'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '1'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL Replica by HTTP'
                        key: gcp.cloudsql.mysql.repl.last_io_errno
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: 'SQL Thread State'
                  x: '36'
                  'y': '5'
                  width: '18'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '1'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL Replica by HTTP'
                        key: gcp.cloudsql.mysql.repl.slave_sql_running
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: 'SQL Thread Error'
                  x: '54'
                  'y': '5'
                  width: '18'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '1'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL Replica by HTTP'
                        key: gcp.cloudsql.mysql.repl.last_sql_errno
                    - type: INTEGER
                      name: show.0
                      value: '2'
      valuemaps:
        - uuid: ea83090a16d94eb3bb643009c784d820
          name: 'Replication state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Syncing
            - value: '2'
              newvalue: Unsynced
            - value: '3'
              newvalue: Stopped
            - value: '4'
              newvalue: Error
            - value: '10'
              newvalue: Unknown
        - uuid: b1acfa66a401499cae56777db6c7750b
          name: 'Thread state'
          mappings:
            - value: '0'
              newvalue: 'No'
            - value: '1'
              newvalue: 'Yes'
            - value: '2'
              newvalue: Connecting
            - value: '10'
              newvalue: Unknown
    - uuid: e74c1e12f82e4d9880a368b53f5e65a4
      template: 'GCP Cloud SQL PostgreSQL by HTTP'
      name: 'GCP Cloud SQL PostgreSQL by HTTP'
      description: |
        Get GCP Cloud SQL PostgreSQL instances monitoring with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 396a555958514890af339f4504a96cc6
          name: 'Reserved CPU cores'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.cpu.reserved_cores
          value_type: FLOAT
          description: 'Number of cores reserved for the database.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_reserved_cores
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: aa2e6d9118ed4b198ed9a28932ea8539
          name: 'CPU usage time'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.cpu.usage_time
          value_type: FLOAT
          units: s
          description: 'Cumulative CPU usage time in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage_time
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: cb7cd1b74e4944d88334f22d25b985fa
          name: 'CPU utilization'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: 'Current CPU utilization represented as a percentage of the reserved CPU that is currently in use.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 3ca3942121bd41029645a19fd3947416
              expression: 'min(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.cpu.utilization,5m) >= {$CLOUD_SQL.PGSQL.CPU.UTIL.MAX}'
              name: 'GCP PostgreSQL: High CPU utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 27ad9640bf734dd49548c19241cc4838
          name: 'DB engine state'
          type: HTTP_AGENT
          key: gcp.cloudsql.pgsql.db.state
          description: 'GCP Cloud SQL PostgreSQL DB Engine State.'
          valuemap:
            name: 'Database availability'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].int64Value'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/up | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: f7b0fc21edcf489ab174eb06dee4fabe
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.db.state)=0'
              name: 'GCP PostgreSQL: Database engine is down'
              priority: AVERAGE
              description: |
                Database engine is down.
                If an instance experiences unplanned (non-maintenance) downtime, the instance state will still be RUNNING, but the database engine state metric will report 0.
              dependencies:
                - name: 'GCP PostgreSQL: Failed to get the instance state'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 10'
                - name: 'GCP PostgreSQL: Instance is in failed state'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 5'
                - name: 'GCP PostgreSQL: Instance is in maintenance'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 4'
                - name: 'GCP PostgreSQL: Instance is in suspended state'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 1'
                - name: 'GCP PostgreSQL: Instance is in unknown state'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 6'
                - name: 'GCP PostgreSQL: Instance is stopped by the owner'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 2'
              tags:
                - tag: scope
                  value: availability
        - uuid: 799cad827e8b44d98b8285b08153842d
          name: 'Disk bytes used'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.disk.bytes_used
          units: B
          description: 'Data utilization in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_bytes_used
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 470510bf76fb47fbbddfc8c4a711a335
          name: 'Disk size'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.disk.quota
          units: B
          description: 'Maximum data disk size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_quota
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: f12ba5129c2d435389f4fb6964294381
          name: 'Disk read I/O'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.disk.read_ops_count
          description: 'Delta count of data disk read I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_read_ops_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: e2d6702514b941cb9586cb98786c6a01
          name: 'Disk utilization'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.disk.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the disk quota that is currently in use. 
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: c4fa1d580ffd4546b82605f94da5d2ba
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.disk.utilization) >= {$CLOUD_SQL.PGSQL.DISK.UTIL.CRIT}'
              name: 'GCP PostgreSQL: Disk space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'Critical utilization of the disk space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 186a707ca3194c32a894ae809177a7e2
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.disk.utilization) >= {$CLOUD_SQL.PGSQL.DISK.UTIL.WARN}'
              name: 'GCP PostgreSQL: Disk space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              dependencies:
                - name: 'GCP PostgreSQL: Disk space is critically low'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.disk.utilization) >= {$CLOUD_SQL.PGSQL.DISK.UTIL.CRIT}'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 8d8d6c13cdb244cb80c03226b7c14a90
          name: 'Disk write I/O'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.disk.write_ops_count
          description: 'Delta count of data disk write I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_write_ops_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 88fd41960538460ebfd2ed9194677cd1
          name: 'Instance state'
          type: HTTP_AGENT
          key: gcp.cloudsql.pgsql.inst.state
          description: 'GCP Cloud SQL PostgreSQL Current instance state.'
          valuemap:
            name: 'Instance state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].stringValue'
              error_handler: CUSTOM_VALUE
              error_handler_params: '10'
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'RUNNING',
                  	'SUSPENDED',
                  	'RUNNABLE',
                  	'PENDING_CREATE',
                  	'MAINTENANCE',
                  	'FAILED',
                  	'UNKNOWN_STATE'
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/state | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 596020e32d0c4193a6626c960b4b5be8
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 10'
              name: 'GCP PostgreSQL: Failed to get the instance state'
              priority: AVERAGE
              description: |
                Failed to get the instance state. 
                Check access permissions to GCP API or service account.
              tags:
                - tag: scope
                  value: availability
            - uuid: 1a2efb6f755444c0bab85d2778018eb1
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 5'
              name: 'GCP PostgreSQL: Instance is in failed state'
              priority: AVERAGE
              description: 'The instance creation failed, or an operation left the instance in an own bad state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: aad6fb2d86c84e33868aacbf160c3d65
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 4'
              name: 'GCP PostgreSQL: Instance is in maintenance'
              priority: INFO
              description: 'The instance is down for maintenance.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 959072ed00c4461196bef71618799b82
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 1'
              name: 'GCP PostgreSQL: Instance is in suspended state'
              priority: WARNING
              description: |
                The instance is in suspended state. 
                It is not available, for example, due to problems with billing.
              tags:
                - tag: scope
                  value: availability
            - uuid: 5f1084f744b444f3b803110baf703973
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 6'
              name: 'GCP PostgreSQL: Instance is in unknown state'
              priority: AVERAGE
              description: 'The state of the instance is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: fb0df2eb001649febb6fc6513e056fcc
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 2'
              name: 'GCP PostgreSQL: Instance is stopped by the owner'
              priority: INFO
              description: |
                The instance has been stopped by the owner. 
                It is not currently running, but it's ready to be restarted.
              tags:
                - tag: scope
                  value: availability
        - uuid: 014d96156a364f2c8eac6a47de3eddfe
          name: 'Memory size'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.memory.quota
          units: B
          description: 'Maximum RAM size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_quota
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: e73876fa0728402db7688a41938f4a12
          name: 'Memory used by DB engine'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.memory.total_usage
          units: B
          description: |
            Total RAM usage in bytes. 
            This metric reports the RAM usage of the database process, including the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_total_usage
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 2a5daa0300564b97a5e744e576a217cb
          name: 'Memory usage'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.memory.usage
          units: B
          description: |
            The RAM usage in bytes. 
            This metric reports the RAM usage of the server, excluding the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 4c524a81bf3b4a6bbc87d23b60c4f74c
          name: 'Memory utilization'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.memory.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the memory quota that is currently in use.
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_ram_pused
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: bbbdbd9c3c5b407491b359f98e4e3fa9
              expression: 'min(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.memory.utilization,5m) >= {$CLOUD_SQL.PGSQL.RAM.UTIL.MAX}'
              name: 'GCP PostgreSQL: High memory utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: HIGH
              description: 'RAM utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 9bf09a42ddd64f7eabf6bbc011eda689
          name: 'Metrics get'
          type: SCRIPT
          key: gcp.cloudsql.pgsql.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/',
            	pgsql_path = 'cloudsql.googleapis.com/database/postgresql/',
            	obj = {},
            	value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            function rawMap(raw, prefix) {
            	var keys = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            		values = getField(raw, 'timeSeriesData.0.pointData.0.values'),
            		re = /(^t_\d+\.value(_|\.)|_sum$)/g;
            
            	for (i in keys) {
            		var key = getField(keys[i], 'key').replace(re, '');
            
            		for (v in value_types) {
            			if (typeof values[i][value_types[v]] !== 'undefined') {
            				if (prefix) {
            					obj[prefix + key] = values[i][value_types[v]];
            				} else {
            					obj[key] = values[i][value_types[v]];
            				}
            
            			}
            		}
            	}
            	return obj;
            }
            
            function singleMetrics(tsd) {
            	result = {};
            	for (t in tsd) {
            		for (v in value_types) {
            			if (typeof tsd[t].pointData[0].values[0][value_types[v]] !== 'undefined') {
            				result['pgsql_' + getField(tsd[t], 'labelValues.3.stringValue').toLowerCase()] = tsd[t].pointData[0].values[0][value_types[v]];
            			}
            		}
            	}
            	return result;
            }
            
            var params = checkParams(JSON.parse(value)),
            	filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	base_paths = [
            		'cpu/reserved_cores',
            		'cpu/usage_time',
            		'cpu/utilization',
            		'disk/read_ops_count',
            		'disk/write_ops_count',
            		'memory/quota',
            		'memory/total_usage',
            		'memory/usage',
            		'network/received_bytes_count',
            		'network/sent_bytes_count | map ignore [destination]'
            	].map(function (path) { return base_path + path; }),
            	pgsql_paths = [
            		'transaction_id_utilization ' + filter,
            		'temp_bytes_written_count' + filter + ' | sum',
            		'temp_files_written_count' + filter + ' | sum',
            		'num_backends' + filter + ' | sum'
            	].map(function (path) { return pgsql_path + path; }).concat(
            		['disk/bytes_used', 'disk/utilization', 'disk/quota'].map(function (path) { return base_path + path; })),
            	queries = [
            		{ name: 'base_', data: { query: '{' + base_paths.join(';') + '}' + j_filter } },
            		{ name: 'pgsql_', data: { query: '{' + pgsql_paths.join(';') + '}' + '| within ' + params.time_window + '| join' } }
            	];
            
            for (q in queries) {
            	raw = getHttpData(url, params.token, queries[q].data);
            	obj = Object.assign(obj, rawMap(raw, queries[q].name));
            }
            
            obj.base_ram_pused = Math.floor((getField(obj, 'base_usage') / getField(obj, 'base_quota')) * 100);
            
            var single_paths = ['transaction_id_count', 'vacuum/oldest_transaction_age'],
            	single_queries = single_paths.map(function (path) { return { query: pgsql_path + path + filter }; });
            
            for (q in single_queries) {
            	raw = getHttpData(url, params.token, single_queries[q]);
            	Object.assign(obj, singleMetrics(getField(raw, 'timeSeriesData')));
            }
            
            return JSON.stringify(obj);
          description: 'PostgreSQL metrics data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: f2d00c86eedd4a1e8efce7661c3da18d
          name: 'Network: Received bytes'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.network.received_bytes_count
          units: B
          description: 'Delta count of bytes received through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_received_bytes_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: dc67deac1a2f4cc993406028d6cc8c3b
          name: 'Network: Sent bytes'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.network.sent_bytes_count
          units: B
          description: 'Delta count of bytes sent through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_sent_bytes_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 512c5d8156fb4d5299284f708e64dffc
          name: Connections
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.num_backends
          description: |
            The number of the connections to the Cloud SQL PostgreSQL instance.
            Includes connections to the system databases, which aren't visible by default.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_num_backends
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 88603b1881114551ba23e8f12d5ab47f
          name: 'Oldest prepared transaction age'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.oldest_transaction.prepared
          description: |
            Age of the oldest prepared transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
            Empty value when there is no such transaction type.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_prepared
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 50df8067afcb42a9ac44fe963ee635d2
          name: 'Oldest replica transaction age'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.oldest_transaction.replica
          description: |
            Age of the oldest replica transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
            Empty value when there is no such transaction type.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_replica
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: fee3d72f615c479389c5fdb46f32229f
          name: 'Oldest replication slot transaction age'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.oldest_transaction.replication_slot
          description: |
            Age of the oldest replication slot transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
            Empty value when there is no such transaction type.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_replication_slot
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 6d51c4865cd04607986ef4e02bc43fb6
          name: 'Oldest running transaction age'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.oldest_transaction.running
          description: |
            Age of the oldest running transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
            Empty value when there is no such transaction type.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_running
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 75bc8d76a59a465fb66a434e13de107d
          name: 'Data written to temporary'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.temp_bytes_written_count
          units: B
          description: 'Total data size (in bytes) written to temporary files by the queries.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_temp_bytes_written_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: bd10ec6251c444a79878e82e3ebe9ac0
          name: 'Temporary files used for writing data'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.temp_files_written_count
          description: 'Total number of temporary files used for writing data while performing algorithms such as join and sort.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_temp_files_written_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 2498b066f4964aa7be03f4cc43eab95e
          name: 'Assigned transactions'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.transaction_id_count_assigned
          description: 'Delta count of assigned transaction IDs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_assigned
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 23d1b88571d347db9672596ec13580cc
          name: 'Frozen transactions'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.transaction_id_count_frozen
          description: 'Delta count of frozen transaction IDs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_frozen
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 004042d342d0478ea8f826466353454d
          name: 'Transaction ID utilization'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.transaction_id_utilization
          value_type: FLOAT
          units: '%'
          description: 'Current utilization represented as a percentage of transaction IDs consumed by the Cloud SQL PostgreSQL instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_transaction_id_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
      discovery_rules:
        - uuid: 090d05a647384858a8b9efe5502c0a76
          name: 'GCP Cloud SQL PostgreSQL: Databases discovery'
          type: HTTP_AGENT
          key: gcp.cloudsql.pgsql.db.discovery
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#PGSQL.DB.NAME}'
                value: '{$GCP.CLOUD_SQL.DB.NAME.MATCHES}'
              - macro: '{#PGSQL.DB.NAME}'
                value: '{$GCP.CLOUD_SQL.DB.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Databases discovery for the particular PostgreSQL instance.'
          item_prototypes:
            - uuid: 997bdb03ba0b437ca2705f28dcc651ed
              name: 'Database [{#PGSQL.DB.NAME}]: Buffer cache blocks read.'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.blocks_read_count_buffer_cache[{#PGSQL.DB.NAME}]'
              description: 'Number of buffer cache blocks read by the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.buffer_cache
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: memory
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: b35c4a888743448688a8c5233ed165e7
              name: 'Database [{#PGSQL.DB.NAME}]: Disk blocks read.'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.blocks_read_count_disk[{#PGSQL.DB.NAME}]'
              description: 'Number of disk blocks read by the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.disk
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 7a1df30ae0c443839fe625142aea61b2
              name: 'Database [{#PGSQL.DB.NAME}]: Metrics raw'
              type: SCRIPT
              key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              delay: '{$GCP.TIME.WINDOW}'
              history: '0'
              value_type: TEXT
              params: |
                var base_path = 'cloudsql.googleapis.com/database/postgresql/',
                	obj = {};
                
                function checkParams(params) {
                	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
                		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
                			throw 'Required param is not set: ' + field + '.';
                		}
                	});
                	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
                		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
                	}
                	return params;
                }
                
                function getField(data, path) {
                	var steps = path.split('.');
                
                	for (var i = 0; i < steps.length; i++) {
                		var step = steps[i];
                
                		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                			throw 'Required field "' + path + '" is not present in data received.';
                		}
                		data = data[step];
                	}
                	return data;
                }
                
                function getHttpData(url, token, body) {
                	var request = new HttpRequest();
                	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
                		request.setProxy(params.proxy);
                	};
                	request.addHeader('Authorization: Bearer ' + token);
                	request.addHeader('Content-Type: application/json');
                
                	var response = request.post(url, JSON.stringify(body));
                
                	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
                
                	if (response !== null) {
                		try {
                			response = JSON.parse(response);
                		}
                		catch (error) {
                			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
                		}
                	}
                
                	if (typeof response !== 'object' || response === null) {
                		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
                	}
                
                	if (request.getStatus() !== 200) {
                		if (typeof (response.error && response.error.message) !== 'undefined') {
                			throw response.error.message;
                		}
                		else {
                			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
                		}
                	}
                	return response;
                };
                
                function singleMetrics(tsd) {
                	var result = {};
                
                	for (i in tsd) {
                		result[getField(tsd[i], 'labelValues.4.stringValue')] = getField(tsd[i], 'pointData.0.values.0.int64Value');
                	}
                	return result;
                }
                
                var params = checkParams(JSON.parse(value)),
                	filter = ' | within ' + params.time_window + " | filter database_id ='" + params.database_id + "'" + " | filter database ='" + params.database_name + "'",
                	j_filter = filter + ' | join',
                	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
                	common_paths = ['deadlock_count', 'tuples_returned_count', 'tuples_fetched_count'],
                	common_raw = getHttpData(url, params.token, { query: '{' + common_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
                	keys = getField(common_raw, 'timeSeriesDescriptor.pointDescriptors'),
                	values = getField(common_raw, 'timeSeriesData.0.pointData.0.values'),
                	re = /(^t_\d+\.value\.)/g;
                
                for (i in keys) {
                	var value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
                
                	for (v in value_types) {
                		if (typeof values[i][value_types[v]] !== 'undefined') {
                			obj[getField(keys[i], 'key').replace(re, '')] = values[i][value_types[v]];
                		}
                	}
                }
                
                var single_paths = ['transaction_count', 'blocks_read_count', 'tuples_processed_count', 'tuple_size'],
                	single_queries = single_paths.map(function (path) { return { query: base_path + path + filter }; });
                
                for (q in single_queries) {
                	raw = getHttpData(url, params.token, single_queries[q]);
                	obj = Object.assign(obj, singleMetrics(getField(raw, 'timeSeriesData')));
                }
                
                return JSON.stringify(obj);
              description: 'PostgreSQL metrics in raw format.'
              preprocessing:
                - type: CHECK_NOT_SUPPORTED
                  parameters:
                    - '-1'
              timeout: '{$GCP.DATA.TIMEOUT}'
              parameters:
                - name: database_id
                  value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
                - name: database_name
                  value: '{#PGSQL.DB.NAME}'
                - name: project_id
                  value: '{$GCP.PROJECT.ID}'
                - name: proxy
                  value: '{$GCP.PROXY}'
                - name: time_window
                  value: '{$GCP.TIME.WINDOW}'
                - name: token
                  value: '{$GCP.AUTH.TOKEN}'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: d5632c60593749209a6e681b396f4cc7
              name: 'Database [{#PGSQL.DB.NAME}]: Deadlocks count'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.deadlock_count[{#PGSQL.DB.NAME}]'
              description: 'Number of deadlocks detected in the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.deadlock_count
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: deadlock
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 6d846507fbc24cbb9fb4ad59167552db
              name: 'Database [{#PGSQL.DB.NAME}]: Committed transactions'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.transaction_count_commit[{#PGSQL.DB.NAME}]'
              description: 'Delta count of number of committed transactions to the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.commit
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 4751ef5e498e4ce184bd07aadc831d2b
              name: 'Database [{#PGSQL.DB.NAME}]: Rolled-back transactions'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.transaction_count_rollback[{#PGSQL.DB.NAME}]'
              description: 'Delta count of number of rolled-back transactions in the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rollback
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: a7451a61e0b04be8b1f85b47c44107e2
              name: 'Database [{#PGSQL.DB.NAME}]: Tuples fetched'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuples_fetched_count[{#PGSQL.DB.NAME}]'
              description: 'Total number of rows fetched as a result of queries to the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tuples_fetched_count
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 7daca0b14f5843669bc5b0823cd4d44f
              name: 'Database [{#PGSQL.DB.NAME}]: Deleted rows processed'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuples_processed_count_delete[{#PGSQL.DB.NAME}]'
              description: 'Number of tuples(rows) processed for delete operations for the database with the name [{#PGSQL.DB.NAME}].'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.delete
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 48a7613fa611410b8353d03d87af0f8d
              name: 'Database [{#PGSQL.DB.NAME}]: Inserted rows processed.'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuples_processed_count_insert[{#PGSQL.DB.NAME}]'
              description: 'Number of tuples(rows) processed for insert operations for the database with the name [{#PGSQL.DB.NAME}].'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.insert
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: e159cc28aec6448b9162f780479f5aab
              name: 'Database [{#PGSQL.DB.NAME}]: Updated rows processed'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuples_processed_count_update[{#PGSQL.DB.NAME}]'
              description: 'Number of tuples(rows) processed for update operations for the database with the name [{#PGSQL.DB.NAME}].'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.update
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: ee6fad5b2fb44a14a29c7cd662b1f5d2
              name: 'Database [{#PGSQL.DB.NAME}]: Tuples returned'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuples_returned_count[{#PGSQL.DB.NAME}]'
              description: 'Total number of rows scanned while processing the queries of the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tuples_returned_count
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: f7a58601a3384b8ba24c89b3693ddb88
              name: 'Database [{#PGSQL.DB.NAME}]: Dead tuples'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuple_size_dead[{#PGSQL.DB.NAME}]'
              description: 'Number of live tuples(rows) in the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.dead
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 16e88225cd41406285b3237ee1e61bb4
              name: 'Database [{#PGSQL.DB.NAME}]: Live tuples'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuple_size_live[{#PGSQL.DB.NAME}]'
              description: 'Number of live tuples(rows) in the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.live
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
          graph_prototypes:
            - uuid: 8ba7dd12152243b4a5a438bd649f96c1
              name: 'GCP Cloud SQL PostgreSQL: Database [{#PGSQL.DB.NAME}]: Tuples'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'GCP Cloud SQL PostgreSQL by HTTP'
                    key: 'gcp.cloudsql.pgsql.tuple_size_dead[{#PGSQL.DB.NAME}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'GCP Cloud SQL PostgreSQL by HTTP'
                    key: 'gcp.cloudsql.pgsql.tuple_size_live[{#PGSQL.DB.NAME}]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'GCP Cloud SQL PostgreSQL by HTTP'
                    key: 'gcp.cloudsql.pgsql.tuples_processed_count_insert[{#PGSQL.DB.NAME}]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'GCP Cloud SQL PostgreSQL by HTTP'
                    key: 'gcp.cloudsql.pgsql.tuples_processed_count_update[{#PGSQL.DB.NAME}]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'GCP Cloud SQL PostgreSQL by HTTP'
                    key: 'gcp.cloudsql.pgsql.tuples_processed_count_delete[{#PGSQL.DB.NAME}]'
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://sqladmin.googleapis.com/sql/v1beta4/projects/{$GCP.PROJECT.ID}/instances/{HOST.NAME}/databases'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          lld_macro_paths:
            - lld_macro: '{#PGSQL.DB.NAME}'
              path: $.name
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.items
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: postgresql
      macros:
        - macro: '{$CLOUD_SQL.PGSQL.CPU.UTIL.MAX}'
          value: '95'
          description: 'GCP Cloud SQL PostgreSQL instance CPU usage threshold.'
        - macro: '{$CLOUD_SQL.PGSQL.DISK.UTIL.CRIT}'
          value: '90'
          description: 'GCP Cloud SQL PostgreSQL instance critical disk usage threshold.'
        - macro: '{$CLOUD_SQL.PGSQL.DISK.UTIL.WARN}'
          value: '80'
          description: 'GCP Cloud SQL PostgreSQL instance warning disk usage threshold.'
        - macro: '{$CLOUD_SQL.PGSQL.RAM.UTIL.MAX}'
          value: '90'
          description: 'GCP Cloud SQL PostgreSQL instance RAM usage threshold.'
        - macro: '{$GCP.CLOUD_SQL.DB.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL PostgreSQL databases by namespace.'
        - macro: '{$GCP.CLOUD_SQL.DB.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL PostgreSQL databases by namespace.'
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'A response timeout for an API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: 'Time interval for the data requests. Supported usage type: 1. The default update interval for most of the items. 2. The minimal time window for the data requested in the Monitoring Query Language REST API request.'
      dashboards:
        - uuid: 21636cfe7d2f4de28d07af09c9812075
          name: 'PostgreSQL instance'
          pages:
            - name: 'PostgreSQL instance'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: gcp.cloudsql.pgsql.cpu.usage_time
                    - type: STRING
                      name: reference
                      value: AAAAA
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Memory usage'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: gcp.cloudsql.pgsql.disk.utilization
                    - type: STRING
                      name: reference
                      value: AAAAE
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Transactions count'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graphprototype
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Database [{#PGSQL.DB.NAME}]: Tuples'
                    - type: STRING
                      name: reference
                      value: AAAAK
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: gcp.cloudsql.pgsql.cpu.utilization
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: gcp.cloudsql.pgsql.memory.utilization
                    - type: STRING
                      name: reference
                      value: AAAAD
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Disk read/write operations'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: gcp.cloudsql.pgsql.transaction_id_utilization
                    - type: STRING
                      name: reference
                      value: AAAAH
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Transaction age'
                    - type: STRING
                      name: reference
                      value: AAAAJ
                - type: graphprototype
                  x: '36'
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: ITEM_PROTOTYPE
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: 'gcp.cloudsql.pgsql.deadlock_count[{#PGSQL.DB.NAME}]'
                    - type: STRING
                      name: reference
                      value: AAAAL
                    - type: INTEGER
                      name: source_type
                      value: '3'
      valuemaps:
        - uuid: c783556dfa214e73b676ca187648c5df
          name: 'Database availability'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
        - uuid: bc3b08ca201d438689678a29e3575823
          name: 'Instance state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Suspended
            - value: '2'
              newvalue: Runnable
            - value: '3'
              newvalue: 'Pending create'
            - value: '4'
              newvalue: Maintenance
            - value: '5'
              newvalue: Failed
            - value: '6'
              newvalue: 'Unknown state'
            - value: '10'
              newvalue: 'Data retrievement error'
    - uuid: b43a7c5f1d1d43d28e2eb8f0a9f6f16f
      template: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
      name: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
      description: |
        Get GCP Cloud SQL PostgreSQL  monitoring for read-only replicas with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: c67dd812c7784948bad5dfa0d9a6cc66
          name: 'Flush location lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.flush_location
          units: B
          description: 'Flush location replication lag in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.flush_location
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 2b8b51f0266049ffbfb7ece2f944fb68
          name: 'Number of log archival failures'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.log_archive_failure_count
          description: 'Number of failed attempts for archiving replication log files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.log_archive_failure_count
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 4657c4bb904b437598b68410e47f7194
          name: 'Number of log archival successes'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.log_archive_success_count
          description: 'Number of failed attempts for archiving replication log files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.log_archive_success_count
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: cb9c5aff913e4deeb29dfa1a20b5ff04
          name: 'Replica metrics get'
          type: SCRIPT
          key: gcp.cloudsql.pgsql.repl.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/replication/',
            	pgsql_path = 'cloudsql.googleapis.com/database/postgresql/replication/',
            	obj = {},
            	base_paths = ['network_lag', 'replica_lag', 'log_archive_failure_count', 'log_archive_success_count'];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            var params = checkParams(JSON.parse(value)),
            	filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	metric_raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
            	metric_keys = getField(metric_raw, 'timeSeriesDescriptor.pointDescriptors'),
            	metric_values = getField(metric_raw, 'timeSeriesData.0.pointData.0.values'),
            	re = /(^t_\d+\.value\.)/g;
            
            for (i in metric_keys) {
            	var value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            	for (v in value_types) {
            		if (typeof metric_values[i][value_types[v]] !== 'undefined') {
            			obj[getField(metric_keys[i], 'key').replace(re, '')] = metric_values[i][value_types[v]];
            		}
            	}
            }
            
            var state_raw = getHttpData(url, params.token, { query: base_path + 'state' + filter }),
            	state_keys = getField(state_raw, 'timeSeriesDescriptor.pointDescriptors'),
            	state_tsd = getField(state_raw, 'timeSeriesData');
            
            for (i in state_keys) {
            	var state_key = getField(state_keys[i], 'key').replace(/value\./g, '');
            
            	obj[state_key] = 'undefined';
            	for (t in state_tsd) {
            		if (getField(state_tsd[t], 'pointData.0.values.' + i + '.boolValue') == true) {
            			obj[state_key] = getField(state_tsd[t], 'labelValues.3.stringValue');
            			break;
            		}
            	}
            }
            
            var lag_raw = getHttpData(url, params.token, { query: pgsql_path + 'replica_byte_lag' + '| within ' + params.time_window + " | filter replica_name = '" + params.database_id + "'" }),
            	lag_tsd = getField(lag_raw, 'timeSeriesData');
            
            for (t in lag_tsd) {
            	obj[getField(lag_tsd[t], 'labelValues.3.stringValue')] = getField(lag_tsd[t], 'pointData.0.values.0.int64Value');
            }
            
            return JSON.stringify(obj);
          description: 'PostgreSQL replica metrics data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: e43272210c45425d871d70a5bb91cdd1
          name: 'Network lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.network_lag
          units: s
          description: 'Indicates time taken from primary binary log to IO thread on replica.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.network_lag
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 7d74736aa2804c899de35634bc072edf
          name: 'Replay location lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.replay_location
          units: B
          description: 'Replay location replication lag in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.replay_location
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 192e0bb3ac744f8eb38a760ee3f7c623
          name: 'Replication lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.replica_lag
          units: s
          description: 'Number of seconds the read replica is behind its primary (approximation).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.replica_lag
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 379c8bc0cfe847d1819ab96aceee5efe
          name: 'Sent location lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.sent_location
          units: B
          description: 'Sent location replication lag in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.sent_location
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: a7f785dbe4954d77a82e6384620b5d6e
          name: 'Replication state'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.state
          description: |
            The current serving state of replication.
            This metric is only available for the MySQL/PostgreSQL instances.
          valuemap:
            name: 'Replication state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.state
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'Running',
                  	'Syncing',
                  	'Unsynced',
                  	'Stopped',
                  	'Error',
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
            - tag: component
              value: status
        - uuid: 10af15bc71ed446eb4e614c2cb6029d5
          name: 'Write location lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.write_location
          units: B
          description: 'Write location replication lag in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.write_location
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: postgresql
        - tag: target
          value: replica
      macros:
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'A response timeout for an API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for the data requests.
            Supported usage type:
            1. The default update interval for most of the items.
            2. The minimal time window for the data requested in the Monitoring Query Language REST API request.
      dashboards:
        - uuid: acb71f4a818d43e0b045ba87c2daa989
          name: 'PostgreSQL replica'
          pages:
            - name: 'PostgreSQL replica'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: WAL archiving'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Lags'
                    - type: STRING
                      name: reference
                      value: AAAAB
      valuemaps:
        - uuid: af111e6b9e5a47cd9c3933b8ce35076c
          name: 'Replication state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Syncing
            - value: '2'
              newvalue: Unsynced
            - value: '3'
              newvalue: Stopped
            - value: '4'
              newvalue: Error
            - value: '10'
              newvalue: Unknown
    - 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.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 3de05ba490644a62ba4a700ffe439c98
          name: 'Guest visible vCPUs'
          type: DEPENDENT
          key: gcp.gce.cpu.guest_visible_vcpus
          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
          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
          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
          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
          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
          params: |
            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 request = new HttpRequest();
            	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: 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
          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
          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
          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
          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
          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
          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
          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
          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
          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
          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
          params: |
            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 request = new HttpRequest();
            	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: 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
          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
          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
          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
          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
          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
          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
          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
          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
          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
          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
          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
          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
          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
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GCE.DISK.DEV_TYPE}'
                value: '{$GCE.DISK.DEV_TYPE.MATCHES}'
              - macro: '{#GCE.DISK.DEV_TYPE}'
                value: '{$GCE.DISK.DEV_TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#GCE.DISK.NAME}'
                value: '{$GCE.DISK.NAME.MATCHES}'
              - macro: '{#GCE.DISK.NAME}'
                value: '{$GCE.DISK.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#GCE.DISK.STOR_TYPE}'
                value: '{$GCE.DISK.STOR_TYPE.MATCHES}'
              - macro: '{#GCE.DISK.STOR_TYPE}'
                value: '{$GCE.DISK.STOR_TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          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}]'
              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}]'
              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}]'
              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}]'
              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}]'
              history: '0'
              value_type: TEXT
              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: subclass
          value: automation
        - tag: subclass
          value: computing
        - 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.'
      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
    - uuid: 178645e229484bcf9cb030dc1edccebb
      template: 'Oracle Cloud Autonomous Database by HTTP'
      name: 'Oracle Cloud Autonomous Database by HTTP'
      description: |
        This template monitors Oracle Cloud Infrastructure (OCI) autonomous database (serverless) resources.
        
        This template is not meant to be used independently, but together with Oracle Cloud by HTTP as a template for
        LLD host prototypes.
        
        Read the template documentation prior to using this 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.4-3
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 8520813edccc4fb9ba975c27914c5633
          name: 'Database availability'
          type: DEPENDENT
          key: oci.aut.db.availability
          value_type: FLOAT
          description: 'The database is available for connections in the given minute.'
          valuemap:
            name: 'Database availability'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.DatabaseAvailability
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 5h
          master_item:
            key: oci.aut.db.metrics.stats
          tags:
            - tag: component
              value: environment
          triggers:
            - uuid: 21b1a5c7d7754eb6be30098b2df99a22
              expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.availability) = 0'
              name: 'OCI Autonomous DB: Database is not available'
              priority: HIGH
              description: 'Autonomous database is not available.'
              dependencies:
                - name: 'OCI Autonomous DB: Database is not available or accessible'
                  expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 19 or last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 20'
              tags:
                - tag: scope
                  value: availability
        - uuid: 038c4b2c000747799b60cb074aebbce5
          name: 'DB block changes'
          type: DEPENDENT
          key: oci.aut.db.block.changes
          description: |
            The number of changes that were part of an update or delete operation that were made to all blocks in the SGA.
            
            Such changes generate redo log entries and thus become permanent changes to the database if
            the transaction is committed.
            
            This statistic approximates total database work and indicates the rate at which buffers are being dirtied
            during the selected time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.DBBlockChanges
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: a471a74943b24a4a81347404e37b7359
          name: 'Failed connections'
          type: DEPENDENT
          key: oci.aut.db.conn.failed
          description: 'The number of failed database connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.FailedConnections
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: cc1244e911314e9aaa6a995636848809
          name: 'CPU time'
          type: DEPENDENT
          key: oci.aut.db.cpu.time
          value_type: FLOAT
          description: 'Average rate of accumulation of CPU time by foreground sessions in the database over the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.CpuTime
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: cpu
        - uuid: da165d0adf324b9e98390d122925fd67
          name: 'CPU utilization, in %'
          type: DEPENDENT
          key: oci.aut.db.cpu.util
          value_type: FLOAT
          units: '%'
          description: |
            The CPU usage expressed as a percentage, aggregated across all consumer groups.
            The utilization percentage is reported with respect to the number of CPUs the database is allowed to use.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.CpuUtilization
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 59fd2d0eff9f4f5493cd0de94ba57572
              expression: 'min(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.cpu.util,5m) >= {$OCI.AUTONOMOUS.DB.CPU.UTIL.WARN}'
              name: 'OCI Autonomous DB: Current CPU utilization is high'
              event_name: 'OCI Autonomous DB: Current CPU utilization is high (util >= {$OCI.AUTONOMOUS.DB.CPU.UTIL.WARN}%)'
              opdata: 'Current: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'Current CPU utilization has exceeded `{$OCI.AUTONOMOUS.DB.CPU.UTIL.WARN}`% of the max available value.'
              dependencies:
                - name: 'OCI Autonomous DB: Current CPU utilization is too high'
                  expression: 'min(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.cpu.util,5m) >= {$OCI.AUTONOMOUS.DB.CPU.UTIL.HIGH}'
              tags:
                - tag: scope
                  value: capacity
            - uuid: f8a53ef11d2140649bc701660183c33d
              expression: 'min(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.cpu.util,5m) >= {$OCI.AUTONOMOUS.DB.CPU.UTIL.HIGH}'
              name: 'OCI Autonomous DB: Current CPU utilization is too high'
              event_name: 'OCI Autonomous DB: Current CPU utilization is too high (util >= {$OCI.AUTONOMOUS.DB.CPU.UTIL.HIGH}%)'
              opdata: 'Current: {ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'Current CPU utilization has exceeded `{$OCI.AUTONOMOUS.DB.CPU.UTIL.HIGH}`% of the max available value.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 47708f3446644bbc9afd11bd0e98d1f5
          name: 'Execute count'
          type: DEPENDENT
          key: oci.aut.db.exec.count
          description: 'The number of user and recursive calls that executed SQL statements during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ExecuteCount
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 4a1af0cbea8645cc897d64e3c1ac802e
          name: 'Connection latency'
          type: DEPENDENT
          key: oci.aut.db.latency.conn
          value_type: FLOAT
          units: s
          description: |
            The time taken to connect to an Oracle Autonomous Database Serverless instance in each region
            from a Compute service virtual machine in the same region.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ConnectionLatency
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 5h
          master_item:
            key: oci.aut.db.metrics.stats
          tags:
            - tag: component
              value: environment
        - uuid: e233b1ab82384297b9ee88556969da31
          name: 'Query latency'
          type: DEPENDENT
          key: oci.aut.db.latency.query
          value_type: FLOAT
          units: s
          description: 'The time taken to display the results of a simple query on the user''s screen.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.QueryLatency
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 5h
          master_item:
            key: oci.aut.db.metrics.stats
          tags:
            - tag: component
              value: environment
        - uuid: b39b36b4a72b4cbf80584614c3d996ed
          name: 'Session logical reads'
          type: DEPENDENT
          key: oci.aut.db.logical.reads.session
          description: |
            The sum of `db block gets` and `consistent gets` during the selected time interval.
            This includes logical reads of database blocks from either the buffer cache or process private memory.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.LogicalReads
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 27b77344e5fc473693e48eb676ceb746
          name: 'Current logons'
          type: DEPENDENT
          key: oci.aut.db.logons
          description: 'The number of successful logons during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.CurrentLogons
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: f4c0af10cea04decbb049c02f06795e4
          name: 'Failed logons'
          type: DEPENDENT
          key: oci.aut.db.logons.failed
          value_type: FLOAT
          description: |
            The number of logons that failed because of an invalid user name and/or password
            during the selected time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.FailedLogons
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 6104537179324cb48d82e05d64f3a19f
          name: 'Get frequent metrics'
          type: SCRIPT
          key: oci.aut.db.metrics.frequent.get
          history: '0'
          value_type: TEXT
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            function buildMql(id, metrics, defaultStatistic, resourceType) {
            	resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType;
            	this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.';
            
            	for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            		const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic]));
            		metrics[i] = [metric[0], this.query + metric[1]];
            	}
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'db_id', 'http_status_code', 'req_interval', 'compartment_id'], params);
            var oci = new OCI('Autonomous DB', 'Get metrics ' + params['req_interval'] + 'm', params);
            
            const metrics = [
            	['CpuTime', 'mean'],
            	['CpuUtilization', 'mean'],
            	['CurrentLogons', 'count'],
            	'DBBlockChanges',
            	['DBTime', 'mean'],
            	'ExecuteCount',
            	'FailedConnections',
            	['FailedLogons', 'mean'],
            	'HardParseCount',
            	'LogicalReads',
            	'ParseCount',
            	'ParseFailureCount',
            	'PhysicalReads',
            	'PhysicalReadTotalBytes',
            	'PhysicalWrites',
            	'PhysicalWriteTotalBytes',
            	'QueuedStatements',
            	'RedoGenerated',
            	['RunningStatements', 'mean'],
            	'Sessions',
            	'SQLNetBytesFromClient',
            	'SQLNetBytesFromDBLink',
            	'SQLNetBytesToClient',
            	'SQLNetBytesToDBLink',
            	'TransactionCount',
            	'UserCalls',
            	'UserCommits',
            	'UserRollbacks',
            	['WaitTime', 'mean']
            ];
            buildMql(params['db_id'], metrics, 'sum');
            
            var result = {};
            for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            	result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_autonomous_database'), 'aggregatedDatapoints');
            }
            return JSON.stringify(result);
          description: 'Gets all metrics related to the database that have a collection frequency of 1 minute.'
          timeout: 30s
          parameters:
            - name: api_host
              value: '{$OCI.API.TELEMETRY.HOST}'
            - name: compartment_id
              value: '{$OCI.AUTONOMOUS.DB.COMPARTMENT.ID}'
            - name: db_id
              value: '{$OCI.AUTONOMOUS.DB.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: req_interval
              value: '1'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: raw
        - uuid: 87a25240776a4b8a9a17ac053b69fd99
          name: 'Get database stats'
          type: SCRIPT
          key: oci.aut.db.metrics.stats
          delay: 5m
          history: '0'
          value_type: TEXT
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            function buildMql(id, metrics, defaultStatistic, resourceType) {
            	resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType;
            	this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.';
            
            	for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            		const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic]));
            		metrics[i] = [metric[0], this.query + metric[1]];
            	}
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'db_id', 'http_status_code', 'req_interval', 'compartment_id'], params);
            var oci = new OCI('Autonomous DB', 'Get metrics ' + params['req_interval'] + 'm', params);
            
            const metrics = [
            	['DatabaseAvailability', 'last'],
            	'ConnectionLatency',
            	'QueryLatency'
            ];
            buildMql(params['db_id'], metrics, 'max');
            
            var result = {};
            for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            	result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_autonomous_database'), 'aggregatedDatapoints');
            }
            return JSON.stringify(result);
          description: 'Gets all metrics related to specific database that have a collection frequency of 5 minutes.'
          timeout: 30s
          parameters:
            - name: api_host
              value: '{$OCI.API.TELEMETRY.HOST}'
            - name: compartment_id
              value: '{$OCI.AUTONOMOUS.DB.COMPARTMENT.ID}'
            - name: db_id
              value: '{$OCI.AUTONOMOUS.DB.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: req_interval
              value: '5'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: raw
        - uuid: cb2936c594e4450096559b3023f6aa4f
          name: 'Get storage stats'
          type: SCRIPT
          key: oci.aut.db.metrics.storage.stats
          delay: 60m
          history: '0'
          value_type: TEXT
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            function buildMql(id, metrics, defaultStatistic, resourceType) {
            	resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType;
            	this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.';
            
            	for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            		const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic]));
            		metrics[i] = [metric[0], this.query + metric[1]];
            	}
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'db_id', 'http_status_code', 'req_interval', 'compartment_id'], params);
            var oci = new OCI('Autonomous DB', 'Get metrics ' + params['req_interval'] + 'm', params);
            
            const metrics = [
            	'StorageAllocated',
            	'StorageMax',
            	'StorageUsed',
            	['StorageUtilization', 'mean']
            ];
            buildMql(params['db_id'], metrics, 'max');
            
            var result = {};
            for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            	result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_autonomous_database'), 'aggregatedDatapoints');
            }
            return JSON.stringify(result);
          description: 'Gets all storage metrics related to a specific database that have a collection frequency of 60 minutes.'
          timeout: 30s
          parameters:
            - name: api_host
              value: '{$OCI.API.TELEMETRY.HOST}'
            - name: compartment_id
              value: '{$OCI.AUTONOMOUS.DB.COMPARTMENT.ID}'
            - name: db_id
              value: '{$OCI.AUTONOMOUS.DB.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: req_interval
              value: '60'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: raw
        - uuid: 8ca09dafd8a744489ac122d995367a76
          name: 'Parse count (failures)'
          type: DEPENDENT
          key: oci.aut.db.parse.count.failed
          description: 'The number of parse failures during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ParseFailureCount
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 0f052e0dd75d4ae190c3b87581e29136
          name: 'Parse count (hard)'
          type: DEPENDENT
          key: oci.aut.db.parse.count.hard
          description: |
            The number of parse calls (real parses) during the selected time interval.
            A hard parse is an expensive operation in terms of memory use as it requires Oracle to allocate a
            workheap and other memory structures and then build a parse tree.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.HardParseCount
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: d5097f4c85ee40608ca8096f1d5f81c1
          name: 'Parse count (total)'
          type: DEPENDENT
          key: oci.aut.db.parse.count.total
          description: 'The number of hard and soft parses during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ParseCount
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: db1b10f32442428b89a0437176b94906
          name: 'Physical read total bytes'
          type: DEPENDENT
          key: oci.aut.db.physical.read.bytes
          units: B
          description: |
            The size in bytes of disk reads by all database instance activity including
            application reads, backup and recovery, and other utilities during the selected time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.PhysicalReadTotalBytes
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: a0e9f2b67c364a8baecc611ff1637399
          name: 'Physical reads'
          type: DEPENDENT
          key: oci.aut.db.physical.reads
          description: 'The number of data blocks read from disk during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.PhysicalReads
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 81f85ed2baa44bb3a0b05255cc866c3e
          name: 'Physical write total bytes'
          type: DEPENDENT
          key: oci.aut.db.physical.write.bytes
          units: B
          description: |
            The size in bytes of all disk writes for the database instance including
            application activity, backup and recovery, and other utilities during the selected time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.PhysicalWriteTotalBytes
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 2b9998f8dd7d493496146d10fff0a5ee
          name: 'Physical writes'
          type: DEPENDENT
          key: oci.aut.db.physical.writes
          description: 'The number of data blocks written to disk during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.PhysicalWrites
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 2acac07f1c30472a84b8864a6cfa7985
          name: 'Queued statements'
          type: DEPENDENT
          key: oci.aut.db.queued.statements
          description: 'The number of queued SQL statements aggregated across all consumer groups during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.QueuedStatements
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 0f79764cca3f45688d79bb79c762ef99
          name: 'Redo generated'
          type: DEPENDENT
          key: oci.aut.db.redo.gen
          description: 'Amount of redo generated in bytes during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.RedoGenerated
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 11ca43167a374fe99eab91817957a3fb
          name: Sessions
          type: DEPENDENT
          key: oci.aut.db.sessions
          description: 'The number of sessions in the database.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Sessions
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: a71a6114736f4ce89425ed8de504140d
          name: 'Bytes received via SQL*Net from client'
          type: DEPENDENT
          key: oci.aut.db.sqlnet.bytes.recv.client
          units: B
          description: 'The number of bytes received from the client over Oracle Net Services during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.SQLNetBytesFromClient
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: a1555ae851e1432c94169e430a782c7d
          name: 'Bytes received via SQL*Net from DBLink'
          type: DEPENDENT
          key: oci.aut.db.sqlnet.bytes.recv.dblink
          units: B
          description: 'The number of bytes received from a database link over Oracle Net Services during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.SQLNetBytesFromDBLink
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 35cdcf2b736745708910f2389a64670d
          name: 'Bytes sent via SQL*Net to client'
          type: DEPENDENT
          key: oci.aut.db.sqlnet.bytes.sent.client
          units: B
          description: 'The number of bytes sent to the client from the foreground processes during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.SQLNetBytesToClient
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 5cc3975e76a842b89a7c6d2ac5108b8c
          name: 'Bytes sent via SQL*Net to DBLink'
          type: DEPENDENT
          key: oci.aut.db.sqlnet.bytes.sent.dblink
          units: B
          description: 'The number of bytes sent over a database link during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.SQLNetBytesToDBLink
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 48d69be6970c41fcb110f18e18ff6387
          name: State
          type: SCRIPT
          key: oci.aut.db.state
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'db_id', 'http_status_code'], params);
            var oci = new OCI('Autonomous DB', 'Get state', params);
            
            return oci.extractData('get', oci.executeRequest('get', '/20160918/autonomousDatabases/' + encodeURIComponent(params['db_id']), ''), 'lifecycleState');
          description: 'Gets the autonomous database state.'
          valuemap:
            name: 'Autonomous database state'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = {
                  	'PROVISIONING': 1,
                  	'AVAILABLE': 2,
                  	'STOPPING': 3,
                  	'STOPPED': 4,
                  	'STARTING': 5,
                  	'TERMINATING': 6,
                  	'TERMINATED': 7,
                  	'RESTORE_IN_PROGRESS': 8,
                  	'RESTORE_FAILED': 9,
                  	'BACKUP_IN_PROGRESS': 10,
                  	'SCALE_IN_PROGRESS': 11,
                  	'AVAILABLE_NEEDS_ATTENTION': 12,
                  	'UPDATING': 13,
                  	'MAINTENANCE_IN_PROGRESS': 14,
                  	'RESTARTING': 15,
                  	'RECREATING': 16,
                  	'ROLE_CHANGE_IN_PROGRESS': 17,
                  	'UPGRADING': 18,
                  	'UNAVAILABLE': 19,
                  	'INACCESSIBLE': 20,
                  	'STANDBY': 21
                  };
                  
                  return typeof idx[value] === 'undefined' ? 0 : idx[value];
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.AUTONOMOUS.DB.HOST}'
            - name: db_id
              value: '{$OCI.AUTONOMOUS.DB.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: environment
          triggers:
            - uuid: bb790262359f4e35af895b1a69ad511c
              expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 12'
              name: 'OCI Autonomous DB: Available, needs attention'
              priority: WARNING
              description: 'Autonomous database is available, but needs attention.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 18594a88549843c498d0e037f51afc59
              expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 19 or last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 20'
              name: 'OCI Autonomous DB: Database is not available or accessible'
              priority: HIGH
              description: 'Autonomous database is not available or accessible.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 4ee1a96f29ef461c8830667e19637911
              expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 9'
              name: 'OCI Autonomous DB: Restore has failed'
              priority: WARNING
              description: 'Autonomous database restore has failed.'
              tags:
                - tag: scope
                  value: notice
            - uuid: 783550ed705944259190fb10dae3f5a8
              expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state,#1)<>last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state,#2)'
              name: 'OCI Autonomous DB: State has changed'
              event_name: 'OCI Autonomous DB: State has changed (new state: {ITEM.VALUE})'
              opdata: 'Current state: {ITEM.LASTVALUE}'
              priority: INFO
              description: 'Autonomous database state has changed.'
              manual_close: 'YES'
              dependencies:
                - name: 'OCI Autonomous DB: Available, needs attention'
                  expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 12'
                - name: 'OCI Autonomous DB: Database is not available or accessible'
                  expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 19 or last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 20'
                - name: 'OCI Autonomous DB: Restore has failed'
                  expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 9'
                - name: 'OCI Autonomous DB: State unknown'
                  expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 0'
              tags:
                - tag: scope
                  value: notice
            - uuid: 2bc79a5a19a544d39c6de861b94564af
              expression: 'last(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.state) = 0'
              name: 'OCI Autonomous DB: State unknown'
              priority: WARNING
              description: 'Autonomous database state is unknown.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 6111b1843fe94fefbf1ca1d530832d39
          name: 'Running statements'
          type: DEPENDENT
          key: oci.aut.db.statements.running
          value_type: FLOAT
          description: 'The number of running SQL statements aggregated across all consumer groups during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.RunningStatements
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 7901279fcb2a4f6285874680ed5f55f5
          name: 'Storage space allocated'
          type: DEPENDENT
          key: oci.aut.db.storage.space.alloc
          value_type: FLOAT
          units: B
          description: 'Amount of space allocated to the database for all tablespaces during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.StorageAllocated
            - type: MULTIPLIER
              parameters:
                - '1073741824'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: oci.aut.db.metrics.storage.stats
          tags:
            - tag: component
              value: storage
        - uuid: 9dd27df012b24019ad2562822b471a25
          name: 'Maximum storage space'
          type: DEPENDENT
          key: oci.aut.db.storage.space.max
          value_type: FLOAT
          units: B
          description: 'Maximum amount of storage reserved for the database during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.StorageMax
            - type: MULTIPLIER
              parameters:
                - '1073741824'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: oci.aut.db.metrics.storage.stats
          tags:
            - tag: component
              value: storage
        - uuid: e5378b6a3d33462eb4f3ed6228532d10
          name: 'Storage space used'
          type: DEPENDENT
          key: oci.aut.db.storage.space.used
          value_type: FLOAT
          units: B
          description: 'Maximum amount of space used during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.StorageUsed
            - type: MULTIPLIER
              parameters:
                - '1073741824'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: oci.aut.db.metrics.storage.stats
          tags:
            - tag: component
              value: storage
        - uuid: 5cad114ed74341199a4d3ef17c9acd8e
          name: 'Storage utilization, in %'
          type: DEPENDENT
          key: oci.aut.db.storage.space.util
          value_type: FLOAT
          units: '%'
          description: |
            The percentage of the reserved maximum storage currently allocated for all database tablespaces.
            Represents the total reserved space for all tablespaces.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.StorageUtilization
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: oci.aut.db.metrics.storage.stats
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 37bb41d830424ba2871e768957225add
              expression: 'min(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.storage.space.util,5m) >= {$OCI.AUTONOMOUS.DB.STORAGE.UTIL.WARN}'
              name: 'OCI Autonomous DB: Current storage utilization is high'
              event_name: 'OCI Autonomous DB: Current storage utilization is high (util >= {$OCI.AUTONOMOUS.DB.STORAGE.UTIL.WARN}%)'
              opdata: 'Current: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'Current storage utilization has exceeded `{$OCI.AUTONOMOUS.DB.STORAGE.UTIL.WARN}`% of the max available value.'
              dependencies:
                - name: 'OCI Autonomous DB: Current storage utilization is too high'
                  expression: 'min(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.storage.space.util,5m) >= {$OCI.AUTONOMOUS.DB.STORAGE.UTIL.HIGH}'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 8e16451106094713abaa624967026dc3
              expression: 'min(/Oracle Cloud Autonomous Database by HTTP/oci.aut.db.storage.space.util,5m) >= {$OCI.AUTONOMOUS.DB.STORAGE.UTIL.HIGH}'
              name: 'OCI Autonomous DB: Current storage utilization is too high'
              event_name: 'OCI Autonomous DB: Current storage utilization is too high (util >= {$OCI.AUTONOMOUS.DB.STORAGE.UTIL.HIGH}%)'
              opdata: 'Current: {ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'Current storage utilization has exceeded `{$OCI.AUTONOMOUS.DB.STORAGE.UTIL.HIGH}`% of the max available value.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 3455978b6e2a4291984bf1e7c95551e1
          name: 'DB time'
          type: DEPENDENT
          key: oci.aut.db.time
          value_type: FLOAT
          description: |
            The amount of time database user sessions spend executing database code (CPU time + wait time).
            Database time is used to infer database call latency as it increases in direct proportion
            to both database call latency (response time) and call volume.
            
            It is calculated as the average rate of accumulation of database time by foreground sessions in
            the database over the selected time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.DBTime
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 35995e92de8e45b0a8493bc285ccd0c8
          name: 'Transaction count'
          type: DEPENDENT
          key: oci.aut.db.transaction.count
          description: 'The combined number of user commits and user rollbacks during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.TransactionCount
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 3e1cd8b4c829451499d605512e1a1bf0
          name: 'User calls'
          type: DEPENDENT
          key: oci.aut.db.user.calls
          description: 'The combined number of logons, parses, and execute calls during the selected time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.UserCalls
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 0cda6a956ca1476da28083cfc6de8bcc
          name: 'User commits'
          type: DEPENDENT
          key: oci.aut.db.user.commits
          description: |
            The number of user commits during the selected time interval.
            When a user commits a transaction, the generated redo that reflects the changes made to database
            blocks must be written to disk. Commits often represent the closest thing to a user transaction rate.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.UserCommits
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 99292418f1764484b1cda27b70af84cc
          name: 'User rollbacks'
          type: DEPENDENT
          key: oci.aut.db.user.rollbacks
          description: |
            Number of times users manually issue the `ROLLBACK` statement or an error occurs during a user's
            transactions during the selected time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.UserRollbacks
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
        - uuid: 8f627c48a0a94e41ad1b66d7a4817898
          name: 'Wait time'
          type: DEPENDENT
          key: oci.aut.db.wait.time
          value_type: FLOAT
          description: |
            Average rate of accumulation of non-idle wait time by foreground sessions in the database over the selected
            time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.WaitTime
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.aut.db.metrics.frequent.get
          tags:
            - tag: component
              value: environment
      tags:
        - tag: class
          value: cloud
        - tag: class
          value: database
        - tag: subclass
          value: automation
        - tag: subclass
          value: bigdata
        - tag: subclass
          value: deploy
        - tag: target
          value: oci
        - tag: target
          value: oracle-cloud-infrastructure
      macros:
        - macro: '{$OCI.AUTONOMOUS.DB.CPU.UTIL.HIGH}'
          value: '90'
          description: 'Sets the percentage threshold for creating a "high" severity event about CPU resource utilization.'
        - macro: '{$OCI.AUTONOMOUS.DB.CPU.UTIL.WARN}'
          value: '75'
          description: 'Sets the percentage threshold for creating a "warning" severity event about CPU resource utilization.'
        - macro: '{$OCI.AUTONOMOUS.DB.STORAGE.UTIL.HIGH}'
          value: '90'
          description: 'Sets the percentage threshold for creating a "high" severity event about storage resource utilization.'
        - macro: '{$OCI.AUTONOMOUS.DB.STORAGE.UTIL.WARN}'
          value: '75'
          description: 'Sets the percentage threshold for creating a "warning" severity event about storage resource utilization.'
        - macro: '{$OCI.HTTP.PROXY}'
          description: 'Set an HTTP proxy for OCI API requests if needed.'
        - macro: '{$OCI.HTTP.RETURN.CODE.OK}'
          value: '200'
          description: 'Set the HTTP return code that represents an OK response from the API. The default is "200",  but can vary, for example, if a proxy is used.'
      dashboards:
        - uuid: 26fb1668002c42e2b311eaef5850f2ad
          name: 'OCI Autonomous DB: Overview'
          pages:
            - name: Main
              display_period: '30'
              widgets:
                - type: item
                  name: State
                  width: '27'
                  height: '4'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: STRING
                      name: description
                      value: 'Current State'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.state
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_size
                      value: '35'
                - type: graph
                  name: 'CPU utilization'
                  'y': '4'
                  width: '21'
                  height: '7'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: CPU utilization'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'Storage stats'
                  x: '21'
                  'y': '4'
                  width: '21'
                  height: '7'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Storage stats'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: item
                  name: Availability
                  x: '27'
                  width: '15'
                  height: '4'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: STRING
                      name: description
                      value: Availability
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.availability
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_size
                      value: '20'
                - type: item
                  name: 'Connection latency'
                  x: '42'
                  width: '30'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: INTEGER
                      name: decimal_size
                      value: '60'
                    - type: STRING
                      name: description
                      value: 'Connection latency'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_size
                      value: '30'
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.latency.conn
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '40'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_size
                      value: '60'
                - type: gauge
                  name: 'CPU utilization'
                  x: '42'
                  'y': '2'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: STRING
                      name: description
                      value: CPU
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: STRING
                      name: empty_color
                      value: 145C96
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.cpu.util
                    - type: STRING
                      name: max
                      value: '100'
                    - type: STRING
                      name: min
                      value: '0'
                    - type: INTEGER
                      name: rf_rate
                      value: '30'
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: show.2
                      value: '5'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_bold
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: STRING
                      name: value_arc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_arc_size
                      value: '35'
                    - type: INTEGER
                      name: value_bold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: Sessions
                  x: '42'
                  'y': '5'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: Sessions
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.sessions
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Running statements'
                  x: '42'
                  'y': '8'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Running Statements'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.statements.running
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: gauge
                  name: 'Storage utilization'
                  x: '57'
                  'y': '2'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: STRING
                      name: description
                      value: 'Storage Utilization'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: STRING
                      name: empty_color
                      value: 00701c
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.storage.space.util
                    - type: STRING
                      name: max
                      value: '100'
                    - type: STRING
                      name: min
                      value: '0'
                    - type: INTEGER
                      name: rf_rate
                      value: '30'
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: show.2
                      value: '5'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_bold
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: STRING
                      name: value_arc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_arc_size
                      value: '35'
                    - type: INTEGER
                      name: value_bold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Execute count'
                  x: '57'
                  'y': '5'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Execute Count'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.exec.count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Queued statements'
                  x: '57'
                  'y': '8'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Queued Statements'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.queued.statements
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
            - name: CPU
              display_period: '30'
              widgets:
                - type: gauge
                  name: 'CPU utilization'
                  width: '36'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: STRING
                      name: description
                      value: CPU
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: STRING
                      name: empty_color
                      value: 145C96
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.cpu.util
                    - type: STRING
                      name: max
                      value: '100'
                    - type: STRING
                      name: min
                      value: '0'
                    - type: INTEGER
                      name: rf_rate
                      value: '30'
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: show.2
                      value: '5'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_bold
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: STRING
                      name: value_arc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_arc_size
                      value: '35'
                    - type: INTEGER
                      name: value_bold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'CPU utilization'
                  'y': '3'
                  width: '36'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: CPU utilization'
                    - type: STRING
                      name: reference
                      value: ABAAA
                - type: gauge
                  name: 'CPU time'
                  x: '36'
                  width: '36'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: STRING
                      name: description
                      value: 'CPU Time'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: STRING
                      name: empty_color
                      value: 145C96
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.cpu.util
                    - type: STRING
                      name: max
                      value: '100'
                    - type: STRING
                      name: min
                      value: '0'
                    - type: INTEGER
                      name: rf_rate
                      value: '30'
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: show.2
                      value: '5'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_bold
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: STRING
                      name: value_arc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_arc_size
                      value: '35'
                    - type: INTEGER
                      name: value_bold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'CPU time'
                  x: '36'
                  'y': '3'
                  width: '36'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: CPU time'
                    - type: STRING
                      name: reference
                      value: ABAAB
            - name: Storage
              display_period: '30'
              widgets:
                - type: gauge
                  name: 'Storage utilization'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: STRING
                      name: description
                      value: 'Storage Utilization'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: STRING
                      name: empty_color
                      value: 00701c
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.storage.space.util
                    - type: STRING
                      name: max
                      value: '100'
                    - type: STRING
                      name: min
                      value: '0'
                    - type: INTEGER
                      name: rf_rate
                      value: '30'
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: show.2
                      value: '5'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_bold
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: STRING
                      name: value_arc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_arc_size
                      value: '35'
                    - type: INTEGER
                      name: value_bold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Storage utilization'
                  'y': '3'
                  width: '18'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Storage utilization'
                    - type: STRING
                      name: reference
                      value: ACAAA
                - type: item
                  name: 'Max storage space'
                  x: '18'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Max storage space'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.storage.space.max
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Storage stats'
                  x: '18'
                  'y': '3'
                  width: '54'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Storage stats'
                    - type: STRING
                      name: reference
                      value: ACAAB
                - type: item
                  name: 'Allocated Storage Space'
                  x: '36'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Allocated Storage Space'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.storage.space.alloc
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Used storage space'
                  x: '54'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Used Storage Space'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.storage.space.used
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
            - name: Read/Writes
              display_period: '30'
              widgets:
                - type: item
                  name: 'Physical reads'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Physical Reads'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.physical.reads
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: Read/writes
                  'y': '3'
                  width: '27'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Physical reads/writes'
                    - type: STRING
                      name: reference
                      value: ADAAA
                - type: item
                  name: 'Physical writes'
                  x: '15'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Physical Writes'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.physical.writes
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Physical read total bytes'
                  x: '27'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Physical Read Total Bytes'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.physical.read.bytes
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Physical total read/write bytes'
                  x: '27'
                  'y': '3'
                  width: '27'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Physical read/write total bytes'
                    - type: STRING
                      name: reference
                      value: ADAAB
                - type: item
                  name: 'Physical write total bytes'
                  x: '42'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Physical Write Total Bytes'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.physical.write.bytes
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Logical reads session'
                  x: '54'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Logical Reads Session'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.logical.reads.session
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Logical reads session'
                  x: '54'
                  'y': '3'
                  width: '18'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Session logical reads'
                    - type: STRING
                      name: reference
                      value: ADAAC
                    - type: INTEGER
                      name: show_legend
                      value: '0'
            - name: Sessions
              display_period: '30'
              widgets:
                - type: item
                  name: Sessions
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: Sessions
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.sessions
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Failed connections'
                  'y': '3'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FF0000
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Failed Connections'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.conn.failed
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Session stats'
                  'y': '6'
                  width: '30'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Session stats'
                    - type: STRING
                      name: reference
                      value: AEAAA
                - type: item
                  name: Logons
                  x: '15'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: Logons
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.logons
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Failed logons'
                  x: '15'
                  'y': '3'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FF0000
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Failed Logons'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.logons.failed
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Wait time'
                  x: '30'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Wait Time'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.wait.time
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Wait time'
                  x: '30'
                  'y': '3'
                  width: '15'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Wait time'
                    - type: STRING
                      name: reference
                      value: AEAAB
                    - type: INTEGER
                      name: show_legend
                      value: '0'
                - type: item
                  name: 'DB time'
                  x: '45'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'DB Time'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.time
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'DB time'
                  x: '45'
                  'y': '3'
                  width: '15'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: DB time'
                    - type: STRING
                      name: reference
                      value: AEAAC
                    - type: INTEGER
                      name: show_legend
                      value: '0'
                - type: item
                  name: 'Connection latency'
                  x: '60'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Connection Latency'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.latency.conn
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Connection latency'
                  x: '60'
                  'y': '3'
                  width: '12'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Connection latency'
                    - type: STRING
                      name: reference
                      value: AEAAD
                    - type: INTEGER
                      name: show_legend
                      value: '0'
            - name: Users
              display_period: '30'
              widgets:
                - type: item
                  name: 'User calls'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'User Calls'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.user.calls
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'User calls'
                  'y': '3'
                  width: '18'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: User calls'
                    - type: STRING
                      name: reference
                      value: AFAAA
                - type: item
                  name: 'User commits'
                  x: '18'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'User Commits'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.user.commits
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'User commits'
                  x: '18'
                  'y': '3'
                  width: '18'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: User commits'
                    - type: STRING
                      name: reference
                      value: AFAAB
                - type: item
                  name: 'User rollbacks'
                  x: '36'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'User Rollbacks'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.user.rollbacks
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'User rollbacks'
                  x: '36'
                  'y': '3'
                  width: '18'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: User rollbacks'
                    - type: STRING
                      name: reference
                      value: AFAAC
                - type: item
                  name: 'Execute count'
                  x: '54'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Execute Count'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.exec.count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Execute count'
                  x: '54'
                  'y': '3'
                  width: '18'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Execute count'
                    - type: STRING
                      name: reference
                      value: AFAAD
            - name: Parses
              display_period: '30'
              widgets:
                - type: item
                  name: 'Parse count (hard)'
                  width: '24'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Parse Count (Hard)'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.parse.count.hard
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Parse count (hard)'
                  'y': '3'
                  width: '24'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Parse count hard'
                    - type: STRING
                      name: reference
                      value: AGAAA
                - type: item
                  name: 'Parse count (failures)'
                  x: '24'
                  width: '24'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Parse Count (Failures)'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.parse.count.failed
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Parse count (failures)'
                  x: '24'
                  'y': '3'
                  width: '24'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Parse count failures'
                    - type: STRING
                      name: reference
                      value: AGAAB
                - type: item
                  name: 'Parse count (total)'
                  x: '48'
                  width: '24'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Parse Count (Total)'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.parse.count.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Parse count (total)'
                  x: '48'
                  'y': '3'
                  width: '24'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Parse count total'
                    - type: STRING
                      name: reference
                      value: AGAAC
            - name: 'SQL*Net'
              display_period: '30'
              widgets:
                - type: item
                  name: 'Bytes received from client'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Bytes Received From Client'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.sqlnet.bytes.recv.client
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'SQL*Net client bytes'
                  'y': '3'
                  width: '36'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: SQL*Net client bytes'
                    - type: STRING
                      name: reference
                      value: AHAAA
                - type: item
                  name: 'Bytes sent to client'
                  x: '18'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Bytes Sent To Client'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.sqlnet.bytes.sent.client
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Bytes received from DBLink'
                  x: '36'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Bytes Received From DBLink'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.sqlnet.bytes.recv.dblink
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'SQL*Net DBLink bytes'
                  x: '36'
                  'y': '3'
                  width: '36'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: SQL*Net DBLink bytes'
                    - type: STRING
                      name: reference
                      value: AHAAB
                - type: item
                  name: 'Bytes sent to DBLink'
                  x: '54'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Bytes Sent To DBLink'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.sqlnet.bytes.sent.dblink
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
            - name: 'DB Calls'
              display_period: '30'
              widgets:
                - type: item
                  name: 'Query latency'
                  width: '21'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Query Latency'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.latency.query
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Query latency'
                  'y': '3'
                  width: '21'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Query latency'
                    - type: STRING
                      name: reference
                      value: AIAAA
                - type: item
                  name: 'Running statements'
                  x: '21'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Running Statements'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.statements.running
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: Statements
                  x: '21'
                  'y': '3'
                  width: '36'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        name: 'OCI Autonomous DB: Statements'
                    - type: STRING
                      name: reference
                      value: AIAAB
                - type: item
                  name: 'Queued statements'
                  x: '33'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Queued Statements'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.queued.statements
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Transaction count'
                  x: '45'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Transaction Count'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.transaction.count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'DB block changes'
                  x: '57'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'DB Block Changes'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.block.changes
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Redo generated'
                  x: '57'
                  'y': '3'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Redo Generated'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Autonomous Database by HTTP'
                        key: oci.aut.db.redo.gen
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
      valuemaps:
        - uuid: e336c0d4e22f4f9f9c42d6de65fed068
          name: 'Autonomous database state'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Provisioning
            - value: '2'
              newvalue: Available
            - value: '3'
              newvalue: Stopping
            - value: '4'
              newvalue: Stopped
            - value: '5'
              newvalue: Starting
            - value: '6'
              newvalue: Terminating
            - value: '7'
              newvalue: Terminated
            - value: '8'
              newvalue: 'Restore in progress'
            - value: '9'
              newvalue: 'Restore failed'
            - value: '10'
              newvalue: 'Backup in progress'
            - value: '11'
              newvalue: 'Scale in progress'
            - value: '12'
              newvalue: 'Available needs attention'
            - value: '13'
              newvalue: Updating
            - value: '14'
              newvalue: 'Maintenance in progress'
            - value: '15'
              newvalue: Restarting
            - value: '16'
              newvalue: Recreating
            - value: '17'
              newvalue: 'Role change in progress'
            - value: '18'
              newvalue: Upgrading
            - value: '19'
              newvalue: Unavailable
            - value: '20'
              newvalue: Inaccessible
            - value: '21'
              newvalue: Standby
        - uuid: 3b30e8a71ef342e78f9f29243aafd992
          name: 'Database availability'
          mappings:
            - value: '0'
              newvalue: Unavailable
            - value: '1'
              newvalue: Available
    - uuid: 8afa1796d280425b99c7ea36900dac24
      template: 'Oracle Cloud Block Volume by HTTP'
      name: 'Oracle Cloud Block Volume by HTTP'
      description: |
        This template monitors Oracle Cloud Infrastructure (OCI) block volume resources.
        
        This template is not meant to be used independently, but together with Oracle Cloud by HTTP as a template for
        LLD host prototypes.
        
        Read the template documentation prior to using this 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.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: dc2887a2b954406db8588c0ead37411f
          name: 'Volume guaranteed IOPS'
          type: DEPENDENT
          key: oci.block.volume.iops
          value_type: FLOAT
          units: '!IOPS'
          description: |
            Rate of change for guaranteed IOPS per SLA.
            Expressed as the average of guaranteed IOPS during a given time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeGuaranteedIOPS
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.block.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 5c1d0fd1686e4c74b33dbe12956d7b7c
          name: 'Get metrics'
          type: SCRIPT
          key: oci.block.volume.metrics.get
          history: '0'
          value_type: TEXT
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            function buildMql(id, metrics, defaultStatistic, resourceType) {
            	resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType;
            	this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.';
            
            	for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            		const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic]));
            		metrics[i] = [metric[0], this.query + metric[1]];
            	}
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'volume_id', 'http_status_code', 'req_interval', 'compartment_id'], params);
            var oci = new OCI('Block volume', 'Get metrics', params);
            
            const metrics = [
            	'VolumeReadThroughput',
            	'VolumeWriteThroughput',
            	'VolumeReadOps',
            	'VolumeWriteOps',
            	['VolumeThrottledIOs', 'sum'],
            	'VolumeGuaranteedVPUsPerGB',
            	'VolumeGuaranteedIOPS',
            	'VolumeGuaranteedThroughput'
            ];
            buildMql(params['volume_id'], metrics, 'mean');
            
            var result = {};
            for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            	result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_blockstore'), 'aggregatedDatapoints');
            }
            return JSON.stringify(result);
          description: 'Gets block volume metrics.'
          timeout: 30s
          parameters:
            - name: api_host
              value: '{$OCI.API.TELEMETRY.HOST}'
            - name: compartment_id
              value: '{$OCI.VOLUME.BLOCK.COMPARTMENT.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: req_interval
              value: '1'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
            - name: volume_id
              value: '{$OCI.VOLUME.BLOCK.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: 680f9e8c96d34c099533adc99c33a48f
          name: 'Volume read throughput'
          type: DEPENDENT
          key: oci.block.volume.read
          value_type: FLOAT
          units: Bps
          description: 'Read throughput. Expressed as bytes read per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeReadThroughput
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.block.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 6b8060ce122142968e73da9a3e0813a1
          name: 'Volume read operations'
          type: DEPENDENT
          key: oci.block.volume.read.ops
          value_type: FLOAT
          units: '!reads'
          description: 'Activity level from I/O reads. Expressed as reads per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeReadOps
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.block.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 4fdab3067ada41219c8208862e7c8b14
          name: State
          type: SCRIPT
          key: oci.block.volume.state
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'volume_id', 'http_status_code'], params);
            var oci = new OCI('Block volume', 'Get volume state', params);
            
            return oci.extractData('get', oci.executeRequest('get', '/20160918/volumes/' + encodeURIComponent(params['volume_id']), ''), 'lifecycleState');
          description: 'Gets the block volume state.'
          valuemap:
            name: 'Block volume state'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = {
                  	'PROVISIONING': 1,
                  	'RESTORING': 2,
                  	'AVAILABLE': 3,
                  	'TERMINATING': 4,
                  	'TERMINATED': 5,
                  	'FAULTY': 6
                  };
                  
                  return typeof idx[value] === 'undefined' ? 0 : idx[value];
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.CORE.HOST}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
            - name: volume_id
              value: '{$OCI.VOLUME.BLOCK.ID}'
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 4ea859d86e29455aa4bdd2f3667894f6
              expression: 'min(/Oracle Cloud Block Volume by HTTP/oci.block.volume.state,5m) = 0'
              name: 'OCI Block Volume: Block volume state unknown'
              priority: WARNING
              description: 'Block volume state is unknown.'
              dependencies:
                - name: 'OCI Block Volume: Block volume terminated or faulty'
                  expression: 'min(/Oracle Cloud Block Volume by HTTP/oci.block.volume.state,5m) >= 4'
              tags:
                - tag: scope
                  value: availability
            - uuid: b8d9491d762f40c58fb1094fa0468d9e
              expression: 'min(/Oracle Cloud Block Volume by HTTP/oci.block.volume.state,5m) >= 4'
              name: 'OCI Block Volume: Block volume terminated or faulty'
              priority: HIGH
              description: 'Block volume state is "terminated"/"terminating" or "faulty".'
              tags:
                - tag: scope
                  value: availability
        - uuid: cc9ef37437b04a40a4b48a9f21e36ff1
          name: 'Volume throttled operations'
          type: DEPENDENT
          key: oci.block.volume.throttled.ops
          description: 'Total sum of all the I/O operations that were throttled during a given time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeThrottledIOs
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.block.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: d1b199adc996404db814ba7568b054df
          name: 'Volume guaranteed throughput'
          type: DEPENDENT
          key: oci.block.volume.throughput
          value_type: FLOAT
          units: Bps
          description: 'Rate of change for guaranteed throughput per SLA. Expressed as megabytes per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeGuaranteedThroughput
            - type: MULTIPLIER
              parameters:
                - '1048576'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.block.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 607f3c4a8197473bb1872e4ed45edd26
          name: 'Volume guaranteed VPUs/GB'
          type: DEPENDENT
          key: oci.block.volume.vpu
          value_type: FLOAT
          units: '!VPUs'
          description: |
            Rate of change for currently active VPUs/GB.
            Expressed as the average of active VPUs/GB during a given time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeGuaranteedVPUsPerGB
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.block.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 9ec2ce2d21154028a5623b5d0ac9c082
          name: 'Volume write throughput'
          type: DEPENDENT
          key: oci.block.volume.write
          value_type: FLOAT
          units: Bps
          description: 'Write throughput. Expressed as bytes read per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeWriteThroughput
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.block.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: e55fee2db439493992a80e39ca647e9a
          name: 'Volume write operations'
          type: DEPENDENT
          key: oci.block.volume.write.ops
          value_type: FLOAT
          units: '!writes'
          description: 'Activity level from I/O writes. Expressed as writes per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeWriteOps
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.block.volume.metrics.get
          tags:
            - tag: component
              value: storage
      tags:
        - tag: class
          value: cloud
        - tag: class
          value: database
        - tag: subclass
          value: automation
        - tag: subclass
          value: bigdata
        - tag: subclass
          value: deploy
        - tag: target
          value: oci
        - tag: target
          value: oracle-cloud-infrastructure
      macros:
        - macro: '{$OCI.HTTP.PROXY}'
          description: 'Set an HTTP proxy for OCI API requests if needed.'
        - macro: '{$OCI.HTTP.RETURN.CODE.OK}'
          value: '200'
          description: 'Set the HTTP return code that represents an OK response from the API. The default is "200",  but can vary, for example, if a proxy is used.'
      dashboards:
        - uuid: f87041e2902c4286a648b0f53daee03f
          name: 'OCI Block Volume: Overview'
          pages:
            - name: Overview
              display_period: '30'
              widgets:
                - type: item
                  name: Availability
                  width: '27'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Block Volume by HTTP'
                        key: oci.block.volume.state
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Volume read operations'
                  'y': '3'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Volume Read Operations'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Block Volume by HTTP'
                        key: oci.block.volume.read.ops
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: Operations
                  'y': '6'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Block Volume by HTTP'
                        name: 'OCI Block Volume: Operations'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: item
                  name: 'Volume write operations'
                  x: '18'
                  'y': '3'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Volume Write Operations'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Block Volume by HTTP'
                        key: oci.block.volume.write.ops
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Guaranteed IOPS'
                  x: '27'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Guaranteed IOPS'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Block Volume by HTTP'
                        key: oci.block.volume.iops
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Volume read throughput'
                  x: '36'
                  'y': '3'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Volume Read Throughput'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Block Volume by HTTP'
                        key: oci.block.volume.read
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: Throughput
                  x: '36'
                  'y': '6'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Block Volume by HTTP'
                        name: 'OCI Block Volume: Throughput'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: item
                  name: 'Guaranteed throughput'
                  x: '42'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Guaranteed Throughput'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Block Volume by HTTP'
                        key: oci.block.volume.throughput
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Volume write throughput'
                  x: '54'
                  'y': '3'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Volume Write Throughput'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Block Volume by HTTP'
                        key: oci.block.volume.write
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Guaranteed VPUs/GB'
                  x: '57'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Guaranteed VPUs/GB'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Block Volume by HTTP'
                        key: oci.block.volume.vpu
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
      valuemaps:
        - uuid: 780a56fd95474839943cbd2f8be2fc18
          name: 'Block volume state'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Provisioning
            - value: '2'
              newvalue: Restoring
            - value: '3'
              newvalue: Available
            - value: '4'
              newvalue: Terminating
            - value: '5'
              newvalue: Terminated
            - value: '6'
              newvalue: Faulty
    - uuid: e5486d98ff414c1391de1bd369a7f9db
      template: 'Oracle Cloud Boot Volume by HTTP'
      name: 'Oracle Cloud Boot Volume by HTTP'
      description: |
        Monitor Oracle Cloud Infrastructure (OCI) boot volume.
        
        This template is not meant to be used independently, but instead with Oracle Cloud by HTTP as a template for
        LLD host prototypes.
        
        Read the template documentation prior to using this 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.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: c629f4e4424b48288b7e7058eef2ca92
          name: 'Volume guaranteed IOPS'
          type: DEPENDENT
          key: oci.boot.volume.iops
          value_type: FLOAT
          units: '!IOPS'
          description: |
            Rate of change for guaranteed IOPS per SLA.
            Expressed as the average of guaranteed IOPS during a given time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeGuaranteedIOPS
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.boot.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 388e89b8e68149438d714237e785ccde
          name: 'Get metrics'
          type: SCRIPT
          key: oci.boot.volume.metrics.get
          history: '0'
          value_type: TEXT
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            function buildMql(id, metrics, defaultStatistic, resourceType) {
            	resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType;
            	this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.';
            
            	for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            		const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic]));
            		metrics[i] = [metric[0], this.query + metric[1]];
            	}
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'volume_id', 'http_status_code', 'req_interval', 'compartment_id'], params);
            var oci = new OCI('Boot volume', 'Get metrics', params);
            
            const metrics = [
            	'VolumeReadThroughput',
            	'VolumeWriteThroughput',
            	'VolumeReadOps',
            	'VolumeWriteOps',
            	['VolumeThrottledIOs', 'sum'],
            	'VolumeGuaranteedVPUsPerGB',
            	'VolumeGuaranteedIOPS',
            	'VolumeGuaranteedThroughput'
            ];
            buildMql(params['volume_id'], metrics, 'mean');
            
            var result = {};
            for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            	result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_blockstore'), 'aggregatedDatapoints');
            }
            return JSON.stringify(result);
          description: 'Gets boot volume metrics.'
          timeout: 30s
          parameters:
            - name: api_host
              value: '{$OCI.API.TELEMETRY.HOST}'
            - name: compartment_id
              value: '{$OCI.VOLUME.BOOT.COMPARTMENT.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: req_interval
              value: '1'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
            - name: volume_id
              value: '{$OCI.VOLUME.BOOT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: 01700702f306414892828674c0046e5c
          name: 'Volume read throughput'
          type: DEPENDENT
          key: oci.boot.volume.read
          value_type: FLOAT
          units: Bps
          description: 'Read throughput. Expressed as bytes read per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeReadThroughput
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.boot.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: b004ee7931dd4eccbfc89d3a8c363209
          name: 'Volume read operations'
          type: DEPENDENT
          key: oci.boot.volume.read.ops
          value_type: FLOAT
          units: '!reads'
          description: 'Activity level from I/O reads. Expressed as reads per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeReadOps
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.boot.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 3f0e4bed1fd14293b40b23595f01ebb1
          name: State
          type: SCRIPT
          key: oci.boot.volume.state
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'volume_id', 'http_status_code'], params);
            var oci = new OCI('Boot volume', 'Get volume state', params);
            
            return oci.extractData('get', oci.executeRequest('get', '/20160918/bootVolumes/' + encodeURIComponent(params['volume_id']), ''), 'lifecycleState');
          description: 'Gets the boot volume state.'
          valuemap:
            name: 'Boot volume state'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = {
                  	'PROVISIONING': 1,
                  	'RESTORING': 2,
                  	'AVAILABLE': 3,
                  	'TERMINATING': 4,
                  	'TERMINATED': 5,
                  	'FAULTY': 6
                  };
                  
                  return typeof idx[value] === 'undefined' ? 0 : idx[value];
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.CORE.HOST}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
            - name: volume_id
              value: '{$OCI.VOLUME.BOOT.ID}'
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: b31f698c5b164afc85a14acc813f463d
              expression: 'min(/Oracle Cloud Boot Volume by HTTP/oci.boot.volume.state,5m) = 0'
              name: 'OCI Boot Volume: Boot volume state unknown'
              priority: WARNING
              description: 'Boot volume state is unknown.'
              dependencies:
                - name: 'OCI Boot Volume: Boot volume terminated or faulty'
                  expression: 'min(/Oracle Cloud Boot Volume by HTTP/oci.boot.volume.state,5m) >= 4'
              tags:
                - tag: scope
                  value: availability
            - uuid: 6525eef6dd6c4cb0a22a6442773c3cfa
              expression: 'min(/Oracle Cloud Boot Volume by HTTP/oci.boot.volume.state,5m) >= 4'
              name: 'OCI Boot Volume: Boot volume terminated or faulty'
              priority: HIGH
              description: 'Boot volume state is "terminated"/"terminating" or "faulty".'
              tags:
                - tag: scope
                  value: availability
        - uuid: cfdc208b621b46508f9addc7ddb0808c
          name: 'Volume throttled operations'
          type: DEPENDENT
          key: oci.boot.volume.throttled.ops
          value_type: FLOAT
          description: 'Total sum of all the I/O operations that were throttled during a given time interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeThrottledIOs
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.boot.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 09bc5d7c95fe4b41bed9d786b78eba88
          name: 'Volume guaranteed throughput'
          type: DEPENDENT
          key: oci.boot.volume.throughput
          value_type: FLOAT
          units: Bps
          description: 'Rate of change for guaranteed throughput per SLA. Expressed as megabytes per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeGuaranteedThroughput
            - type: MULTIPLIER
              parameters:
                - '1048576'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.boot.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: a3e5f888d2c84d7eb105f1061b9fadd1
          name: 'Volume guaranteed VPUs/GB'
          type: DEPENDENT
          key: oci.boot.volume.vpu
          value_type: FLOAT
          units: '!VPUs'
          description: |
            Rate of change for currently active VPUs/GB.
            Expressed as the average of active VPUs/GB during a given time interval.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeGuaranteedVPUsPerGB
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.boot.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: a92206102a7a45d7b5c46096486465b6
          name: 'Volume write throughput'
          type: DEPENDENT
          key: oci.boot.volume.write
          value_type: FLOAT
          units: Bps
          description: 'Write throughput. Expressed as bytes read per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeWriteThroughput
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.boot.volume.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 724197c8dcfe4c3ea52bc25d99de727c
          name: 'Volume write operations'
          type: DEPENDENT
          key: oci.boot.volume.write.ops
          value_type: FLOAT
          units: '!writes'
          description: 'Activity level from I/O writes. Expressed as writes per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.VolumeWriteOps
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.boot.volume.metrics.get
          tags:
            - tag: component
              value: storage
      tags:
        - tag: class
          value: cloud
        - tag: class
          value: database
        - tag: subclass
          value: automation
        - tag: subclass
          value: bigdata
        - tag: subclass
          value: deploy
        - tag: target
          value: oci
        - tag: target
          value: oracle-cloud-infrastructure
      macros:
        - macro: '{$OCI.HTTP.PROXY}'
          description: 'Set an HTTP proxy for OCI API requests if needed.'
        - macro: '{$OCI.HTTP.RETURN.CODE.OK}'
          value: '200'
          description: 'Set the HTTP return code that represents an OK response from the API. The default is "200",  but can vary, for example, if a proxy is used.'
      dashboards:
        - uuid: 67db0d25f18a45b4913a15ab2618608c
          name: 'OCI Boot Volume: Overview'
          pages:
            - name: Overview
              display_period: '30'
              widgets:
                - type: item
                  name: Availability
                  width: '27'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Boot Volume by HTTP'
                        key: oci.boot.volume.state
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Volume read operations'
                  'y': '3'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Volume Read Operations'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Boot Volume by HTTP'
                        key: oci.boot.volume.read.ops
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: Operations
                  'y': '6'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Boot Volume by HTTP'
                        name: 'OCI Boot Volume: Operations'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: item
                  name: 'Volume write operations'
                  x: '18'
                  'y': '3'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Volume Write Operations'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Boot Volume by HTTP'
                        key: oci.boot.volume.write.ops
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Guaranteed IOPS'
                  x: '27'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Guaranteed IOPS'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Boot Volume by HTTP'
                        key: oci.boot.volume.iops
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Volume read throughput'
                  x: '36'
                  'y': '3'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Volume Read Throughput'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Boot Volume by HTTP'
                        key: oci.boot.volume.read
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: Throughput
                  x: '36'
                  'y': '6'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Boot Volume by HTTP'
                        name: 'OCI Boot Volume: Throughput'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: item
                  name: 'Guaranteed throughput'
                  x: '42'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Guaranteed Throughput'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Boot Volume by HTTP'
                        key: oci.boot.volume.throughput
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Volume write throughput'
                  x: '54'
                  'y': '3'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Volume Write Throughput'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Boot Volume by HTTP'
                        key: oci.boot.volume.write
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Guaranteed VPUs/GB'
                  x: '57'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Guaranteed VPUs/GB'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Boot Volume by HTTP'
                        key: oci.boot.volume.vpu
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
      valuemaps:
        - uuid: d881a2a2bedc4556a36f3d676ece0456
          name: 'Boot volume state'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Provisioning
            - value: '2'
              newvalue: Restoring
            - value: '3'
              newvalue: Available
            - value: '4'
              newvalue: Terminating
            - value: '5'
              newvalue: Terminated
            - value: '6'
              newvalue: Faulty
    - uuid: 057558a26d934b4683d73a7058499d62
      template: 'Oracle Cloud by HTTP'
      name: 'Oracle Cloud by HTTP'
      description: |
        Monitor resources of Oracle Cloud Infrastructure (OCI) services.
        
        This template handles discovery of various OCI services.
        
        Read the template documentation prior to using this 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"
      wizard_ready: 'YES'
      readme: |
        ## Overview
        
        This template is designed as a master template that discovers various Oracle Cloud Infrastructure (OCI) services
        and resources, such as:
        
        * OCI Compute;
        
        * OCI Autonomous Database (serverless);
        
        * OCI Object Storage;
        
        * OCI Virtual Cloud Networks (VCNs);
        
        * OCI Block Volumes;
        
        * OCI Boot Volumes.
        
        For communication with OCI, this template utilizes script items which execute HTTP `GET` and `POST` requests. 
        `POST` requests are required for OCI Monitoring API as it utilizes Monitoring Query Language (MQL) which uses an
        HTTP request body for queries.
        
        
        ## Setup
        
        ## Required setup
        
        For this template to work, it needs authentication details to use in requests. To acquire this information, see
        the following steps:
        
        1. Log into your administrator account in Oracle Cloud Console.
        
        2. Create a new user that will be used by Zabbix for monitoring.
        
        3. Create a new security policy and assign a previously created user to it.
        
        4. This policy will contain a set of rules that will give monitoring user access to specific resources in your
        OCI. Make sure to add the following rules to the policy:
          
            ```
            Allow group 'zabbix_api' to read metrics in tenancy
            Allow group 'zabbix_api' to read instances in tenancy
            Allow group 'zabbix_api' to read subnets in tenancy
            Allow group 'zabbix_api' to read vcns in tenancy
            Allow group 'zabbix_api' to read vnic-attachments in tenancy
            Allow group 'zabbix_api' to read volumes in tenancy
            Allow group 'zabbix_api' to read objectstorage-namespaces in tenancy
            Allow group 'zabbix_api' to read buckets in tenancy
            Allow group 'zabbix_api' to read autonomous-databases in tenancy
            ```
          
            In this example, `zabbix_api` is the name of the previously created monitoring user. Rename it to your
        monitoring user's name.
        
        5. Generate an API key pair for your monitoring user - open your monitoring user profile and on the left side,
        press `API keys` and then, `Add API key` (if generating a new key pair, do not forget to save the private key).
          
        6. After this, Oracle Cloud Console will provide additional information that is required for access, such as:
        
            * Tenancy OCID;
              
            * User OCID;
              
            * Fingerprint;
              
            * Region.
        
            > Save this information somewhere or keep this window open. This information will be required in later steps.
        
        7. In Zabbix, create a new host and assign this template to it (Oracle Cloud by HTTP).
        
        8. In host wizard configuration fields please set next values (from step #6):
        
            * `OCID tenancy` - set the tenancy OCID value;
              
            * `OCID user` - set the user OCID value;
              
            * `Fingerprint` - set the fingerprint value;
              
            * `Private key` - copy and paste the contents of private key file here.
        
        9. After the authentication credentials are entered, you need to identify the OCI API endpoints that match your
        region (as provided by Oracle Cloud Console in step #6).
        To do so, you can use the OCI [API Reference and Endpoints](https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/api/#/) list, where each API service has a dedicated page with the respective API endpoints.
        
           The required API service endpoints are:
          
           * [Core Services API](https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/api/#/en/iaas/20160918/);
          
           * [Database Service API](https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/api/#/en/database/20160918/);
          
           * [Object Storage Service API](https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/api/#/en/objectstorage/20160918/);
          
           * [Monitoring API](https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/api/#/en/monitoring/20180401/).
                
        10. When the API endpoints are identified, you need to set them in host wizard configuration fields (similarly to step #8):
        
            * `Core Services host` - Core Services API endpoint, for example, `iaas.eu-stockholm-1.oraclecloud.com`;
        
            * `Database Service host` - Database Service API endpoint, for example, `database.eu-stockholm-1.oraclecloud.com`;
        
            * `Object Storage host` - Object Storage Service API endpoint, for example, `objectstorage.eu-stockholm-1.oraclecloud.com`;
        
            * `Monitoring host` - Monitoring API endpoint, for example, `telemetry.eu-stockholm-1.oraclecloud.com`;
                                    
            > IMPORTANT! API Endpoint URLs need to be entered without the HTTP scheme (`https://`).
                                    
        11. Once you've completed adding the host to Zabbix, and it will automatically discover services and monitor them.
        
        ## Optional setup
        
        #### Example
        
        1. In Oracle Cloud Console, add a free-form tag to a resource, for example, a compute instance.
        The tag key will be `location_group` and the tag value will be `eu-north-1`.
        
        2. Open the Oracle Cloud by HTTP template in Zabbix and go to "Discovery rules".
        Find "Compute instances discovery" and open it.
        
        3. Under "LLD macros", add a new macro that will represent this location group tag, for example:
        `{#LOCATION_GROUP}` `$.tags.location_group`.
                                                                                                    
        4. Under the "Filters" tab, there will already be filters regarding the compute instance name and state.
        Click "Add" to add a new filter and define the previously created LLD macro and add a matching pattern and
        value, for example, `{#LOCATION_GROUP}` `matches` `eu-north-*`.
        
        5. The next time `Compute instances discovery` is executed, it will only discover OCI compute instances that
        have the free-form tag `location_group` that matches the regex of `eu-north-*`. You can also experiment with
        the LLD filter pattern matching value to receive different matching results for a specified value.
      vendor:
        name: Zabbix
        version: 7.4-2
      groups:
        - name: Templates/Cloud
      discovery_rules:
        - uuid: 72fa6dfedfd8497298c5930f48594e72
          name: 'Block volumes discovery'
          type: SCRIPT
          key: oci.block.volumes.discovery
          delay: 1h
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function prepareCompartments(compartments, tenancy) {
            	if (typeof compartments === 'undefined' || compartments === '') {
            		return [tenancy];
            	} else {
            		return compartments.split(',')
            	}
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'http_status_code'], params);
            var oci = new OCI('Block volume', 'Get volumes', params);
            var compartments = prepareCompartments(params['compartment_ocid'], params['tenancy_ocid']);
            
            var buffer = [];
            compartments.forEach(function (compartment) {
            	Array.prototype.push.apply(buffer, oci.extractData('get', oci.executeRequest('get', '/20160918/volumes', '?compartmentId=' + encodeURIComponent(compartment)), ['id', 'displayName', 'lifecycleState', 'freeformTags'], compartment));
            })
            return JSON.stringify(buffer);
          filter:
            evaltype: AND
            conditions:
              - macro: '{#NAME}'
                value: '{$OCI.VOLUME.BLOCK.DISCOVERY.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$OCI.VOLUME.BLOCK.DISCOVERY.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#STATE}'
                value: '{$OCI.VOLUME.BLOCK.DISCOVERY.STATE.MATCHES}'
              - macro: '{#STATE}'
                value: '{$OCI.VOLUME.BLOCK.DISCOVERY.STATE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover block volumes.'
          host_prototypes:
            - uuid: 5030f7dadd5b40558e07a4545d7346bd
              host: 'OCI Block Volume - {#ID}'
              name: 'OCI Block Volume - {#ID}'
              group_links:
                - group:
                    name: Applications
              templates:
                - name: 'Oracle Cloud Block Volume by HTTP'
              macros:
                - macro: '{$OCI.VOLUME.BLOCK.COMPARTMENT.ID}'
                  value: '{#COMPARTMENT}'
                  description: 'Block volume compartment ID.'
                - macro: '{$OCI.VOLUME.BLOCK.ID}'
                  value: '{#ID}'
                  description: 'Block volume ID.'
              tags:
                - tag: oci-block-vol-name
                  value: '{#NAME}'
                - tag: oci-compartment-id
                  value: '{#COMPARTMENT}'
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.CORE.HOST}'
            - name: compartment_ocid
              value: '{$OCI.API.COMPARTMENT.VOLUME.BLOCK}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          lld_macro_paths:
            - lld_macro: '{#COMPARTMENT}'
              path: $.compartment
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#STATE}'
              path: $.state
        - uuid: 90982afdf2f9430bb1c5a3755d8e6c6d
          name: 'Boot volumes discovery'
          type: SCRIPT
          key: oci.boot.volumes.discovery
          delay: 1h
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function prepareCompartments(compartments, tenancy) {
            	if (typeof compartments === 'undefined' || compartments === '') {
            		return [tenancy];
            	} else {
            		return compartments.split(',')
            	}
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'http_status_code'], params);
            var oci = new OCI('Boot volume', 'Get volumes', params);
            var compartments = prepareCompartments(params['compartment_ocid'], params['tenancy_ocid']);
            
            var buffer = [];
            compartments.forEach(function (compartment) {
            	Array.prototype.push.apply(buffer, oci.extractData('get', oci.executeRequest('get', '/20160918/bootVolumes', '?compartmentId=' + encodeURIComponent(compartment)), ['id', 'displayName', 'lifecycleState', 'freeformTags'], compartment));
            })
            return JSON.stringify(buffer);
          filter:
            evaltype: AND
            conditions:
              - macro: '{#NAME}'
                value: '{$OCI.VOLUME.BOOT.DISCOVERY.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$OCI.VOLUME.BOOT.DISCOVERY.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#STATE}'
                value: '{$OCI.VOLUME.BOOT.DISCOVERY.STATE.MATCHES}'
              - macro: '{#STATE}'
                value: '{$OCI.VOLUME.BOOT.DISCOVERY.STATE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover boot volumes.'
          host_prototypes:
            - uuid: 914b808a4a014f6e824a3b9c53f1b492
              host: 'OCI Boot Volume - {#ID}'
              name: 'OCI Boot Volume - {#ID}'
              group_links:
                - group:
                    name: Applications
              templates:
                - name: 'Oracle Cloud Boot Volume by HTTP'
              macros:
                - macro: '{$OCI.VOLUME.BOOT.COMPARTMENT.ID}'
                  value: '{#COMPARTMENT}'
                  description: 'Boot volume compartment ID.'
                - macro: '{$OCI.VOLUME.BOOT.ID}'
                  value: '{#ID}'
                  description: 'Boot volume ID.'
              tags:
                - tag: oci-boot-vol-name
                  value: '{#NAME}'
                - tag: oci-compartment-id
                  value: '{#COMPARTMENT}'
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.CORE.HOST}'
            - name: compartment_ocid
              value: '{$OCI.API.COMPARTMENT.VOLUME.BOOT}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          lld_macro_paths:
            - lld_macro: '{#COMPARTMENT}'
              path: $.compartment
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#STATE}'
              path: $.state
        - uuid: ea4bbd0e9737406693aa0051cf861115
          name: 'Compute instances discovery'
          type: SCRIPT
          key: oci.compute.discovery
          delay: 1h
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function prepareCompartments(compartments, tenancy) {
            	if (typeof compartments === 'undefined' || compartments === '') {
            		return [tenancy];
            	} else {
            		return compartments.split(',')
            	}
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'http_status_code'], params);
            var oci = new OCI('Compute', 'Get instances', params);
            var compartments = prepareCompartments(params['compartment_ocid'], params['tenancy_ocid']);
            
            var buffer = [];
            compartments.forEach(function (compartment) {
            	Array.prototype.push.apply(buffer, oci.extractData('get', oci.executeRequest('get', '/20160918/instances', '?compartmentId=' + encodeURIComponent(compartment)), ['id', 'displayName', 'lifecycleState', 'freeformTags', 'availabilityDomain'], compartment));
            })
            return JSON.stringify(buffer);
          filter:
            evaltype: AND
            conditions:
              - macro: '{#NAME}'
                value: '{$OCI.COMPUTE.DISCOVERY.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$OCI.COMPUTE.DISCOVERY.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#STATE}'
                value: '{$OCI.COMPUTE.DISCOVERY.STATE.MATCHES}'
              - macro: '{#STATE}'
                value: '{$OCI.COMPUTE.DISCOVERY.STATE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover compute instances.'
          host_prototypes:
            - uuid: 9337374066e04291b2f94f8ad5470f54
              host: 'OCI Compute - {#ID}'
              name: 'OCI Compute - {#ID}'
              group_links:
                - group:
                    name: 'Virtual machines'
              templates:
                - name: 'Oracle Cloud Compute by HTTP'
              macros:
                - macro: '{$OCI.COMPUTE.AVAILABILITY.DOMAIN}'
                  value: '{#DOMAIN}'
                  description: 'Availability domain for instance.'
                - macro: '{$OCI.COMPUTE.COMPARTMENT.ID}'
                  value: '{#COMPARTMENT}'
                  description: 'Compartment ID of OCI compute instance.'
                - macro: '{$OCI.COMPUTE.INSTANCE.ID}'
                  value: '{#ID}'
                  description: 'ID of OCI compute instance.'
              tags:
                - tag: oci-compartment-id
                  value: '{#COMPARTMENT}'
                - tag: oci-compute-name
                  value: '{#NAME}'
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.CORE.HOST}'
            - name: compartment_ocid
              value: '{$OCI.API.COMPARTMENT.COMPUTE}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          lld_macro_paths:
            - lld_macro: '{#COMPARTMENT}'
              path: $.compartment
            - lld_macro: '{#DOMAIN}'
              path: $.domain
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#STATE}'
              path: $.state
        - uuid: c69611c5b86043b28c8ce2bc0627b377
          name: 'Autonomous database discovery'
          type: SCRIPT
          key: oci.object.autonomous.db.discovery
          delay: 1h
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function prepareCompartments(compartments, tenancy) {
            	if (typeof compartments === 'undefined' || compartments === '') {
            		return [tenancy];
            	} else {
            		return compartments.split(',')
            	}
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'http_status_code'], params);
            var oci = new OCI('Autonomous DB', 'Get DBs', params);
            var compartments = prepareCompartments(params['compartment_ocid'], params['tenancy_ocid']);
            
            var buffer = [];
            compartments.forEach(function (compartment) {
            	Array.prototype.push.apply(buffer, oci.extractData('get', oci.executeRequest('get', '/20160918/autonomousDatabases', '?compartmentId=' + encodeURIComponent(compartment)), ['id', 'dbName', 'lifecycleState', 'freeformTags'], compartment));
            })
            return JSON.stringify(buffer);
          filter:
            evaltype: AND
            conditions:
              - macro: '{#NAME}'
                value: '{$OCI.AUTONOMOUS.DB.DISCOVERY.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$OCI.AUTONOMOUS.DB.DISCOVERY.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#STATE}'
                value: '{$OCI.AUTONOMOUS.DB.DISCOVERY.STATE.MATCHES}'
              - macro: '{#STATE}'
                value: '{$OCI.AUTONOMOUS.DB.DISCOVERY.STATE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover autonomous databases.'
          host_prototypes:
            - uuid: 88d0076a057c441ab5a531cfcb650e84
              host: 'OCI Autonomous DB - {#NAME}'
              name: 'OCI Autonomous DB - {#NAME}'
              group_links:
                - group:
                    name: Databases
              templates:
                - name: 'Oracle Cloud Autonomous Database by HTTP'
              macros:
                - macro: '{$OCI.AUTONOMOUS.DB.COMPARTMENT.ID}'
                  value: '{#COMPARTMENT}'
                  description: 'Autonomous database compartment ID.'
                - macro: '{$OCI.AUTONOMOUS.DB.ID}'
                  value: '{#ID}'
                  description: 'ID of OCI autonomous database.'
              tags:
                - tag: oci-aut-db-name
                  value: '{#NAME}'
                - tag: oci-compartment-id
                  value: '{#COMPARTMENT}'
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.AUTONOMOUS.DB.HOST}'
            - name: compartment_ocid
              value: '{$OCI.API.COMPARTMENT.AUTONOMOUS.DB}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          lld_macro_paths:
            - lld_macro: '{#COMPARTMENT}'
              path: $.compartment
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#STATE}'
              path: $.state
        - uuid: e1949f127af04efeb8c192f23e45b58a
          name: 'Object storage discovery'
          type: SCRIPT
          key: oci.object.storage.discovery
          delay: 1h
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function prepareCompartments(compartments, tenancy) {
            	if (typeof compartments === 'undefined' || compartments === '') {
            		return [tenancy];
            	} else {
            		return compartments.split(',')
            	}
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'http_status_code'], params);
            var oci = new OCI('Object storage', 'Get buckets', params);
            var compartments = prepareCompartments(params['compartment_ocid'], params['tenancy_ocid']);
            const namespace = JSON.parse(oci.executeRequest('get', '/n', ''));
            
            var buffer = [];
            compartments.forEach(function (compartment) {
            	Array.prototype.push.apply(buffer, oci.extractData('get', oci.executeRequest('get', '/n/' + encodeURIComponent(namespace) + '/b/', '?compartmentId=' + encodeURIComponent(compartment) + '&fields=tags'), ['name', 'freeformTags'], compartment));
            })
            return JSON.stringify(buffer);
          filter:
            evaltype: AND
            conditions:
              - macro: '{#NAME}'
                value: '{$OCI.OBJECT.STORAGE.DISCOVERY.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$OCI.OBJECT.STORAGE.DISCOVERY.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover object storage.'
          host_prototypes:
            - uuid: f71e979727ce42daa80a34da5ffb296f
              host: 'OCI Bucket - {#NAME}'
              name: 'OCI Bucket - {#NAME}'
              group_links:
                - group:
                    name: Applications
              templates:
                - name: 'Oracle Cloud Object Storage by HTTP'
              macros:
                - macro: '{$OCI.OBJECT.STORAGE.BUCKET}'
                  value: '{#NAME}'
                  description: 'Object storage bucket name.'
                - macro: '{$OCI.OBJECT.STORAGE.COMPARTMENT.ID}'
                  value: '{#COMPARTMENT}'
                  description: 'Object storage bucket compartment ID.'
              tags:
                - tag: oci-compartment-id
                  value: '{#COMPARTMENT}'
                - tag: oci-obj-store-name
                  value: '{#NAME}'
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.OBJECT.STORAGE.HOST}'
            - name: compartment_ocid
              value: '{$OCI.API.COMPARTMENT.OBJECT.STORAGE}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          lld_macro_paths:
            - lld_macro: '{#COMPARTMENT}'
              path: $.compartment
            - lld_macro: '{#NAME}'
              path: $.name
        - uuid: 378d760173924bf48fbc25c74a520a8b
          name: 'Virtual cloud networks discovery'
          type: SCRIPT
          key: oci.vcn.discovery
          delay: 1h
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function prepareCompartments(compartments, tenancy) {
            	if (typeof compartments === 'undefined' || compartments === '') {
            		return [tenancy];
            	} else {
            		return compartments.split(',')
            	}
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'http_status_code'], params);
            var oci = new OCI('VCN', 'Get VCNs', params);
            var compartments = prepareCompartments(params['compartment_ocid'], params['tenancy_ocid']);
            
            var buffer = [];
            compartments.forEach(function (compartment) {
            	Array.prototype.push.apply(buffer, oci.extractData('get', oci.executeRequest('get', '/20160918/vcns', '?compartmentId=' + encodeURIComponent(compartment)), ['id', 'displayName', 'lifecycleState', 'freeformTags'], compartment));
            })
            return JSON.stringify(buffer);
          filter:
            evaltype: AND
            conditions:
              - macro: '{#NAME}'
                value: '{$OCI.VCN.DISCOVERY.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$OCI.VCN.DISCOVERY.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#STATE}'
                value: '{$OCI.VCN.DISCOVERY.STATE.MATCHES}'
              - macro: '{#STATE}'
                value: '{$OCI.VCN.DISCOVERY.STATE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover virtual cloud networks (VCNs).'
          host_prototypes:
            - uuid: 5329fee3dbc643ebbb99472c67a0a207
              host: 'OCI VCN - {#ID}'
              name: 'OCI VCN - {#ID}'
              group_links:
                - group:
                    name: Applications
              templates:
                - name: 'Oracle Cloud Networking by HTTP'
              macros:
                - macro: '{$OCI.VCN.COMPARTMENT.ID}'
                  value: '{#COMPARTMENT}'
                  description: 'Compartment ID of OCI VCN (virtual cloud network).'
                - macro: '{$OCI.VCN.ID}'
                  value: '{#ID}'
                  description: 'ID of the OCI VCN (virtual cloud network).'
              tags:
                - tag: oci-compartment-id
                  value: '{#COMPARTMENT}'
                - tag: oci-vcn-name
                  value: '{#NAME}'
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.CORE.HOST}'
            - name: compartment_ocid
              value: '{$OCI.API.COMPARTMENT.VCN}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          lld_macro_paths:
            - lld_macro: '{#COMPARTMENT}'
              path: $.compartment
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#STATE}'
              path: $.state
      tags:
        - tag: class
          value: cloud
        - tag: class
          value: database
        - tag: subclass
          value: automation
        - tag: subclass
          value: bigdata
        - tag: subclass
          value: deploy
        - tag: target
          value: oci
        - tag: target
          value: oracle-cloud-infrastructure
      macros:
        - macro: '{$OCI.API.AUTONOMOUS.DB.HOST}'
          description: 'Host for OCI Autonomous Database API endpoint.'
          config:
            type: TEXT
            priority: '4'
            label: 'Database Service host'
            description: 'Host for Database Service API endpoint.'
            required: 'YES'
        - macro: '{$OCI.API.COMPARTMENT.AUTONOMOUS.DB}'
          description: 'Compartment OCIDs for autonomous databases. Can be a single value or a comma separated list of values.'
          config:
            type: TEXT
            priority: '10'
            label: 'Compartment  for autonomous databases'
            description: 'Compartment OCIDs for autonomous databases.'
            required: 'YES'
        - macro: '{$OCI.API.COMPARTMENT.COMPUTE}'
          description: 'Compartment OCIDs for compute instances. Can be a single value or a comma separated list of values.'
          config:
            type: TEXT
            priority: '5'
            label: 'Compartment for compute'
            description: 'Compartment OCIDs for compute instances.'
            required: 'YES'
        - macro: '{$OCI.API.COMPARTMENT.OBJECT.STORAGE}'
          description: 'Compartment OCIDs for object storage buckets. Can be a single value or a comma separated list of values.'
          config:
            type: TEXT
            priority: '9'
            label: 'Compartment for object storage buckets'
            description: 'Compartment OCIDs for object storage buckets.'
            required: 'YES'
        - macro: '{$OCI.API.COMPARTMENT.VCN}'
          description: 'Compartment OCIDs for virtual cloud networks. Can be a single value or a comma separated list of values.'
          config:
            type: TEXT
            priority: '6'
            label: 'Compartment for virtual cloud networks'
            description: 'Compartment OCIDs for virtual cloud networks.'
            required: 'YES'
        - macro: '{$OCI.API.COMPARTMENT.VOLUME.BLOCK}'
          description: 'Compartment OCIDs for block volumes. Can be a single value or a comma separated list of values.'
          config:
            type: TEXT
            priority: '7'
            label: 'Compartment for block volumes'
            description: 'Compartment OCIDs for block volumes.'
            required: 'YES'
        - macro: '{$OCI.API.COMPARTMENT.VOLUME.BOOT}'
          description: 'Compartment OCIDs for boot volumes. Can be a single value or a comma separated list of values.'
          config:
            type: TEXT
            priority: '8'
            label: 'Compartment for boot volumes'
            description: 'Compartment OCIDs for boot volumes.'
            required: 'YES'
        - macro: '{$OCI.API.CORE.HOST}'
          description: 'Host for OCI Core Services API endpoint.'
          config:
            type: TEXT
            priority: '1'
            label: 'Core Services host'
            description: 'Host for Core Services API endpoint.'
            required: 'YES'
        - macro: '{$OCI.API.FINGERPRINT}'
          type: SECRET_TEXT
          description: 'Fingerprint of private key.'
          config:
            type: TEXT
            priority: '14'
            label: Fingerprint
            description: 'Fingerprint value here.'
            required: 'YES'
        - macro: '{$OCI.API.OBJECT.STORAGE.HOST}'
          description: 'Host for OCI Object Storage API endpoint.'
          config:
            type: TEXT
            priority: '3'
            label: 'Object Storage host'
            description: 'Host for Object Storage Service API endpoint.'
            required: 'YES'
        - macro: '{$OCI.API.PRIVATE.KEY}'
          type: SECRET_TEXT
          description: 'Entire private key for API access.'
          config:
            type: TEXT
            priority: '13'
            label: 'Private key'
            description: 'Contents of private key file.'
            required: 'YES'
        - macro: '{$OCI.API.TELEMETRY.HOST}'
          description: 'Host for OCI Monitoring API endpoint.'
          config:
            type: TEXT
            priority: '2'
            label: 'Monitoring host'
            description: 'Host for Monitoring API endpoint.'
            required: 'YES'
        - macro: '{$OCI.API.TENANCY}'
          description: 'OCID of tenancy.'
          config:
            type: TEXT
            priority: '11'
            label: 'OCID tenancy'
            description: 'Tenancy OCID value.'
            required: 'YES'
        - macro: '{$OCI.API.USER}'
          description: 'OCID of user.'
          config:
            type: TEXT
            priority: '12'
            label: 'OCID user'
            description: 'User OCID value.'
            required: 'YES'
        - macro: '{$OCI.AUTONOMOUS.DB.DISCOVERY.NAME.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of autonomous database names to allow in discovery.'
          config:
            type: TEXT
            priority: '35'
            section_name: Filters
            label: 'Include autonomous database names filter'
            description: 'Regex string of autonomous database names to allow in discovery.'
        - macro: '{$OCI.AUTONOMOUS.DB.DISCOVERY.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of autonomous database names to ignore in discovery.'
          config:
            type: TEXT
            priority: '36'
            section_name: Filters
            label: 'Exclude autonomous database names filter'
            description: 'Regex string of autonomous database names to ignore in discovery.'
        - macro: '{$OCI.AUTONOMOUS.DB.DISCOVERY.STATE.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of autonomous database states to allow in discovery.'
          config:
            type: TEXT
            priority: '33'
            section_name: Filters
            label: 'Include autonomous database states filter'
            description: 'Regex string of autonomous database states to allow in discovery.'
        - macro: '{$OCI.AUTONOMOUS.DB.DISCOVERY.STATE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of autonomous database states to ignore in discovery.'
          config:
            type: TEXT
            priority: '34'
            section_name: Filters
            label: 'Exclude autonomous database states filter'
            description: 'Regex string of autonomous database states to ignore in discovery.'
        - macro: '{$OCI.COMPUTE.DISCOVERY.NAME.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of compute instance names to allow in discovery.'
          config:
            type: TEXT
            priority: '17'
            section_name: Filters
            label: 'Include compute instance names filter'
            description: 'Regex string of compute instance names to allow in discovery.'
        - macro: '{$OCI.COMPUTE.DISCOVERY.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of compute instance names to ignore in discovery.'
          config:
            type: TEXT
            priority: '18'
            section_name: Filters
            label: 'Exclude compute instance names filter'
            description: 'Regex string of compute instance names to ignore in discovery.'
        - macro: '{$OCI.COMPUTE.DISCOVERY.STATE.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of compute instance states to allow in discovery.'
          config:
            type: TEXT
            priority: '15'
            section_name: Filters
            label: 'Include compute instance states filter'
            description: 'Regex string of compute instance states to allow in discovery.'
        - macro: '{$OCI.COMPUTE.DISCOVERY.STATE.NOT_MATCHES}'
          value: TERMINATED
          description: 'Sets the regex string of compute instance states to ignore in discovery.'
          config:
            type: TEXT
            priority: '16'
            section_name: Filters
            label: 'Exclude compute instance states filter'
            description: 'Regex string of compute instance states to ignore in discovery.'
        - macro: '{$OCI.HTTP.PROXY}'
          description: 'Set an HTTP proxy for OCI API requests if needed.'
          config:
            type: TEXT
            priority: '37'
            section_name: Other
            label: 'HTTP proxy'
            description: 'HTTP proxy to use for requests.'
        - macro: '{$OCI.HTTP.RETURN.CODE.OK}'
          value: '200'
          description: 'Set the HTTP return code that represents an OK response from the API. The default is "200",  but can vary, for example, if a proxy is used.'
          config:
            type: TEXT
            priority: '38'
            section_name: Other
            label: 'HTTP return code'
            description: 'HTTP return code that represents an OK response from the API.'
        - macro: '{$OCI.OBJECT.STORAGE.DISCOVERY.NAME.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of storage names to allow in discovery.'
          config:
            type: TEXT
            priority: '31'
            section_name: Filters
            label: 'Include storage names filter'
            description: 'Regex string of storage names to allow in discovery.'
        - macro: '{$OCI.OBJECT.STORAGE.DISCOVERY.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of storage names to ignore in discovery.'
          config:
            type: TEXT
            priority: '32'
            section_name: Filters
            label: 'Exclude storage names filter'
            description: 'Regex string of storage names to ignore in discovery.'
        - macro: '{$OCI.VCN.DISCOVERY.NAME.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of virtual cloud network names to allow in discovery.'
          config:
            type: TEXT
            priority: '21'
            section_name: Filters
            label: 'Include virtual cloud network names filter'
            description: 'Regex string of virtual cloud network names to allow in discovery.'
        - macro: '{$OCI.VCN.DISCOVERY.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of virtual cloud network names to ignore in discovery.'
          config:
            type: TEXT
            priority: '22'
            section_name: Filters
            label: 'Exclude virtual cloud network names filter'
            description: 'Regex string of virtual cloud network names to ignore in discovery.'
        - macro: '{$OCI.VCN.DISCOVERY.STATE.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of virtual cloud network states to allow in discovery.'
          config:
            type: TEXT
            priority: '19'
            section_name: Filters
            label: 'Include virtual cloud network states filter'
            description: 'Regex string of virtual cloud network states to allow in discovery.'
        - macro: '{$OCI.VCN.DISCOVERY.STATE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of virtual cloud network states to ignore in discovery.'
          config:
            type: TEXT
            priority: '20'
            section_name: Filters
            label: 'Exclude virtual cloud network states filter'
            description: 'Regex string of virtual cloud network states to ignore in discovery.'
        - macro: '{$OCI.VOLUME.BLOCK.DISCOVERY.NAME.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of block volume names to allow in discovery.'
          config:
            type: TEXT
            priority: '25'
            section_name: Filters
            label: 'Include block volume names filter'
            description: 'Regex string of block volume names to allow in discovery.'
        - macro: '{$OCI.VOLUME.BLOCK.DISCOVERY.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of block volume names to ignore in discovery.'
          config:
            type: TEXT
            priority: '26'
            section_name: Filters
            label: 'Exclude block volume names filter'
            description: 'Regex string of block volume names to ignore in discovery.'
        - macro: '{$OCI.VOLUME.BLOCK.DISCOVERY.STATE.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of block volume states to allow in discovery.'
          config:
            type: TEXT
            priority: '23'
            section_name: Filters
            label: 'Include block volume states filter'
            description: 'Regex string of block volume states to allow in discovery.'
        - macro: '{$OCI.VOLUME.BLOCK.DISCOVERY.STATE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of block volume states to ignore in discovery.'
          config:
            type: TEXT
            priority: '24'
            section_name: Filters
            label: 'Exclude block volume states filter'
            description: 'Regex string of block volume states to ignore in discovery.'
        - macro: '{$OCI.VOLUME.BOOT.DISCOVERY.NAME.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of boot volume names to allow in discovery.'
          config:
            type: TEXT
            priority: '29'
            section_name: Filters
            label: 'Include boot volume names filter'
            description: 'Regex string of boot volume names to allow in discovery.'
        - macro: '{$OCI.VOLUME.BOOT.DISCOVERY.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of boot volume names to ignore in discovery.'
          config:
            type: TEXT
            priority: '30'
            section_name: Filters
            label: 'Exclude boot volume names filter'
            description: 'Regex string of boot volume names to ignore in discovery.'
        - macro: '{$OCI.VOLUME.BOOT.DISCOVERY.STATE.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of boot volume states to allow in discovery.'
          config:
            type: TEXT
            priority: '27'
            section_name: Filters
            label: 'Include boot volume states filter'
            description: 'Regex string of boot volume states to allow in discovery.'
        - macro: '{$OCI.VOLUME.BOOT.DISCOVERY.STATE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of boot volume states to ignore in discovery.'
          config:
            type: TEXT
            priority: '28'
            section_name: Filters
            label: 'Exclude boot volume states filter'
            description: 'Regex string of boot volume states to ignore in discovery.'
    - uuid: e6b0aada359944d09ee4bd46c1a55587
      template: 'Oracle Cloud Compute by HTTP'
      name: 'Oracle Cloud Compute by HTTP'
      description: |
        This template monitors Oracle Cloud Infrastructure (OCI) single compute instance resources and discovers attached
        virtual network interface cards (VNICs) and monitors their resources.
        
        This template is not meant to be used independently, but together with Oracle Cloud by HTTP as a template for
        LLD host prototypes.
        
        Read the template documentation prior to using this 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.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 657ad1d54de4454696573418f5f17f11
          name: 'Get instance availability'
          type: SCRIPT
          key: oci.compute.availability.get
          delay: 5m
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'instance_id', 'http_status_code', 'req_interval', 'compartment_id'], params);
            var oci = new OCI('Compute', 'Get health', params);
            const mql = 'InstanceAccessibilityStatus[' + params['req_interval'] + 'm]{resourceId=' + params['instance_id'] + '}.max()';
            
            return JSON.stringify(oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), mql, 'oci_compute_instance_health'), 'aggregatedDatapoints'));
          description: |
            The accessibility status of a virtual machine instance.
            A value of "1" indicates that the instance is unresponsive due to an issue with
            the infrastructure or the instance itself.
            A value of "0" indicates that an accessibility issue has not been detected.
            If the instance is stopped, then the metric does not have a value.
          valuemap:
            name: 'Compute instance availability'
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.TELEMETRY.HOST}'
            - name: compartment_id
              value: '{$OCI.COMPUTE.COMPARTMENT.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: instance_id
              value: '{$OCI.COMPUTE.INSTANCE.ID}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: req_interval
              value: '5'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: environment
          triggers:
            - uuid: dbaee26c1de544d08fa6dd76ddc4c06a
              expression: 'last(/Oracle Cloud Compute by HTTP/oci.compute.availability.get) = 1'
              name: 'OCI Compute: Compute instance is not available'
              priority: HIGH
              description: 'Current instance availability.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 04a1f534ae844021be0935abf1214951
          name: 'CPU utilization, in %'
          type: DEPENDENT
          key: oci.compute.cpu.util
          value_type: FLOAT
          units: '%'
          description: 'Activity level from the CPU. Expressed as a percentage of the total time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.CpuUtilization
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.compute.metrics.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 38987527713b404f842e26ad12ce3015
              expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.cpu.util,5m) >= {$OCI.COMPUTE.CPU.UTIL.WARN}'
              name: 'OCI Compute: Current CPU utilization is high'
              event_name: 'OCI Compute: Current CPU utilization is high (util >= {$OCI.COMPUTE.CPU.UTIL.WARN}%)'
              opdata: 'Current: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'Current CPU utilization has exceeded `{$OCI.COMPUTE.CPU.UTIL.WARN}`% of the max available value.'
              dependencies:
                - name: 'OCI Compute: Current CPU utilization is too high'
                  expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.cpu.util,5m) >= {$OCI.COMPUTE.CPU.UTIL.HIGH}'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 082ba105bf614996a68054ad8c7d7101
              expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.cpu.util,5m) >= {$OCI.COMPUTE.CPU.UTIL.HIGH}'
              name: 'OCI Compute: Current CPU utilization is too high'
              event_name: 'OCI Compute: Current CPU utilization is too high (util >= {$OCI.COMPUTE.CPU.UTIL.HIGH}%)'
              opdata: 'Current: {ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'Current CPU utilization has exceeded `{$OCI.COMPUTE.CPU.UTIL.HIGH}`% of the max available value.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 670783a729a647db9349d78ac61f1d94
          name: 'Disk read I/O'
          type: DEPENDENT
          key: oci.compute.disk.io.read
          value_type: FLOAT
          units: '!reads/s'
          description: 'Activity level from I/O reads. Expressed as reads per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.DiskIopsRead
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.compute.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: cbd32ebd403c48b2b2f9815f13407afe
          name: 'Disk write I/O'
          type: DEPENDENT
          key: oci.compute.disk.io.write
          value_type: FLOAT
          units: '!writes/s'
          description: 'Activity level from I/O writes. Expressed as writes per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.DiskIopsWritten
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.compute.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 15d234ef381747bfb76e7ccf9169046d
          name: 'Disk bytes read'
          type: DEPENDENT
          key: oci.compute.disk.read
          value_type: FLOAT
          units: Bps
          description: 'Read throughput. Expressed as bytes read per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.DiskBytesRead
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.compute.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: c7e061599b474ac49082d28572ab74c6
          name: 'Disk bytes written'
          type: DEPENDENT
          key: oci.compute.disk.written
          value_type: FLOAT
          units: Bps
          description: 'Write throughput. Expressed as bytes written per interval.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.DiskBytesWritten
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.compute.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 75308c4fb9bd4bad8fbb80aa9b62b099
          name: 'Load average'
          type: DEPENDENT
          key: oci.compute.load.avg
          value_type: FLOAT
          units: '!processes'
          description: 'Average system load calculated over a 1-minute period. Expressed as a number of processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.LoadAverage
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.compute.metrics.get
          tags:
            - tag: component
              value: environment
        - uuid: 610796958f694aa99f3e9ea1082972bf
          name: 'Memory allocation stalls'
          type: DEPENDENT
          key: oci.compute.mem.stalls
          value_type: FLOAT
          units: '!stalls'
          description: 'Number of times page reclaim was called directly.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.MemoryAllocationStalls
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.compute.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: ef284ac17689442e835b686126161bc5
          name: 'Memory utilization, in %'
          type: DEPENDENT
          key: oci.compute.mem.util
          value_type: FLOAT
          units: '%'
          description: 'Space currently in use, measured in pages. Expressed as a percentage of used pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.MemoryUtilization
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.compute.metrics.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 9baaacf70a4446a7ae816afdc4db0ae8
              expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.mem.util,5m) >= {$OCI.COMPUTE.MEM.UTIL.WARN}'
              name: 'OCI Compute: Current memory utilization is high'
              event_name: 'OCI Compute: Current memory utilization is high (util >= {$OCI.COMPUTE.MEM.UTIL.WARN}%)'
              opdata: 'Current: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'Current memory utilization has exceeded `{$OCI.COMPUTE.MEM.UTIL.WARN}`% of the max available value.'
              dependencies:
                - name: 'OCI Compute: Current memory utilization is too high'
                  expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.mem.util,5m) >= {$OCI.COMPUTE.MEM.UTIL.HIGH}'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 3b894aa250f04ebdb63fb8a914fbd72a
              expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.mem.util,5m) >= {$OCI.COMPUTE.MEM.UTIL.HIGH}'
              name: 'OCI Compute: Current memory utilization is too high'
              event_name: 'OCI Compute: Current memory utilization is too high (util >= {$OCI.COMPUTE.MEM.UTIL.HIGH}%)'
              opdata: 'Current: {ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'Current memory utilization has exceeded `{$OCI.COMPUTE.MEM.UTIL.HIGH}`% of the max available value.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 65ff665a67374bb082f260ca473dfb1b
          name: 'Get compute metrics'
          type: SCRIPT
          key: oci.compute.metrics.get
          history: '0'
          value_type: TEXT
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            function buildMql(id, metrics, defaultStatistic, resourceType) {
            	resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType;
            	this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.';
            
            	for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            		const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic]));
            		metrics[i] = [metric[0], this.query + metric[1]];
            	}
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'instance_id', 'http_status_code', 'req_interval', 'compartment_id'], params);
            var oci = new OCI('Compute', 'Get metrics', params);
            
            const metrics = [
            	['CpuUtilization', 'mean'],
            	['MemoryUtilization', 'mean'],
            	['LoadAverage', 'mean'],
            	['MemoryAllocationStalls', 'mean'],
            	'DiskBytesRead',
            	'DiskBytesWritten',
            	'DiskIopsRead',
            	'DiskIopsWritten',
            	'NetworksBytesIn',
            	'NetworksBytesOut'
            ];
            buildMql(params['instance_id'], metrics, 'rate');
            
            var result = {};
            for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            	result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_computeagent'), 'aggregatedDatapoints');
            }
            return JSON.stringify(result);
          description: 'Gets compute instance metrics.'
          timeout: 30s
          parameters:
            - name: api_host
              value: '{$OCI.API.TELEMETRY.HOST}'
            - name: compartment_id
              value: '{$OCI.COMPUTE.COMPARTMENT.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: instance_id
              value: '{$OCI.COMPUTE.INSTANCE.ID}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: req_interval
              value: '1'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: raw
        - uuid: 0c910a86a99b47f08dee930f07422f45
          name: 'Network bytes in'
          type: DEPENDENT
          key: oci.compute.network.in
          value_type: FLOAT
          units: Bps
          description: 'Network bytes in for the compute instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.NetworksBytesIn
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.compute.metrics.get
          tags:
            - tag: component
              value: network
        - uuid: a7a027ae583740e19e5f6288b3f15d10
          name: 'Network bytes out'
          type: DEPENDENT
          key: oci.compute.network.out
          value_type: FLOAT
          units: Bps
          description: 'Network bytes out for the compute instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.NetworksBytesOut
            - type: JAVASCRIPT
              parameters:
                - 'return Math.round(value * 100) / 100;'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.compute.metrics.get
          tags:
            - tag: component
              value: network
        - uuid: 3c4a11c3c8fe40fca36635e2a6882816
          name: State
          type: SCRIPT
          key: oci.compute.state.get
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'instance_id', 'http_status_code'], params);
            var oci = new OCI('Compute', 'Get state', params);
            
            return oci.extractData('get', oci.executeRequest('get', '/20160918/instances/' + encodeURIComponent(params['instance_id']), ''), 'lifecycleState');
          description: 'The current state of the instance.'
          valuemap:
            name: 'Compute instance state'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = {
                  	'MOVING': 1,
                  	'PROVISIONING': 2,
                  	'RUNNING': 3,
                  	'STARTING': 4,
                  	'STOPPING': 5,
                  	'STOPPED': 6,
                  	'CREATING_IMAGE': 7,
                  	'TERMINATING': 8,
                  	'TERMINATED': 9
                  };
                  
                  return typeof idx[value] === 'undefined' ? 0 : idx[value];
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.CORE.HOST}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: instance_id
              value: '{$OCI.COMPUTE.INSTANCE.ID}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: environment
          triggers:
            - uuid: 2bce7c23998f4331a5eca3507fc671d9
              expression: 'last(/Oracle Cloud Compute by HTTP/oci.compute.state.get,#1)<>last(/Oracle Cloud Compute by HTTP/oci.compute.state.get,#2)'
              name: 'OCI Compute: State has changed'
              event_name: 'OCI Compute: State has changed (new state: {ITEM.VALUE})'
              opdata: 'Current state: {ITEM.LASTVALUE}'
              priority: INFO
              description: 'Compute instance state has changed.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: c0e74098afb14984af6355ac0711662e
          name: 'Get VNICs'
          type: SCRIPT
          key: oci.compute.vnic.get
          history: '0'
          value_type: TEXT
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'instance_id', 'availability_domain', 'http_status_code', 'compartment_id'], params);
            var oci = new OCI('Compute', 'Get VNICs', params);
            
            return JSON.stringify(oci.extractData('get', oci.executeRequest('get', '/20160918/vnicAttachments', '?compartmentId=' + encodeURIComponent(params['compartment_id']) + '&availabilityDomain=' + encodeURIComponent(params['availability_domain']) + '&instanceId=' + encodeURIComponent(params['instance_id'])), ['vnicId', 'displayName', 'lifecycleState']));
          description: 'Gets information about all virtual network interface cards attached to the instance.'
          timeout: 30s
          parameters:
            - name: api_host
              value: '{$OCI.API.CORE.HOST}'
            - name: availability_domain
              value: '{$OCI.COMPUTE.AVAILABILITY.DOMAIN}'
            - name: compartment_id
              value: '{$OCI.COMPUTE.COMPARTMENT.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: instance_id
              value: '{$OCI.COMPUTE.INSTANCE.ID}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: raw
      discovery_rules:
        - uuid: 4f4a058b2a0b4bddb4ddbdb7613934af
          name: 'VNIC discovery'
          type: DEPENDENT
          key: oci.compute.vnic.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#NAME}'
                value: '{$OCI.COMPUTE.VNIC.DISCOVERY.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$OCI.COMPUTE.VNIC.DISCOVERY.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#STATE}'
                value: '{$OCI.COMPUTE.VNIC.DISCOVERY.STATE.MATCHES}'
              - macro: '{#STATE}'
                value: '{$OCI.COMPUTE.VNIC.DISCOVERY.STATE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover compute instance VNICs.'
          item_prototypes:
            - uuid: 45fc4a9241f147c88e45352ac0f5018d
              name: 'VNIC [{#NAME}]: Attachment state'
              type: DEPENDENT
              key: 'oci.compute.vnic.attachment[{#ID}]'
              description: 'Current attachment state of the VNIC.'
              valuemap:
                name: 'VNIC attachment state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == ''{#ID}'')].state.first()'
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const idx = {
                      	'ATTACHING': 1,
                      	'ATTACHED': 2,
                      	'DETACHING': 3,
                      	'DETACHED': 4
                      };
                      
                      return typeof idx[value] === 'undefined' ? 0 : idx[value];
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: oci.compute.vnic.get
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
              trigger_prototypes:
                - uuid: 7176da6364464cfcacadfcfe7e81fdb3
                  expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.vnic.attachment[{#ID}],5m) >= 3'
                  name: 'OCI Compute: VNIC [{#NAME}]: VNIC is not attached'
                  priority: HIGH
                  description: 'Virtual network interface card attachment status.'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: a9f4e55f3dd848b8bf0c861c81c2690a
              name: 'VNIC [{#NAME}]: Egress packets dropped by security list'
              type: DEPENDENT
              key: 'oci.compute.vnic.egress.packets.dropped[{#ID}]'
              units: '!packets'
              description: 'Packets sent by the VNIC, destined for the network, dropped due to security rule violations.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicEgressDropsSecurityList
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: 0ac50b3b570a470ca301185489c4d2a4
              name: 'VNIC [{#NAME}]: Smartnic buffer drops from host'
              type: DEPENDENT
              key: 'oci.compute.vnic.host.smartnic.drops[{#ID}]'
              units: '!packets'
              description: |
                Number of packets dropped in SmartNIC from the host due to buffer exhaustion.
                This metric is available only for Bare Metal Instances. For virtual machines, these metric values are zero.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.SmartnicBufferDropsFromHost
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: 86258bd1db6a46c9862f175acac2daf2
              name: 'VNIC [{#NAME}]: Ingress packets dropped by security list'
              type: DEPENDENT
              key: 'oci.compute.vnic.ingress.packets.dropped[{#ID}]'
              units: '!packets'
              description: 'Packets received from the network, destined for the VNIC, dropped due to security rule violations.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicIngressDropsSecurityList
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: eb79782153524452ba4ba8506fb207a5
              name: 'VNIC [{#NAME}]: Get metrics'
              type: SCRIPT
              key: 'oci.compute.vnic.metrics.get[{#ID}]'
              history: '0'
              value_type: TEXT
              params: |
                function validateZabbixParams(requiredParams, allParams) {
                	requiredParams.forEach(function (field) {
                		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
                			throw 'Required param is not set: ' + field + '.';
                		}
                	});
                }
                
                function OCI(service, action, params) {
                	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
                	this.request = new HttpRequest();
                
                	this.hash = function (string) {
                		return sha256(string);
                	};
                
                	this.sign = function (string) {
                		return sign('sha256', params['private_key'], string);
                	};
                
                	this.encode = function (hash) {
                		const hexArr = hash.match(/.{1,2}/g);
                		var uInt8Array = new Uint8Array(hexArr.length);
                		hexArr.forEach(function (hex, idx) {
                			uInt8Array[idx] = parseInt(hex, 16);
                		});
                		return btoa(uInt8Array);
                	};
                
                	this.getDate = function () {
                		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
                		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
                		const today = new Date();
                		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
                	};
                
                	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
                		var headers = '(request-target) date host';
                		const contentTypeHeader = 'content-type: application/json';
                		const dateHeader = 'date: ' + this.getDate();
                		const hostHeader = 'host: ' + params['api_host'];
                		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
                		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
                		var reqHeaders = [contentTypeHeader, dateHeader];
                
                		if (httpMethod === 'post') {
                			var body = JSON.stringify({
                				'namespace': namespace,
                				'query': mql
                			});
                			headers = headers + ' x-content-sha256 content-type content-length';
                			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
                			const bodyLengthHeader = 'content-length: ' + body.length;
                			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
                			reqHeaders.push(bodyHeader, bodyLengthHeader);
                		}
                
                		const signature = this.encode(this.sign(signingString));
                
                		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
                		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
                			this.request.addHeader(reqHeaders[header]);
                		}
                
                		if (params['http_proxy']) {
                			this.request.setProxy(params['http_proxy']);
                			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
                		}
                
                		if (httpMethod === 'post') {
                			var apiRateLimitExceeded = false;
                			do {
                				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
                
                				try {
                					if (JSON.parse(response)['code'] === 'TooManyRequests') {
                
                						apiRateLimitExceeded = true;
                						Zabbix.sleep(1000);
                					} else {
                						apiRateLimitExceeded = false;
                					}
                				} catch (error) {
                					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
                					throw 'Could not parse the response. See logs for more information.';
                				}
                			} while (apiRateLimitExceeded);
                		} else {
                			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
                		}
                
                		this.request.clearHeader();
                
                		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
                			return response;
                		} else {
                			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
                			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
                		}
                	};
                
                	this.extractData = function (httpMethod, data, keys, compartment) {
                		try {
                			data = JSON.parse(data);
                		} catch (error) {
                			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
                			throw 'Could not parse received JSON object. See logs for more information.';
                		}
                
                		if (typeof keys == 'object') {
                			var returnBuffer = [];
                			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
                
                				var objectBuffer = {};
                				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
                					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
                						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
                					} else {
                						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
                						throw 'Received an unexpected JSON object. See logs for more information.';
                					}
                				}
                				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
                				returnBuffer.push(objectBuffer);
                			}
                			return returnBuffer;
                		}
                
                		try {
                			if (httpMethod === 'get') {
                				return data[keys];
                			} else {
                				if (data.length === 0) {
                					return 0;
                				}
                				data = data[0][keys];
                				return data[data.length - 1]['value'];
                			}
                		} catch (error) {
                			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
                			throw 'Could not find required key in JSON object. See logs for more information.';
                		}
                	};
                }
                
                function buildMql(id, metrics, defaultStatistic, resourceType) {
                	resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType;
                	this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.';
                
                	for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
                		const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic]));
                		metrics[i] = [metric[0], this.query + metric[1]];
                	}
                }
                
                
                const params = JSON.parse(value);
                validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'vnic_id', 'http_status_code', 'req_interval', 'compartment_id'], params);
                var oci = new OCI('Compute - VNIC', 'Get metrics', params);
                
                const metrics = [
                	'VnicEgressDropsSecurityList',
                	'VnicIngressDropsSecurityList',
                	'VnicFromNetworkBytes',
                	'VnicFromNetworkPackets',
                	'VnicToNetworkBytes',
                	'VnicToNetworkPackets',
                	'VnicIngressDropsThrottle',
                	'VnicEgressDropsThrottle',
                	'VnicIngressDropsConntrackFull',
                	'VnicEgressDropsConntrackFull',
                	'VnicConntrackUtilPercent',
                	['VnicConntrackIsFull', 'last'],
                	'SmartnicBufferDropsFromNetwork',
                	'SmartnicBufferDropsFromHost'
                ];
                buildMql(params['vnic_id'], metrics, 'sum');
                
                var result = {};
                for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
                	result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_vcn'), 'aggregatedDatapoints');
                }
                return JSON.stringify(result);
              description: 'Gets virtual network interface card metrics.'
              timeout: 30s
              parameters:
                - name: api_host
                  value: '{$OCI.API.TELEMETRY.HOST}'
                - name: compartment_id
                  value: '{$OCI.COMPUTE.COMPARTMENT.ID}'
                - name: fingerprint
                  value: '{$OCI.API.FINGERPRINT}'
                - name: http_proxy
                  value: '{$OCI.HTTP.PROXY}'
                - name: http_status_code
                  value: '{$OCI.HTTP.RETURN.CODE.OK}'
                - name: private_key
                  value: '{$OCI.API.PRIVATE.KEY}'
                - name: req_interval
                  value: '1'
                - name: tenancy_ocid
                  value: '{$OCI.API.TENANCY}'
                - name: user_ocid
                  value: '{$OCI.API.USER}'
                - name: vnic_id
                  value: '{#ID}'
              tags:
                - tag: component
                  value: raw
            - uuid: e083fab486984a1d8c0947924e2e6c60
              name: 'VNIC [{#NAME}]: Bytes to network'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.bytes.egr[{#ID}]'
              units: B
              description: 'Bytes sent from the VNIC to the network, before drops.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicToNetworkBytes
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: 09b608c006b34276b34356802f755ce7
              name: 'VNIC [{#NAME}]: Bytes from network'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.bytes.ingr[{#ID}]'
              units: B
              description: 'Bytes received at the VNIC from the network, after drops.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicFromNetworkBytes
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: 9e4d0babdaad4f7291974881d88fa991
              name: 'VNIC [{#NAME}]: Connection tracking table full'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.conntrack.full[{#ID}]'
              description: 'Boolean (0/false, 1/true) that indicates the connection tracking table is full.'
              valuemap:
                name: 'Generic Bool'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicConntrackIsFull
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
              trigger_prototypes:
                - uuid: 4faafcd1719745749ae1e3b2c58a09d0
                  expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.vnic.net.conntrack.full[{#ID}],5m) = 1'
                  name: 'OCI Compute: VNIC [{#NAME}]: Conntrack table full'
                  priority: HIGH
                  description: 'Virtual network interface card connection tracking table is full.'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 088fc9f8d317402099ed0cda9dffb525
              name: 'VNIC [{#NAME}]: Connection tracking table utilization, in %'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.conntrack.util[{#ID}]'
              units: '%'
              description: 'Total utilization percentage (0-100%) of the connection tracking table.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicConntrackUtilPercent
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
              trigger_prototypes:
                - uuid: c2fd382491624a74b2956be3dad187ea
                  expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.vnic.net.conntrack.util[{#ID}],5m) >= {$OCI.COMPUTE.VNIC.CONNTRACK.UTIL.WARN}'
                  name: 'OCI Compute: VNIC [{#NAME}]: Current conntrack table utilization is high'
                  event_name: 'OCI Compute: VNIC [{#NAME}]: Current conntrack table utilization is high (util >= {$OCI.COMPUTE.VNIC.CONNTRACK.UTIL.WARN}%)'
                  opdata: 'Current: {ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: 'Current conntrack table utilization has exceeded `{$OCI.COMPUTE.VNIC.CONNTRACK.UTIL.WARN}`% of the max available value.'
                  dependencies:
                    - name: 'OCI Compute: VNIC [{#NAME}]: Current conntrack table utilization is too high'
                      expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.vnic.net.conntrack.util[{#ID}],5m) >= {$OCI.COMPUTE.VNIC.CONNTRACK.UTIL.HIGH}'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: cf98ffe12a2b413c9b1384e9ec167cbd
                  expression: 'min(/Oracle Cloud Compute by HTTP/oci.compute.vnic.net.conntrack.util[{#ID}],5m) >= {$OCI.COMPUTE.VNIC.CONNTRACK.UTIL.HIGH}'
                  name: 'OCI Compute: VNIC [{#NAME}]: Current conntrack table utilization is too high'
                  event_name: 'OCI Compute: VNIC [{#NAME}]: Current conntrack table utilization is too high (util >= {$OCI.COMPUTE.VNIC.CONNTRACK.UTIL.HIGH}%)'
                  opdata: 'Current: {ITEM.LASTVALUE1}'
                  priority: HIGH
                  description: 'Current conntrack table utilization has exceeded `{$OCI.COMPUTE.VNIC.CONNTRACK.UTIL.HIGH}`% of the max available value.'
                  tags:
                    - tag: scope
                      value: capacity
            - uuid: 23be348ca25948468df11644a5f51d0d
              name: 'VNIC [{#NAME}]: Egress packets dropped by full connection tracking table'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.packets.egr.drop[{#ID}]'
              units: '!packets'
              description: 'Packets sent from the VNIC, destined for the network, dropped due to the full connection tracking table.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicEgressDropsConntrackFull
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: bfa72f1cfc294d2b819cea22dbe7ddd8
              name: 'VNIC [{#NAME}]: Throttled egress packets'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.packets.egr.throttled[{#ID}]'
              units: '!packets'
              description: 'Packets sent from the VNIC, destined for the network, dropped due to throttling.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicEgressDropsThrottle
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: 06cee1bacd744926ac61f72cd8ba3ae5
              name: 'VNIC [{#NAME}]: Packets to network'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.packets.egr[{#ID}]'
              units: '!packets'
              description: 'Packets sent from the VNIC to the network, before drops.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicToNetworkPackets
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: 2564ee2fa8bd4d5f9859506c1486f45f
              name: 'VNIC [{#NAME}]: Ingress packets dropped by full connection tracking table'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.packets.ingr.drop[{#ID}]'
              units: '!packets'
              description: 'Packets received from the network, destined for the VNIC, dropped due to the full connection tracking table.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicIngressDropsConntrackFull
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: 595654f8255f454fba44abfcfeeb8c14
              name: 'VNIC [{#NAME}]: Throttled ingress packets'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.packets.ingr.throttled[{#ID}]'
              units: '!packets'
              description: 'Packets received from the network, destined for the VNIC, dropped due to throttling.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicIngressDropsThrottle
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: 9c37d782e3594e199f0c77010853d893
              name: 'VNIC [{#NAME}]: Packets from network'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.packets.ingr[{#ID}]'
              units: '!packets'
              description: 'Packets received at the VNIC from the network, after drops.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.VnicFromNetworkPackets
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
            - uuid: 400c523fe78b4264948e363f278bbc6d
              name: 'VNIC [{#NAME}]: Smartnic buffer drops from network'
              type: DEPENDENT
              key: 'oci.compute.vnic.net.smartnic.drops[{#ID}]'
              units: '!packets'
              description: |
                Number of packets dropped in SmartNIC from the network due to buffer exhaustion.
                This metric is available only for Bare Metal Instances. For virtual machines, these metric values are zero.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.SmartnicBufferDropsFromNetwork
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'oci.compute.vnic.metrics.get[{#ID}]'
              tags:
                - tag: component
                  value: network
                - tag: vnic
                  value: '{#ID}'
          graph_prototypes:
            - uuid: 7a02ebf104a24f3ebd1631003dc7365c
              name: 'VNIC [{#NAME}]: Network bytes in'
              graph_items:
                - color: 00D936
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.bytes.ingr[{#ID}]'
            - uuid: 50306b25bef24d95acd2d9ae9e0c1f6f
              name: 'VNIC [{#NAME}]: Network bytes out'
              graph_items:
                - color: 2196F3
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.bytes.egr[{#ID}]'
            - uuid: 4f3c1eabc2be43b68c4a76a6bed17761
              name: 'VNIC [{#NAME}]: Network packets dropped by connection tracking table'
              graph_items:
                - color: 199C0D
                  yaxisside: RIGHT
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.conntrack.util[{#ID}]'
                - sortorder: '1'
                  color: 00D936
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.packets.ingr.drop[{#ID}]'
                - sortorder: '2'
                  color: 0208bf
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.packets.egr.drop[{#ID}]'
            - uuid: 3d9f549442ac455eb0e5296594eac004
              name: 'VNIC [{#NAME}]: Network packets dropped by security list'
              graph_items:
                - color: 00D936
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.packets.ingr.drop[{#ID}]'
                - sortorder: '1'
                  color: 0208bf
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.packets.egr.drop[{#ID}]'
            - uuid: 2c4626b63df0468caef94e405e499aaa
              name: 'VNIC [{#NAME}]: Network packets in'
              graph_items:
                - color: 00D936
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.packets.ingr[{#ID}]'
                - sortorder: '1'
                  color: 008C23
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.packets.ingr.throttled[{#ID}]'
            - uuid: 4fe14e23a0414b8787749aababc35ceb
              name: 'VNIC [{#NAME}]: Network packets out'
              graph_items:
                - color: 2196F3
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.packets.egr[{#ID}]'
                - sortorder: '1'
                  color: 0208bf
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.packets.egr.throttled[{#ID}]'
            - uuid: fdaad88126dd486b948348e993217c8f
              name: 'VNIC [{#NAME}]: Smartnic buffer drops'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.net.smartnic.drops[{#ID}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Oracle Cloud Compute by HTTP'
                    key: 'oci.compute.vnic.host.smartnic.drops[{#ID}]'
          master_item:
            key: oci.compute.vnic.get
          lld_macro_paths:
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#STATE}'
              path: $.state
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
      tags:
        - tag: class
          value: cloud
        - tag: class
          value: database
        - tag: subclass
          value: automation
        - tag: subclass
          value: bigdata
        - tag: subclass
          value: deploy
        - tag: target
          value: oci
        - tag: target
          value: oracle-cloud-infrastructure
      macros:
        - macro: '{$OCI.COMPUTE.CPU.UTIL.HIGH}'
          value: '90'
          description: 'Sets the percentage threshold for creating a "high" severity event about CPU resource utilization.'
        - macro: '{$OCI.COMPUTE.CPU.UTIL.WARN}'
          value: '75'
          description: 'Sets the percentage threshold for creating a "warning" severity event about CPU resource utilization.'
        - macro: '{$OCI.COMPUTE.MEM.UTIL.HIGH}'
          value: '90'
          description: 'Sets the percentage threshold for creating a "high" severity event about memory resource utilization.'
        - macro: '{$OCI.COMPUTE.MEM.UTIL.WARN}'
          value: '75'
          description: 'Sets the percentage threshold for creating a "warning" severity event about memory resource utilization.'
        - macro: '{$OCI.COMPUTE.VNIC.CONNTRACK.UTIL.HIGH}'
          value: '90'
          description: 'Sets the percentage threshold for creating a "high" severity event about VNIC connection tracking table utilization.'
        - macro: '{$OCI.COMPUTE.VNIC.CONNTRACK.UTIL.WARN}'
          value: '75'
          description: 'Sets the percentage threshold for creating a "warning" severity event about VNIC connection tracking table utilization.'
        - macro: '{$OCI.COMPUTE.VNIC.DISCOVERY.NAME.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of VNIC names to allow in discovery.'
        - macro: '{$OCI.COMPUTE.VNIC.DISCOVERY.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of VNIC names to ignore in discovery.'
        - macro: '{$OCI.COMPUTE.VNIC.DISCOVERY.STATE.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of VNIC states to allow in discovery.'
        - macro: '{$OCI.COMPUTE.VNIC.DISCOVERY.STATE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of VNIC states to ignore in discovery.'
        - macro: '{$OCI.HTTP.PROXY}'
          description: 'Set an HTTP proxy for OCI API requests if needed.'
        - macro: '{$OCI.HTTP.RETURN.CODE.OK}'
          value: '200'
          description: 'Set the HTTP return code that represents an OK response from the API. The default is "200",  but can vary, for example, if a proxy is used.'
      dashboards:
        - uuid: edab80c89bcf43d6ada2e4ed5477d36f
          name: 'OCI Compute: Overview'
          pages:
            - name: Main
              display_period: '60'
              widgets:
                - type: item
                  name: State
                  width: '27'
                  height: '4'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: STRING
                      name: description
                      value: 'Current State'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.availability.get
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_size
                      value: '35'
                - type: item
                  name: 'Disk bytes read'
                  'y': '4'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Disk Bytes Read'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.disk.read
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '20'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Disk read I/O'
                  'y': '7'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Disk Read I/O'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.disk.io.read
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '20'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Disk bytes written'
                  x: '15'
                  'y': '4'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Disk Bytes Written'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.disk.written
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '20'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Disk write I/O'
                  x: '15'
                  'y': '7'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Disk Write I/O'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.disk.io.write
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '20'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: Availability
                  x: '27'
                  width: '15'
                  height: '4'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: STRING
                      name: description
                      value: Availability
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.availability.get
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_size
                      value: '20'
                - type: item
                  name: 'Net bytes in'
                  x: '30'
                  'y': '4'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FF0000
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Net Bytes In'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.network.in
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Net bytes out'
                  x: '30'
                  'y': '7'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FF0000
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Net Bytes Out'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.network.out
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Load average'
                  x: '42'
                  width: '30'
                  height: '4'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Load Average'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.load.avg
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: gauge
                  name: CPU
                  x: '48'
                  'y': '4'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: STRING
                      name: description
                      value: CPU
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: STRING
                      name: empty_color
                      value: 145C96
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.cpu.util
                    - type: STRING
                      name: max
                      value: '100'
                    - type: STRING
                      name: min
                      value: '0'
                    - type: INTEGER
                      name: rf_rate
                      value: '30'
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: show.2
                      value: '5'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_bold
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: STRING
                      name: value_arc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_arc_size
                      value: '35'
                    - type: INTEGER
                      name: value_bold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Memory allocation stalls'
                  x: '48'
                  'y': '7'
                  width: '24'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FBC02D
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Memory Allocation Stalls'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.mem.stalls
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: gauge
                  name: Memory
                  x: '60'
                  'y': '4'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: STRING
                      name: description
                      value: Memory
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: STRING
                      name: empty_color
                      value: 145C96
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.mem.util
                    - type: STRING
                      name: max
                      value: '100'
                    - type: STRING
                      name: min
                      value: '0'
                    - type: INTEGER
                      name: rf_rate
                      value: '30'
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: show.2
                      value: '5'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_bold
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: STRING
                      name: value_arc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_arc_size
                      value: '35'
                    - type: INTEGER
                      name: value_bold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
            - name: CPU/Mem
              display_period: '30'
              widgets:
                - type: gauge
                  name: CPU
                  width: '24'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: STRING
                      name: description
                      value: CPU
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: STRING
                      name: empty_color
                      value: 145C96
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.cpu.util
                    - type: STRING
                      name: max
                      value: '100'
                    - type: STRING
                      name: min
                      value: '0'
                    - type: INTEGER
                      name: rf_rate
                      value: '30'
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: show.2
                      value: '5'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_bold
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: STRING
                      name: value_arc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_arc_size
                      value: '35'
                    - type: INTEGER
                      name: value_bold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'CPU utilization'
                  'y': '3'
                  width: '24'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Cpu utilization'
                    - type: STRING
                      name: reference
                      value: ABAAA
                - type: gauge
                  name: Memory
                  x: '24'
                  width: '48'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: STRING
                      name: description
                      value: Memory
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: STRING
                      name: empty_color
                      value: 145C96
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.mem.util
                    - type: STRING
                      name: max
                      value: '100'
                    - type: STRING
                      name: min
                      value: '0'
                    - type: INTEGER
                      name: rf_rate
                      value: '30'
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: INTEGER
                      name: show.2
                      value: '5'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_bold
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: STRING
                      name: value_arc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_arc_size
                      value: '35'
                    - type: INTEGER
                      name: value_bold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Memory utilization'
                  x: '24'
                  'y': '3'
                  width: '24'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Memory utilization'
                    - type: STRING
                      name: reference
                      value: ABAAB
                - type: graph
                  name: 'Memory allocation stalls'
                  x: '48'
                  'y': '3'
                  width: '24'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Memory allocation stalls'
                    - type: STRING
                      name: reference
                      value: ABAAC
            - name: 'Net In/Out'
              display_period: '30'
              widgets:
                - type: item
                  name: 'Net bytes in'
                  width: '36'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FF0000
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Net Bytes In'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.network.in
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Network bytes in'
                  'y': '3'
                  width: '36'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Network bytes in'
                    - type: STRING
                      name: reference
                      value: ACAAA
                - type: item
                  name: 'Net bytes out'
                  x: '36'
                  width: '36'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FF0000
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Net Bytes Out'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.network.out
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Network bytes out'
                  x: '36'
                  'y': '3'
                  width: '36'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Network bytes out'
                    - type: STRING
                      name: reference
                      value: ACAAC
            - name: Disk
              display_period: '30'
              widgets:
                - type: item
                  name: 'Disk bytes read'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Disk Bytes Read'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.disk.read
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Disk bytes read'
                  'y': '3'
                  width: '18'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Disk bytes read'
                    - type: STRING
                      name: reference
                      value: ADAAA
                - type: item
                  name: 'Disk bytes written'
                  x: '18'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Disk Bytes Written'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.disk.written
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Disk bytes written'
                  x: '18'
                  'y': '3'
                  width: '18'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Disk bytes written'
                    - type: STRING
                      name: reference
                      value: ADAAB
                - type: item
                  name: 'Disk read i/o'
                  x: '36'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Disk Read I/O'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.disk.io.read
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Disk read i/o'
                  x: '36'
                  'y': '3'
                  width: '18'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Disk bytes read I/O'
                    - type: STRING
                      name: reference
                      value: ADAAC
                - type: item
                  name: 'Disk write i/o'
                  x: '54'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Disk Write I/O'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.disk.io.write
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Disk write i/o'
                  x: '54'
                  'y': '3'
                  width: '18'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Disk bytes write I/O'
                    - type: STRING
                      name: reference
                      value: ADAAD
            - name: 'VNIC In/Out'
              display_period: '30'
              widgets:
                - type: item
                  name: 'Total bytes in'
                  width: '6'
                  height: '11'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FF0000
                    - type: INTEGER
                      name: decimal_places
                      value: '1'
                    - type: INTEGER
                      name: decimal_size
                      value: '4'
                    - type: STRING
                      name: description
                      value: Ingress
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_size
                      value: '3'
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.network.in
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '2'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_size
                      value: '4'
                - type: graph
                  name: 'Network bytes in'
                  x: '6'
                  width: '30'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Network bytes in'
                    - type: STRING
                      name: reference
                      value: AEAAA
                    - type: INTEGER
                      name: show_legend
                      value: '0'
                - type: graphprototype
                  name: 'VNIC bytes in'
                  x: '6'
                  'y': '3'
                  width: '30'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'VNIC [{#NAME}]: Network bytes in'
                    - type: STRING
                      name: reference
                      value: AEAAB
                - type: graphprototype
                  name: 'VNIC packets in'
                  x: '6'
                  'y': '7'
                  width: '30'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'VNIC [{#NAME}]: Network packets in'
                    - type: STRING
                      name: reference
                      value: AEAAC
                - type: item
                  name: 'Total bytes out'
                  x: '36'
                  width: '6'
                  height: '11'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FF0000
                    - type: INTEGER
                      name: decimal_places
                      value: '1'
                    - type: INTEGER
                      name: decimal_size
                      value: '4'
                    - type: STRING
                      name: description
                      value: Egress
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_size
                      value: '3'
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        key: oci.compute.network.out
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '2'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_size
                      value: '4'
                - type: graph
                  name: 'Network bytes out'
                  x: '42'
                  width: '30'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'OCI Compute: Network bytes out'
                    - type: STRING
                      name: reference
                      value: AEAAD
                    - type: INTEGER
                      name: show_legend
                      value: '0'
                - type: graphprototype
                  name: 'VNIC bytes out'
                  x: '42'
                  'y': '3'
                  width: '30'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'VNIC [{#NAME}]: Network bytes out'
                    - type: STRING
                      name: reference
                      value: AEAAE
                - type: graphprototype
                  name: 'VNIC packets out'
                  x: '42'
                  'y': '7'
                  width: '30'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'VNIC [{#NAME}]: Network packets out'
                    - type: STRING
                      name: reference
                      value: AEAAF
            - name: 'VNIC Detailed'
              display_period: '30'
              widgets:
                - type: graphprototype
                  name: 'Connection tracking table'
                  width: '24'
                  height: '11'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'VNIC [{#NAME}]: Network packets dropped by connection tracking table'
                    - type: STRING
                      name: reference
                      value: AFAAA
                - type: graphprototype
                  name: 'Security list'
                  x: '24'
                  width: '24'
                  height: '11'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'VNIC [{#NAME}]: Network packets dropped by security list'
                    - type: STRING
                      name: reference
                      value: AFAAB
                - type: graphprototype
                  name: Smartnic
                  x: '48'
                  width: '24'
                  height: '11'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Compute by HTTP'
                        name: 'VNIC [{#NAME}]: Smartnic buffer drops'
                    - type: STRING
                      name: reference
                      value: AFAAC
      valuemaps:
        - uuid: 9e238671edca4ed7b58eefacc861a77d
          name: 'Compute instance availability'
          mappings:
            - value: '0'
              newvalue: Available
            - value: '1'
              newvalue: Unavailable
        - uuid: c336821eced54261afb0d10a0de6601d
          name: 'Compute instance state'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Moving
            - value: '2'
              newvalue: Provisioning
            - value: '3'
              newvalue: Running
            - value: '4'
              newvalue: Starting
            - value: '5'
              newvalue: Stopping
            - value: '6'
              newvalue: Stopped
            - value: '7'
              newvalue: 'Creating image'
            - value: '8'
              newvalue: Terminating
            - value: '9'
              newvalue: Terminated
        - uuid: dce0b4413ede4dbca55f89cbc86736b3
          name: 'Generic Bool'
          mappings:
            - value: '0'
              newvalue: 'False'
            - value: '1'
              newvalue: 'True'
        - uuid: 8fdcb86d1dde4d2489239dd61fbd8b08
          name: 'VNIC attachment state'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Attaching
            - value: '2'
              newvalue: Attached
            - value: '3'
              newvalue: Detaching
            - value: '4'
              newvalue: Detached
    - uuid: 62d99b55585e41dd89736f5f46074dcb
      template: 'Oracle Cloud Networking by HTTP'
      name: 'Oracle Cloud Networking by HTTP'
      description: |
        This template monitors Oracle Cloud Infrastructure (OCI) single virtual network card availability and discovers
        attached subnets and monitors their availability.
        
        This template is not meant to be used independently, but together with Oracle Cloud by HTTP as a template for 
        LLD host prototypes.
        
        Read the template documentation prior to using this 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.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 7b2fdfb034ba4657a731ab11ffa175f6
          name: 'Get VCN state'
          type: SCRIPT
          key: oci.vcn.state.get
          delay: 5m
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'vcn_id', 'http_status_code'], params);
            var oci = new OCI('VCN', 'Get VCN status', params);
            
            return JSON.stringify(oci.extractData('get', oci.executeRequest('get', '/20160918/vcns/' + encodeURIComponent(params['vcn_id']), ''), 'lifecycleState'));
          description: 'State of the virtual cloud network.'
          valuemap:
            name: 'Lifecycle state'
          preprocessing:
            - type: STR_REPLACE
              parameters:
                - '"'
                - ''
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = {
                  	'PROVISIONING': 1,
                  	'AVAILABLE': 2,
                  	'TERMINATING': 3,
                  	'TERMINATED': 4,
                  	'UPDATING': 5
                  };
                  
                  return typeof idx[value] === 'undefined' ? 0 : idx[value];
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.CORE.HOST}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
            - name: vcn_id
              value: '{$OCI.VCN.ID}'
          tags:
            - tag: component
              value: network
          triggers:
            - uuid: 8a5a94ea28db43df93e85d26703f9e7c
              expression: 'min(/Oracle Cloud Networking by HTTP/oci.vcn.state.get,5m) = 3 or min(/Oracle Cloud Networking by HTTP/oci.vcn.state.get,5m) = 4'
              name: 'OCI VCN: VCN state terminated'
              priority: HIGH
              description: 'Virtual cloud network state is "terminated" or "terminating".'
              tags:
                - tag: scope
                  value: availability
            - uuid: 80c3f4d6696c40a78ddb2c00378eeae1
              expression: 'min(/Oracle Cloud Networking by HTTP/oci.vcn.state.get,5m) = 0'
              name: 'OCI VCN: VCN state unknown'
              priority: WARNING
              description: 'Virtual cloud network state is unknown.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 83236aeedf5e4ba39f0425c21f745690
          name: 'Get subnets'
          type: SCRIPT
          key: oci.vcn.subnets.get
          delay: 5m
          history: '0'
          value_type: TEXT
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'vcn_id', 'http_status_code', 'compartment_id'], params);
            var oci = new OCI('VCN', 'Get subnets', params);
            
            return JSON.stringify(oci.extractData('get', oci.executeRequest('get', '/20160918/subnets', '?compartmentId=' + encodeURIComponent(params['compartment_id']) + '&vcnId=' + encodeURIComponent(params['vcn_id'])), ['id', 'displayName', 'lifecycleState', 'freeformTags']));
          description: 'Get data about subnets linked to the particular VCN.'
          timeout: 30s
          parameters:
            - name: api_host
              value: '{$OCI.API.CORE.HOST}'
            - name: compartment_id
              value: '{$OCI.VCN.COMPARTMENT.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
            - name: vcn_id
              value: '{$OCI.VCN.ID}'
          tags:
            - tag: component
              value: raw
      discovery_rules:
        - uuid: 6aca3a2d8b9a4231ae9364611ed4df82
          name: 'Subnet discovery'
          type: DEPENDENT
          key: oci.vcn.subnet.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#NAME}'
                value: '{$OCI.VCN.SUBNET.DISCOVERY.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$OCI.VCN.SUBNET.DISCOVERY.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#STATE}'
                value: '{$OCI.VCN.SUBNET.DISCOVERY.STATE.MATCHES}'
              - macro: '{#STATE}'
                value: '{$OCI.VCN.SUBNET.DISCOVERY.STATE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discover subnets linked to the particular VCN.'
          item_prototypes:
            - uuid: 759c6bff98fb4cb3bc8c9269513339bf
              name: 'Subnet [{#NAME}]: Get subnet state'
              type: DEPENDENT
              key: 'oci.vcn.subnet.state[{#ID}]'
              description: 'Current state of subnet.'
              valuemap:
                name: 'Lifecycle state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$..[?(@.id == ''{#ID}'')].state.first()'
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const idx = {
                      	'PROVISIONING': 1,
                      	'AVAILABLE': 2,
                      	'TERMINATING': 3,
                      	'TERMINATED': 4
                      };
                      
                      return typeof idx[value] === 'undefined' ? 0 : idx[value];
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: oci.vcn.subnets.get
              tags:
                - tag: component
                  value: network
                - tag: subnet
                  value: '{#ID}'
              trigger_prototypes:
                - uuid: f048db860c0c4134acdbcbf19ea554eb
                  expression: 'min(/Oracle Cloud Networking by HTTP/oci.vcn.subnet.state[{#ID}],5m) = 3 or min(/Oracle Cloud Networking by HTTP/oci.vcn.subnet.state[{#ID}],5m) = 4'
                  name: 'OCI VCN: Subnet [{#NAME}]: Subnet state terminated'
                  priority: HIGH
                  description: 'Virtual cloud network subnet state is "terminated" or "terminating".'
                  tags:
                    - tag: scope
                      value: availability
                - uuid: d34e5b8c571b41f9ba5dc11453431860
                  expression: 'min(/Oracle Cloud Networking by HTTP/oci.vcn.subnet.state[{#ID}],5m) = 0'
                  name: 'OCI VCN: Subnet [{#NAME}]: Subnet state unknown'
                  priority: WARNING
                  description: 'Virtual cloud network subnet state is unknown.'
                  tags:
                    - tag: scope
                      value: availability
          master_item:
            key: oci.vcn.subnets.get
          lld_macro_paths:
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#STATE}'
              path: $.state
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
      tags:
        - tag: class
          value: cloud
        - tag: class
          value: database
        - tag: subclass
          value: automation
        - tag: subclass
          value: bigdata
        - tag: subclass
          value: deploy
        - tag: target
          value: oci
        - tag: target
          value: oracle-cloud-infrastructure
      macros:
        - macro: '{$OCI.HTTP.PROXY}'
          description: 'Set an HTTP proxy for OCI API requests if needed.'
        - macro: '{$OCI.HTTP.RETURN.CODE.OK}'
          value: '200'
          description: 'Set the HTTP return code that represents an OK response from the API. The default is "200",  but can vary, for example, if a proxy is used.'
        - macro: '{$OCI.VCN.SUBNET.DISCOVERY.NAME.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of VCN subnet names to allow in discovery.'
        - macro: '{$OCI.VCN.SUBNET.DISCOVERY.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of VCN subnet names to ignore in discovery.'
        - macro: '{$OCI.VCN.SUBNET.DISCOVERY.STATE.MATCHES}'
          value: '.*'
          description: 'Sets the regex string of VCN subnet states to allow in discovery.'
        - macro: '{$OCI.VCN.SUBNET.DISCOVERY.STATE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Sets the regex string of VCN subnet states to ignore in discovery.'
      valuemaps:
        - uuid: abf7b45647ee4a339df92bf06b12f0df
          name: 'Lifecycle state'
          mappings:
            - value: '0'
              newvalue: Unknown
            - value: '1'
              newvalue: Provisioning
            - value: '2'
              newvalue: Available
            - value: '3'
              newvalue: Terminating
            - value: '4'
              newvalue: Terminated
            - value: '5'
              newvalue: Updating
    - uuid: e8f89476695848e99ba900a5664d290b
      template: 'Oracle Cloud Object Storage by HTTP'
      name: 'Oracle Cloud Object Storage by HTTP'
      description: |
        This template monitors Oracle Cloud Infrastructure (OCI) object storage resources.
        
        This template is not meant to be used independently, but together with Oracle Cloud by HTTP as a template for
        LLD host prototypes.
        
        Read the template documentation prior to using this 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.4-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 8a216ff99ea84e169ba24305a5501b45
          name: 'Client-side error count'
          type: DEPENDENT
          key: oci.obj.storage.client.errors
          value_type: FLOAT
          description: 'The total number of 4xx errors for requests made in a bucket.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ClientErrors
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.obj.storage.metrics.frequent.get
          tags:
            - tag: component
              value: storage
        - uuid: 3d41eed5ab23438d9f2a87c48bb3def4
          name: 'First byte latency time'
          type: DEPENDENT
          key: oci.obj.storage.latency.byte
          value_type: FLOAT
          units: s
          description: 'The per-request time measured from the time Object Storage receives the complete request to when Object Storage returns the first byte of the response.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.FirstByteLatency
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.obj.storage.metrics.frequent.get
          tags:
            - tag: component
              value: storage
        - uuid: a47bb44ccb35489e965432c332bd8892
          name: 'Overall latency time'
          type: DEPENDENT
          key: oci.obj.storage.latency.overall
          value_type: FLOAT
          units: s
          description: |
            The per-request time from the first byte received by Object Storage to the last byte sent from
            Object Storage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.TotalRequestLatency
            - type: MULTIPLIER
              parameters:
                - '0.001'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.obj.storage.metrics.frequent.get
          tags:
            - tag: component
              value: storage
        - uuid: 5463c35f2c48408997532001025989fa
          name: 'Get frequent metrics'
          type: SCRIPT
          key: oci.obj.storage.metrics.frequent.get
          history: '0'
          value_type: TEXT
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            function buildMql(id, metrics, defaultStatistic, resourceType) {
            	resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType;
            	this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.';
            
            	for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            		const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic]));
            		metrics[i] = [metric[0], this.query + metric[1]];
            	}
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'bucket_name', 'http_status_code', 'req_interval', 'compartment_id'], params);
            var oci = new OCI('Object storage', 'Get metrics ' + params['req_interval'] + 'm', params);
            
            const metrics = [
            	'AllRequests',
            	'ClientErrors',
            	'FirstByteLatency',
            	'PostRequests',
            	'PutRequests',
            	'TotalRequestLatency'
            ];
            buildMql(params['bucket_name'], metrics, 'mean', 'resourceDisplayName');
            
            var result = {};
            for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            	result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_objectstorage'), 'aggregatedDatapoints');
            }
            return JSON.stringify(result);
          description: 'Gets all metrics related to a specific bucket that have frequent update time (100 milliseconds).'
          timeout: 30s
          parameters:
            - name: api_host
              value: '{$OCI.API.TELEMETRY.HOST}'
            - name: bucket_name
              value: '{$OCI.OBJECT.STORAGE.BUCKET}'
            - name: compartment_id
              value: '{$OCI.OBJECT.STORAGE.COMPARTMENT.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: req_interval
              value: '1'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: raw
        - uuid: 4a12f1c73e8f40be9136a095ad147775
          name: 'Get hourly metrics'
          type: SCRIPT
          key: oci.obj.storage.metrics.hourly.get
          delay: 1h
          history: '0'
          value_type: TEXT
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            function buildMql(id, metrics, defaultStatistic, resourceType) {
            	resourceType = resourceType === '' || resourceType === undefined ? 'resourceId' : resourceType;
            	this.query = '[' + params['req_interval'] + 'm]{' + resourceType + '=' + id + '}.';
            
            	for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            		const metric = ((Array.isArray(metrics[i]) ? metrics[i] : [metrics[i], defaultStatistic]));
            		metrics[i] = [metric[0], this.query + metric[1]];
            	}
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'bucket_name', 'http_status_code', 'req_interval', 'compartment_id'], params);
            var oci = new OCI('Object storage', 'Get metrics ' + params['req_interval'] + 'm', params);
            
            const metrics = [
            	'ObjectCount',
            	'StoredBytes',
            	'UncommittedParts'
            ];
            buildMql(params['bucket_name'], metrics, 'mean', 'resourceDisplayName')
            
            var result = {};
            for (var i = 0, metricsLength = metrics.length; i < metricsLength; i++) {
            	result[metrics[i][0]] = oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), metrics[i][0] + metrics[i][1] + '()', 'oci_objectstorage'), 'aggregatedDatapoints');
            }
            return JSON.stringify(result);
          description: 'Gets all metrics related to specific bucket that have update time of 1 hour.'
          timeout: 30s
          parameters:
            - name: api_host
              value: '{$OCI.API.TELEMETRY.HOST}'
            - name: bucket_name
              value: '{$OCI.OBJECT.STORAGE.BUCKET}'
            - name: compartment_id
              value: '{$OCI.OBJECT.STORAGE.COMPARTMENT.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: req_interval
              value: '60'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: raw
        - uuid: 5bb5ba3011e94e43bb1fdc79668c9537
          name: 'Get enabled object lifecycle management'
          type: SCRIPT
          key: oci.obj.storage.metrics.olm.get
          delay: 3h
          params: |
            function validateZabbixParams(requiredParams, allParams) {
            	requiredParams.forEach(function (field) {
            		if (typeof allParams !== 'object' || typeof allParams[field] === 'undefined' || allParams[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            }
            
            function OCI(service, action, params) {
            	this.zabbixLogPrefix = '[ OCI ] [ ' + service + ' ] [ ' + action + ' ]';
            	this.request = new HttpRequest();
            
            	this.hash = function (string) {
            		return sha256(string);
            	};
            
            	this.sign = function (string) {
            		return sign('sha256', params['private_key'], string);
            	};
            
            	this.encode = function (hash) {
            		const hexArr = hash.match(/.{1,2}/g);
            		var uInt8Array = new Uint8Array(hexArr.length);
            		hexArr.forEach(function (hex, idx) {
            			uInt8Array[idx] = parseInt(hex, 16);
            		});
            		return btoa(uInt8Array);
            	};
            
            	this.getDate = function () {
            		const weekdayShortList = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
            		const monthShortList = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
            		const today = new Date();
            		return weekdayShortList[today.getUTCDay()] + ', ' + today.getUTCDate() + ' ' + monthShortList[today.getUTCMonth()] + ' ' + today.getUTCFullYear() + ' ' + today.getUTCHours() + ':' + today.getUTCMinutes() + ':' + today.getUTCSeconds() + ' GMT';
            	};
            
            	this.executeRequest = function (httpMethod, apiPath, apiParams, mql, namespace) {
            		var headers = '(request-target) date host';
            		const contentTypeHeader = 'content-type: application/json';
            		const dateHeader = 'date: ' + this.getDate();
            		const hostHeader = 'host: ' + params['api_host'];
            		const requestTarget = '(request-target): ' + httpMethod + ' ' + apiPath + apiParams;
            		var signingString = requestTarget + '\n' + dateHeader + '\n' + hostHeader;
            		var reqHeaders = [contentTypeHeader, dateHeader];
            
            		if (httpMethod === 'post') {
            			var body = JSON.stringify({
            				'namespace': namespace,
            				'query': mql
            			});
            			headers = headers + ' x-content-sha256 content-type content-length';
            			const bodyHeader = 'x-content-sha256: ' + this.encode(this.hash(body));
            			const bodyLengthHeader = 'content-length: ' + body.length;
            			signingString = signingString + '\n' + bodyHeader + '\n' + contentTypeHeader + '\n' + bodyLengthHeader;
            			reqHeaders.push(bodyHeader, bodyLengthHeader);
            		}
            
            		const signature = this.encode(this.sign(signingString));
            
            		reqHeaders.push('Authorization: Signature version="1",keyId="' + params['tenancy_ocid'] + '/' + params['user_ocid'] + '/' + params['fingerprint'] + '",algorithm="rsa-sha256",headers="' + headers + '",signature="' + signature + '"');
            		for (var header = 0, headerLength = reqHeaders.length; header < headerLength; header++) {
            			this.request.addHeader(reqHeaders[header]);
            		}
            
            		if (params['http_proxy']) {
            			this.request.setProxy(params['http_proxy']);
            			Zabbix.log(4, this.zabbixLogPrefix + ' Using http proxy: ' + params['http_proxy']);
            		}
            
            		if (httpMethod === 'post') {
            			var apiRateLimitExceeded = false;
            			do {
            				const response = this.request.post('https://' + params['api_host'] + apiPath + apiParams, body);
            
            				try {
            					if (JSON.parse(response)['code'] === 'TooManyRequests') {
            
            						apiRateLimitExceeded = true;
            						Zabbix.sleep(1000);
            					} else {
            						apiRateLimitExceeded = false;
            					}
            				} catch (error) {
            					Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the response: ' + JSON.stringify(response));
            					throw 'Could not parse the response. See logs for more information.';
            				}
            			} while (apiRateLimitExceeded);
            		} else {
            			const response = this.request.get('https://' + params['api_host'] + apiPath + apiParams);
            		}
            
            		this.request.clearHeader();
            
            		if (this.request.getStatus() === parseInt(params['http_status_code'])) {
            			return response;
            		} else {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Unexpected HTTP response code: ' + this.request.getStatus());
            			throw 'Unexpected HTTP response code: ' + this.request.getStatus();
            		}
            	};
            
            	this.extractData = function (httpMethod, data, keys, compartment) {
            		try {
            			data = JSON.parse(data);
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not parse the received JSON object: ' + data);
            			throw 'Could not parse received JSON object. See logs for more information.';
            		}
            
            		if (typeof keys == 'object') {
            			var returnBuffer = [];
            			for (var dataObj = 0, dataLength = data.length; dataObj < dataLength; dataObj++) {
            
            				var objectBuffer = {};
            				for (var key = 0, keysLength = keys.length; key < keysLength; key++) {
            					if (data[dataObj][keys[key]] || data[dataObj][keys[key]] == null) {
            						objectBuffer[keys[key].match(/^[a-z]+$|[A-Z][a-z]+$/)[0].toLowerCase()] = data[dataObj][keys[key]];
            					} else {
            						Zabbix.log(3, this.zabbixLogPrefix + ' Received an unexpected JSON object. Could not get value for key "' + keys[key] + '" in JSON: ' + JSON.stringify(data[dataObj]));
            						throw 'Received an unexpected JSON object. See logs for more information.';
            					}
            				}
            				if (typeof compartment != 'undefined' && compartment != '') objectBuffer['compartment'] = compartment;
            				returnBuffer.push(objectBuffer);
            			}
            			return returnBuffer;
            		}
            
            		try {
            			if (httpMethod === 'get') {
            				return data[keys];
            			} else {
            				if (data.length === 0) {
            					return 0;
            				}
            				data = data[0][keys];
            				return data[data.length - 1]['value'];
            			}
            		} catch (error) {
            			Zabbix.log(3, this.zabbixLogPrefix + ' Could not find key "' + keys + '" in JSON: ' + JSON.stringify(data));
            			throw 'Could not find required key in JSON object. See logs for more information.';
            		}
            	};
            }
            
            
            const params = JSON.parse(value);
            validateZabbixParams(['tenancy_ocid', 'user_ocid', 'private_key', 'fingerprint', 'api_host', 'bucket_name', 'http_status_code', 'req_interval', 'compartment_id'], params);
            var oci = new OCI('Object storage', 'Get metrics ' + params['req_interval'] + 'm', params);
            const mql = 'EnabledOLM[' + params['req_interval'] + 'm]{resourceDisplayName=' + params['bucket_name'] + '}.mean()';
            
            return JSON.stringify(oci.extractData('post', oci.executeRequest('post', '/20180401/metrics/actions/summarizeMetricsData', '?compartmentId=' + encodeURIComponent(params['compartment_id']), mql, 'oci_objectstorage'), 'aggregatedDatapoints'));
          description: |
            Indicates whether a bucket has any executable Object Lifecycle Management policies configured. `EnabledOLM` emits:
            
                1 - if policies are configured
                0 - if no policies are configured
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          timeout: 10s
          parameters:
            - name: api_host
              value: '{$OCI.API.TELEMETRY.HOST}'
            - name: bucket_name
              value: '{$OCI.OBJECT.STORAGE.BUCKET}'
            - name: compartment_id
              value: '{$OCI.OBJECT.STORAGE.COMPARTMENT.ID}'
            - name: fingerprint
              value: '{$OCI.API.FINGERPRINT}'
            - name: http_proxy
              value: '{$OCI.HTTP.PROXY}'
            - name: http_status_code
              value: '{$OCI.HTTP.RETURN.CODE.OK}'
            - name: private_key
              value: '{$OCI.API.PRIVATE.KEY}'
            - name: req_interval
              value: '180'
            - name: tenancy_ocid
              value: '{$OCI.API.TENANCY}'
            - name: user_ocid
              value: '{$OCI.API.USER}'
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 5d9652a8736247c2bcac15cf02012824
              expression: 'last(/Oracle Cloud Object Storage by HTTP/oci.obj.storage.metrics.olm.get,#1)<>last(/Oracle Cloud Object Storage by HTTP/oci.obj.storage.metrics.olm.get,#2) and length(last(/Oracle Cloud Object Storage by HTTP/oci.obj.storage.metrics.olm.get))>0'
              name: 'OCI Object Storage: Object lifecycle management policy has changed'
              priority: INFO
              description: 'The object lifecycle management policy configuration has changed.'
              tags:
                - tag: scope
                  value: notice
        - uuid: 867aa1736d4c40a18a4f660023d117f4
          name: 'Number of objects'
          type: DEPENDENT
          key: oci.obj.storage.objects
          value_type: FLOAT
          description: 'The count of objects in the bucket, excluding any multipart upload parts that have not been discarded (aborted) or committed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ObjectCount
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: oci.obj.storage.metrics.hourly.get
          tags:
            - tag: component
              value: storage
        - uuid: a3d83de1735d4c409192d187d793f7b2
          name: 'All requests count'
          type: DEPENDENT
          key: oci.obj.storage.requests
          value_type: FLOAT
          description: 'The total number of all HTTP requests made in a bucket.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.AllRequests
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.obj.storage.metrics.frequent.get
          tags:
            - tag: component
              value: storage
        - uuid: 2baef7eb0b1348499eda8fb9fd11e0c8
          name: 'Post object request count'
          type: DEPENDENT
          key: oci.obj.storage.requests.post
          value_type: FLOAT
          description: 'The total number of HTTP `POST` requests made in a bucket.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.PostRequests
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.obj.storage.metrics.frequent.get
          tags:
            - tag: component
              value: storage
        - uuid: 1853b681b5e64a0f9c172e6166a430ae
          name: 'Put object request count'
          type: DEPENDENT
          key: oci.obj.storage.requests.put
          value_type: FLOAT
          description: 'The total number of `PutObject` requests made in a bucket.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.PutRequests
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: oci.obj.storage.metrics.frequent.get
          tags:
            - tag: component
              value: storage
        - uuid: 61901f89399c413186c9df957760c2d5
          name: 'Bucket size'
          type: DEPENDENT
          key: oci.obj.storage.size
          value_type: FLOAT
          units: B
          description: 'The size of the bucket, excluding any multipart upload parts that have not been discarded (aborted) or committed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.StoredBytes
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: oci.obj.storage.metrics.hourly.get
          tags:
            - tag: component
              value: storage
        - uuid: a4dc04db6b294aef865d137e5fdd0dc2
          name: 'Incomplete multipart upload size'
          type: DEPENDENT
          key: oci.obj.storage.size.incomplete
          value_type: FLOAT
          units: B
          description: 'The size of any multipart upload parts that have not been discarded (aborted) or committed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.UncommittedParts
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: oci.obj.storage.metrics.hourly.get
          tags:
            - tag: component
              value: storage
      tags:
        - tag: class
          value: cloud
        - tag: class
          value: database
        - tag: subclass
          value: automation
        - tag: subclass
          value: bigdata
        - tag: subclass
          value: deploy
        - tag: target
          value: oci
        - tag: target
          value: oracle-cloud-infrastructure
      macros:
        - macro: '{$OCI.HTTP.PROXY}'
          description: 'Set an HTTP proxy for OCI API requests if needed.'
        - macro: '{$OCI.HTTP.RETURN.CODE.OK}'
          value: '200'
          description: 'Set the HTTP return code that represents an OK response from the API. The default is "200",  but can vary, for example, if a proxy is used.'
      dashboards:
        - uuid: 6dd3714db62046249cf3ff50a09091e2
          name: 'OCI Object Storage: Overview'
          pages:
            - name: Overview
              display_period: '30'
              widgets:
                - type: item
                  name: 'Overall latency time'
                  width: '30'
                  height: '5'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Overall Latency Time'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.latency.overall
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Bucket Size'
                  'y': '5'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Bucket Size'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.size
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Client-side error count'
                  'y': '8'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FF0000
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Client-side Error Count'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.client.errors
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Number of objects'
                  x: '15'
                  'y': '5'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 00D936
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Number of Objects'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.objects
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Incomplete multipart upload size'
                  x: '15'
                  'y': '8'
                  width: '15'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FF0000
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Incomplete Multipart Upload Size'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.size.incomplete
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'First byte latency time'
                  x: '30'
                  width: '30'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'First Byte Latency Time'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.latency.byte
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'All requests'
                  x: '30'
                  'y': '3'
                  width: '18'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'All Requests'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.requests
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: Requests
                  x: '30'
                  'y': '6'
                  width: '42'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        name: 'OCI Object Storage: Requests'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: item
                  name: 'Post object requests'
                  x: '48'
                  'y': '3'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Post Object Requests'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.requests.post
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'OLM status'
                  x: '60'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'OLM Status'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.metrics.olm.get
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: item
                  name: 'Put object requests'
                  x: '60'
                  'y': '3'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 2196F3
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Post Object Requests'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.requests.post
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
            - name: Latency
              display_period: '30'
              widgets:
                - type: item
                  name: 'Overall latency time'
                  width: '36'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'Overall Latency Time'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.latency.overall
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'Overall latency'
                  'y': '3'
                  width: '36'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        name: 'OCI Object Storage: Overall latency'
                    - type: STRING
                      name: reference
                      value: ABAAA
                - type: item
                  name: 'First byte latency time'
                  x: '36'
                  width: '36'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 6C00D9
                    - type: INTEGER
                      name: decimal_size
                      value: '45'
                    - type: STRING
                      name: description
                      value: 'First Byte Latency Time'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        key: oci.obj.storage.latency.byte
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '1'
                    - type: STRING
                      name: units_color
                      value: FFFFFF
                    - type: INTEGER
                      name: units_size
                      value: '25'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                - type: graph
                  name: 'First byte latency'
                  x: '36'
                  'y': '3'
                  width: '36'
                  height: '8'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Oracle Cloud Object Storage by HTTP'
                        name: 'OCI Object Storage: First byte latency'
                    - type: STRING
                      name: reference
                      value: ABAAB
  graphs:
    - uuid: 1ff7d04868284c07829382c44301fe0e
      name: 'GCP Cloud SQL MSSQL: Disk read/write operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.disk.read_ops_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.disk.write_ops_count
    - uuid: 0ef4b456168d4ecd87c3dc68092c673d
      name: 'GCP Cloud SQL MSSQL: Disk usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.disk.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.disk.bytes_used
    - uuid: 09b009aa17f1410bb926043b4c7c39e4
      name: 'GCP Cloud SQL MSSQL: Memory Read/Writes'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.page_ops.read
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.page_ops.write
    - uuid: 3273bee668e84b26911307ea4c1f620f
      name: 'GCP Cloud SQL MSSQL: Memory usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.usage
    - uuid: 4d5afffa67804f4da73474d2ee26bd5d
      name: 'GCP Cloud SQL MSSQL: Memory workflow'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.checkpoint_page_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.free_list_stall_count
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.lazy_write_count
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.memory_grants_pending
    - uuid: 558283815ab2414f8da6387724a784a3
      name: 'GCP Cloud SQL MSSQL: Network traffic'
      type: STACKED
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.network.received_bytes_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.network.sent_bytes_count
    - uuid: 0bfd3e8be20c4b5a88b23f16aff4eb82
      name: 'GCP Cloud SQL MSSQL: Replication data'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL Replica by HTTP'
            key: gcp.cloudsql.mssql.repl.bytes_sent_to_replica_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL Replica by HTTP'
            key: gcp.cloudsql.mssql.repl.log_bytes_received_count
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL MSSQL Replica by HTTP'
            key: gcp.cloudsql.mssql.repl.redone_bytes_count
    - uuid: 922d35bf685b473ca9848a9b9e7e34c3
      name: 'GCP Cloud SQL MSSQL: Transactions'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.batch_request_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.forwarded_record_count
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.full_scan_count
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.page_split_count
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.probe_scan_count
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.sql_compilation_count
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.sql_recompilation_count
    - uuid: 935c2f388185469f82100541d9efb2c7
      name: 'GCP Cloud SQL MySQL: Disk read/write operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.disk.read_ops_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.disk.write_ops_count
    - uuid: 1b0ea2b38fe740b197ecbcfdd7464b02
      name: 'GCP Cloud SQL MySQL: Disk usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.disk.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.disk.bytes_used
    - uuid: e94b7e8241b544e2beb4ea95db3e139f
      name: 'GCP Cloud SQL MySQL: Lags'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MySQL Replica by HTTP'
            key: gcp.cloudsql.mysql.repl.network_lag
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL Replica by HTTP'
            key: gcp.cloudsql.mysql.repl.replica_lag
    - uuid: 4378be58ccff4592a1b54838b90e9ea8
      name: 'GCP Cloud SQL MySQL: Memory usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.memory.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.memory.usage
    - uuid: c23964e5e54541ccb3c8b7b5f5a4b24d
      name: 'GCP Cloud SQL MySQL: Network traffic'
      type: STACKED
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.network.received_bytes_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.network.sent_bytes_count
    - uuid: e680755183ec4927893e03f8d83bc0f2
      name: 'GCP Cloud SQL MySQL: pages'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_free
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_dirty
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_total
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.innodb_pages_read
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.innodb_pages_written
    - uuid: e447dd13336446b1a965e92d7ddeaf96
      name: 'GCP Cloud SQL MySQL: Queries'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.queries
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.questions
    - uuid: e2e4ef0a2c1a43d68ae9f4ee881f070e
      name: 'GCP Cloud SQL PostgreSQL: Disk read/write operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.disk.read_ops_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.disk.write_ops_count
    - uuid: 707d5cca2ba349f18088d00ef7657eef
      name: 'GCP Cloud SQL PostgreSQL: Disk usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.disk.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.disk.bytes_used
    - uuid: 30fe61bafae64ae6b29dacd68e9a6b3b
      name: 'GCP Cloud SQL PostgreSQL: Lags'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.network_lag
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.replica_lag
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.flush_location
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.replay_location
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.sent_location
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.write_location
    - uuid: 897843c1fef540c2ab033c9bad0e9de1
      name: 'GCP Cloud SQL PostgreSQL: Memory usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.memory.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.memory.usage
    - uuid: 8a61208f44c94cf5bfcb851c4de6412a
      name: 'GCP Cloud SQL PostgreSQL: Network traffic'
      type: STACKED
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.network.received_bytes_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.network.sent_bytes_count
    - uuid: bf09992b7f324703b3d51250e47d37f4
      name: 'GCP Cloud SQL PostgreSQL: Transaction age'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.oldest_transaction.prepared
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.oldest_transaction.replication_slot
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.oldest_transaction.replica
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.oldest_transaction.running
    - uuid: 5c567b9d1ef14fcb93eef332fccbe198
      name: 'GCP Cloud SQL PostgreSQL: Transactions count'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.transaction_id_count_assigned
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.transaction_id_count_frozen
    - uuid: e96be84efaf7445fbfd8cf707b585fe7
      name: 'GCP Cloud SQL PostgreSQL: WAL archiving'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.log_archive_failure_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.log_archive_success_count
    - 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
    - uuid: 97956d8f4b084cf38c8e46c842e806f5
      name: 'OCI Autonomous DB: Connection latency'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.latency.conn
    - uuid: adcd338dbf2746c980929932575ed953
      name: 'OCI Autonomous DB: CPU time'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.cpu.time
    - uuid: 1324dac0566447fa9ae3808fb79a65e1
      name: 'OCI Autonomous DB: CPU utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.cpu.util
    - uuid: 14ffe3b6eb084fdeac6cbdefdb356a3b
      name: 'OCI Autonomous DB: DB time'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.time
    - uuid: 464902ef122a438bba519071f29df0c8
      name: 'OCI Autonomous DB: Execute count'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.exec.count
    - uuid: a23cf1625b5d4f6c848a6f7236dbeb6b
      name: 'OCI Autonomous DB: Parse count failures'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.parse.count.failed
    - uuid: e13b6b26310d4954a2df15244a7b2de9
      name: 'OCI Autonomous DB: Parse count hard'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.parse.count.hard
    - uuid: 75997227333c46de87199c0247d5bdb5
      name: 'OCI Autonomous DB: Parse count total'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.parse.count.total
    - uuid: e160cc5a9e22404a91e2bdcc33e22108
      name: 'OCI Autonomous DB: Physical read/write total bytes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.physical.read.bytes
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.physical.write.bytes
    - uuid: 2def3ab2a81a4b6abfb2b209f134c1af
      name: 'OCI Autonomous DB: Physical reads/writes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.physical.reads
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.physical.writes
    - uuid: fd5d001fb93a409db9ebfdc66d0a8861
      name: 'OCI Autonomous DB: Query latency'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.latency.query
    - uuid: 71a7e76a9bc34cc58abd77ef76d9ed4a
      name: 'OCI Autonomous DB: Session logical reads'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.logical.reads.session
    - uuid: c03100979bbf485dbd5c36900ec73469
      name: 'OCI Autonomous DB: Session stats'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.sessions
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.conn.failed
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.logons
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.logons.failed
    - uuid: e8f1cdda63e44ca9a5b73bbd8c55ffa0
      name: 'OCI Autonomous DB: SQL*Net client bytes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.sqlnet.bytes.recv.client
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.sqlnet.bytes.sent.client
    - uuid: c485b41073d341a98e5aa239fc7afd21
      name: 'OCI Autonomous DB: SQL*Net DBLink bytes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.sqlnet.bytes.recv.dblink
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.sqlnet.bytes.sent.dblink
    - uuid: 8adb6f1a0b3242be8142fc62370db900
      name: 'OCI Autonomous DB: Statements'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.statements.running
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.queued.statements
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.transaction.count
    - uuid: 2579982f4501490283fe2cbcf90330f0
      name: 'OCI Autonomous DB: Storage stats'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.storage.space.max
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.storage.space.alloc
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.storage.space.used
    - uuid: d96a821b6e6e4557a40e87246d2ffdfe
      name: 'OCI Autonomous DB: Storage utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.storage.space.util
    - uuid: 3040bdaf0f8c49a68b80dbe60f8f9c9a
      name: 'OCI Autonomous DB: User calls'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.user.calls
    - uuid: 2620ae19fd7243d2ac37daabf9dbce46
      name: 'OCI Autonomous DB: User commits'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.user.commits
    - uuid: 1e5d6a326c7e45cb83f7689c9a4bfce1
      name: 'OCI Autonomous DB: User rollbacks'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.user.rollbacks
    - uuid: 3d55d19a57b34764a5f5cdc364204849
      name: 'OCI Autonomous DB: Wait time'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Autonomous Database by HTTP'
            key: oci.aut.db.wait.time
    - uuid: 68f6c72e67f947b29f879b89a205d59c
      name: 'OCI Block Volume: Operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Block Volume by HTTP'
            key: oci.block.volume.read.ops
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Block Volume by HTTP'
            key: oci.block.volume.write.ops
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle Cloud Block Volume by HTTP'
            key: oci.block.volume.throttled.ops
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'Oracle Cloud Block Volume by HTTP'
            key: oci.block.volume.iops
    - uuid: 16076dfa25244b5093e8985ca2e3f18c
      name: 'OCI Block Volume: Throughput'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Block Volume by HTTP'
            key: oci.block.volume.read
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Block Volume by HTTP'
            key: oci.block.volume.write
        - sortorder: '2'
          color: 00611C
          yaxisside: RIGHT
          item:
            host: 'Oracle Cloud Block Volume by HTTP'
            key: oci.block.volume.throughput
    - uuid: 6078da9c1eb249548536663e57e7743c
      name: 'OCI Block Volume: VPUs/GB'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Block Volume by HTTP'
            key: oci.block.volume.vpu
    - uuid: 265e1b5e20084bfb9ab272996915b45d
      name: 'OCI Boot Volume: Operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Boot Volume by HTTP'
            key: oci.boot.volume.read.ops
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Boot Volume by HTTP'
            key: oci.boot.volume.write.ops
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle Cloud Boot Volume by HTTP'
            key: oci.boot.volume.throttled.ops
        - sortorder: '3'
          color: F7941D
          yaxisside: RIGHT
          item:
            host: 'Oracle Cloud Boot Volume by HTTP'
            key: oci.boot.volume.iops
    - uuid: 7e8aa92414d5431f80fdb1d1981d25f9
      name: 'OCI Boot Volume: Throughput'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Boot Volume by HTTP'
            key: oci.boot.volume.read
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Boot Volume by HTTP'
            key: oci.boot.volume.write
        - sortorder: '2'
          color: 00611C
          yaxisside: RIGHT
          item:
            host: 'Oracle Cloud Boot Volume by HTTP'
            key: oci.boot.volume.throughput
    - uuid: fdfb060d0823480abe77581503f82a96
      name: 'OCI Boot Volume: VPUs/GB'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Boot Volume by HTTP'
            key: oci.boot.volume.vpu
    - uuid: 70f0b43207cd4e28bf93e0b41ad45a10
      name: 'OCI Compute: Cpu utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Compute by HTTP'
            key: oci.compute.cpu.util
    - uuid: 944bf71570b549ce8682d3f1beea5c57
      name: 'OCI Compute: Disk bytes read'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Compute by HTTP'
            key: oci.compute.disk.read
    - uuid: 39ece65d2b2b402abee59432cc3a3cea
      name: 'OCI Compute: Disk bytes read I/O'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Compute by HTTP'
            key: oci.compute.disk.io.read
    - uuid: f073ce71549946509fe9f021b3c2d2e9
      name: 'OCI Compute: Disk bytes write I/O'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Compute by HTTP'
            key: oci.compute.disk.io.write
    - uuid: 784735022c1e40fc9cf7d065e95124f3
      name: 'OCI Compute: Disk bytes written'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Compute by HTTP'
            key: oci.compute.disk.written
    - uuid: 9f4a1426c49f47bfade03875a6af0a60
      name: 'OCI Compute: Memory allocation stalls'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Compute by HTTP'
            key: oci.compute.mem.stalls
    - uuid: db9ad56d9e334de0a3ba7f6c3862fb76
      name: 'OCI Compute: Memory utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Compute by HTTP'
            key: oci.compute.mem.util
    - uuid: 609ba54782934bb8b60696588bf57038
      name: 'OCI Compute: Network bytes in'
      graph_items:
        - color: 00D936
          item:
            host: 'Oracle Cloud Compute by HTTP'
            key: oci.compute.network.in
    - uuid: 807729ba0afb4710a33307286d5c027a
      name: 'OCI Compute: Network bytes out'
      graph_items:
        - color: 2196F3
          item:
            host: 'Oracle Cloud Compute by HTTP'
            key: oci.compute.network.out
    - uuid: fa3fab6874614a3cbea45dee87660253
      name: 'OCI Object Storage: Bucket size'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Object Storage by HTTP'
            key: oci.obj.storage.size
        - sortorder: '1'
          color: F63100
          yaxisside: RIGHT
          item:
            host: 'Oracle Cloud Object Storage by HTTP'
            key: oci.obj.storage.objects
    - uuid: 2c32d269e0274b26a40b0b5069abda7c
      name: 'OCI Object Storage: Client-side error count'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Object Storage by HTTP'
            key: oci.obj.storage.client.errors
    - uuid: 445af3dbf17e4046b5350fd1b4b3734b
      name: 'OCI Object Storage: First byte latency'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Object Storage by HTTP'
            key: oci.obj.storage.latency.byte
    - uuid: 15fb3f080d6244a48d1a7c98f69a2793
      name: 'OCI Object Storage: Incomplete multipart upload size'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Object Storage by HTTP'
            key: oci.obj.storage.size.incomplete
    - uuid: 0f71c9aa038d437fa28312c58d417ad1
      name: 'OCI Object Storage: Overall latency'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Object Storage by HTTP'
            key: oci.obj.storage.latency.overall
    - uuid: 49c9abb27e194d1788ee1c62688ff57b
      name: 'OCI Object Storage: Requests'
      graph_items:
        - color: 199C0D
          item:
            host: 'Oracle Cloud Object Storage by HTTP'
            key: oci.obj.storage.requests
        - sortorder: '1'
          color: F63100
          item:
            host: 'Oracle Cloud Object Storage by HTTP'
            key: oci.obj.storage.requests.post
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Oracle Cloud Object Storage by HTTP'
            key: oci.obj.storage.requests.put
