zabbix_export:
  version: '7.0'
  template_groups:
    - uuid: c2c162144c2d4c5491c8801193af4945
      name: Templates/Cloud
  templates:
    - uuid: c6d9475847f44d9193f8253e5995b8f8
      template: 'AWS RDS instance by HTTP'
      name: 'AWS RDS instance by HTTP'
      description: |
        The template gets AWS RDS instance metrics and uses the script item to make HTTP requests to the CloudWatch API.
        Don't forget to read the README.md for the correct setup of the template.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 94471806c4cf482fb66cbe305a0e87a5
          name: 'Get alarms check'
          type: DEPENDENT
          key: aws.rds.alarms.check
          value_type: CHAR
          description: 'Data collection check.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_alarms
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 112da2ba956740fda7edcd9bd3a8651c
              expression: 'length(last(/AWS RDS instance by HTTP/aws.rds.alarms.check))>0'
              name: 'Failed to get alarms data'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              tags:
                - tag: scope
                  value: availability
        - uuid: 9e40764a74e54c3b8bf0e7f75fe5f115
          name: 'Disk: Binlog Usage'
          type: DEPENDENT
          key: aws.rds.bin_log_disk_usage
          value_type: FLOAT
          units: B
          description: 'The amount of disk space occupied by binary logs on the master. Applies to MySQL read replicas.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "BinLogDiskUsage")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
            - tag: engine
              value: mariadb
            - tag: engine
              value: mysql
        - uuid: 7b7273f5d9144dd1b82c8c3fb649f593
          name: 'Burst balance'
          type: DEPENDENT
          key: aws.rds.burst_balance
          value_type: FLOAT
          units: '%'
          description: 'The percent of General Purpose SSD (gp2) burst-bucket I/O credits available.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "BurstBalance")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
          triggers:
            - uuid: 730337e340cf4b129d4b38f1c7c82cf6
              expression: 'max(/AWS RDS instance by HTTP/aws.rds.burst_balance,5m)<{$AWS.RDS.BURST.CREDIT.BALANCE.MIN.WARN}'
              name: 'Burst balance is too low'
              event_name: 'Burst balance is too low (less {$AWS.RDS.BURST.CREDIT.BALANCE.MIN.WARN}% for 5m)'
              opdata: 'Current value: {ITEM.LASTVALUE1}'
              priority: WARNING
              tags:
                - tag: scope
                  value: capacity
        - uuid: 975ee74af92c4b589f2488d403fdb18d
          name: Class
          type: DEPENDENT
          key: aws.rds.class
          value_type: CHAR
          description: 'Contains the name of the compute and memory capacity class of the DB instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[*].DBInstanceClass.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: instance
        - uuid: 83d19e8a062b4890a4897e97bb1d5a24
          name: 'Credit CPU: Balance'
          type: DEPENDENT
          key: aws.rds.cpu.credit_balance
          value_type: FLOAT
          description: |
            The number of CPU credits that an instance has accumulated, reported at 5-minute intervals.
            You can use this metric to determine how long a DB instance can burst beyond its baseline performance level at a given rate.
            When an instance is running, credits in the CPUCreditBalance don't expire. When the instance stops, the CPUCreditBalance does not persist, and all accrued credits are lost.
            
            This metric applies only to db.t2.small and db.t2.medium instances for Aurora MySQL, and to db.t3 instances for Aurora PostgreSQL.
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "CPUCreditBalance")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: cpu
            - tag: component
              value: credit
          triggers:
            - uuid: 32994f2b06b8491b9b13d0b280e09001
              expression: 'max(/AWS RDS instance by HTTP/aws.rds.cpu.credit_balance,5m)<{$AWS.RDS.CPU.CREDIT.BALANCE.MIN.WARN}'
              name: 'Instance CPU Credit balance is too low'
              event_name: 'Instance CPU Credit balance is too low (less {$AWS.RDS.CPU.CREDIT.BALANCE.MIN.WARN} for 5m)'
              opdata: 'Current value: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The number of earned CPU credits has been less than {$AWS.RDS.CPU.CREDIT.BALANCE.MIN.WARN} in the last 5 minutes.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 14c1c44a312b4343b0ded785a7ae910c
          name: 'Credit CPU: Usage'
          type: DEPENDENT
          key: aws.rds.cpu.credit_usage
          value_type: FLOAT
          description: |
            The number of CPU credits consumed during the specified period, reported at 5-minute intervals.
            This metric measures the amount of time during which physical CPUs have been used for processing instructions by virtual CPUs allocated to the DB instance.
            
            This metric applies only to db.t2.small and db.t2.medium instances for Aurora MySQL, and to db.t3 instances for Aurora PostgreSQL
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "CPUCreditUsage")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: cpu
            - tag: component
              value: credit
        - uuid: b69d180c94a34882bd3faa58f8847f65
          name: 'CPU: Utilization'
          type: DEPENDENT
          key: aws.rds.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: 'The percentage of CPU utilization.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "CPUUtilization")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 0272980a53e14f22b06db30af49a1233
              expression: 'min(/AWS RDS instance by HTTP/aws.rds.cpu.utilization,15m)>{$AWS.RDS.CPU.UTIL.WARN.MAX}'
              name: 'High CPU utilization'
              event_name: 'High CPU utilization (over {$AWS.RDS.CPU.UTIL.WARN.MAX}% for 15m)'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: capacity
                - tag: scope
                  value: performance
        - uuid: 8b4cbe054bd04d67bf7bcca006740599
          name: 'Create time'
          type: DEPENDENT
          key: aws.rds.create_time
          value_type: FLOAT
          units: unixtime
          description: 'Provides the date and time the DB instance was created.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..InstanceCreateTime.first()
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: instance
        - uuid: 9def6dbb88c249e8bdbac484f2e1cfb0
          name: Connections
          type: DEPENDENT
          key: aws.rds.database_connections
          value_type: FLOAT
          description: |
            The number of client network connections to the database instance.
            The number of database sessions can be higher than the metric value because the metric value doesn't include the following:
            
            - Sessions that no longer have a network connection but which the database hasn't cleaned up
            - Sessions created by the database engine for its own purposes
            - Sessions created by the database engine's parallel execution capabilities
            - Sessions created by the database engine job scheduler
            - Amazon Aurora/RDS connections
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "DatabaseConnections")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: connections
        - uuid: a60833d27daf49329c58a4ca0d9affa5
          name: 'Disk: Queue depth'
          type: DEPENDENT
          key: aws.rds.disk_queue_depth
          value_type: FLOAT
          description: 'The number of outstanding read/write requests waiting to access the disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "DiskQueueDepth")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: 1fb56b1936024dfca328660471827ce2
          name: 'EBS: Byte balance'
          type: DEPENDENT
          key: aws.rds.ebs_byte_balance
          value_type: FLOAT
          units: '%'
          description: |
            The percentage of throughput credits remaining in the burst bucket of your RDS database. This metric is available for basic monitoring only.
            To find the instance sizes that support this metric, see the instance sizes with an asterisk (*) in the EBS optimized by default table (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-optimized.html#current) in Amazon RDS User Guide for Linux Instances.
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "EBSByteBalance%")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: ebs
          triggers:
            - uuid: b878ee69a01a47a09677b184f8352668
              expression: 'max(/AWS RDS instance by HTTP/aws.rds.ebs_byte_balance,5m)<{$AWS.EBS.BYTE.CREDIT.BALANCE.MIN.WARN}'
              name: 'Byte Credit balance is too low'
              event_name: 'Byte Credit balance is too low (less {$AWS.EBS.BYTE.CREDIT.BALANCE.MIN.WARN}% for 5m)'
              opdata: 'Current value: {ITEM.LASTVALUE1}'
              priority: WARNING
              tags:
                - tag: scope
                  value: capacity
        - uuid: 44eadf0d51244375a302110cb00e8e88
          name: 'EBS: IO balance'
          type: DEPENDENT
          key: aws.rds.ebs_io_balance
          value_type: FLOAT
          units: '%'
          description: |
            The percentage of I/O credits remaining in the burst bucket of your RDS database. This metric is available for basic monitoring only.
            To find the instance sizes that support this metric, see the instance sizes with an asterisk (*) in the EBS optimized by default table (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-optimized.html#current) in Amazon RDS User Guide for Linux Instances.
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "EBSIOBalance%")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: ebs
          triggers:
            - uuid: 556100b7e8414543bf88017e13fb718f
              expression: 'max(/AWS RDS instance by HTTP/aws.rds.ebs_io_balance,5m)<{$AWS.EBS.IO.CREDIT.BALANCE.MIN.WARN}'
              name: 'I/O Credit balance is too low'
              event_name: 'I/O Credit balance is too low (less {$AWS.EBS.IO.CREDIT.BALANCE.MIN.WARN}% for 5m)'
              opdata: 'Current value: {ITEM.LASTVALUE1}'
              priority: WARNING
              tags:
                - tag: scope
                  value: capacity
        - uuid: cad47e37ddc04100a8a7c3bca5f9049f
          name: Engine
          type: DEPENDENT
          key: aws.rds.engine
          value_type: CHAR
          description: 'Database engine.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..Engine.first()
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: instance
        - uuid: fefdac322230485cb792f295bb1420af
          name: 'Engine version'
          type: DEPENDENT
          key: aws.rds.engine.version
          value_type: CHAR
          description: 'Indicates the database engine version.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[*].EngineVersion.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: instance
        - uuid: 5e83a36bcbf64098938ab7bb4725c39c
          name: 'Get events check'
          type: DEPENDENT
          key: aws.rds.events.check
          value_type: CHAR
          description: 'Data collection check.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_events
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 600805420f704d4daca1ac20903f27f5
              expression: 'length(last(/AWS RDS instance by HTTP/aws.rds.events.check))>0'
              name: 'Failed to get events data'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              tags:
                - tag: scope
                  value: availability
        - uuid: 641677b6f7c147058b1e77967754028f
          name: 'SQLServer: Failed agent jobs'
          type: DEPENDENT
          key: aws.rds.failed_sql_server_agent_jobs_count
          value_type: FLOAT
          units: Rpm
          description: 'The number of failed Microsoft SQL Server Agent jobs during the last minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "FailedSQLServerAgentJobsCount")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: application
            - tag: engine
              value: sqlserver
        - uuid: df8b49f346f8468b887526700295a6c4
          name: 'Memory, freeable'
          type: DEPENDENT
          key: aws.rds.freeable_memory
          value_type: FLOAT
          units: B
          description: |
            The amount of available random access memory.
            
            For MariaDB, MySQL, Oracle, and PostgreSQL DB instances, this metric reports the value of the MemAvailable field of /proc/meminfo.
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "FreeableMemory")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: memory
        - uuid: 33dfd559dd93470cabf27f3a9a0968f1
          name: 'Storage: Local free'
          type: DEPENDENT
          key: aws.rds.free_local_storage
          value_type: FLOAT
          units: B
          description: |
            The amount of local storage available, in bytes.
            
            Unlike for other DB engines, for Aurora DB instances this metric reports the amount of storage available to each DB instance. 
            This value depends on the DB instance class. You can increase the amount of free storage space for an instance by choosing a larger DB instance class for your instance.
            (This doesn't apply to Aurora Serverless v2.)
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "FreeLocalStorage")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: fc3fbf1da0b9481c9eee00838c05157f
          name: 'Storage: Space free'
          type: DEPENDENT
          key: aws.rds.free_storage_space
          value_type: FLOAT
          units: B
          description: 'The amount of available storage space.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "FreeStorageSpace")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: a2f85e777eae4fe789446de21136c510
          name: 'Get instance alarms data'
          type: SCRIPT
          key: aws.rds.get_alarms
          delay: 0s;m/1
          history: '0'
          value_type: TEXT
          params: |
            var AWS = {
            	params: {},
            	metadata: 'http://169.254.169.254/latest/meta-data/iam/security-credentials',
            
            	getField: function (data, path) {
            		var steps = path.split('.');
            		for (var i = 0; i < steps.length; i++) {
            			var step = steps[i];
            			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            				throw 'Required field was not found: ' + path;
            			}
            
            			data = data[step];
            		}
            
            		return data;
            	},
            
            	setParams: function (params) {
            		AWS.params['proxy'] = params.proxy;
            		switch (AWS.getField(params, 'auth_type')) {
            			case 'role_base':
            				AWS.params['auth_type'] = 'role_base';
            				var request = new HttpRequest();
            				if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
            					request.setProxy(AWS.params.proxy);
            				}
            				var IamRoleName = request.get(AWS.metadata);
            
            				if (request.getStatus() !== 200 || IamRoleName === null || IamRoleName === '') {
            					throw 'Error getting security credentials from instance metadata. Role not found.';
            				}
            
            				credentials = request.get(AWS.metadata + '/' + encodeURI(IamRoleName));
            
            				if (request.getStatus() !== 200 || credentials === null || credentials === '') {
            					throw 'Error getting security credentials from instance metadata.';
            				}
            
            				try {
            					credentials = JSON.parse(credentials);
            				}
            				catch (error) {
            					throw 'Failed to parse response received from instance metadata. Check debug log for more information.';
            				}
            
            				['AccessKeyId', 'SecretAccessKey', 'Token'].forEach(function (field) {
            					if (typeof credentials !== 'object' || typeof credentials[field] === 'undefined' || credentials[field] === '') {
            						throw 'Required credentials is not set: "' + field + '".';
            					};
            					AWS.params[field] = credentials[field];
            				});
            				break;
            			case 'access_key':
            			default:
            				AWS.params['auth_type'] = 'access_key';
            				['AccessKeyId', 'SecretAccessKey'].forEach(function (field) {
            					if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            						throw 'Required param is not set: "' + field + '".';
            					}
            					AWS.params[field] = params[field];
            				});
            		}
            		['region', 'db_instance_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: "' + field + '".';
            			}
            			AWS.params[field] = params[field];
            		});
            	},
            
            	sign: function (key, message) {
            		var hex = hmac('sha256', key, message);
            
            		if ((hex.length % 2) === 1) {
            			throw 'Invalid length of a hex string!';
            		}
            
            		var result = new Int8Array(hex.length / 2);
            		for (var i = 0, b = 0; i < hex.length; i += 2, b++) {
            			result[b] = parseInt(hex.substring(i, i + 2), 16);
            		}
            
            		return result;
            	},
            
            	prepareParams: function (params) {
            		var result = [];
            
            		Object.keys(params).sort().forEach(function (key) {
            			if (typeof params[key] !== 'object') {
            				result.push(key + '=' + encodeURIComponent(params[key]));
            			}
            			else {
            				result.push(prepareObject(key, params[key]));
            			}
            		});
            
            		return result.join('&');
            	},
            
            	request: function (method, region, service, params, data) {
            		if (typeof data === 'undefined' || data === null) {
            			data = '';
            		}
            
            		var amzdate = (new Date()).toISOString().replace(/\.\d+Z/, 'Z').replace(/[-:]/g, ''),
            			date = amzdate.replace(/T\d+Z/, ''),
            			host = service + '.' + region + '.amazonaws.com',
            			canonical_uri = '/',
            			canonical_headers = 'content-encoding:amz-1.0\n' + 'host:' + host + '\n' + 'x-amz-date:' + amzdate + '\n',
            			signed_headers = 'content-encoding;host;x-amz-date',
            			canonical_request = method + '\n' + canonical_uri + '\n' + params + '\n' + canonical_headers + '\n' + signed_headers + '\n' + sha256(data),
            			credential_scope = date + '/' + region + '/' + service + '/' + 'aws4_request',
            			request_string = 'AWS4-HMAC-SHA256' + '\n' + amzdate + '\n' + credential_scope + '\n' + sha256(canonical_request),
            			key = AWS.sign('AWS4' + AWS.params.SecretAccessKey, date);
            
            		key = AWS.sign(key, region);
            		key = AWS.sign(key, service);
            		key = AWS.sign(key, 'aws4_request');
            
            		var request = new HttpRequest(),
            			url = 'https://' + host + canonical_uri + '?' + params;
            
            		if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
            			request.setProxy(AWS.params.proxy);
            		}
            		request.addHeader('x-amz-date: ' + amzdate);
            		request.addHeader('Accept: application/json');
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Content-Encoding: amz-1.0');
            		request.addHeader('Authorization: ' + 'AWS4-HMAC-SHA256 Credential=' + AWS.params.AccessKeyId + '/' + credential_scope + ', ' + 'SignedHeaders=' + signed_headers + ', ' + 'Signature=' + hmac('sha256', key, request_string));
            		if (AWS.params.auth_type === 'role_base')
            			request.addHeader('X-Amz-Security-Token: ' + AWS.params.Token);
            
            		Zabbix.log(4, '[ AWS RDS ] Sending request: ' + url);
            
            		response = request.get(url);
            
            		Zabbix.log(4, '[ AWS RDS ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		if (response[0] === '<') {
            			try {
            				response = XML.toJson(response);
            			}
            			catch (error) {
            				throw 'Failed to parse response received from AWS CloudWatch API. Check debug log for more information.';
            			}
            		}
            
            		if (response !== null) {
            			try {
            				response = JSON.parse(response);
            			}
            			catch (error) {
            				throw 'Failed to parse response received from AWS CloudWatch API. Check debug log for more information.';
            			}
            		}
            
            		return response;
            	},
            
            	getAlarms: function () {
            		var payload = {
            			'Action': 'DescribeAlarms',
            			'Version': '2010-08-01',
            			'MaxRecords': 100
            		},
            			result = [];
            
            		while (payload.NextToken !== '') {
            			var alarms = AWS.getField(AWS.request('GET', AWS.params.region, 'monitoring', AWS.prepareParams(payload)), 'DescribeAlarmsResponse.DescribeAlarmsResult');
            			payload.NextToken = alarms.NextToken || '';
            			alarms_list = AWS.getField(alarms, 'MetricAlarms');
            
            			if (!Array.isArray(alarms_list))
            				alarms_list = [alarms_list];
            			alarms_list.forEach(function (alarm) {
            				var dimensions = alarm.Dimensions;
            
            				if (Array.isArray(alarm.Metrics)) {
            					alarm.Metrics.forEach(function (metric) {
            						if (typeof metric.MetricStat === 'object' && metric.MetricStat !== null
            							&& typeof metric.MetricStat.Metric === 'object' && metric.MetricStat.Metric !== null
            							&& Array.isArray(metric.MetricStat.Metric.Dimensions)) {
            							dimensions = dimensions.concat(metric.MetricStat.Metric.Dimensions);
            						}
            					});
            				}
            				for (var i in dimensions) {
            					if (dimensions[i].Name === 'DBInstanceIdentifier' && dimensions[i].Value === AWS.params.db_instance_id) {
            						result.push(alarm);
            						break;
            					}
            				}
            			});
            		}
            
            		return result;
            	}
            };
            
            try {
            	AWS.setParams(JSON.parse(value));
            
            	return JSON.stringify(AWS.getAlarms());
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ AWS RDS ] ERROR: ' + error);
            
            	return JSON.stringify({ 'error': error });
            }
          description: 'DescribeAlarms API method: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarms.html'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: 15s
          parameters:
            - name: AccessKeyId
              value: '{$AWS.ACCESS.KEY.ID}'
            - name: auth_type
              value: '{$AWS.AUTH_TYPE}'
            - name: db_instance_id
              value: '{$AWS.RDS.INSTANCE.ID}'
            - name: proxy
              value: '{$AWS.PROXY}'
            - name: region
              value: '{$AWS.REGION}'
            - name: SecretAccessKey
              value: '{$AWS.SECRET.ACCESS.KEY}'
          tags:
            - tag: component
              value: raw
        - uuid: f0d1041fa09d4ba38c9d0b39c4b76b0b
          name: 'Get instance events data'
          type: SCRIPT
          key: aws.rds.get_events
          delay: 0s;m/10
          history: '0'
          value_type: TEXT
          params: |
            var AWS = {
            	params: {},
            	metadata: 'http://169.254.169.254/latest/meta-data/iam/security-credentials',
            
            	getField: function (data, path) {
            		var steps = path.split('.');
            		for (var i = 0; i < steps.length; i++) {
            			var step = steps[i];
            			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            				throw 'Required field was not found: ' + path;
            			}
            
            			data = data[step];
            		}
            
            		return data;
            	},
            
            	setParams: function (params) {
            		AWS.params['proxy'] = params.proxy;
            		switch (AWS.getField(params, 'auth_type')) {
            			case 'role_base':
            				AWS.params['auth_type'] = 'role_base';
            				var request = new HttpRequest();
            				if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
            					request.setProxy(AWS.params.proxy);
            				}
            				var IamRoleName = request.get(AWS.metadata);
            
            				if (request.getStatus() !== 200 || IamRoleName === null || IamRoleName === '') {
            					throw 'Error getting security credentials from instance metadata. Role not found.';
            				}
            
            				credentials = request.get(AWS.metadata + '/' + encodeURI(IamRoleName));
            
            				if (request.getStatus() !== 200 || credentials === null || credentials === '') {
            					throw 'Error getting security credentials from instance metadata.';
            				}
            
            				try {
            					credentials = JSON.parse(credentials);
            				}
            				catch (error) {
            					throw 'Failed to parse response received from instance metadata. Check debug log for more information.';
            				}
            
            				['AccessKeyId', 'SecretAccessKey', 'Token'].forEach(function (field) {
            					if (typeof credentials !== 'object' || typeof credentials[field] === 'undefined' || credentials[field] === '') {
            						throw 'Required credentials is not set: "' + field + '".';
            					};
            					AWS.params[field] = credentials[field];
            				});
            				break;
            			case 'access_key':
            			default:
            				AWS.params['auth_type'] = 'access_key';
            				['AccessKeyId', 'SecretAccessKey'].forEach(function (field) {
            					if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            						throw 'Required param is not set: "' + field + '".';
            					}
            					AWS.params[field] = params[field];
            				});
            		}
            		['region', 'db_instance_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: "' + field + '".';
            			}
            			AWS.params[field] = params[field];
            		});
            	},
            
            	sign: function (key, message) {
            		var hex = hmac('sha256', key, message);
            
            		if ((hex.length % 2) === 1) {
            			throw 'Invalid length of a hex string!';
            		}
            
            		var result = new Int8Array(hex.length / 2);
            		for (var i = 0, b = 0; i < hex.length; i += 2, b++) {
            			result[b] = parseInt(hex.substring(i, i + 2), 16);
            		}
            
            		return result;
            	},
            
            	prepareParams: function (params) {
            		var result = [];
            
            		Object.keys(params).sort().forEach(function (key) {
            			if (typeof params[key] !== 'object') {
            				result.push(key + '=' + encodeURIComponent(params[key]));
            			}
            			else {
            				result.push(prepareObject(key, params[key]));
            			}
            		});
            
            		return result.join('&');
            	},
            
            	request: function (method, region, service, params, data) {
            		if (typeof data === 'undefined' || data === null) {
            			data = '';
            		}
            
            		var amzdate = (new Date()).toISOString().replace(/\.\d+Z/, 'Z').replace(/[-:]/g, ''),
            			date = amzdate.replace(/T\d+Z/, ''),
            			host = service + '.' + region + '.amazonaws.com',
            			canonical_uri = '/',
            			canonical_headers = 'content-encoding:amz-1.0\n' + 'host:' + host + '\n' + 'x-amz-date:' + amzdate + '\n',
            			signed_headers = 'content-encoding;host;x-amz-date',
            			canonical_request = method + '\n' + canonical_uri + '\n' + params + '\n' + canonical_headers + '\n' + signed_headers + '\n' + sha256(data),
            			credential_scope = date + '/' + region + '/' + service + '/' + 'aws4_request',
            			request_string = 'AWS4-HMAC-SHA256' + '\n' + amzdate + '\n' + credential_scope + '\n' + sha256(canonical_request),
            			key = AWS.sign('AWS4' + AWS.params.SecretAccessKey, date);
            
            		key = AWS.sign(key, region);
            		key = AWS.sign(key, service);
            		key = AWS.sign(key, 'aws4_request');
            
            		var request = new HttpRequest(),
            			url = 'https://' + host + canonical_uri + '?' + params;
            
            		if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
            			request.setProxy(AWS.params.proxy);
            		}
            		request.addHeader('x-amz-date: ' + amzdate);
            		request.addHeader('Accept: application/json');
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Content-Encoding: amz-1.0');
            		request.addHeader('Authorization: ' + 'AWS4-HMAC-SHA256 Credential=' + AWS.params.AccessKeyId + '/' + credential_scope + ', ' + 'SignedHeaders=' + signed_headers + ', ' + 'Signature=' + hmac('sha256', key, request_string));
            		if (AWS.params.auth_type === 'role_base')
            			request.addHeader('X-Amz-Security-Token: ' + AWS.params.Token);
            
            		Zabbix.log(4, '[ AWS RDS ] Sending request: ' + url);
            
            		response = request.get(url);
            
            		Zabbix.log(4, '[ AWS RDS ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		if (response[0] === '<') {
            			try {
            				response = XML.toJson(response);
            			}
            			catch (error) {
            				throw 'Failed to parse response received from AWS RDS API. Check debug log for more information.';
            			}
            		}
            
            		if (response !== null) {
            			try {
            				response = JSON.parse(response);
            			}
            			catch (error) {
            				throw 'Failed to parse response received from AWS RDS API. Check debug log for more information.';
            			}
            		}
            
            		return response;
            	},
            
            	getEvents: function () {
            		var payload = {
            			'Action': 'DescribeEvents',
            			'Version': '2014-09-01',
            			'MaxRecords': 100,
            			'Duration': 30,
            			'SourceType': 'db-instance',
            			'SourceIdentifier': AWS.params.db_instance_id
            		},
            			result = [];
            
            		while (payload.nextToken !== '') {
            			var events = AWS.getField(AWS.request('GET', AWS.params.region, 'rds', AWS.prepareParams(payload)), 'DescribeEventsResponse.DescribeEventsResult');
            			events_list = AWS.getField(events, 'Events');
            
            			if (!Array.isArray(events_list))
            				events_list = [events_list];
            			events_list.forEach(function (event) {
            				event.EventCategories = event.EventCategories.toString();
            				result.push(event);
            			});
            			payload.nextToken = events.nextToken || '';
            
            
            		};
            
            		return result;
            	}
            };
            
            try {
            	AWS.setParams(JSON.parse(value));
            
            	return JSON.stringify(AWS.getEvents());
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ AWS RDS ] ERROR: ' + error);
            
            	return JSON.stringify({ 'error': error });
            }
          description: 'DescribeEvents API method: https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeEvents.html'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: 15s
          parameters:
            - name: AccessKeyId
              value: '{$AWS.ACCESS.KEY.ID}'
            - name: auth_type
              value: '{$AWS.AUTH_TYPE}'
            - name: db_instance_id
              value: '{$AWS.RDS.INSTANCE.ID}'
            - name: proxy
              value: '{$AWS.PROXY}'
            - name: region
              value: '{$AWS.REGION}'
            - name: SecretAccessKey
              value: '{$AWS.SECRET.ACCESS.KEY}'
          tags:
            - tag: component
              value: raw
        - uuid: 85ac4a5313994e0f94fe6480d3c85193
          name: 'Get instance info'
          type: SCRIPT
          key: aws.rds.get_instance_info
          delay: 5m
          history: '0'
          value_type: TEXT
          params: |
            var AWS = {
            	params: {},
            	request_period: 600,
            	metadata: 'http://169.254.169.254/latest/meta-data/iam/security-credentials',
            
            	getField: function (data, path) {
            		var steps = path.split('.');
            		for (var i = 0; i < steps.length; i++) {
            			var step = steps[i];
            			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            				throw 'Required field was not found: ' + path;
            			}
            
            			data = data[step];
            		}
            
            		return data;
            	},
            
            	setParams: function (params) {
            		AWS.params['proxy'] = params.proxy;
            		switch (AWS.getField(params, 'auth_type')) {
            			case 'role_base':
            				AWS.params['auth_type'] = 'role_base';
            				var request = new HttpRequest();
            				if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
            					request.setProxy(AWS.params.proxy);
            				}
            				var IamRoleName = request.get(AWS.metadata);
            
            				if (request.getStatus() !== 200 || IamRoleName === null || IamRoleName === '') {
            					throw 'Error getting security credentials from instance metadata. Role not found.';
            				}
            
            				credentials = request.get(AWS.metadata + '/' + encodeURI(IamRoleName));
            
            				if (request.getStatus() !== 200 || credentials === null || credentials === '') {
            					throw 'Error getting security credentials from instance metadata.';
            				}
            
            				try {
            					credentials = JSON.parse(credentials);
            				}
            				catch (error) {
            					throw 'Failed to parse response received from instance metadata. Check debug log for more information.';
            				}
            
            				['AccessKeyId', 'SecretAccessKey', 'Token'].forEach(function (field) {
            					if (typeof credentials !== 'object' || typeof credentials[field] === 'undefined' || credentials[field] === '') {
            						throw 'Required credentials is not set: "' + field + '".';
            					};
            					AWS.params[field] = credentials[field];
            				});
            				break;
            			case 'access_key':
            			default:
            				AWS.params['auth_type'] = 'access_key';
            				['AccessKeyId', 'SecretAccessKey'].forEach(function (field) {
            					if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            						throw 'Required param is not set: "' + field + '".';
            					}
            					AWS.params[field] = params[field];
            				});
            		}
            		['region', 'db_instance_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: "' + field + '".';
            			}
            			AWS.params[field] = params[field];
            		});
            	},
            
            	sign: function (key, message) {
            		var hex = hmac('sha256', key, message);
            
            		if ((hex.length % 2) === 1) {
            			throw 'Invalid length of a hex string!';
            		}
            
            		var result = new Int8Array(hex.length / 2);
            		for (var i = 0, b = 0; i < hex.length; i += 2, b++) {
            			result[b] = parseInt(hex.substring(i, i + 2), 16);
            		}
            
            		return result;
            	},
            
            	prepareParams: function (params) {
            		var result = [];
            
            		Object.keys(params).sort().forEach(function (key) {
            			if (typeof params[key] !== 'object') {
            				result.push(key + '=' + encodeURIComponent(params[key]));
            			}
            			else {
            				result.push(prepareObject(key, params[key]));
            			}
            		});
            
            		return result.join('&');
            	},
            
            	request: function (method, region, service, params, data) {
            		if (typeof data === 'undefined' || data === null) {
            			data = '';
            		}
            
            		var amzdate = (new Date()).toISOString().replace(/\.\d+Z/, 'Z').replace(/[-:]/g, ''),
            			date = amzdate.replace(/T\d+Z/, ''),
            			host = service + '.' + region + '.amazonaws.com',
            			canonical_uri = '/',
            			canonical_headers = 'content-encoding:amz-1.0\n' + 'host:' + host + '\n' + 'x-amz-date:' + amzdate + '\n',
            			signed_headers = 'content-encoding;host;x-amz-date',
            			canonical_request = method + '\n' + canonical_uri + '\n' + params + '\n' + canonical_headers + '\n' + signed_headers + '\n' + sha256(data),
            			credential_scope = date + '/' + region + '/' + service + '/' + 'aws4_request',
            			request_string = 'AWS4-HMAC-SHA256' + '\n' + amzdate + '\n' + credential_scope + '\n' + sha256(canonical_request),
            			key = AWS.sign('AWS4' + AWS.params.SecretAccessKey, date);
            
            		key = AWS.sign(key, region);
            		key = AWS.sign(key, service);
            		key = AWS.sign(key, 'aws4_request');
            
            		var request = new HttpRequest(),
            			url = 'https://' + host + canonical_uri + '?' + params;
            
            		if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
            			request.setProxy(AWS.params.proxy);
            		}
            		request.addHeader('x-amz-date: ' + amzdate);
            		request.addHeader('Accept: application/json');
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Content-Encoding: amz-1.0');
            		request.addHeader('Authorization: ' + 'AWS4-HMAC-SHA256 Credential=' + AWS.params.AccessKeyId + '/' + credential_scope + ', ' + 'SignedHeaders=' + signed_headers + ', ' + 'Signature=' + hmac('sha256', key, request_string));
            		if (AWS.params.auth_type === 'role_base')
            			request.addHeader('X-Amz-Security-Token: ' + AWS.params.Token);
            
            		Zabbix.log(4, '[ AWS RDS ] Sending request: ' + url);
            
            		response = request.get(url);
            
            		Zabbix.log(4, '[ AWS RDS ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		if (response !== null) {
            			try {
            				response = JSON.parse(response);
            			}
            			catch (error) {
            				throw 'Failed to parse response received from AWS RDS API. Check debug log for more information.';
            			}
            		}
            		return response;
            	},
            
            	getInstanceData: function () {
            		var payload = {};
            
            		payload['Action'] = 'DescribeDBInstances',
            			payload['Version'] = '2014-10-31',
            			payload['DBInstanceIdentifier'] = AWS.params.db_instance_id;
            
            		result = AWS.request('GET', AWS.params.region, 'rds', AWS.prepareParams(payload));
            		if (typeof result !== 'object'
            			|| typeof result.DescribeDBInstancesResponse !== 'object'
            			|| typeof result.DescribeDBInstancesResponse.DescribeDBInstancesResult !== 'object'
            			|| typeof result.DescribeDBInstancesResponse.DescribeDBInstancesResult.DBInstances !== 'object') {
            			throw 'Cannot get metrics data from AWS RDS API. Check debug log for more information.';
            		}
            
            		return result.DescribeDBInstancesResponse.DescribeDBInstancesResult.DBInstances;
            	}
            };
            
            try {
            	AWS.setParams(JSON.parse(value));
            
            	return JSON.stringify(AWS.getInstanceData());
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ AWS RDS ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
          description: |
            Get instance info.
            DescribeDBInstances API method: https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: 15s
          parameters:
            - name: AccessKeyId
              value: '{$AWS.ACCESS.KEY.ID}'
            - name: auth_type
              value: '{$AWS.AUTH_TYPE}'
            - name: db_instance_id
              value: '{$AWS.RDS.INSTANCE.ID}'
            - name: proxy
              value: '{$AWS.PROXY}'
            - name: region
              value: '{$AWS.REGION}'
            - name: SecretAccessKey
              value: '{$AWS.SECRET.ACCESS.KEY}'
          tags:
            - tag: component
              value: raw
        - uuid: b22171fe7de44ac3952468ceb0c1a9b0
          name: 'Get metrics data'
          type: SCRIPT
          key: aws.rds.get_metrics
          delay: 0s;m/5
          history: '0'
          value_type: TEXT
          params: |
            var AWS = {
            	params: {},
            	request_period: 600,
            	metadata: 'http://169.254.169.254/latest/meta-data/iam/security-credentials',
            
            	getField: function (data, path) {
            		var steps = path.split('.');
            		for (var i = 0; i < steps.length; i++) {
            			var step = steps[i];
            			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            				throw 'Required field was not found: ' + path;
            			}
            
            			data = data[step];
            		}
            
            		return data;
            	},
            
            	setParams: function (params) {
            		AWS.params['proxy'] = params.proxy;
            		switch (AWS.getField(params, 'auth_type')) {
            			case 'role_base':
            				AWS.params['auth_type'] = 'role_base';
            				var request = new HttpRequest();
            				if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
            					request.setProxy(AWS.params.proxy);
            				}
            				var IamRoleName = request.get(AWS.metadata);
            
            				if (request.getStatus() !== 200 || IamRoleName === null || IamRoleName === '') {
            					throw 'Error getting security credentials from instance metadata. Role not found.';
            				}
            
            				credentials = request.get(AWS.metadata + '/' + encodeURI(IamRoleName));
            
            				if (request.getStatus() !== 200 || credentials === null || credentials === '') {
            					throw 'Error getting security credentials from instance metadata.';
            				}
            
            				try {
            					credentials = JSON.parse(credentials);
            				}
            				catch (error) {
            					throw 'Failed to parse response received from instance metadata. Check debug log for more information.';
            				}
            
            				['AccessKeyId', 'SecretAccessKey', 'Token'].forEach(function (field) {
            					if (typeof credentials !== 'object' || typeof credentials[field] === 'undefined' || credentials[field] === '') {
            						throw 'Required credentials is not set: "' + field + '".';
            					};
            					AWS.params[field] = credentials[field];
            				});
            				break;
            			case 'access_key':
            			default:
            				AWS.params['auth_type'] = 'access_key';
            				['AccessKeyId', 'SecretAccessKey'].forEach(function (field) {
            					if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            						throw 'Required param is not set: "' + field + '".';
            					}
            					AWS.params[field] = params[field];
            				});
            		}
            		['region', 'db_instance_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: "' + field + '".';
            			}
            			AWS.params[field] = params[field];
            		});
            	},
            
            	sign: function (key, message) {
            		var hex = hmac('sha256', key, message);
            
            		if ((hex.length % 2) === 1) {
            			throw 'Invalid length of a hex string!';
            		}
            
            		var result = new Int8Array(hex.length / 2);
            		for (var i = 0, b = 0; i < hex.length; i += 2, b++) {
            			result[b] = parseInt(hex.substring(i, i + 2), 16);
            		}
            
            		return result;
            	},
            
            	renderMetricQuery: function (period, db_instance_id) {
            		var metrics_list = [
            			'AbortedClients:Count',
            			'ActiveTransactions:Count/Second',
            			'AuroraBinlogReplicaLag:Seconds',
            			'AuroraReplicaLag:Milliseconds',
            			'AuroraReplicaLagMaximum:Milliseconds',
            			'AuroraReplicaLagMinimum:Milliseconds',
            			'BacktrackWindowActual:Count',
            			'BacktrackWindowAlert:Count',
            			'BinLogDiskUsage:Bytes',
            			'BlockedTransactions:Count/Second',
            			'BufferCacheHitRatio:Percent',
            			'CheckpointLag:Seconds',
            			'CommitLatency:Milliseconds',
            			'CommitThroughput:Count/Second',
            			'CPUCreditBalance:Count',
            			'CPUCreditUsage:Count',
            			'CPUUtilization:Percent',
            			'DatabaseConnections:Count',
            			'DDLLatency:Milliseconds',
            			'DDLThroughput:Count/Second',
            			'Deadlocks:Count/Second',
            			'DeleteLatency:Milliseconds',
            			'DeleteThroughput:Count/Second',
            			'DiskQueueDepth:Count',
            			'DMLLatency:Milliseconds',
            			'DMLThroughput:Count/Second',
            			'EBSByteBalance%:Percent',
            			'EBSIOBalance%:Percent',
            			'EngineUptime:Seconds',
            			'FailedSQLServerAgentJobsCount:Count/Second',
            			'FreeableMemory:Bytes',
            			'FreeLocalStorage:Bytes',
            			'InsertLatency:Milliseconds',
            			'InsertThroughput:Count/Second',
            			'LoginFailures:Count/Second',
            			'MaximumUsedTransactionIDs:Count',
            			'NetworkReceiveThroughput:Bytes/Second',
            			'NetworkThroughput:Bytes/Second',
            			'NetworkTransmitThroughput:Bytes/Second',
            			'NumBinaryLogFiles:Count',
            			'Queries:Count/Second',
            			'RDSToAuroraPostgreSQLReplicaLag:Seconds',
            			'ReadIOPS:Count/Second',
            			'ReadLatency:Seconds',
            			'ReadLatencyLocalStorage:Seconds',
            			'ReadThroughput:Bytes/Second',
            			'ReadThroughputLocalStorage:Bytes/Second',
            			'ReplicationSlotDiskUsage:Bytes',
            			'ResultSetCacheHitRatio:Percent',
            			'RollbackSegmentHistoryListLength:Count',
            			'RowLockTime:Milliseconds',
            			'SelectLatency:Milliseconds',
            			'SelectThroughput:Count/Second',
            			'StorageNetworkReceiveThroughput:Bytes/Second',
            			'StorageNetworkThroughput:Bytes/Second',
            			'StorageNetworkTransmitThroughput:Bytes/Second',
            			'SumBinaryLogSize:Bytes',
            			'SwapUsage:Bytes',
            			'TransactionLogsDiskUsage:Bytes',
            			'UpdateLatency:Milliseconds',
            			'UpdateThroughput:Count/Second',
            			'WriteIOPS:Count/Second',
            			'WriteLatency:Seconds',
            			'WriteThroughput:Bytes/Second',
            			'BurstBalance:Percent',
            			'FreeStorageSpace:Bytes',
            			'OldestReplicationSlotLag:Bytes',
            			'ReplicaLag:Seconds',
            			'TransactionLogsGeneration:Bytes/Second'
            		];
            
            		var metric_payload = [];
            		metrics_list.forEach(function (metric) {
            			var parts = metric.split(':', 2);
            			var name = parts[0].replace(/[^a-zA-Z0-9]/g, '');
            			metric_payload.push({
            				'Id': name.charAt(0).toLowerCase() + name.slice(1),
            				'MetricStat': {
            					'Metric': {
            						'MetricName': parts[0],
            						'Namespace': 'AWS/RDS',
            						'Dimensions': [
            							{
            								'Name': 'DBInstanceIdentifier',
            								'Value': db_instance_id
            							}
            						]
            					},
            					'Period': period,
            					'Stat': 'Average',
            					'Unit': parts[1]
            				}
            			});
            		});
            
            		return metric_payload;
            
            	},
            	prepareParams: function (params) {
            		var result = [];
            
            		Object.keys(params).sort().forEach(function (key) {
            			if (typeof params[key] !== 'object') {
            				result.push(key + '=' + encodeURIComponent(params[key]));
            			}
            			else {
            				result.push(prepareObject(key, params[key]));
            			}
            		});
            
            		return result.join('&');
            	},
            
            	request: function (method, region, service, request_data) {
            		if (typeof request_data === 'undefined' || request_data === null) {
            			request_data = '';
            		}
            		else {
            			request_data = JSON.stringify(request_data);
            		}
            
            		var amzdate = (new Date()).toISOString().replace(/\.\d+Z/, 'Z').replace(/[-:]/g, ''),
            			date = amzdate.replace(/T\d+Z/, ''),
            			host = service + '.' + region + '.amazonaws.com',
            			canonical_uri = '/',
            			canonical_headers = 'content-encoding:amz-1.0\n' + 'host:' + host + '\n' + 'x-amz-date:' + amzdate + '\n',
            			signed_headers = 'content-encoding;host;x-amz-date',
            			canonical_request = method + '\n' + canonical_uri + '\n' + '\n' + canonical_headers + '\n' + signed_headers + '\n' + sha256(request_data),
            			credential_scope = date + '/' + region + '/' + service + '/' + 'aws4_request',
            			request_string = 'AWS4-HMAC-SHA256' + '\n' + amzdate + '\n' + credential_scope + '\n' + sha256(canonical_request),
            			key = AWS.sign('AWS4' + AWS.params.SecretAccessKey, date);
            
            		key = AWS.sign(key, region);
            		key = AWS.sign(key, service);
            		key = AWS.sign(key, 'aws4_request');
            
            		var request = new HttpRequest(),
            			url = 'https://' + host + canonical_uri;
            
            		if (typeof AWS.params.proxy !== 'undefined' && AWS.params.proxy !== '') {
            			request.setProxy(AWS.params.proxy);
            		}
            		request.addHeader('x-amz-date: ' + amzdate);
            		request.addHeader('X-Amz-Target: GraniteServiceVersion20100801.GetMetricData');
            		request.addHeader('Accept: application/json');
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Content-Encoding: amz-1.0');
            		request.addHeader('Authorization: ' + 'AWS4-HMAC-SHA256 Credential=' + AWS.params.AccessKeyId + '/' + credential_scope + ', ' + 'SignedHeaders=' + signed_headers + ', ' + 'Signature=' + hmac('sha256', key, request_string));
            		if (AWS.params.auth_type === 'role_base')
            			request.addHeader('X-Amz-Security-Token: ' + AWS.params.Token);
            
            		Zabbix.log(4, '[ AWS RDS ] Sending request: ' + url);
            
            		response = request.post(url, request_data);
            		Zabbix.log(4, '[ AWS RDS ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		if (response !== null) {
            			try {
            				response = JSON.parse(response);
            			}
            			catch (error) {
            				throw 'Failed to parse response received from AWS CloudWatch API. Check debug log for more information.';
            			}
            		}
            
            		return response;
            	},
            
            	getMetricsData: function () {
            		var payload = {},
            			end_time = Math.floor((new Date().getTime()) / 1000),
            			start_time = end_time - AWS.request_period;
            
            		payload['StartTime'] = start_time;
            		payload['EndTime'] = end_time;
            		payload['ScanBy'] = 'TimestampDescending';
            		payload['MetricDataQueries'] = AWS.renderMetricQuery(AWS.request_period, AWS.params.db_instance_id);
            		result = AWS.request('POST', AWS.params.region, 'monitoring', payload);
            		if (typeof result !== 'object' || typeof result.MetricDataResults !== 'object') {
            			throw 'Cannot get metrics data from AWS CloudWatch API. Check debug log for more information.';
            		}
            
            		return result.MetricDataResults;
            	}
            };
            
            try {
            	AWS.setParams(JSON.parse(value));
            
            	return JSON.stringify(AWS.getMetricsData());
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ AWS RDS ] ERROR: ' + error);
            
            	return JSON.stringify({ 'error': error });
            }
          description: |
            Get instance metrics.
            Full metrics list related to RDS: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-metrics.html
            Full metrics list related to Amazon Aurora: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.AuroraMySQL.Monitoring.Metrics.html#Aurora.AuroraMySQL.Monitoring.Metrics.instances
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: 15s
          parameters:
            - name: AccessKeyId
              value: '{$AWS.ACCESS.KEY.ID}'
            - name: auth_type
              value: '{$AWS.AUTH_TYPE}'
            - name: db_instance_id
              value: '{$AWS.RDS.INSTANCE.ID}'
            - name: proxy
              value: '{$AWS.PROXY}'
            - name: region
              value: '{$AWS.REGION}'
            - name: SecretAccessKey
              value: '{$AWS.SECRET.ACCESS.KEY}'
          tags:
            - tag: component
              value: raw
        - uuid: 72fb52bfbcf44ad58df0d49525654cde
          name: 'Get instance info check'
          type: DEPENDENT
          key: aws.rds.instance_info.check
          value_type: CHAR
          description: 'Data collection check.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 452195309f1f4211aeb71b43a373f86f
              expression: 'length(last(/AWS RDS instance by HTTP/aws.rds.instance_info.check))>0'
              name: 'Failed to get instance data'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              tags:
                - tag: scope
                  value: availability
        - uuid: 8f651a01cd1d4639b6a4ef443285b24c
          name: 'Get metrics check'
          type: DEPENDENT
          key: aws.rds.metrics.check
          value_type: CHAR
          description: 'Data collection check.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 54c70842bf314ce2a9c95e0cfc57cc21
              expression: 'length(last(/AWS RDS instance by HTTP/aws.rds.metrics.check))>0'
              name: 'Failed to get metrics data'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              tags:
                - tag: scope
                  value: availability
        - uuid: 4d5ce2d0bb0648a6b4e4df98dc20fb49
          name: 'Network: Receive throughput'
          type: DEPENDENT
          key: aws.rds.network_receive_throughput.rate
          value_type: FLOAT
          units: Bps
          description: 'The incoming (Receive) network traffic on the DB instance, including both customer database traffic and Amazon RDS traffic used for monitoring and replication.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "NetworkReceiveThroughput")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: network
        - uuid: 8de924155ca646e0a63de9fb4184e2b7
          name: 'Network: Throughput'
          type: DEPENDENT
          key: aws.rds.network_throughput.rate
          value_type: FLOAT
          units: Bps
          description: 'The amount of network throughput both received from and transmitted to clients by each instance in the Aurora MySQL DB cluster, in bytes per second. This throughput doesn''t include network traffic between instances in the DB cluster and the cluster volume.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "NetworkThroughput")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: network
        - uuid: a97083537fce49c99caf71d1b0b2926f
          name: 'Network: Transmit throughput'
          type: DEPENDENT
          key: aws.rds.network_transmit_throughput.rate
          value_type: FLOAT
          units: Bps
          description: 'The outgoing (Transmit) network traffic on the DB instance, including both customer database traffic and Amazon RDS traffic used for monitoring and replication.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "NetworkTransmitThroughput")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: network
        - uuid: 3f9ac8ce149e4fb2a65580941c4d5428
          name: 'Disk: Read IOPS'
          type: DEPENDENT
          key: aws.rds.read_iops.rate
          value_type: FLOAT
          units: Rps
          description: 'The average number of disk I/O operations per second. Aurora PostgreSQL-Compatible Edition reports read and write IOPS separately, in 1-minute intervals.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "ReadIOPS")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: bd55865999364de890e87da30676adea
          name: 'Disk: Read IOPS, local storage'
          type: DEPENDENT
          key: aws.rds.read_iops_local_storage.rate
          value_type: FLOAT
          units: Rps
          description: 'The average number of disk read I/O operations to local storage per second. Only applies to Multi-AZ DB clusters.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "ReadIOPSLocalStorage")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: 3ad5d0d0bbbb4e579c74dd54923ccd8b
          name: 'Disk: Read latency'
          type: DEPENDENT
          key: aws.rds.read_latency
          value_type: FLOAT
          units: s
          description: 'The average amount of time taken per disk I/O operation.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "ReadLatency")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: 2d85eb0d8e2641bf95b3c5dbbb125089
          name: 'Disk: Read latency, local storage'
          type: DEPENDENT
          key: aws.rds.read_latency_local_storage
          value_type: FLOAT
          units: s
          description: 'The average amount of time taken per disk I/O operation for local storage. Only applies to Multi-AZ DB clusters.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "ReadLatencyLocalStorage")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: 9253279ef6c34d86a2b1750c8d8b29d0
          name: 'Read replica: State'
          type: DEPENDENT
          key: aws.rds.read_replica_state
          value_type: CHAR
          description: |
            The status of a read replica. If the instance isn't a read replica, this is blank.
            Boolean value that is true if the instance is operating normally, or false if the instance is in an error state.
          valuemap:
            name: 'Read replica state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..StatusInfos..Normal.first()
              error_handler: DISCARD_VALUE
            - type: BOOL_TO_DECIMAL
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: replication
          triggers:
            - uuid: 1f4767ba167f43b7ae9730ec834152a4
              expression: 'last(/AWS RDS instance by HTTP/aws.rds.read_replica_state)=0'
              name: 'Read replica in error state'
              priority: AVERAGE
              description: |
                The status of a read replica.
                False if the instance is in an error state.
              tags:
                - tag: scope
                  value: availability
        - uuid: 8fd266a7e4744395b21638b58c939072
          name: 'Read replica: Status'
          type: DEPENDENT
          key: aws.rds.read_replica_status
          value_type: CHAR
          description: |
            The status of a read replica. If the instance isn't a read replica, this is blank.
            Status of the DB instance. For a StatusType of read replica, the values can be replicating, replication stop point set, replication stop point reached, error, stopped, or terminated.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..StatusInfos..Status.first()
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: replication
        - uuid: 14b63bcb60fd4c91b87357d3f77e71df
          name: 'Disk: Read throughput'
          type: DEPENDENT
          key: aws.rds.read_throughput.rate
          value_type: FLOAT
          units: Bps
          description: 'The average number of bytes read from disk per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "ReadThroughput")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: bc963bae1664421c8874d77b085006a6
          name: 'Disk: Read throughput, local storage'
          type: DEPENDENT
          key: aws.rds.read_throughput_local_storage.rate
          value_type: FLOAT
          units: Bps
          description: 'The average number of bytes read from disk per second for local storage. Only applies to Multi-AZ DB clusters.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "ReadThroughputLocalStorage")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: 7be22cd083bc401bbbd2d75f2f6816de
          name: 'Replication: Lag'
          type: DEPENDENT
          key: aws.rds.replica_lag
          value_type: FLOAT
          units: s
          description: 'The amount of time a read replica DB instance lags behind the source DB instance. Applies to MySQL, MariaDB, Oracle, PostgreSQL, and SQL Server read replicas.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "ReplicaLag")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: replication
            - tag: engine
              value: mariadb
            - tag: engine
              value: mysql
            - tag: engine
              value: oracle
            - tag: engine
              value: postgres
            - tag: engine
              value: sqlserver
        - uuid: f6fe45dc205241cb99b1822d3f78cce6
          name: Status
          type: DEPENDENT
          key: aws.rds.status
          value_type: CHAR
          description: |
            Specifies the current state of this database.
            All possible status values and their description: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/accessing-monitoring.html#Overview.DBInstance.Status
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..DBInstanceStatus.first()
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: instance
        - uuid: 2694163a440f40e4a5ec41111f9abf59
          name: 'Storage: Allocated'
          type: DEPENDENT
          key: aws.rds.storage.allocated
          value_type: FLOAT
          units: '!GiB'
          description: 'Specifies the allocated storage size specified in gibibytes (GiB).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[*].AllocatedStorage.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: storage
        - uuid: 1aafa7a752274a1abb30b7b2e067b857
          name: 'Storage: Max allocated'
          type: DEPENDENT
          key: aws.rds.storage.max_allocated
          value_type: FLOAT
          units: '!GiB'
          description: |
            The upper limit in gibibytes (GiB) to which Amazon RDS can automatically scale the storage of the DB instance.
            If limit is not specified returns -1.
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data = JSON.parse(value);
                  return (typeof data.MaxAllocatedStorage === 'undefined') ? -1 : data.MaxAllocatedStorage;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: storage
        - uuid: 842f80f586794da39562ceb3cb09d5a4
          name: 'Network: Receive throughput'
          type: DEPENDENT
          key: aws.rds.storage_network_receive_throughput
          value_type: FLOAT
          units: Bps
          description: |
            The incoming (receive) network traffic on the DB instance, including both customer database traffic and Amazon RDS traffic used for monitoring and replication.
            For Amazon Aurora: The amount of network throughput received from the Aurora storage subsystem by each instance in the DB cluster.
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "StorageNetworkReceiveThroughput")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: network
        - uuid: bab141cde0114edf8b02211565df5b1f
          name: 'Network: Transmit throughput'
          type: DEPENDENT
          key: aws.rds.storage_network_transmit_throughput
          value_type: FLOAT
          units: Bps
          description: |
            The outgoing (transmit) network traffic on the DB instance, including both customer database traffic and Amazon RDS traffic used for monitoring and replication.
            For Amazon Aurora: The amount of network throughput sent to the Aurora storage subsystem by each instance in the Aurora MySQL DB cluster.
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "StorageNetworkTransmitThroughput")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: network
        - uuid: 6b3a8fd76fe6466395dcc4926d7177b4
          name: 'Storage type'
          type: DEPENDENT
          key: aws.rds.storage_type
          value_type: CHAR
          description: 'Specifies the storage type associated with DB instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[*].StorageType.first()'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: aws.rds.get_instance_info
          tags:
            - tag: component
              value: instance
        - uuid: f9d1a5169ec54f648937eac63b3ebcbb
          name: 'Swap usage'
          type: DEPENDENT
          key: aws.rds.swap_usage
          value_type: FLOAT
          units: B
          description: |
            The amount of swap space used. 
            This metric is available for the Aurora PostgreSQL DB instance classes db.t3.medium, db.t3.large, db.r4.large, db.r4.xlarge, db.r5.large, db.r5.xlarge, db.r6g.large, and db.r6g.xlarge. 
            For Aurora MySQL, this metric applies only to db.t* DB instance classes.
            This metric is not available for SQL Server.
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "SwapUsage")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: memory
        - uuid: a64c2caccd884f0f9bb7c9c9295baf45
          name: 'Disk: Write IOPS'
          type: DEPENDENT
          key: aws.rds.write_iops.rate
          value_type: FLOAT
          units: Rps
          description: 'The number of write records generated per second. This is more or less the number of log records generated by the database. These do not correspond to 8K page writes, and do not correspond to network packets sent.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "WriteIOPS")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: 19dc221c59ec4587af496bd644830869
          name: 'Disk: Write IOPS, local storage'
          type: DEPENDENT
          key: aws.rds.write_iops_local_storage.rate
          value_type: FLOAT
          units: Rps
          description: 'The average number of disk write I/O operations per second on local storage in a Multi-AZ DB cluster.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "WriteIOPSLocalStorage")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: 57e84381425d4706a2bcea41e0373157
          name: 'Disk: Write latency'
          type: DEPENDENT
          key: aws.rds.write_latency
          value_type: FLOAT
          units: s
          description: 'The average amount of time taken per disk I/O operation.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "WriteLatency")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: b34b656492e8479ea03b97815d368752
          name: 'Disk: Write latency, local storage'
          type: DEPENDENT
          key: aws.rds.write_latency_local_storage
          value_type: FLOAT
          units: s
          description: 'The average amount of time taken per disk I/O operation on local storage in a Multi-AZ DB cluster.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "WriteLatencyLocalStorage")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: db6932f63f7843508bb9e5559a69e8c3
          name: 'Disk: Write throughput'
          type: DEPENDENT
          key: aws.rds.write_throughput.rate
          value_type: FLOAT
          units: Bps
          description: 'The average number of bytes written to persistent storage every second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "WriteThroughput")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
        - uuid: f30df9f386be49948bce7817d56dae09
          name: 'Disk: Write throughput, local storage'
          type: DEPENDENT
          key: aws.rds.write_throughput_local_storage.rate
          value_type: FLOAT
          units: Bps
          description: 'The average number of bytes written to disk per second for local storage.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.Label == "WriteThroughputLocalStorage")].Values.first().first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: aws.rds.get_metrics
          tags:
            - tag: component
              value: disk
      discovery_rules:
        - uuid: 29b2b32b0d82450393f77ec7e093ef81
          name: 'Instance Alarms discovery'
          type: DEPENDENT
          key: aws.rds.alarms.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#ALARM_NAME}'
                value: '{$AWS.RDS.LLD.FILTER.ALARM_NAME.MATCHES}'
              - macro: '{#ALARM_NAME}'
                value: '{$AWS.RDS.LLD.FILTER.ALARM_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#ALARM_SERVICE_NAMESPACE}'
                value: '{$AWS.RDS.LLD.FILTER.ALARM_SERVICE_NAMESPACE.MATCHES}'
              - macro: '{#ALARM_SERVICE_NAMESPACE}'
                value: '{$AWS.RDS.LLD.FILTER.ALARM_SERVICE_NAMESPACE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery instance alarms.'
          item_prototypes:
            - uuid: aab5aaf6e27740c6ac92f5494b3aef4b
              name: '[{#ALARM_NAME}]: State'
              type: DEPENDENT
              key: 'aws.rds.alarm.state["{#ALARM_NAME}"]'
              description: |
                The state value for the alarm. Possible values: 0 (OK), 1 (INSUFFICIENT_DATA), 2 (ALARM).
                Alarm description:
                {#ALARM_DESCRIPTION}
              valuemap:
                name: 'Alarm state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.AlarmName == "{#ALARM_NAME}")].StateValue.first()'
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '3'
                - type: JAVASCRIPT
                  parameters:
                    - |
                      var state = ['OK', 'INSUFFICIENT_DATA', 'ALARM'];
                      
                      return state.indexOf(value.trim()) === -1 ? 255 : state.indexOf(value.trim());
              master_item:
                key: aws.rds.get_alarms
              tags:
                - tag: component
                  value: alarms
              trigger_prototypes:
                - uuid: 7d87b8d84fef4aff8aa9c0fd49e49619
                  expression: 'last(/AWS RDS instance by HTTP/aws.rds.alarm.state["{#ALARM_NAME}"])=1'
                  name: '[{#ALARM_NAME}] has ''Insufficient data'' state'
                  priority: INFO
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 6e95f834b2284447b5ab0f6516d29946
              name: '[{#ALARM_NAME}]: State reason'
              type: DEPENDENT
              key: 'aws.rds.alarm.state_reason["{#ALARM_NAME}"]'
              value_type: TEXT
              description: |
                An explanation for the alarm state, in text format.
                Alarm description:
                {#ALARM_DESCRIPTION}
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.AlarmName == "{#ALARM_NAME}")].StateReason.first()'
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: aws.rds.get_alarms
              tags:
                - tag: component
                  value: alarms
          trigger_prototypes:
            - uuid: 0f70f3d91d9c403c9d4c3cfb3283865f
              expression: 'last(/AWS RDS instance by HTTP/aws.rds.alarm.state["{#ALARM_NAME}"])=2 and length(last(/AWS RDS instance by HTTP/aws.rds.alarm.state_reason["{#ALARM_NAME}"]))>0'
              name: '[{#ALARM_NAME}] has ''Alarm'' state'
              priority: AVERAGE
              description: |
                Alarm "{#ALARM_NAME}" has 'Alarm' state. 
                Reason: {ITEM.LASTVALUE2}
              tags:
                - tag: scope
                  value: availability
          master_item:
            key: aws.rds.get_alarms
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var result = [];
                  var alarms = JSON.parse(value);
                  
                  alarms.forEach(function (alarm) {
                  
                  	result.push({
                  		'{#ALARM_DESCRIPTION}': alarm.AlarmDescription !== null ? alarm.AlarmDescription : 'None',
                  		'{#ALARM_NAME}': alarm.AlarmName,
                  		'{#ALARM_PERIOD}': alarm.Period,
                  		'{#METRIC_NAME}': alarm.MetricName,
                  		'{#ALARM_SERVICE_NAMESPACE}': alarm.Namespace !== null ? alarm.Namespace : 'None'
                  	});
                  });
                  
                  return JSON.stringify(result);
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: f13154dfb6b547718d1bf4b0ed12d35f
          name: 'Aurora metrics discovery'
          type: DEPENDENT
          key: aws.rds.aurora.discovery
          description: |
            Discovery Amazon Aurora metrics.
            https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.AuroraMySQL.Monitoring.Metrics.html#Aurora.AuroraMySQL.Monitoring.Metrics.instances
          item_prototypes:
            - uuid: 28df1a214515425099514140a1244cc4
              name: 'Replication: Lag, max'
              type: DEPENDENT
              key: 'aws.rds.aurora_replica_lag.max[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'The maximum amount of lag between the primary instance and each Aurora DB instance in the DB cluster.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "AuroraReplicaLagMaximum")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: replication
                - tag: engine
                  value: aurora
            - uuid: 39e226420be740bd81712624d4d86882
              name: 'Replication: Lag, min'
              type: DEPENDENT
              key: 'aws.rds.aurora_replica_lag.min[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'The minimum amount of lag between the primary instance and each Aurora DB instance in the DB cluster.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "AuroraReplicaLagMinimum")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: replication
                - tag: engine
                  value: aurora
            - uuid: 966022d4bc484918b9497d3515c35f9d
              name: 'Replication: Lag'
              type: DEPENDENT
              key: 'aws.rds.aurora_replica_lag[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'For an Aurora replica, the amount of lag when replicating updates from the primary instance.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "AuroraReplicaLag")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: replication
                - tag: engine
                  value: aurora
            - uuid: 4a76341c354540b48677c29a92270d57
              name: 'Buffer Cache hit ratio'
              type: DEPENDENT
              key: 'aws.rds.buffer_cache_hit_ratio[{#SINGLETON}]'
              value_type: FLOAT
              units: '%'
              description: 'The percentage of requests that are served by the buffer cache.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "BufferCacheHitRatio")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: cache
                - tag: engine
                  value: aurora
            - uuid: a988ecbcb5804916a37e2c4270cf1261
              name: 'Operations: Commit latency'
              type: DEPENDENT
              key: 'aws.rds.commit_latency[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'The amount of latency for commit operations.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "CommitLatency")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora
            - uuid: 0892af875af04dbebd3954b37a196605
              name: 'Operations: Commit throughput'
              type: DEPENDENT
              key: 'aws.rds.commit_throughput.rate[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The average number of commit operations per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "CommitThroughput")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora
            - uuid: febdffdd64974deb91185af1bbc78ffd
              name: 'Deadlocks, rate'
              type: DEPENDENT
              key: 'aws.rds.deadlocks.rate[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The average number of deadlocks in the database per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "Deadlocks")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora
            - uuid: 24d139d74b034e2096f50943fa003e4f
              name: 'Engine uptime'
              type: DEPENDENT
              key: 'aws.rds.engine_uptime[{#SINGLETON}]'
              value_type: FLOAT
              units: s
              description: 'The amount of time that the instance has been running.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "EngineUptime")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: instance
                - tag: engine
                  value: aurora
            - uuid: 65ee7a93945d4c7baf6c20137e62b9dc
              name: 'Rollback segment history list length'
              type: DEPENDENT
              key: 'aws.rds.rollback_segment_history_list_length[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The undo logs that record committed transactions with delete-marked records. These records are scheduled to be processed by the InnoDB purge operation.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "RollbackSegmentHistoryListLength")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: application
                - tag: engine
                  value: aurora-mysql
            - uuid: 2c1b3f9701f343e5845c78c52e71f72f
              name: 'Row lock time'
              type: DEPENDENT
              key: 'aws.rds.row_locktime[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'The total time spent acquiring row locks for InnoDB tables.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "RowLockTime")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: application
                - tag: engine
                  value: aurora-mysql
            - uuid: 05218f79a137466392af0652acfe2db5
              name: 'Operations: Select latency'
              type: DEPENDENT
              key: 'aws.rds.select_latency[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'The amount of latency for select queries.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "SelectLatency")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora-mysql
            - uuid: 849c0bd9b5d940568bc1e71eb6318738
              name: 'Operations: Select throughput'
              type: DEPENDENT
              key: 'aws.rds.select_throughput.rate[{#SINGLETON}]'
              value_type: FLOAT
              units: rps
              description: 'The average number of select queries per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "SelectThroughput")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora-mysql
            - uuid: 62e6fa21b2f54030bbbd04f268de5737
              name: 'Network: Throughput'
              type: DEPENDENT
              key: 'aws.rds.storage_network_throughput[{#SINGLETON}]'
              value_type: FLOAT
              units: Bps
              description: 'The amount of network throughput received from and sent to the Aurora storage subsystem by each instance in the Aurora MySQL DB cluster.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "StorageNetworkThroughput")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: network
                - tag: engine
                  value: aurora
          graph_prototypes:
            - uuid: 3a753d02e4b8465a9f4da698c2acd387
              name: 'AWS RDS: [{#SINGLETON}]Operations Latency (commit/select)'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.commit_latency[{#SINGLETON}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.select_latency[{#SINGLETON}]'
            - uuid: c856d61be8594efda8f87396c6ba31f9
              name: 'AWS RDS: [{#SINGLETON}]Operations Throughput (commit/select)'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.commit_throughput.rate[{#SINGLETON}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.select_throughput.rate[{#SINGLETON}]'
          master_item:
            key: aws.rds.engine
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return JSON.stringify(value.includes(''aurora'') ? [{ ''{#SINGLETON}'': '''' }] : []);'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
        - uuid: cb9080a3bf4c4c51936bb8d818f69adc
          name: 'Instance Events discovery'
          type: DEPENDENT
          key: aws.rds.events.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#EVENT_CATEGORY}'
                value: '{$AWS.RDS.LLD.FILTER.EVENT_CATEGORY.MATCHES}'
              - macro: '{#EVENT_CATEGORY}'
                value: '{$AWS.RDS.LLD.FILTER.EVENT_CATEGORY.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#EVENT_SOURCE_TYPE}'
                value: '{$AWS.RDS.LLD.FILTER.EVENT_SOURCE_TYPE.MATCHES}'
              - macro: '{#EVENT_SOURCE_TYPE}'
                value: '{$AWS.RDS.LLD.FILTER.EVENT_SOURCE_TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery instance events.'
          item_prototypes:
            - uuid: 21b9df85f2e841c48204c7cb4fb5caeb
              name: '[{#EVENT_CATEGORY}]: {#EVENT_SOURCE_TYPE}/{#EVENT_SOURCE_ID} : Date'
              type: DEPENDENT
              key: 'aws.rds.event_date["{#EVENT_CATEGORY}/{#EVENT_SOURCE_TYPE}/{#EVENT_SOURCE_ID}"]'
              value_type: FLOAT
              units: unixtime
              description: 'Provides the text of this event.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.SourceIdentifier == "{#EVENT_SOURCE_ID}" && @.SourceType == "{#EVENT_SOURCE_TYPE}" && @.EventCategories == "{#EVENT_CATEGORY}")].Date'
                  error_handler: DISCARD_VALUE
                - type: JSONPATH
                  parameters:
                    - '$[-1]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: aws.rds.get_events
              tags:
                - tag: component
                  value: events
                - tag: event-categories
                  value: '{#EVENT_CATEGORY}'
            - uuid: 10cf420329fa42c08266a5d38bc7678b
              name: '[{#EVENT_CATEGORY}]: {#EVENT_SOURCE_TYPE}/{#EVENT_SOURCE_ID}: Message'
              type: DEPENDENT
              key: 'aws.rds.event_message["{#EVENT_CATEGORY}/{#EVENT_SOURCE_TYPE}/{#EVENT_SOURCE_ID}"]'
              value_type: TEXT
              description: 'Provides the text of this event.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.SourceIdentifier == "{#EVENT_SOURCE_ID}" && @.SourceType == "{#EVENT_SOURCE_TYPE}" && @.EventCategories == "{#EVENT_CATEGORY}")].Message'
                  error_handler: DISCARD_VALUE
                - type: JSONPATH
                  parameters:
                    - '$[-1]'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: aws.rds.get_events
              tags:
                - tag: component
                  value: events
                - tag: event-categories
                  value: '{#EVENT_CATEGORY}'
          master_item:
            key: aws.rds.get_events
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var lookup = {},
                  	result = [];
                  
                  JSON.parse(value).forEach(function (event) {
                  	var filter = event.EventCategories + event.SourceIdentifier + event.SourceType;
                  	if (!(lookup[filter])) {
                  		lookup[filter] = 1;
                  		result.push({
                  			'{#EVENT_CATEGORY}': event.EventCategories,
                  			'{#EVENT_SOURCE_ID}': event.SourceIdentifier,
                  			'{#EVENT_SOURCE_TYPE}': event.SourceType
                  		});
                  	}
                  });
                  
                  return JSON.stringify(result);
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: ec07301eaaad4f32a3759692d96150ab
          name: 'Aurora MySQL metrics discovery'
          type: DEPENDENT
          key: aws.rds.postgresql.discovery
          description: |
            Discovery Aurora MySQL metrics.
            Storage types:
             aurora (for MySQL 5.6-compatible Aurora)
             aurora-mysql (for MySQL 5.7-compatible and MySQL 8.0-compatible Aurora)
          item_prototypes:
            - uuid: 3842a935bedf446d8b8b9a7fd58fc24b
              name: 'Connections: Aborted'
              type: DEPENDENT
              key: 'aws.rds.aurora_clients_aborted[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The number of client connections that have not been closed properly.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "AbortedClients")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: connections
                - tag: engine
                  value: aurora-mysql
            - uuid: 8b87e0f4f1fc4290a7c72ec382b74941
              name: 'Replication: Binlog lag'
              type: DEPENDENT
              key: 'aws.rds.aurora_replication_binlog_lag[{#SINGLETON}]'
              value_type: FLOAT
              units: s
              description: |
                The amount of time that a binary log replica DB cluster running on Aurora MySQL-Compatible Edition lags behind the binary log replication source. 
                A lag means that the source is generating records faster than the replica can apply them.
                The metric value indicates the following:
                
                A high value: The replica is lagging the replication source.
                0 or a value close to 0: The replica process is active and current.
                -1: Aurora can't determine the lag, which can happen during replica setup or when the replica is in an error state
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "AuroraBinlogReplicaLag")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: replication
                - tag: engine
                  value: aurora-mysql
            - uuid: 97f85bd65fc64b66b57b122f8689bc38
              name: 'Transactions: Active, rate'
              type: DEPENDENT
              key: 'aws.rds.aurora_transactions_active.rate[{#SINGLETON}]'
              value_type: FLOAT
              units: Rps
              description: |
                The average number of current transactions executing on an Aurora database instance per second.
                By default, Aurora doesn't enable this metric. To begin measuring this value, set innodb_monitor_enable='all' in the DB parameter group for a specific DB instance.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "ActiveTransactions")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: transactions
                - tag: engine
                  value: aurora-mysql
            - uuid: 44ca3ca16bd1450790099a0354e78f13
              name: 'Backtrack: Window, actual'
              type: DEPENDENT
              key: 'aws.rds.backtrack_window_actual[{#SINGLETON}]'
              value_type: FLOAT
              units: '!minutes'
              description: 'The difference between the target backtrack window and the actual backtrack window.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "BacktrackWindowActual")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: backtrack
                - tag: engine
                  value: aurora-mysql
            - uuid: 20de520b7f53459db765eb221fcef248
              name: 'Backtrack: Window, alert'
              type: DEPENDENT
              key: 'aws.rds.backtrack_window_alert[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The number of times that the actual backtrack window is smaller than the target backtrack window for a given period of time.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "BacktrackWindowAlert")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: backtrack
                - tag: engine
                  value: aurora-mysql
            - uuid: 570e88d397524dfeb10d6c46cc859404
              name: 'Transactions: Blocked, rate'
              type: DEPENDENT
              key: 'aws.rds.blocked_transactions.rate[{#SINGLETON}]'
              value_type: FLOAT
              units: Rps
              description: 'The average number of transactions in the database that are blocked per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "BlockedTransactions")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: transactions
                - tag: engine
                  value: aurora-mysql
            - uuid: 3033650e795943bfab73e9d7347f3d24
              name: 'DDL: Latency'
              type: DEPENDENT
              key: 'aws.rds.ddl_latency[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'The amount of latency for data definition language (DDL) requests - for example, create, alter, and drop requests.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "DDLLatency")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: requests
                - tag: engine
                  value: aurora-mysql
            - uuid: 1ee5fdb6ed004e708ebe5ec8b2d039ba
              name: 'DDL: Throughput'
              type: DEPENDENT
              key: 'aws.rds.ddl_throughput.rate[{#SINGLETON}]'
              value_type: FLOAT
              units: Rps
              description: 'The average number of DDL requests per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "DDLThroughput")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: requests
                - tag: engine
                  value: aurora-mysql
            - uuid: ab6a2d6f9c04497c86464f10aafa178c
              name: 'Operations: Delete latency'
              type: DEPENDENT
              key: 'aws.rds.delete_latency[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'The amount of latency for delete queries.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "DeleteLatency")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora-mysql
            - uuid: 9a28a1a0e1194d4fb55a5c2e926a7142
              name: 'Operations: Delete throughput'
              type: DEPENDENT
              key: 'aws.rds.delete_throughput.rate[{#SINGLETON}]'
              value_type: FLOAT
              units: Rps
              description: 'The average number of delete queries per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "DeleteThroughput")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora-mysql
            - uuid: 0ff7f102065a450cb77030c5f2e9cc76
              name: 'DML: Latency'
              type: DEPENDENT
              key: 'aws.rds.dml_latency[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'The amount of latency for inserts, updates, and deletes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "DMLLatency")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: requests
                - tag: engine
                  value: aurora-mysql
            - uuid: 97ce5f3d119c4381a99ead5effe6af44
              name: 'DML: Throughput'
              type: DEPENDENT
              key: 'aws.rds.dml_throughput.rate[{#SINGLETON}]'
              value_type: FLOAT
              units: rate
              description: 'The average number of inserts, updates, and deletes per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "DMLThroughput")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: requests
                - tag: engine
                  value: aurora-mysql
            - uuid: 182efdd016e9473eb4791e5343043b57
              name: 'Operations: Insert latency'
              type: DEPENDENT
              key: 'aws.rds.insert_latency[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'The amount of latency for insert queries, in milliseconds.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "InsertLatency")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora-mysql
            - uuid: db20ce55abbf4f248b8ac40a6f5576ec
              name: 'Operations: Insert throughput'
              type: DEPENDENT
              key: 'aws.rds.insert_throughput.rate[{#SINGLETON}]'
              value_type: FLOAT
              units: Rps
              description: 'The average number of insert queries per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "InsertThroughput")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora-mysql
            - uuid: c68d9d4496a84bf883330b1a82b62171
              name: 'Login failures, rate'
              type: DEPENDENT
              key: 'aws.rds.login_failures.rate[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The average number of failed login attempts per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "LoginFailures")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: application
                - tag: engine
                  value: aurora-mysql
            - uuid: c932d4f773c04499b045ddb4b767decb
              name: 'Binary log files, number'
              type: DEPENDENT
              key: 'aws.rds.num_binary_log_files[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The number of binlog files generated.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "NumBinaryLogFiles")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: replication
                - tag: engine
                  value: aurora
                - tag: engine
                  value: mysql
            - uuid: c7a191af58644441bfe9aa8579dd9190
              name: 'Queries, rate'
              type: DEPENDENT
              key: 'aws.rds.queries.rate[{#SINGLETON}]'
              value_type: FLOAT
              description: 'The average number of queries executed per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "Queries")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: queries
                - tag: engine
                  value: aurora-mysql
            - uuid: 886f68d6a1eb4953aef3fc4cf1296c62
              name: 'Resultset cache hit ratio'
              type: DEPENDENT
              key: 'aws.rds.result_set_cache_hit_ratio[{#SINGLETON}]'
              value_type: FLOAT
              units: '%'
              description: 'The percentage of requests that are served by the Resultset cache.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "ResultSetCacheHitRatio")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: cache
                - tag: engine
                  value: aurora-mysql
            - uuid: 3b66ac67006b4229b1d523dfe19fcb1f
              name: 'Binary log files, size'
              type: DEPENDENT
              key: 'aws.rds.sum_binary_log_files[{#SINGLETON}]'
              value_type: FLOAT
              units: B
              description: 'The total size of the binlog files.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "SumBinaryLogSize")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: replication
                - tag: engine
                  value: aurora
                - tag: engine
                  value: mysql
            - uuid: 44dcd553afe641d1b147426e614a7b41
              name: 'Operations: Update latency'
              type: DEPENDENT
              key: 'aws.rds.update_latency[{#SINGLETON}]'
              value_type: FLOAT
              units: ms
              description: 'The amount of latency for update queries.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "UpdateLatency")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora
                - tag: engine
                  value: mysql
            - uuid: 3a3548d63e1a4aab8853e13645f5898f
              name: 'Operations: Update throughput'
              type: DEPENDENT
              key: 'aws.rds.update_throughput.rate[{#SINGLETON}]'
              value_type: FLOAT
              units: Rps
              description: 'The average number of update queries per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.Label == "UpdateThroughput")].Values.first().first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: aws.rds.get_metrics
              tags:
                - tag: component
                  value: operations
                - tag: engine
                  value: aurora
                - tag: engine
                  value: mysql
          graph_prototypes:
            - uuid: 981fd77559f247908b58ffcf883ade78
              name: 'AWS RDS: [{#SINGLETON}]DML/DDL Latency'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.ddl_latency[{#SINGLETON}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.dml_latency[{#SINGLETON}]'
            - uuid: 7277bbc0b7c0427697348c8a182b954f
              name: 'AWS RDS: [{#SINGLETON}]DML/DDL Throughput'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.ddl_throughput.rate[{#SINGLETON}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.dml_throughput.rate[{#SINGLETON}]'
            - uuid: 13a9823d2a2444b7867859aacca47022
              name: 'AWS RDS: [{#SINGLETON}]Operations Latency (insert/delete/update)'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.insert_latency[{#SINGLETON}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.delete_latency[{#SINGLETON}]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.update_latency[{#SINGLETON}]'
            - uuid: 72117fc5b5434711ab15f07f117b22bd
              name: 'AWS RDS: [{#SINGLETON}]Operations Throughput(insert/delete/update)'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.insert_throughput.rate[{#SINGLETON}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.delete_throughput.rate[{#SINGLETON}]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'AWS RDS instance by HTTP'
                    key: 'aws.rds.update_throughput.rate[{#SINGLETON}]'
          master_item:
            key: aws.rds.engine
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - 'return JSON.stringify((value === ''aurora-mysql'' || value === ''aurora'') ? [{ ''{#SINGLETON}'': '''' }] : []);'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
      tags:
        - tag: class
          value: software
        - tag: target
          value: aws
        - tag: target
          value: rds
      macros:
        - macro: '{$AWS.ACCESS.KEY.ID}'
          description: 'Access key ID.'
        - macro: '{$AWS.AUTH_TYPE}'
          value: access_key
          description: 'Authorization method. Possible values: role_base, access_key.'
        - macro: '{$AWS.EBS.BYTE.CREDIT.BALANCE.MIN.WARN}'
          value: '20'
          description: 'Minimum percentage of Byte credits remaining for trigger expression.'
        - macro: '{$AWS.EBS.IO.CREDIT.BALANCE.MIN.WARN}'
          value: '20'
          description: 'Minimum percentage of I/O credits remaining for trigger expression.'
        - macro: '{$AWS.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty then no proxy is used.'
        - macro: '{$AWS.RDS.BURST.CREDIT.BALANCE.MIN.WARN}'
          value: '20'
          description: 'Minimum percentage of Byte credits remaining for trigger expression.'
        - macro: '{$AWS.RDS.CPU.CREDIT.BALANCE.MIN.WARN}'
          value: '50'
          description: 'Minimum number of free earned CPU credits for trigger expression.'
        - macro: '{$AWS.RDS.CPU.UTIL.WARN.MAX}'
          value: '85'
          description: 'The warning threshold of the CPU utilization expressed in %.'
        - macro: '{$AWS.RDS.INSTANCE.ID}'
          description: 'RDS DB Instance identifier.'
        - macro: '{$AWS.RDS.LLD.FILTER.ALARM_NAME.MATCHES}'
          value: '.*'
          description: 'Filter of discoverable alarms by name.'
        - macro: '{$AWS.RDS.LLD.FILTER.ALARM_NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discovered alarms by name.'
        - macro: '{$AWS.RDS.LLD.FILTER.ALARM_SERVICE_NAMESPACE.MATCHES}'
          value: '.*'
          description: 'Filter of discoverable alarms by namespace.'
        - macro: '{$AWS.RDS.LLD.FILTER.ALARM_SERVICE_NAMESPACE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discovered alarms by namespace.'
        - macro: '{$AWS.RDS.LLD.FILTER.EVENT_CATEGORY.MATCHES}'
          value: '.*'
          description: 'Filter of discoverable events by category.'
        - macro: '{$AWS.RDS.LLD.FILTER.EVENT_CATEGORY.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discovered events by category.'
        - macro: '{$AWS.RDS.LLD.FILTER.EVENT_SOURCE_TYPE.MATCHES}'
          value: '.*'
          description: 'Filter of discoverable events by source type.'
        - macro: '{$AWS.RDS.LLD.FILTER.EVENT_SOURCE_TYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discovered events by source type.'
        - macro: '{$AWS.REGION}'
          value: us-west-1
          description: 'Amazon RDS Region code.'
        - macro: '{$AWS.SECRET.ACCESS.KEY}'
          type: SECRET_TEXT
          description: 'Secret access key.'
      valuemaps:
        - uuid: 4ff4cda021a4464ebbebb42b7ee02673
          name: 'Alarm state'
          mappings:
            - value: '0'
              newvalue: OK
            - value: '1'
              newvalue: 'Insufficient data'
            - value: '2'
              newvalue: Alarm
            - value: '255'
              newvalue: Unknown
        - uuid: 69bbb2cfded14be6ac596408bdd4de37
          name: 'Read replica state'
          mappings:
            - value: '0'
              newvalue: Error
            - value: '1'
              newvalue: Normal
  graphs:
    - uuid: f2178fe21bc4454a9d3eee3b17ef11bc
      name: 'AWS RDS: Disk read/write IOPS'
      graph_items:
        - color: 199C0D
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.read_iops.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.write_iops.rate
    - uuid: e0fbc3a0256c41cf99acb307921f448f
      name: 'AWS RDS: Disk read/write latency'
      graph_items:
        - color: 199C0D
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.read_latency
        - sortorder: '1'
          color: F63100
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.write_latency
    - uuid: a479a587e0c5484293e939ff56060270
      name: 'AWS RDS: Disk read/write throughput'
      graph_items:
        - color: 199C0D
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.read_throughput.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.write_throughput.rate
    - uuid: 4f76da00f7ea417d9156a8ab21b2d61f
      name: 'AWS RDS: Local storage read/write IOPS'
      graph_items:
        - color: 199C0D
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.write_iops_local_storage.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.read_iops_local_storage.rate
    - uuid: a38ee12797874a57bd30307d1ba7b589
      name: 'AWS RDS: Local storage read/write latency'
      graph_items:
        - color: 199C0D
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.read_latency_local_storage
        - sortorder: '1'
          color: F63100
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.write_latency_local_storage
    - uuid: f2a25a07efea46d1836188bf9cdb12d2
      name: 'AWS RDS: Local storage read/write throughput'
      graph_items:
        - color: 199C0D
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.read_throughput_local_storage.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.write_throughput_local_storage.rate
    - uuid: 05c0cf7b37664e06a0fd74f62761fe5e
      name: 'AWS RDS: Network traffic'
      graph_items:
        - color: 199C0D
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.network_receive_throughput.rate
        - sortorder: '1'
          color: F63100
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.network_transmit_throughput.rate
        - sortorder: '2'
          color: 00611C
          item:
            host: 'AWS RDS instance by HTTP'
            key: aws.rds.network_throughput.rate
