zabbix_export:
  version: '8.0'
  template_groups:
    - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
      name: Templates/Applications
    - uuid: c2c162144c2d4c5491c8801193af4945
      name: Templates/Cloud
    - uuid: 36bff6c29af64692839d077febfc7079
      name: 'Templates/Network devices'
  host_groups:
    - uuid: 748ad4d098d447d492bb935c907f652f
      name: Databases
    - uuid: 137f19e6e2dc4219b33553b812627bc2
      name: 'Virtual machines'
  templates:
    - uuid: e56c9577c225476eb6d8f1c2f5dc90a5
      template: 'FortiGate by HTTP'
      name: 'FortiGate by HTTP'
      description: |
        The template for monitoring FortiGate Next Generation Firewall by HTTP.
        
        1. On the FortiGate GUI, select System > Admin Profiles > Create New.
        2. Enter a profile name (ex. zabbix_ro) and enable all the Read permissions. Please note the profile name, it will be used a bit later.
        3. Go to System > Administrators > Create New > REST API Admin.
        4. Enter the API-user's name and select the profile name you created in step 2.
        5. The trusted host can be specified to ensure that only Zabbix server can reach the FortiGate.
        6. Click OK and an API token will be generated. Make a note of the API token as it's only shown once and cannot be retrieved.
        7. Put the API token into {$FGATE.API.TOKEN} macro.
        8. Set your FortiGate GUI IP/FQDN as {$FGATE.API.FQDN} macro value.
        9. If FortiGate GUI uses HTTPS, put "https" value into {$FGATE.SCHEME} macro and "443" into {$FGATE.API.PORT} macro.
        10. If FortiGate GUI port differs from the standard one, specify it in {$FGATE.API.PORT} macro.
        
        NOTE: Starting from template version '8.0-2', the API token is used in the request header. For older template versions (where the API token is passed in the URL query parameter), when using FortiGate v7.4.5+, you must enable the following global setting:
        https://docs.fortinet.com/document/fortigate/7.6.4/administration-guide/940602/using-apis
        
        For added security, it is strongly recommended to use the latest template version, which passes the API token in the request header instead of the URL parameter.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        1. On the FortiGate GUI, select `System > Admin Profiles > Create New`.
        2. Enter a profile name (ex. zabbix_ro) and enable all the Read permissions. Please note the profile name, it will be used a bit later.
        3. Go to `System > Administrators > Create New > REST API Admin`.
        4. Enter the API-user's name and select the profile name you created in step 2.
        5. The trusted host can be specified to ensure that only Zabbix server can reach the FortiGate.
        6. Click OK and an API token will be generated. Make a note of the API token as it's only shown once and cannot be retrieved.
        7. Put the API token into `Token` host wizard configuration field.
        8. Set your FortiGate GUI IP/FQDN as `Address` host wizard configuration field value.
        9. If FortiGate GUI uses HTTPS, put **https** value into `Scheme` and **443** into `Port` host wizard configuration fields.
        10. If FortiGate GUI port differs from the standard one, specify it in `Port` host wizard configuration field.
        
        **NOTE**: Starting from template version '8.0-2', the API token is used in the request header. For older template versions (where the API token is passed in the URL query parameter), when using FortiGate v7.4.5+, you must enable the following global setting:
        [Using APIs](https://docs.fortinet.com/document/fortigate/7.6.4/administration-guide/940602/using-apis)
        
        For added security, it is strongly recommended to use the latest template version, which passes the API token in the request header instead of the URL parameter.
        
        Please, refer to the [vendor documentation](https://docs.fortinet.com/document/fortigate/7.6.4/administration-guide/399023/rest-api-administrator) about the FortiGate REST API Authentication.
      vendor:
        name: Zabbix
        version: 8.0-2
      groups:
        - name: 'Templates/Network devices'
      items:
        - uuid: e74af8e347814085a7d01142c9aae447
          name: 'API availability status'
          type: DEPENDENT
          key: fgate.api.status
          description: 'Checking API availability by response.'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.build
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
            - type: IN_RANGE
              parameters:
                - ''
                - '0'
              error_handler: CUSTOM_VALUE
              error_handler_params: '1'
          master_item:
            key: fgate.system.get_data
          tags:
            - tag: component
              value: health
            - tag: component
              value: network
          triggers:
            - uuid: 8b8c03f1497f4f18a417d103267d2947
              expression: 'last(/FortiGate by HTTP/fgate.api.status)=0'
              name: 'FortiGate: Unexpected response from API'
              priority: AVERAGE
              description: 'Received an unexpected response from API. It may be unavailable.'
              dependencies:
                - name: 'FortiGate: Port {$FGATE.API.PORT} is unavailable'
                  expression: 'last(/FortiGate by HTTP/net.tcp.service["{$FGATE.SCHEME}","{$FGATE.API.FQDN}","{$FGATE.API.PORT}"])=0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 3a54a2ef2ad94f0d8df190356ca0ac9b
          name: 'Number of CPUs'
          type: DEPENDENT
          key: fgate.cpu.num
          description: 'Number of processors according to the current license.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data.vm.cpu_used
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: fgate.service.get_data
          tags:
            - tag: component
              value: cpu
        - uuid: 4c83427d66764255be934ea7e2c6084a
          name: 'CPU utilization'
          type: DEPENDENT
          key: fgate.cpu.util
          value_type: FLOAT
          units: '%'
          description: 'CPU utilization, expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data.cpu
          master_item:
            key: fgate.resources.get_data
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 4698d35fa5e242ef828ac4e3dba5bc09
              expression: 'min(/FortiGate by HTTP/fgate.cpu.util,5m)>{$CPU.UTIL.WARN}'
              name: 'FortiGate: CPU utilization is high'
              event_name: 'FortiGate: High CPU utilization (over {$CPU.UTIL.WARN}% for 5m)'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The CPU utilization is high.'
              dependencies:
                - name: 'FortiGate: CPU utilization is too high'
                  expression: 'min(/FortiGate by HTTP/fgate.cpu.util,5m)>{$CPU.UTIL.CRIT}'
              tags:
                - tag: scope
                  value: performance
            - uuid: 170087cd8ebf4fc29093e5c1dbd86fea
              expression: 'min(/FortiGate by HTTP/fgate.cpu.util,5m)>{$CPU.UTIL.CRIT}'
              name: 'FortiGate: CPU utilization is too high'
              event_name: 'FortiGate: High CPU utilization (over {$CPU.UTIL.CRIT}% for 5m)'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: c29e3336f92f448587e7492c55db8e7c
          name: 'Device firmware version'
          type: DEPENDENT
          key: fgate.device.firmware
          value_type: CHAR
          description: 'Current version of the device firmware.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.results.current
            - type: JAVASCRIPT
              parameters:
                - |
                  var firmware = JSON.parse(value);
                  return firmware.name + ' ' + firmware.version + ' build' + String(firmware.build);
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: fgate.firmware.get_data
          tags:
            - tag: component
              value: system
        - uuid: 75084a08e92042e5869b57e34506849d
          name: 'Available firmware versions'
          type: DEPENDENT
          key: fgate.device.firmwares_avail
          description: 'Number of available firmware versions to download.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.results.available.length()
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: fgate.firmware.get_data
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: da4a8352ffb94c15a62523a0b97460c4
              expression: '{$FIRMWARE.UPDATES.CONTROL}=1 and last(/FortiGate by HTTP/fgate.device.firmwares_avail)>0'
              name: 'FortiGate: New available firmware found'
              priority: INFO
              description: |
                New available firmware versions found to download.
                
                This trigger expression works as follows:
                1. It can be triggered if there are one or more available firmware versions.
                2. `{$FIRMWARE.UPDATES.CONTROL}=1` - a user can redefine context macro to value - 0. That marks this notification as not important. No new trigger will be fired if new firmware is found.
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: d42b5e392a6a468a84b009ff02f77b18
          name: 'Device model name'
          type: DEPENDENT
          key: fgate.device.model
          value_type: CHAR
          description: 'The model name of the device.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.results
            - type: JAVASCRIPT
              parameters:
                - |
                  var info = JSON.parse(value);
                  return info.model_name + ' ' + info.model_number + ' (' + info.model + ')';
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: fgate.system.get_data
          tags:
            - tag: component
              value: system
        - uuid: 80bafe55b05f416ebcdde86b58bda1f4
          name: 'Device serial number'
          type: DEPENDENT
          key: fgate.device.serialnumber
          value_type: CHAR
          description: 'The device serial number.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.serial
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: fgate.system.get_data
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: 1426177b905e442fb2cdd963e8e8bba1
              expression: |
                last(/FortiGate by HTTP/fgate.device.serialnumber,#1)<>last(/FortiGate by HTTP/fgate.device.serialnumber,#2) and
                length(last(/FortiGate by HTTP/fgate.device.serialnumber))>0
              name: 'FortiGate: Device has been replaced'
              event_name: 'FortiGate: Device has been replaced (new serial number received)'
              priority: INFO
              description: 'Device serial number has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 07d3dd60460340929288fd21211aa2e0
          name: 'Current VDOM'
          type: DEPENDENT
          key: fgate.device.vdom
          value_type: CHAR
          description: 'Name of the current Virtual Domain.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.vdom
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: fgate.system.get_data
          tags:
            - tag: component
              value: system
        - uuid: a6729f9b5da54e67951963a869fab31c
          name: 'Device firmware info item errors'
          type: DEPENDENT
          key: fgate.firmware.data_errors
          value_type: TEXT
          description: 'Item for gathering errors of the device firmware info.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: fgate.firmware.get_data
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: c4ab39fa9c104eaa8f9c5da529e416d8
              expression: 'length(last(/FortiGate by HTTP/fgate.firmware.data_errors))>0 and length(last(/FortiGate by HTTP/fgate.firmware.data_errors,#1:now-1m))>0 and nodata(/FortiGate by HTTP/fgate.firmware.data_errors,2m)=0'
              name: 'FortiGate: There are errors in the ''Get firmware info'' metric'
              priority: WARNING
              dependencies:
                - name: 'FortiGate: Unexpected response from API'
                  expression: 'last(/FortiGate by HTTP/fgate.api.status)=0'
              tags:
                - tag: scope
                  value: availability
        - uuid: bc2ac899ea284703a6a8753ac5abc7c6
          name: 'Get firmware info'
          type: HTTP_AGENT
          key: fgate.firmware.get_data
          history: '0'
          value_type: TEXT
          description: 'Item for gathering device firmware info from FortiGate API.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
              error_handler: CUSTOM_VALUE
              error_handler_params: '{"error":"Not supported value received"}'
          timeout: '{$FGATE.DATA.TIMEOUT}'
          url: '{$FGATE.SCHEME}://{$FGATE.API.FQDN}:{$FGATE.API.PORT}/api/v2/monitor/system/firmware'
          http_proxy: '{$FGATE.HTTP.PROXY}'
          headers:
            - name: Accept
              value: application/json
            - name: Authorization
              value: 'Bearer {$FGATE.API.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 3d93f75ee3084a5487814c2175028229
          name: 'Free disk space'
          type: DEPENDENT
          key: fgate.fs.free
          units: B
          description: 'The free space of the current disk, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data.disk_free
          master_item:
            key: fgate.resources.get_data
          tags:
            - tag: component
              value: storage
        - uuid: 3e595bf084f342ecaf94af97c2751c26
          name: 'Total disk space'
          type: DEPENDENT
          key: fgate.fs.total
          units: B
          description: 'The total space of the current disk, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data.disk_total
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: fgate.resources.get_data
          tags:
            - tag: component
              value: storage
        - uuid: 6ddf5a6fc9cd4b7ca6522f8e86a7aac8
          name: 'Used disk space'
          type: DEPENDENT
          key: fgate.fs.used
          units: B
          description: 'The used space of the current disk, in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data.disk_used
          master_item:
            key: fgate.resources.get_data
          tags:
            - tag: component
              value: storage
        - uuid: 847069b5ceaa417cbd84b1b0d5184771
          name: 'Disk utilization'
          type: DEPENDENT
          key: fgate.fs.util
          value_type: FLOAT
          units: '%'
          description: 'Disk utilization, expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data.disk
          master_item:
            key: fgate.resources.get_data
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 649a5e3ba39e4e799835cdba8bba8d34
              expression: '(100-last(/FortiGate by HTTP/fgate.fs.util))<{$DISK.FREE.WARN}'
              name: 'FortiGate: Free disk space is low'
              event_name: 'FortiGate: Free disk space is less than {$DISK.FREE.WARN}%'
              priority: WARNING
              description: 'Left disk space is not enough.'
              dependencies:
                - name: 'FortiGate: Free disk space is too low'
                  expression: '(100-last(/FortiGate by HTTP/fgate.fs.util))<{$DISK.FREE.CRIT}'
              tags:
                - tag: scope
                  value: capacity
                - tag: scope
                  value: performance
            - uuid: 33c78beb669142baa66befba2456d810
              expression: '(100-last(/FortiGate by HTTP/fgate.fs.util))<{$DISK.FREE.CRIT}'
              name: 'FortiGate: Free disk space is too low'
              event_name: 'FortiGate: Free disk space is less than {$DISK.FREE.CRIT}%'
              priority: HIGH
              description: 'Left disk space is too low.'
              tags:
                - tag: scope
                  value: capacity
                - tag: scope
                  value: performance
        - uuid: 26441b122d1148b6ba1045fcdfd092ad
          name: 'Firewall data item errors'
          type: DEPENDENT
          key: fgate.fwp.data_errors
          value_type: TEXT
          description: 'Item for gathering errors of firewall policies.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: fgate.fwp.get_data
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: a6f52f84c66c4d9b9831be03afc725b5
              expression: 'length(last(/FortiGate by HTTP/fgate.fwp.data_errors))>0 and length(last(/FortiGate by HTTP/fgate.fwp.data_errors,#1:now-1m))>0 and nodata(/FortiGate by HTTP/fgate.fwp.data_errors,2m)=0'
              name: 'FortiGate: There are errors in the ''Get firewall policies data'' metric'
              priority: WARNING
              dependencies:
                - name: 'FortiGate: Unexpected response from API'
                  expression: 'last(/FortiGate by HTTP/fgate.api.status)=0'
              tags:
                - tag: scope
                  value: availability
        - uuid: a7f8a7da176040ab8a43618e14944e42
          name: 'Get firewall data'
          type: SCRIPT
          key: fgate.fwp.get_data
          history: '0'
          value_type: TEXT
          params: |
            var params = JSON.parse(value),
            	request = new HttpRequest(),
            	result = { "data": {}, "error": "" },
            	api_url = "",
            	policies = {},
            	error_msg = "";
            
            function getHttpData(url) {
            	request.addHeader('Accept: application/json');
            	request.addHeader('Authorization: Bearer ' + params.token);
            	response = request.get(url);
            	Zabbix.log(4, '[ FortiGate ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (request.getStatus() !== 200) {
            		throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            	}
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from FortiGate API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object.';
            	}
            
            	if ((typeof response.status !== 'undefined' && response.status != 'success') || typeof response.results === 'undefined') {
            		var uri = '/' + response.path + '/' + response.name + ((typeof response.action !== 'undefined') ? '?action=' + response.action : "");
            		throw 'Failed to parse response received from ' + uri + '. Check debug log for more information.';
            	}
            
            	return response;
            };
            
            try {
            	['scheme', 'api.token', 'api.fqdn', 'api.port'].forEach(function (field) {
            		var macro = '{$FGATE.' + field.toUpperCase() + '}';
            		var key = field.split('.').pop();
            		if (params[key] === macro || params[key] === '') {
            			throw 'Please change ' + macro + ' macro to the proper value.';
            		}
            		if (typeof params[key] === 'undefined') {
            			throw 'Please set "' + key + '" script input parameter to ' + macro + ' macro value.';
            		}
            	});
            
            	if (typeof params.http_proxy !== 'undefined' && params.http_proxy !== '{' + '$FGATE.HTTP.PROXY}' && params.http_proxy !== '') {
            		request.setProxy(params.http_proxy);
            	}
            
            	api_url = params.scheme + '://' + params.fqdn + ':' + params.port;
            
            	var firewall_data = getHttpData(
            		api_url + '/api/v2/monitor/firewall/policy'
            	);
            
            	var firewall_list = getHttpData(
            		api_url + '/api/v2/cmdb/firewall/policy'
            	);
            
            	firewall_list.results.forEach(function (v) {
            		var item = {};
            		['q_origin_key', 'status', 'name', 'uuid', 'action', 'ip-version-type', 'label'].forEach(function (k) {
            			item[k] = v[k];
            		});
            		policies[v.policyid] = item;
            	});
            
            	result.data = firewall_data.results.map(function (v) {
            		if (typeof v.policyid !== 'undefined' && typeof policies[String(v.policyid)] !== 'undefined') {
            			Object.assign(v, policies[String(v.policyid)]);
            		}
            		return v;
            	}).filter(function (v) {
            		if (typeof v.name !== 'undefined') {
            			return v;
            		}
            	});
            } catch (error) {
            	error_msg = error.toString();
            	error_msg += error_msg.endsWith('.') ? '' : '.';
            	Zabbix.log(3, '[ FortiGate ] ERROR: ' + error_msg);
            };
            
            result.error = error_msg;
            
            return JSON.stringify(result);
          description: 'Item for gathering firewall policies info from FortiGate API.'
          timeout: '{$FGATE.DATA.TIMEOUT}'
          parameters:
            - name: fqdn
              value: '{$FGATE.API.FQDN}'
            - name: http_proxy
              value: '{$FGATE.HTTP.PROXY}'
            - name: port
              value: '{$FGATE.API.PORT}'
            - name: scheme
              value: '{$FGATE.SCHEME}'
            - name: token
              value: '{$FGATE.API.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 529076e8494e40f7b823f981e7159fd0
          name: 'Total memory'
          type: DEPENDENT
          key: fgate.memory.total
          units: B
          description: 'Total memory, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data.vm.mem_used
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: fgate.service.get_data
          tags:
            - tag: component
              value: memory
        - uuid: 51f4b31cc3d045a983843d9a8e534668
          name: 'Memory utilization'
          type: DEPENDENT
          key: fgate.memory.util
          value_type: FLOAT
          units: '%'
          description: 'Memory utilization, expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data.mem
          master_item:
            key: fgate.resources.get_data
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 0f0b467715bb420a80cae7a7df50177d
              expression: 'min(/FortiGate by HTTP/fgate.memory.util,5m)>{$MEMORY.UTIL.WARN}'
              name: 'FortiGate: Memory utilization is high'
              event_name: 'FortiGate: High memory utilization (>{$MEMORY.UTIL.WARN}% for 5m)'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The system is running out of free memory.'
              dependencies:
                - name: 'FortiGate: Memory utilization is too high'
                  expression: 'min(/FortiGate by HTTP/fgate.memory.util,5m)>{$MEMORY.UTIL.CRIT}'
              tags:
                - tag: scope
                  value: capacity
                - tag: scope
                  value: performance
            - uuid: 4cd6cb4e21154f8489de2ba73f32e62d
              expression: 'min(/FortiGate by HTTP/fgate.memory.util,5m)>{$MEMORY.UTIL.CRIT}'
              name: 'FortiGate: Memory utilization is too high'
              event_name: 'FortiGate: High memory utilization (>{$MEMORY.UTIL.CRIT}% for 5m)'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'Free memory size is too low.'
              tags:
                - tag: scope
                  value: capacity
                - tag: scope
                  value: performance
        - uuid: 562ec5b9dc7f49bb8ee404f05b1c54b7
          name: 'System name'
          type: DEPENDENT
          key: fgate.name
          value_type: CHAR
          description: 'The system host name.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.results.hostname
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 12h
          master_item:
            key: fgate.system.get_data
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: a522d2cdd55947fabf1c152f6f6dd374
              expression: 'last(/FortiGate by HTTP/fgate.name,#1)<>last(/FortiGate by HTTP/fgate.name,#2) and length(last(/FortiGate by HTTP/fgate.name))>0'
              name: 'FortiGate: System name has changed'
              event_name: 'FortiGate: System name has changed (new name: {ITEM.VALUE})'
              priority: INFO
              description: 'The name of the system has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
                - tag: scope
                  value: security
        - uuid: c1dbb528c4324b6daa59c4393c3fd178
          name: 'Device interfaces item errors'
          type: DEPENDENT
          key: fgate.netif.data_errors
          value_type: TEXT
          description: 'Item for gathering errors of network interfaces.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: fgate.netif.get_data
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: 20b8b33c1a36452ca280da95b8247409
              expression: 'length(last(/FortiGate by HTTP/fgate.netif.data_errors))>0 and length(last(/FortiGate by HTTP/fgate.netif.data_errors,#1:now-1m))>0 and nodata(/FortiGate by HTTP/fgate.netif.data_errors,2m)=0'
              name: 'FortiGate: There are errors in the ''Get interfaces data'' metric'
              priority: WARNING
              dependencies:
                - name: 'FortiGate: Unexpected response from API'
                  expression: 'last(/FortiGate by HTTP/fgate.api.status)=0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 3bf84b70672d4fbca282ce1bf970581d
          name: 'Get interfaces data'
          type: SCRIPT
          key: fgate.netif.get_data
          history: '0'
          value_type: TEXT
          params: |
            var params = JSON.parse(value),
            	request = new HttpRequest(),
            	result = {"data": {}, "error": ""},
            	api_url = "",
            	interfaces = {},
            	error_msg = "";
            
            function getHttpData(url) {
            	request.addHeader('Accept: application/json');
            	request.addHeader('Authorization: Bearer ' + params.token);
            	response = request.get(url);
            	Zabbix.log(4, '[ FortiGate ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (request.getStatus() !== 200) {
            		throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            	}
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from FortiGate API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object.';
            	}
            
            	if ((typeof response.status !== 'undefined' && response.status != 'success') || typeof response.results === 'undefined') {
            		var uri = '/' + response.path + '/' + response.name + ((typeof response.action !== 'undefined') ? '?action=' + response.action : "");
            		throw 'Failed to parse response received from ' + uri + '. Check debug log for more information.';
            	}
            
            	return response;
            };
            
            try {
            	['scheme', 'api.token', 'api.fqdn', 'api.port'].forEach(function (field) {
            		var macro = '{$FGATE.' + field.toUpperCase() + '}';
            		var key = field.split('.').pop();
            		if (params[key] === macro || params[key] === '') {
            			throw 'Please change ' + macro + ' macro to the proper value.';
            		}
            		if (typeof params[key] === 'undefined') {
            			throw 'Please set "' + key + '" script input parameter to ' + macro + ' macro value.';
            		}
            	});
            
            	if (typeof params.http_proxy !== 'undefined' && params.http_proxy !== '{' + '$FGATE.HTTP.PROXY}' && params.http_proxy !== '') {
            		request.setProxy(params.http_proxy);
            	}
            
            	api_url = params.scheme + '://' + params.fqdn + ':' + params.port;
            
            	var netif_data = getHttpData(
            		api_url + '/api/v2/monitor/system/interface'
            	);
            
            	var netif_list = getHttpData(
            		api_url + '/api/v2/cmdb/system/interface'
            	);
            
            	result.data = netif_list.results.map(function (v) {
            		var item = {};
            		['q_origin_key', 'name', 'mode', 'type', 'description'].forEach(function (k) {
            			item[k] = v[k];
            		});
            		if (typeof item.q_origin_key !== 'undefined' && typeof netif_data.results[String(item.q_origin_key)] !== 'undefined') {
            			Object.assign(item, netif_data.results[String(item.q_origin_key)]);
            		}
            		if (typeof item.alias !== 'undefined') {
            			item.alias = item.alias.slice(1,-1);
            		}
            		else {
            			item.alias = '';
            		}
            		if (typeof item.link === 'undefined') {
            			item.link = false;
            		}
            		if (typeof item.id === 'undefined') {
            			item.id = item.q_origin_key;
            		}
            		return item;
            	});
            } catch (error) {
            	error_msg = error.toString();
            	error_msg += error_msg.endsWith('.') ? '' : '.';
            	Zabbix.log(3, '[ FortiGate ] ERROR: ' + error_msg);
            };
            
            result.error = error_msg;
            
            return JSON.stringify(result);
          description: 'Item for gathering network interfaces info from FortiGate API.'
          timeout: '{$FGATE.DATA.TIMEOUT}'
          parameters:
            - name: fqdn
              value: '{$FGATE.API.FQDN}'
            - name: http_proxy
              value: '{$FGATE.HTTP.PROXY}'
            - name: port
              value: '{$FGATE.API.PORT}'
            - name: scheme
              value: '{$FGATE.SCHEME}'
            - name: token
              value: '{$FGATE.API.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 1f612317d885472ea8b25ecb99a8debf
          name: 'Device resources item errors'
          type: DEPENDENT
          key: fgate.resources.data_errors
          value_type: TEXT
          description: 'Item for gathering errors of the device resources.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: fgate.resources.get_data
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: e6ed25293ca64de1ae01e2ab6c92f5c7
              expression: 'length(last(/FortiGate by HTTP/fgate.resources.data_errors))>0 and length(last(/FortiGate by HTTP/fgate.resources.data_errors,#1:now-1m))>0 and nodata(/FortiGate by HTTP/fgate.resources.data_errors,2m)=0'
              name: 'FortiGate: There are errors in the ''Get resources data'' metric'
              priority: WARNING
              dependencies:
                - name: 'FortiGate: Unexpected response from API'
                  expression: 'last(/FortiGate by HTTP/fgate.api.status)=0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 06199d6a96f2414b976d357cd2c95cb6
          name: 'Get resources data'
          type: SCRIPT
          key: fgate.resources.get_data
          history: '0'
          value_type: TEXT
          params: |
            var params = JSON.parse(value),
            	request = new HttpRequest(),
            	result = {"data": {}, "error": ""},
            	api_url = "",
            	error_msg = "";
            
            function getHttpData(url) {
            	request.addHeader('Accept: application/json');
            	request.addHeader('Authorization: Bearer ' + params.token);
            	response = request.get(url);
            	Zabbix.log(4, '[ FortiGate ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (request.getStatus() !== 200) {
            		throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            	}
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from FortiGate API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object.';
            	}
            
            	if ((typeof response.status !== 'undefined' && response.status != 'success') || typeof response.results === 'undefined') {
            		var uri = '/' + response.path + '/' + response.name + ((typeof response.action !== 'undefined') ? '?action=' + response.action : "");
            		throw 'Failed to parse response received from ' + uri + '. Check debug log for more information.';
            	}
            
            	return response;
            };
            
            try {
            	['scheme', 'api.token', 'api.fqdn', 'api.port'].forEach(function (field) {
            		var macro = '{$FGATE.' + field.toUpperCase() + '}';
            		var key = field.split('.').pop();
            		if (params[key] === macro || params[key] === '') {
            			throw 'Please change ' + macro + ' macro to the proper value.';
            		}
            		if (typeof params[key] === 'undefined') {
            			throw 'Please set "' + key + '" script input parameter to ' + macro + ' macro value.';
            		}
            	});
            
            	if (typeof params.http_proxy !== 'undefined' && params.http_proxy !== '{' + '$FGATE.HTTP.PROXY}' && params.http_proxy !== '') {
            		request.setProxy(params.http_proxy);
            	}
            
            	api_url = params.scheme + '://' + params.fqdn + ':' + params.port;
            
            	var resource_list = getHttpData(
            		api_url + '/api/v2/monitor/system/resource/usage?interval=1-min'
            	);
            
            	var disk_info = getHttpData(
            		api_url + '/api/v2/monitor/log/current-disk-usage'
            	);
            
            	if (typeof resource_list.results !== 'undefined' && typeof resource_list.results === 'object') {
            		Object.keys(resource_list.results).forEach(function (key) {
            			var resource = resource_list.results[key];
            			if (resource.length > 0) {
            				result.data[key] = resource[0].current;
            			}
            		});
            	}
            	else {
            		throw 'Failed to parse response received from FortiGate API. Check debug log for more information.';
            	}
            
            	Object.keys(disk_info.results).forEach(function (key) {
            		result.data['disk_' + key.split('_')[0]] = disk_info.results[key];
            	});
            } catch (error) {
            	error_msg = error.toString();
            	error_msg += error_msg.endsWith('.') ? '' : '.';
            	Zabbix.log(3, '[ FortiGate ] ERROR: ' + error_msg);
            };
            
            result.error = error_msg;
            
            return JSON.stringify(result);
          description: 'Item for gathering device resource data from FortiGate API.'
          timeout: '{$FGATE.DATA.TIMEOUT}'
          parameters:
            - name: fqdn
              value: '{$FGATE.API.FQDN}'
            - name: http_proxy
              value: '{$FGATE.HTTP.PROXY}'
            - name: port
              value: '{$FGATE.API.PORT}'
            - name: scheme
              value: '{$FGATE.SCHEME}'
            - name: token
              value: '{$FGATE.API.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 1f2885ffb1524d909292aa9e5d1d8c89
          name: 'Get SD-WAN item errors'
          type: DEPENDENT
          key: fgate.sdwan.data_errors
          value_type: TEXT
          description: 'Item for gathering errors of SD-WAN.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: fgate.sdwan.get_data
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: b2ec3a4cf468449388a33f76688dc259
              expression: 'length(last(/FortiGate by HTTP/fgate.sdwan.data_errors))>0 and length(last(/FortiGate by HTTP/fgate.sdwan.data_errors,#1:now-1m))>0 and nodata(/FortiGate by HTTP/fgate.sdwan.data_errors,2m)=0'
              name: 'FortiGate: There are errors in the ''Get SD-WAN data'' metric'
              priority: WARNING
              dependencies:
                - name: 'FortiGate: Unexpected response from API'
                  expression: 'last(/FortiGate by HTTP/fgate.api.status)=0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 01814568a3bc4774a37957ff3d8c5e09
          name: 'Get SD-WAN data'
          type: SCRIPT
          key: fgate.sdwan.get_data
          history: '0'
          value_type: TEXT
          params: |
            var params = JSON.parse(value),
            	request = new HttpRequest(),
            	result = {"data": {}, "error": ""},
            	api_url = "",
            	health_members = [],
            	health_checks = [],
            	members = {},
            	error_msg = "";
            
            function getHttpData(url) {
            	request.addHeader('Accept: application/json');
            	request.addHeader('Authorization: Bearer ' + params.token);
            	response = request.get(url);
            	Zabbix.log(4, '[ FortiGate ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (request.getStatus() !== 200) {
            		throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            	}
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from FortiGate API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object.';
            	}
            
            	if ((typeof response.status !== 'undefined' && response.status != 'success') || typeof response.results === 'undefined') {
            		var uri = '/' + response.path + '/' + response.name + ((typeof response.action !== 'undefined') ? '?action=' + response.action : "");
            		throw 'Failed to parse response received from ' + uri + '. Check debug log for more information.';
            	}
            
            	return response;
            };
            
            try {
            	['scheme', 'api.token', 'api.fqdn', 'api.port'].forEach(function (field) {
            		var macro = '{$FGATE.' + field.toUpperCase() + '}';
            		var key = field.split('.').pop();
            		if (params[key] === macro || params[key] === '') {
            			throw 'Please change ' + macro + ' macro to the proper value.';
            		}
            		if (typeof params[key] === 'undefined') {
            			throw 'Please set "' + key + '" script input parameter to ' + macro + ' macro value.';
            		}
            	});
            
            	if (typeof params.http_proxy !== 'undefined' && params.http_proxy !== '{' + '$FGATE.HTTP.PROXY}' && params.http_proxy !== '') {
            		request.setProxy(params.http_proxy);
            	}
            
            	api_url = params.scheme + '://' + params.fqdn + ':' + params.port;
            
            	var sdwan_member_data = getHttpData(
            		api_url + '/api/v2/monitor/virtual-wan/members'
            	);
            
            	var sdwan_health_data = getHttpData(
            		api_url + '/api/v2/monitor/virtual-wan/health-check'
            	);
            
            	var sdwan_list = getHttpData(
            		api_url + '/api/v2/cmdb/system/sdwan'
            	);
            
            	sdwan_list.results['health-check'].forEach(function (item) {
            		health_checks[item.q_origin_key] = item.members.length;
            		item.members.forEach(function (m) {
            			health_members.push({
            				'member_id': m.q_origin_key,
            				'health_id': item.q_origin_key,
            				'health_name': item.name,
            			});
            		});
            	});
            
            	sdwan_list.results.members.forEach(function (item) {
            		members[item.q_origin_key] = item;
            	});
            
            	result.data = {
            		'member_lld': sdwan_list.results.members.filter(function (v) {
            			if (v.interface.length > 0) {
            				return v;
            			}
            		}).map(function (v) {
            			if (typeof v.interface !== 'undefined' && typeof sdwan_member_data.results[v.interface] !== 'undefined') {
            				Object.assign(v, sdwan_member_data.results[v.interface]);
            			}
            			return v;
            		}),
            		'health_lld': health_members.map(function (m) {
            			var item = {};
            			if (typeof members[String(m.member_id)] !== 'undefined') {
            				['interface', 'status'].forEach(function (k) {
            					item[k] = members[String(m.member_id)][k];
            				});
            				Object.assign(item, m);
            			};
            			return item;
            		}).filter(function (v) {
            			if (v.interface.length > 0) {
            				return v;
            			}
            		}),
            		'health_data': sdwan_list.results['health-check'].filter(function (v) {
            			if (typeof health_checks[String(v.q_origin_key)] !== 'undefined' && health_checks[String(v.q_origin_key)] > 0) {
            				return v;
            			}
            		}).map(function (v) {
            			delete v.members;
            			if (typeof v.name !== 'undefined' && typeof sdwan_health_data.results[v.name] !== 'undefined') {
            				Object.assign(v, sdwan_health_data.results[v.name]);
            			}
            			return v;
            		})
            	}
            } catch (error) {
            	error_msg = error.toString();
            	error_msg += error_msg.endsWith('.') ? '' : '.';
            	Zabbix.log(3, '[ FortiGate ] ERROR: ' + error_msg);
            };
            
            result.error = error_msg;
            
            return JSON.stringify(result);
          description: 'Item for gathering SD-WAN information from FortiGate API.'
          timeout: '{$FGATE.DATA.TIMEOUT}'
          parameters:
            - name: fqdn
              value: '{$FGATE.API.FQDN}'
            - name: http_proxy
              value: '{$FGATE.HTTP.PROXY}'
            - name: port
              value: '{$FGATE.API.PORT}'
            - name: scheme
              value: '{$FGATE.SCHEME}'
            - name: token
              value: '{$FGATE.API.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 547c3bfa4a2d4b8e8ebfad01b200c4fd
          name: 'Service licenses item errors'
          type: DEPENDENT
          key: fgate.service.data_errors
          value_type: TEXT
          description: 'Item for gathering errors of the service licenses data.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: fgate.service.get_data
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: eeb819b2813f488ea3792a029f25a08d
              expression: 'length(last(/FortiGate by HTTP/fgate.service.data_errors))>0 and length(last(/FortiGate by HTTP/fgate.service.data_errors,#1:now-1m))>0 and nodata(/FortiGate by HTTP/fgate.service.data_errors,2m)=0'
              name: 'FortiGate: There are errors in the ''Get service licenses'' metric'
              priority: WARNING
              dependencies:
                - name: 'FortiGate: Unexpected response from API'
                  expression: 'last(/FortiGate by HTTP/fgate.api.status)=0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 90a78cff28d54a1b9b955e9dc94d48c7
          name: 'Get service licenses'
          type: SCRIPT
          key: fgate.service.get_data
          history: '0'
          value_type: TEXT
          params: |
            var params = JSON.parse(value),
            	request = new HttpRequest(),
            	result = {"data": {}, "lld": [], "error": ""},
            	api_url = "",
            	error_msg = "";
            
            function getHttpData(url) {
            	request.addHeader('Accept: application/json');
            	request.addHeader('Authorization: Bearer ' + params.token);
            	response = request.get(url);
            	Zabbix.log(4, '[ FortiGate ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (request.getStatus() !== 200) {
            		throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            	}
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from FortiGate API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object.';
            	}
            
            	if ((typeof response.status !== 'undefined' && response.status != 'success') || typeof response.results === 'undefined') {
            		var uri = '/' + response.path + '/' + response.name + ((typeof response.action !== 'undefined') ? '?action=' + response.action : "");
            		throw 'Failed to parse response received from ' + uri + '. Check debug log for more information.';
            	}
            
            	return response;
            };
            
            function capitalize(word, idx) {
            	return upAcronymCase(word.charAt(idx).toUpperCase() + word.slice(idx+1));
            }
            
            function upAcronymCase(word) {
            	if (word.length < 4) {
            		return word.toUpperCase()
            	}
            	return word;
            }
            
            function prepareServiceName(key) {
            	var result = [];
            	key.split('_').forEach(function (w) {
            		var forti_idx = w.indexOf('forti');
            		w = upAcronymCase(w);
            		if (forti_idx !== -1)
            			w = 'Forti' + capitalize(w, forti_idx + 5);
            		else
            			w = capitalize(w, 0)
            		result.push(w);
            	});
            
            	return result.join(' ');
            };
            
            try {
            	['scheme', 'api.token', 'api.fqdn', 'api.port'].forEach(function (field) {
            		var macro = '{$FGATE.' + field.toUpperCase() + '}';
            		var key = field.split('.').pop();
            		if (params[key] === macro || params[key] === '') {
            			throw 'Please change ' + macro + ' macro to the proper value.';
            		}
            		if (typeof params[key] === 'undefined') {
            			throw 'Please set "' + key + '" script input parameter to ' + macro + ' macro value.';
            		}
            	});
            
            	api_url = params.scheme + '://' + params.fqdn + ':' + params.port;
            
            	if (typeof params.http_proxy !== 'undefined' && params.http_proxy !== '{' + '$FGATE.HTTP.PROXY}' && params.http_proxy !== '') {
            		request.setProxy(params.http_proxy);
            	}
            
            	var licence_list = getHttpData(
            		api_url + '/api/v2/monitor/license/status'
            	);
            
            	result.data = licence_list.results;
            	Object.keys(licence_list.results).forEach(function (key) {
            		var resource = licence_list.results[key];
            		if (typeof resource.status !== 'undefined' && typeof resource.type !== 'undefined') {
            			result.lld.push({
            				"key": key,
            				"name": prepareServiceName(key),
            				"status": resource.status,
            				"type": resource.type,
            			});
            		}
            	});
            } catch (error) {
            	error_msg = error.toString();
            	error_msg += error_msg.endsWith('.') ? '' : '.';
            	Zabbix.log(3, '[ FortiGate ] ERROR: ' + error_msg);
            };
            
            result.error = error_msg;
            
            return JSON.stringify(result);
          description: 'Item for gathering information about service licenses from FortiGate API.'
          timeout: '{$FGATE.DATA.TIMEOUT}'
          parameters:
            - name: fqdn
              value: '{$FGATE.API.FQDN}'
            - name: http_proxy
              value: '{$FGATE.HTTP.PROXY}'
            - name: port
              value: '{$FGATE.API.PORT}'
            - name: scheme
              value: '{$FGATE.SCHEME}'
            - name: token
              value: '{$FGATE.API.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 8d8d4e7073db4ad497f4ca8dfffa043c
          name: 'Device system info item errors'
          type: DEPENDENT
          key: fgate.system.data_errors
          value_type: TEXT
          description: 'Item for gathering errors of the device system info.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: fgate.system.get_data
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: 3d1dbc0964db401fa9c10c1b126349e4
              expression: 'length(last(/FortiGate by HTTP/fgate.system.data_errors))>0 and length(last(/FortiGate by HTTP/fgate.system.data_errors,#1:now-1m))>0 and nodata(/FortiGate by HTTP/fgate.system.data_errors,2m)=0'
              name: 'FortiGate: There are errors in the ''Get system info'' metric'
              priority: WARNING
              dependencies:
                - name: 'FortiGate: Unexpected response from API'
                  expression: 'last(/FortiGate by HTTP/fgate.api.status)=0'
              tags:
                - tag: scope
                  value: availability
        - uuid: a6b831300e7048fbad4502973d0318e7
          name: 'Get system info'
          type: HTTP_AGENT
          key: fgate.system.get_data
          history: '0'
          value_type: TEXT
          description: 'Item for gathering device system info from FortiGate API.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
              error_handler: CUSTOM_VALUE
              error_handler_params: '{"error":"Not supported value received"}'
          timeout: '{$FGATE.DATA.TIMEOUT}'
          url: '{$FGATE.SCHEME}://{$FGATE.API.FQDN}:{$FGATE.API.PORT}/api/v2/monitor/web-ui/state'
          http_proxy: '{$FGATE.HTTP.PROXY}'
          headers:
            - name: Accept
              value: application/json
            - name: Authorization
              value: 'Bearer {$FGATE.API.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 924a859579bd41a9b26dc83f92100577
          name: 'System uptime'
          type: DEPENDENT
          key: fgate.uptime
          units: uptime
          description: 'The system uptime is calculated on the basis of boot time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.results.utc_last_reboot
            - type: JAVASCRIPT
              parameters:
                - 'return (Math.floor(Date.now()/1000)-Math.floor(Number(value)/1000));'
          master_item:
            key: fgate.system.get_data
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: 183385fa495442bcbd3eb28636ca5bb9
              expression: 'last(/FortiGate by HTTP/fgate.uptime)<10m'
              name: 'FortiGate: Device has been restarted'
              event_name: 'FortiGate: {HOST.NAME} has been restarted (uptime < 10m)'
              priority: INFO
              description: 'Uptime is less than 10 minutes.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 27d30f93ff7c49d89537c43bad5f9453
          name: 'Check port availability'
          type: SIMPLE
          key: 'net.tcp.service["{$FGATE.SCHEME}","{$FGATE.API.FQDN}","{$FGATE.API.PORT}"]'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: health
            - tag: component
              value: network
          triggers:
            - uuid: 26abf8698af247d09c325ab1cb3e9903
              expression: 'last(/FortiGate by HTTP/net.tcp.service["{$FGATE.SCHEME}","{$FGATE.API.FQDN}","{$FGATE.API.PORT}"])=0'
              name: 'FortiGate: Port {$FGATE.API.PORT} is unavailable'
              priority: AVERAGE
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: availability
      discovery_rules:
        - uuid: 13ff598606764abbaec4d0b9f6cbbf33
          name: 'Firewall policies discovery'
          type: DEPENDENT
          key: fgate.fwp.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#FWACTION}'
                value: '{$FWP.FWACTION.MATCHES}'
              - macro: '{#FWACTION}'
                value: '{$FWP.FWACTION.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#FWNAME}'
                value: '{$FWP.FWNAME.MATCHES}'
              - macro: '{#FWNAME}'
                value: '{$FWP.FWNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#FWTYPE}'
                value: '{$FWP.FWTYPE.MATCHES}'
              - macro: '{#FWTYPE}'
                value: '{$FWP.FWTYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for FortiGate firewall policies.'
          item_prototypes:
            - uuid: 19b27ab621a1417f86ddbd52d93f6c55
              name: 'FW Policy [{#FWNAME}]: Action'
              type: DEPENDENT
              key: 'fgate.fwp.action[{#FWUUID}]'
              description: 'The firewall policy action (accept / deny / ipsec).'
              valuemap:
                name: 'Firewall policy action'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.action
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const idx = [
                      	'accept',
                      	'deny',
                      	'ipsec'
                      ].indexOf(value);
                      return idx !== -1 ? idx : 10;
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 12h
              master_item:
                key: 'fgate.fwp.get_data[{#FWUUID}]'
              tags:
                - tag: component
                  value: firewall
                - tag: policy
                  value: '{#FWNAME}'
            - uuid: 61bf8afdf8f04c9197077978706b1adc
              name: 'FW Policy [{#FWNAME}]: Total bytes processed'
              type: DEPENDENT
              key: 'fgate.fwp.bytes[{#FWUUID}]'
              units: B
              description: 'Number of bytes processed by both the software and hardware (ASIC) firewall.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.bytes
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.fwp.get_data[{#FWUUID}]'
              tags:
                - tag: component
                  value: firewall
                - tag: policy
                  value: '{#FWNAME}'
            - uuid: ee45ca237e074dd0a599ae1b29896329
              name: 'FW Policy [{#FWNAME}]: Get data'
              type: DEPENDENT
              key: 'fgate.fwp.get_data[{#FWUUID}]'
              history: '0'
              value_type: TEXT
              description: 'Item for gathering data for the {#FWNAME} firewall policy.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.data[?(@.uuid == "{#FWUUID}")].first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: fgate.fwp.get_data
              tags:
                - tag: component
                  value: raw
                - tag: policy
                  value: '{#FWNAME}'
            - uuid: cae79524205c491990b967035ca4e753
              name: 'FW Policy [{#FWNAME}]: Hits into the policy'
              type: DEPENDENT
              key: 'fgate.fwp.hits[{#FWUUID}]'
              description: 'Number of packets hit into the firewall policy per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.hit_count
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.fwp.get_data[{#FWUUID}]'
              tags:
                - tag: component
                  value: firewall
                - tag: policy
                  value: '{#FWNAME}'
            - uuid: 333596806faf457b9dfcb90a8c11bd25
              name: 'FW Policy [{#FWNAME}]: Hardware processed bytes'
              type: DEPENDENT
              key: 'fgate.fwp.hw_bytes[{#FWUUID}]'
              units: B
              description: 'Number of bytes processed only by the hardware (ASIC) firewall.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.asic_bytes
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.fwp.get_data[{#FWUUID}]'
              tags:
                - tag: component
                  value: firewall
                - tag: policy
                  value: '{#FWNAME}'
            - uuid: 5b5c10ff4c8a4e47a550d1c0563e78e1
              name: 'FW Policy [{#FWNAME}]: Last using time'
              type: DEPENDENT
              key: 'fgate.fwp.last_used[{#FWUUID}]'
              units: unixtime
              description: 'The time at which the firewall policy was used the last time.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.last_used
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'fgate.fwp.get_data[{#FWUUID}]'
              tags:
                - tag: component
                  value: firewall
                - tag: policy
                  value: '{#FWNAME}'
            - uuid: 1255b5df630b4af782cd00d59cb49fe0
              name: 'FW Policy [{#FWNAME}]: Active sessions'
              type: DEPENDENT
              key: 'fgate.fwp.sessions[{#FWUUID}]'
              description: 'Number of active sessions covered by this rule.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.active_sessions
              master_item:
                key: 'fgate.fwp.get_data[{#FWUUID}]'
              tags:
                - tag: component
                  value: firewall
                - tag: policy
                  value: '{#FWNAME}'
            - uuid: 3cedbb09e06547e682843679811a6a40
              name: 'FW Policy [{#FWNAME}]: Status'
              type: DEPENDENT
              key: 'fgate.fwp.status[{#FWUUID}]'
              description: 'The firewall policy status.'
              valuemap:
                name: 'Firewall policy status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.status
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const idx = [
                      	'enable',
                      	'disable'
                      ].indexOf(value);
                      return idx !== -1 ? idx : value;
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.fwp.get_data[{#FWUUID}]'
              tags:
                - tag: component
                  value: firewall
                - tag: policy
                  value: '{#FWNAME}'
            - uuid: 838a630bc233403f9be41dd079a52b67
              name: 'FW Policy [{#FWNAME}]: Software processed bytes'
              type: DEPENDENT
              key: 'fgate.fwp.sw_bytes[{#FWUUID}]'
              units: B
              description: 'Number of bytes processed only by the software firewall.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.software_bytes
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.fwp.get_data[{#FWUUID}]'
              tags:
                - tag: component
                  value: firewall
                - tag: policy
                  value: '{#FWNAME}'
          graph_prototypes:
            - uuid: 1bbf600910de437dbc88f9340ebd7afd
              name: 'FW Policy [{#FWNAME}]: Active sessions'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.fwp.sessions[{#FWUUID}]'
            - uuid: 28abccb8b1c94ca787e38a773c0e282c
              name: 'FW Policy [{#FWNAME}]: Hits into the policy'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.fwp.hits[{#FWUUID}]'
            - uuid: b449d42f646b4318a862fa786387d783
              name: 'FW Policy [{#FWNAME}]: Policy processing'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.fwp.sw_bytes[{#FWUUID}]'
                - sortorder: '1'
                  drawtype: GRADIENT_LINE
                  color: F63100
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.fwp.hw_bytes[{#FWUUID}]'
                - sortorder: '2'
                  drawtype: BOLD_LINE
                  color: 00611C
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.fwp.bytes[{#FWUUID}]'
          master_item:
            key: fgate.fwp.get_data
          lld_macro_paths:
            - lld_macro: '{#FWACTION}'
              path: $.action
            - lld_macro: '{#FWINDEX}'
              path: $.policyid
            - lld_macro: '{#FWLABEL}'
              path: $.label
            - lld_macro: '{#FWNAME}'
              path: $.name
            - lld_macro: '{#FWTYPE}'
              path: '$["ip-version-type"]'
            - lld_macro: '{#FWUUID}'
              path: $.uuid
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
        - uuid: b5d0c50d4ff8400a93618df5d2185ff7
          name: 'Network interfaces discovery'
          type: DEPENDENT
          key: fgate.netif.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#IFALIAS}'
                value: '{$NET.IF.IFALIAS.MATCHES}'
              - macro: '{#IFALIAS}'
                value: '{$NET.IF.IFALIAS.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#IFDESCR}'
                value: '{$NET.IF.IFDESCR.MATCHES}'
              - macro: '{#IFDESCR}'
                value: '{$NET.IF.IFDESCR.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#IFNAME}'
                value: '{$NET.IF.IFNAME.MATCHES}'
              - macro: '{#IFNAME}'
                value: '{$NET.IF.IFNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#IFSTATUS}'
                value: '{$NET.IF.IFSTATUS.MATCHES}'
              - macro: '{#IFSTATUS}'
                value: '{$NET.IF.IFSTATUS.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#IFTYPE}'
                value: '{$NET.IF.IFTYPE.MATCHES}'
              - macro: '{#IFTYPE}'
                value: '{$NET.IF.IFTYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for FortiGate network interfaces.'
          item_prototypes:
            - uuid: afb2dec9321a4eb1821b366c5219ce60
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Get data'
              type: DEPENDENT
              key: 'fgate.netif.get_data[{#IFKEY}]'
              history: '0'
              value_type: TEXT
              description: 'Item for gathering data for the {#IFKEY} interface.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.data[?(@.id == "{#IFKEY}")].first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: fgate.netif.get_data
              tags:
                - tag: component
                  value: raw
                - tag: description
                  value: '{#IFALIAS}'
                - tag: interface
                  value: '{#IFKEY}'
            - uuid: 76c143854ca8400ea0af95debdc8f8d9
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Bits received'
              type: DEPENDENT
              key: 'fgate.netif.in[{#IFKEY}]'
              units: bps
              description: 'The total number of octets received on the interface per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rx_bytes
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
                - type: MULTIPLIER
                  parameters:
                    - '8'
              master_item:
                key: 'fgate.netif.get_data[{#IFKEY}]'
              tags:
                - tag: component
                  value: network
                - tag: description
                  value: '{#IFALIAS}'
                - tag: interface
                  value: '{#IFKEY}'
            - uuid: ef7ce50437034277bcc33af137d87e1b
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Inbound packets with errors'
              type: DEPENDENT
              key: 'fgate.netif.in_errors[{#IFKEY}]'
              description: 'The total number of errors received.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rx_errors
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.netif.get_data[{#IFKEY}]'
              tags:
                - tag: component
                  value: network
                - tag: description
                  value: '{#IFALIAS}'
                - tag: interface
                  value: '{#IFKEY}'
              trigger_prototypes:
                - uuid: 9ef845b9e393423f96403ea4c195859e
                  expression: 'min(/FortiGate by HTTP/fgate.netif.in_errors[{#IFKEY}],5m)>{$NET.IF.ERRORS.WARN:"{#IFKEY}"} or min(/FortiGate by HTTP/fgate.netif.in_errors[{#IFKEY}],5m)>{$NET.IF.ERRORS.WARN:"{#IFKEY}"}'
                  recovery_mode: RECOVERY_EXPRESSION
                  recovery_expression: 'max(/FortiGate by HTTP/fgate.netif.in_errors[{#IFKEY}],5m)<{$NET.IF.ERRORS.WARN:"{#IFKEY}"}*0.8 and max(/FortiGate by HTTP/fgate.netif.in_errors[{#IFKEY}],5m)<{$NET.IF.ERRORS.WARN:"{#IFKEY}"}*0.8'
                  name: 'FortiGate: Interface [{#IFNAME}({#IFALIAS})]: High error rate'
                  event_name: 'FortiGate: Interface [{#IFNAME}({#IFALIAS})]: High error rate (>{$NET.IF.ERRORS.WARN:"{#IFKEY}"} for 5m)'
                  opdata: 'errors in: {ITEM.LASTVALUE1}, errors out: {ITEM.LASTVALUE2}'
                  priority: WARNING
                  description: 'It recovers when it is below 80% of the `{$NET.IF.ERRORS.WARN:"{#IFKEY}"}` threshold.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'FortiGate: Interface [{#IFNAME}({#IFALIAS})]: Link down'
                      expression: '{$NET.IF.CONTROL:"{#IFNAME}"}=1 and last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}])=1 and (last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}],#1)<>last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}],#2))'
                      recovery_expression: 'last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}])<>1 or {$NET.IF.CONTROL:"{#IFNAME}"}=0'
                  tags:
                    - tag: scope
                      value: availability
                    - tag: scope
                      value: performance
            - uuid: 75bd8c58c1f94a2aaaca0afdc8ebc1eb
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Inbound packets'
              type: DEPENDENT
              key: 'fgate.netif.in_packets[{#IFKEY}]'
              description: 'The total number of packets received on the interface per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rx_packets
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.netif.get_data[{#IFKEY}]'
              tags:
                - tag: component
                  value: network
                - tag: description
                  value: '{#IFALIAS}'
                - tag: interface
                  value: '{#IFKEY}'
            - uuid: 479786a0a0414a609ce7fffbc51519ec
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Bits sent'
              type: DEPENDENT
              key: 'fgate.netif.out[{#IFKEY}]'
              units: bps
              description: 'The total number of octets transmitted out of the interface.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_bytes
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
                - type: MULTIPLIER
                  parameters:
                    - '8'
              master_item:
                key: 'fgate.netif.get_data[{#IFKEY}]'
              tags:
                - tag: component
                  value: network
                - tag: description
                  value: '{#IFALIAS}'
                - tag: interface
                  value: '{#IFKEY}'
            - uuid: bfab84d969614ef0945ca9ff54d8ea27
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Outbound packets with errors'
              type: DEPENDENT
              key: 'fgate.netif.out_errors[{#IFKEY}]'
              description: 'The total number of errors transmitted.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_errors
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.netif.get_data[{#IFKEY}]'
              tags:
                - tag: component
                  value: network
                - tag: description
                  value: '{#IFALIAS}'
                - tag: interface
                  value: '{#IFKEY}'
            - uuid: 8520c14ac47246c896d068f5be80f4b0
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Outbound packets'
              type: DEPENDENT
              key: 'fgate.netif.out_packets[{#IFKEY}]'
              description: 'The total number of packets transmitted out of the interface per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_packets
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.netif.get_data[{#IFKEY}]'
              tags:
                - tag: component
                  value: network
                - tag: description
                  value: '{#IFALIAS}'
                - tag: interface
                  value: '{#IFKEY}'
            - uuid: 0912c8f0928242df905c43d2320d0004
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Speed'
              type: DEPENDENT
              key: 'fgate.netif.speed[{#IFKEY}]'
              units: bps
              description: 'Speed of the interface.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.speed
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: MULTIPLIER
                  parameters:
                    - '1000000'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.netif.get_data[{#IFKEY}]'
              tags:
                - tag: component
                  value: network
                - tag: description
                  value: '{#IFALIAS}'
                - tag: interface
                  value: '{#IFKEY}'
            - uuid: e0dbfeb62ad14260a299263be8db631c
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Link status'
              type: DEPENDENT
              key: 'fgate.netif.status[{#IFKEY}]'
              description: 'Current link status of the interface.'
              valuemap:
                name: 'Link state'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.link
                - type: BOOL_TO_DECIMAL
              master_item:
                key: 'fgate.netif.get_data[{#IFKEY}]'
              tags:
                - tag: component
                  value: network
                - tag: description
                  value: '{#IFALIAS}'
                - tag: interface
                  value: '{#IFKEY}'
              trigger_prototypes:
                - uuid: e03715db2ab3447ba3dda0e07c3bc604
                  expression: '{$NET.IF.CONTROL:"{#IFNAME}"}=1 and last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}])=1 and (last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}],#1)<>last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}],#2))'
                  recovery_mode: RECOVERY_EXPRESSION
                  recovery_expression: 'last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}])<>1 or {$NET.IF.CONTROL:"{#IFNAME}"}=0'
                  name: 'FortiGate: Interface [{#IFNAME}({#IFALIAS})]: Link down'
                  opdata: 'Current status: {ITEM.LASTVALUE1}'
                  priority: AVERAGE
                  description: |
                    This trigger expression works as follows:
                    1. It can be triggered if the interface link status is down.
                    2. `{$NET.IF.CONTROL:"{#IFNAME}"}=1` - a user can redefine context macro to value - 0. That marks this interface as not important. No new trigger will be fired if this interface link is down.
                    3. `{TEMPLATE_NAME:METRIC.diff()}=1` - the trigger fires only if the interface link status was up to (1) sometime before.
                    
                    WARNING: If closed manually, it will not fire again on the next poll because of .diff.
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: ffba364bc78c446bb57f6673b7b6d255
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Interface type'
              type: DEPENDENT
              key: 'fgate.netif.type[{#IFKEY}]'
              description: 'Type of the interface.'
              valuemap:
                name: 'Interface type'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.type
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const idx = [
                      	'physical',
                      	'vlan',
                      	'aggregate',
                      	'redundant',
                      	'tunnel',
                      	'vdom-link',
                      	'loopback',
                      	'switch',
                      	'vap-switch',
                      	'wl-mesh',
                      	'fext-wan',
                      	'vxlan',
                      	'geneve',
                      	'hdlc',
                      	'switch-vlan',
                      	'emac-vlan',
                      	'ssl',
                      	'lan-extension'
                      ].indexOf(value);
                      return idx !== -1 ? idx : 30;
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.netif.get_data[{#IFKEY}]'
              tags:
                - tag: component
                  value: network
                - tag: description
                  value: '{#IFALIAS}'
                - tag: interface
                  value: '{#IFKEY}'
          trigger_prototypes:
            - uuid: b21dcb60f79d4d6686209ff4bb0d4dad
              expression: |
                change(/FortiGate by HTTP/fgate.netif.speed[{#IFKEY}])<0 and last(/FortiGate by HTTP/fgate.netif.speed[{#IFKEY}])>0
                and last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}])<>0
              recovery_mode: RECOVERY_EXPRESSION
              recovery_expression: |
                (change(/FortiGate by HTTP/fgate.netif.speed[{#IFKEY}])>0 and last(/FortiGate by HTTP/fgate.netif.speed[{#IFKEY}],#2)>0)
                or last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}])=0
              name: 'FortiGate: Interface [{#IFNAME}({#IFALIAS})]: Ethernet has changed to lower speed than it was before'
              opdata: 'Current reported speed: {ITEM.LASTVALUE1}'
              priority: INFO
              description: 'This Ethernet connection has transitioned down from its known maximum speed. This might be a sign of autonegotiation issues. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              dependencies:
                - name: 'FortiGate: Interface [{#IFNAME}({#IFALIAS})]: Link down'
                  expression: '{$NET.IF.CONTROL:"{#IFNAME}"}=1 and last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}])=1 and (last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}],#1)<>last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}],#2))'
                  recovery_expression: 'last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}])<>1 or {$NET.IF.CONTROL:"{#IFNAME}"}=0'
              tags:
                - tag: scope
                  value: performance
            - uuid: 5aa7f2cacfc54b6eadfd9817b967725a
              expression: |
                (avg(/FortiGate by HTTP/fgate.netif.in[{#IFKEY}],15m)>({$NET.IF.UTIL.MAX:"{#IFNAME}"}/100)*last(/FortiGate by HTTP/fgate.netif.speed[{#IFKEY}]) or
                avg(/FortiGate by HTTP/fgate.netif.out[{#IFKEY}],15m)>({$NET.IF.UTIL.MAX:"{#IFNAME}"}/100)*last(/FortiGate by HTTP/fgate.netif.speed[{#IFKEY}]))
                and last(/FortiGate by HTTP/fgate.netif.speed[{#IFKEY}])>0
              recovery_mode: RECOVERY_EXPRESSION
              recovery_expression: |
                avg(/FortiGate by HTTP/fgate.netif.in[{#IFKEY}],15m)<(({$NET.IF.UTIL.MAX:"{#IFNAME}"}-3)/100)*last(/FortiGate by HTTP/fgate.netif.speed[{#IFKEY}])
                and avg(/FortiGate by HTTP/fgate.netif.out[{#IFKEY}],15m)<(({$NET.IF.UTIL.MAX:"{#IFNAME}"}-3)/100)*last(/FortiGate by HTTP/fgate.netif.speed[{#IFKEY}])
              name: 'FortiGate: Interface [{#IFNAME}({#IFALIAS})]: High bandwidth usage'
              event_name: 'FortiGate: Interface [{#IFNAME}({#IFALIAS})]: High bandwidth usage (>{$NET.IF.UTIL.MAX:"{#IFNAME}"}%)'
              opdata: 'In: {ITEM.LASTVALUE1}, out: {ITEM.LASTVALUE3}, speed: {ITEM.LASTVALUE2}'
              priority: WARNING
              description: 'The utilization of the network interface is close to its estimated maximum bandwidth.'
              manual_close: 'YES'
              dependencies:
                - name: 'FortiGate: Interface [{#IFNAME}({#IFALIAS})]: Link down'
                  expression: '{$NET.IF.CONTROL:"{#IFNAME}"}=1 and last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}])=1 and (last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}],#1)<>last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}],#2))'
                  recovery_expression: 'last(/FortiGate by HTTP/fgate.netif.status[{#IFKEY}])<>1 or {$NET.IF.CONTROL:"{#IFNAME}"}=0'
              tags:
                - tag: scope
                  value: performance
          graph_prototypes:
            - uuid: 5d5b2b5c35a7433999f29f4f22a6d380
              name: 'Interface [{#IFNAME}({#IFALIAS})]: Network traffic'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.netif.in[{#IFKEY}]'
                - sortorder: '1'
                  drawtype: BOLD_LINE
                  color: F63100
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.netif.out[{#IFKEY}]'
                - sortorder: '2'
                  color: 00611C
                  yaxisside: RIGHT
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.netif.in_errors[{#IFKEY}]'
                - sortorder: '3'
                  color: F7941D
                  yaxisside: RIGHT
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.netif.out_errors[{#IFKEY}]'
                - sortorder: '4'
                  color: FC6EA3
                  yaxisside: RIGHT
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.netif.in_packets[{#IFKEY}]'
                - sortorder: '5'
                  color: 6C59DC
                  yaxisside: RIGHT
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.netif.out_packets[{#IFKEY}]'
          master_item:
            key: fgate.netif.get_data
          lld_macro_paths:
            - lld_macro: '{#IFALIAS}'
              path: $.alias
            - lld_macro: '{#IFDESCR}'
              path: $.description
            - lld_macro: '{#IFKEY}'
              path: $.id
            - lld_macro: '{#IFNAME}'
              path: $.name
            - lld_macro: '{#IFSTATUS}'
              path: $.link
            - lld_macro: '{#IFTYPE}'
              path: $.type
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
        - uuid: ededd6a88d74407c998f54a63bec5155
          name: 'SD-WAN health-checks discovery'
          type: DEPENDENT
          key: fgate.sdwan_health.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#IFNAME}'
                value: '{$SDWAN.HEALTH.IFNAME.MATCHES}'
              - macro: '{#IFNAME}'
                value: '{$SDWAN.HEALTH.IFNAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#MID}'
                value: '{$SDWAN.HEALTH.ID.MATCHES}'
              - macro: '{#MID}'
                value: '{$SDWAN.HEALTH.ID.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#NAME}'
                value: '{$SDWAN.HEALTH.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$SDWAN.HEALTH.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#STATUS}'
                value: '{$SDWAN.HEALTH.STATUS.MATCHES}'
              - macro: '{#STATUS}'
                value: '{$SDWAN.HEALTH.STATUS.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for FortiGate SD-WAN health-checks.'
          item_prototypes:
            - uuid: 292228d1456f41b094b36edc2e22d24e
              name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Get data'
              type: DEPENDENT
              key: 'fgate.sdwan_health.get_data["{#HID}.{#MID}"]'
              history: '0'
              value_type: TEXT
              description: 'Item for gathering data about the {#IFNAME} interface in the {#NAME} health-check.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.data.health_data[?(@.q_origin_key == "{#HID}")]["{#IFNAME}"].first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: fgate.sdwan.get_data
              tags:
                - tag: component
                  value: raw
                - tag: health_check
                  value: '{#NAME}'
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 29802e18613a4f83a93b68e2aec72d6a
              name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Jitter'
              type: DEPENDENT
              key: 'fgate.sdwan_health.jitter["{#HID}.{#MID}"]'
              value_type: FLOAT
              description: 'Current jitter value for the {#IFNAME} interface in the {#NAME} health-check.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.jitter
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'fgate.sdwan_health.get_data["{#HID}.{#MID}"]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: health_check
                  value: '{#NAME}'
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 207b0b20629a4e4f89980c468b32d6af
              name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Latency'
              type: DEPENDENT
              key: 'fgate.sdwan_health.latency["{#HID}.{#MID}"]'
              value_type: FLOAT
              units: ms
              description: 'Current latency value for the {#IFNAME} interface in the {#NAME} health-check.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.latency
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'fgate.sdwan_health.get_data["{#HID}.{#MID}"]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: health_check
                  value: '{#NAME}'
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 02dee727fc0347f58266fb64646bd28f
              name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Packets loss'
              type: DEPENDENT
              key: 'fgate.sdwan_health.loss["{#HID}.{#MID}"]'
              value_type: FLOAT
              units: '%'
              description: 'Percent of lost packets for the {#IFNAME} interface in the {#NAME} health-check.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.packet_loss
                  error_handler: DISCARD_VALUE
              master_item:
                key: 'fgate.sdwan_health.get_data["{#HID}.{#MID}"]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: health_check
                  value: '{#NAME}'
                - tag: interface
                  value: '{#IFNAME}'
              trigger_prototypes:
                - uuid: 698f0a5da51f43359d917e296fa1a8c2
                  expression: 'min(/FortiGate by HTTP/fgate.sdwan_health.loss["{#HID}.{#MID}"],5m)>{$SDWAN.HEALTH.IF.LOSS.WARN:"{#IFNAME}"}'
                  name: 'FortiGate: SD-WAN [{#NAME}]:[{#IFNAME}]: High packets loss'
                  opdata: 'Loss: {ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: 'High level of packets loss detected.'
                  tags:
                    - tag: scope
                      value: performance
            - uuid: b2eaa836c991459bab433edb2d27a968
              name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Packets received per second'
              type: DEPENDENT
              key: 'fgate.sdwan_health.received["{#HID}.{#MID}"]'
              value_type: FLOAT
              description: 'Number of packets received from the {#IFNAME} interface in the {#NAME} health-check per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.packet_received
                  error_handler: DISCARD_VALUE
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.sdwan_health.get_data["{#HID}.{#MID}"]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: health_check
                  value: '{#NAME}'
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 988c9785e5924a118efae469cf8ea017
              name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Packets sent per second'
              type: DEPENDENT
              key: 'fgate.sdwan_health.sent["{#HID}.{#MID}"]'
              value_type: FLOAT
              description: 'Number of packets sent through the {#IFNAME} interface in the {#NAME} health-check per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.packet_sent
                  error_handler: DISCARD_VALUE
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.sdwan_health.get_data["{#HID}.{#MID}"]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: health_check
                  value: '{#NAME}'
                - tag: interface
                  value: '{#IFNAME}'
            - uuid: 7ccc2ede10064b28877cd7ba9eba64b2
              name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Interface status'
              type: DEPENDENT
              key: 'fgate.sdwan_health.status["{#HID}.{#MID}"]'
              description: 'Current status of the {#IFNAME} interface in the {#NAME} health-check.'
              valuemap:
                name: 'Interface status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.status
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const idx = [
                      	'up',
                      	'down',
                      	'error'
                      ].indexOf(value);
                      return idx !== -1 ? idx : 10;
              master_item:
                key: 'fgate.sdwan_health.get_data["{#HID}.{#MID}"]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: health_check
                  value: '{#NAME}'
                - tag: interface
                  value: '{#IFNAME}'
              trigger_prototypes:
                - uuid: c109ba19ca4d43bd87ffd0a4c9e64784
                  expression: '{$SDWAN.HEALTH.IF.CONTROL:"{#NAME}"}=1 and last(/FortiGate by HTTP/fgate.sdwan_health.status["{#HID}.{#MID}"])=1 and (last(/FortiGate by HTTP/fgate.sdwan_health.status["{#HID}.{#MID}"],#1)<>last(/FortiGate by HTTP/fgate.sdwan_health.status["{#HID}.{#MID}"],#2))'
                  recovery_mode: RECOVERY_EXPRESSION
                  recovery_expression: 'last(/FortiGate by HTTP/fgate.sdwan_health.status["{#HID}.{#MID}"])<>1 or {$SDWAN.HEALTH.IF.CONTROL:"{#NAME}"}=0'
                  name: 'FortiGate: SD-WAN [{#NAME}]:[{#IFNAME}]: Link down'
                  opdata: 'Current state: {ITEM.LASTVALUE1}'
                  priority: AVERAGE
                  description: |
                    This trigger expression works as follows:
                    1. It can be triggered if the interface status is down.
                    2. `{$SDWAN.HEALTH.IF.CONTROL:"{#NAME}"}=1` - a user can redefine context macro to value - 0. That marks this interface as not important. No new trigger will be fired if this interface is down/error.
                    3. `{TEMPLATE_NAME:METRIC.diff()}=1` - the trigger fires only if the interface status was up to (1) sometime before.
                    
                    WARNING: If closed manually, it will not fire again on the next poll because of .diff.
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: availability
                - uuid: d2e5eea705ea470785eeea8145e75f0b
                  expression: '{$SDWAN.HEALTH.IF.CONTROL:"{#IFNAME}"}=1 and last(/FortiGate by HTTP/fgate.sdwan_health.status["{#HID}.{#MID}"])=2 and (last(/FortiGate by HTTP/fgate.sdwan_health.status["{#HID}.{#MID}"],#1)<>last(/FortiGate by HTTP/fgate.sdwan_health.status["{#HID}.{#MID}"],#2))'
                  recovery_mode: RECOVERY_EXPRESSION
                  recovery_expression: 'last(/FortiGate by HTTP/fgate.sdwan_health.status["{#HID}.{#MID}"])<>2 or {$SDWAN.HEALTH.IF.CONTROL:"{#IFNAME}"}=0'
                  name: 'FortiGate: SD-WAN [{#NAME}]:[{#IFNAME}]: Link state is error'
                  opdata: 'Current state: {ITEM.LASTVALUE1}'
                  priority: AVERAGE
                  description: |
                    This trigger expression works as follows:
                    1. It can be triggered if the interface status is error.
                    2. `{$SDWAN.HEALTH.IF.CONTROL:"{#IFNAME}"}=1` - a user can redefine context macro to value - 0. That marks this interface as not important. No new trigger will be fired if this interface is down/error.
                    3. `{TEMPLATE_NAME:METRIC.diff()}=1` - the trigger fires only if the interface status was up to (1) sometime before.
                    
                    WARNING: If closed manually, it will not fire again on the next poll because of .diff.
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: availability
          graph_prototypes:
            - uuid: 8e0ad9c4444b418fb0a632e4126470be
              name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Packets statistics'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.sdwan_health.received["{#HID}.{#MID}"]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.sdwan_health.sent["{#HID}.{#MID}"]'
                - sortorder: '2'
                  drawtype: BOLD_LINE
                  color: 00611C
                  yaxisside: RIGHT
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.sdwan_health.loss["{#HID}.{#MID}"]'
            - uuid: 11741f72e04a4c57a1183baee74ea396
              name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Performance'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.sdwan_health.jitter["{#HID}.{#MID}"]'
                - sortorder: '1'
                  color: F63100
                  yaxisside: RIGHT
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.sdwan_health.latency["{#HID}.{#MID}"]'
          master_item:
            key: fgate.sdwan.get_data
          lld_macro_paths:
            - lld_macro: '{#HID}'
              path: $.health_id
            - lld_macro: '{#IFNAME}'
              path: $.interface
            - lld_macro: '{#MID}'
              path: $.member_id
            - lld_macro: '{#NAME}'
              path: $.health_name
            - lld_macro: '{#STATUS}'
              path: $.status
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data.health_lld
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
        - uuid: eccf64d732d44183866aae9bbdb394ba
          name: 'SD-WAN members discovery'
          type: DEPENDENT
          key: fgate.sdwan_member.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#ID}'
                value: '{$SDWAN.MEMBER.ID.MATCHES}'
              - macro: '{#ID}'
                value: '{$SDWAN.MEMBER.ID.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#NAME}'
                value: '{$SDWAN.MEMBER.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$SDWAN.MEMBER.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#STATUS}'
                value: '{$SDWAN.MEMBER.STATUS.MATCHES}'
              - macro: '{#STATUS}'
                value: '{$SDWAN.MEMBER.STATUS.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#ZONE}'
                value: '{$SDWAN.MEMBER.ZONE.MATCHES}'
              - macro: '{#ZONE}'
                value: '{$SDWAN.MEMBER.ZONE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for FortiGate SD-WAN members.'
          item_prototypes:
            - uuid: 376cf1ce322a4de5af3f86323f411b46
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Get data'
              type: DEPENDENT
              key: 'fgate.sdwan_member.get_data[{#ID}]'
              history: '0'
              value_type: TEXT
              description: 'Item for gathering data about the {#NAME} interface in the {#ZONE} zone.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.data.member_lld[?(@.interface == "{#NAME}")].first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: fgate.sdwan.get_data
              tags:
                - tag: component
                  value: raw
                - tag: interface
                  value: '{#NAME}'
                - tag: zone
                  value: '{#ZONE}'
            - uuid: 937daa113f7d4d4d886cecdf0d5166b8
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Link status'
              type: DEPENDENT
              key: 'fgate.sdwan_member.link_status[{#ID}]'
              description: 'Current link status of the {#NAME} interface in the {#ZONE} zone.'
              valuemap:
                name: 'Interface status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.link
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const idx = [
                      	'up',
                      	'down',
                      	'error'
                      ].indexOf(value);
                      return idx !== -1 ? idx : 10;
              master_item:
                key: 'fgate.sdwan_member.get_data[{#ID}]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: interface
                  value: '{#NAME}'
                - tag: zone
                  value: '{#ZONE}'
              trigger_prototypes:
                - uuid: 858488d06b6f482bbec954d38ad066b3
                  expression: '{$SDWAN.MEMBER.IF.CONTROL:"{#NAME}"}=1 and last(/FortiGate by HTTP/fgate.sdwan_member.link_status[{#ID}])=1 and (last(/FortiGate by HTTP/fgate.sdwan_member.link_status[{#ID}],#1)<>last(/FortiGate by HTTP/fgate.sdwan_member.link_status[{#ID}],#2))'
                  recovery_mode: RECOVERY_EXPRESSION
                  recovery_expression: 'last(/FortiGate by HTTP/fgate.sdwan_member.link_status[{#ID}])<>1 or {$SDWAN.MEMBER.IF.CONTROL:"{#NAME}"}=0'
                  name: 'FortiGate: SD-WAN [{#ZONE}]:[{#NAME}]: Link down'
                  opdata: 'Current state: {ITEM.LASTVALUE1}'
                  priority: AVERAGE
                  description: |
                    This trigger expression works as follows:
                    1. It can be triggered if the interface status is down.
                    2. `{$SDWAN.MEMBER.IF.CONTROL:"{#NAME}"}=1` - a user can redefine context macro to value - 0. That marks this interface as not important. No new trigger will be fired if this interface is down.
                    3. `{TEMPLATE_NAME:METRIC.diff()}=1` - the trigger fires only if the interface status was up to (1) sometime before.
                    
                    WARNING: If closed manually, it will not fire again on the next poll because of .diff.
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 3fcdcefd280d4b9db61624e82df66871
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Input bandwidth'
              type: DEPENDENT
              key: 'fgate.sdwan_member.rx_bandwidth[{#ID}]'
              value_type: FLOAT
              units: Bps
              description: 'Receiving bandwidth of the {#NAME} interface in the {#ZONE} zone.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rx_bandwidth
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.sdwan_member.get_data[{#ID}]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: interface
                  value: '{#NAME}'
                - tag: zone
                  value: '{#ZONE}'
            - uuid: becb1fc1c07540d69490b08efc60847b
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Bytes received per second'
              type: DEPENDENT
              key: 'fgate.sdwan_member.rx_bytes[{#ID}]'
              value_type: FLOAT
              units: Bps
              description: 'Bytes received from the {#NAME} interface in the {#ZONE} zone per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rx_bytes
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.sdwan_member.get_data[{#ID}]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: interface
                  value: '{#NAME}'
                - tag: zone
                  value: '{#ZONE}'
            - uuid: 9b8c8717665c47de96af38b75ebca3fc
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Sessions'
              type: DEPENDENT
              key: 'fgate.sdwan_member.sessions[{#ID}]'
              description: 'Number of active sessions opened through the {#NAME} interface in the {#ZONE} zone.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.session
              master_item:
                key: 'fgate.sdwan_member.get_data[{#ID}]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: interface
                  value: '{#NAME}'
                - tag: zone
                  value: '{#ZONE}'
            - uuid: 86ee2100e0f349cf809afa171c6b985a
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Member status'
              type: DEPENDENT
              key: 'fgate.sdwan_member.status[{#ID}]'
              description: 'Current status of the {#NAME} interface in the {#ZONE} zone.'
              valuemap:
                name: 'Service status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.status
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const idx = [
                      	'enable',
                      	'disable'
                      ].indexOf(value);
                      return idx !== -1 ? idx : 10;
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.sdwan_member.get_data[{#ID}]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: interface
                  value: '{#NAME}'
                - tag: zone
                  value: '{#ZONE}'
            - uuid: c5a29cbdfc1949d18b5b8490ba2230a9
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Output bandwidth'
              type: DEPENDENT
              key: 'fgate.sdwan_member.tx_bandwidth[{#ID}]'
              value_type: FLOAT
              units: Bps
              description: 'Transmitting bandwidth of the {#NAME} interface in the {#ZONE} zone.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_bandwidth
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.sdwan_member.get_data[{#ID}]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: interface
                  value: '{#NAME}'
                - tag: zone
                  value: '{#ZONE}'
            - uuid: c4e0c5747eee460b9a29d0d43d63e974
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Bytes sent per second'
              type: DEPENDENT
              key: 'fgate.sdwan_member.tx_bytes[{#ID}]'
              value_type: FLOAT
              units: Bps
              description: 'Bytes sent through the {#NAME} interface in the {#ZONE} zone per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tx_bytes
                  error_handler: CUSTOM_VALUE
                  error_handler_params: '0'
                - type: CHANGE_PER_SECOND
              master_item:
                key: 'fgate.sdwan_member.get_data[{#ID}]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: interface
                  value: '{#NAME}'
                - tag: zone
                  value: '{#ZONE}'
            - uuid: 908d970054e14c30aa0b33205f2a5ea8
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: State changing time'
              type: DEPENDENT
              key: 'fgate.service.state_changed[{#ID}]'
              units: unixtime
              description: 'Last state changing time of the {#NAME} interface in the {#ZONE} zone.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.state_changed
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.sdwan_member.get_data[{#ID}]'
              tags:
                - tag: component
                  value: sd_wan
                - tag: interface
                  value: '{#NAME}'
                - tag: zone
                  value: '{#ZONE}'
          graph_prototypes:
            - uuid: 6de8957f4392467bb61f4b970a8073b2
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Bandwidth'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.sdwan_member.tx_bandwidth[{#ID}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.sdwan_member.rx_bandwidth[{#ID}]'
            - uuid: 25f114f8837b4b4f811725e035affb80
              name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Network traffic'
              graph_items:
                - drawtype: BOLD_LINE
                  color: 199C0D
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.sdwan_member.tx_bytes[{#ID}]'
                - sortorder: '1'
                  drawtype: GRADIENT_LINE
                  color: F63100
                  item:
                    host: 'FortiGate by HTTP'
                    key: 'fgate.sdwan_member.rx_bytes[{#ID}]'
          master_item:
            key: fgate.sdwan.get_data
          lld_macro_paths:
            - lld_macro: '{#ID}'
              path: $.q_origin_key
            - lld_macro: '{#NAME}'
              path: $.interface
            - lld_macro: '{#STATUS}'
              path: $.status
            - lld_macro: '{#ZONE}'
              path: $.zone
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data.member_lld
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
        - uuid: 5fe5e9dfee0448d7a6552c3c5ec9e72c
          name: 'Service discovery'
          type: DEPENDENT
          key: fgate.service.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#KEY}'
                value: '{$SERVICE.KEY.MATCHES}'
              - macro: '{#KEY}'
                value: '{$SERVICE.KEY.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#STATUS}'
                value: '{$SERVICE.STATUS.MATCHES}'
              - macro: '{#STATUS}'
                value: '{$SERVICE.STATUS.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#TYPE}'
                value: '{$SERVICE.TYPE.MATCHES}'
              - macro: '{#TYPE}'
                value: '{$SERVICE.TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for FortiGate services.'
          item_prototypes:
            - uuid: c759d226d28143da977879550e913d5e
              name: 'Service [{#NAME}]: Expiration date'
              type: DEPENDENT
              key: 'fgate.service.expire["{#KEY}"]'
              units: unixtime
              description: 'Expiration date for the license of the current service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.expires
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.service.get_data["{#KEY}"]'
              tags:
                - tag: component
                  value: service
                - tag: name
                  value: '{#KEY}'
              trigger_prototypes:
                - uuid: 4b921a823a5a4a2cbf35b140c26eb514
                  expression: '{$SERVICE.LICENSE.CONTROL:"{#KEY}"}=1 and (last(/FortiGate by HTTP/fgate.service.expire["{#KEY}"]) - now()) / 86400 < {$SERVICE.EXPIRY.WARN:"{#KEY}"} and last(/FortiGate by HTTP/fgate.service.expire["{#KEY}"]) > now()'
                  name: 'FortiGate: Service [{#NAME}]: License expires soon'
                  event_name: 'FortiGate: Service [{#NAME}]: License expires soon (less than {$SERVICE.EXPIRY.WARN:"{#KEY}"} days)'
                  opdata: 'Current expiration date: {ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: |
                    This trigger expression works as follows:
                    1. It can be triggered if the license expires soon.
                    2. `{$SERVICE.LICENSE.CONTROL:"{#IFNAME}"}=1` - a user can redefine context macro to value - 0. That marks the license of this service as not important. No new trigger will be fired if this license expires.
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 84dd123ec16a4616bbf4d9a8c9ea9c8a
              name: 'Service [{#NAME}]: Get data'
              type: DEPENDENT
              key: 'fgate.service.get_data["{#KEY}"]'
              history: '0'
              value_type: TEXT
              description: 'Item for gathering data about license for the {#NAME} service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.data["{#KEY}"]'
                  error_handler: DISCARD_VALUE
              master_item:
                key: fgate.service.get_data
              tags:
                - tag: component
                  value: raw
                - tag: service
                  value: '{#KEY}'
            - uuid: d2e2c614e1dd428caa251b77d9a24f9a
              name: 'Service [{#NAME}]: License status'
              type: DEPENDENT
              key: 'fgate.service.license["{#KEY}"]'
              description: 'Current license status of the {#NAME} service.'
              valuemap:
                name: 'License status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.status
                  error_handler: DISCARD_VALUE
                - type: JAVASCRIPT
                  parameters:
                    - |
                      const idx = [
                      	'cloud_logged_in',
                      	'licensed',
                      	'registered',
                      	'vm_eval',
                      	'free_license',
                      	'vm_valid',
                      	'cloud_confirm_email',
                      	'cloud_error',
                      	'cloud_logged_out',
                      	'cloud_login_in_progress',
                      	'expired',
                      	'expires_soon',
                      	'free_license_exhausted',
                      	'licensed_exhausted',
                      	'no_license',
                      	'no_support',
                      	'not_registered',
                      	'pending',
                      	'unavailable',
                      	'update_manual',
                      	'update_push',
                      	'update_sched',
                      	'vm_eval_expired',
                      	'vm_expired',
                      	'vm_expires_soon',
                      	'vm_grace_period',
                      	'vm_invalid',
                      	'vm_pending',
                      	'vm_validation_overdue',
                      ].indexOf(value);
                      return idx !== -1 ? idx : 30;
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.service.get_data["{#KEY}"]'
              tags:
                - tag: component
                  value: service
                - tag: name
                  value: '{#KEY}'
              trigger_prototypes:
                - uuid: ad27092f227545d48f550bb58e61dd4c
                  expression: '{$SERVICE.LICENSE.CONTROL:"{#KEY}"}=1 and last(/FortiGate by HTTP/fgate.service.license["{#KEY}"])>5'
                  name: 'FortiGate: Service [{#NAME}]: License status is unsuccessful'
                  event_name: 'FortiGate: Service [{#NAME}]: License status is {ITEM.LASTVALUE1}'
                  opdata: 'Current status: {ITEM.LASTVALUE1}'
                  priority: AVERAGE
                  description: |
                    This trigger expression works as follows:
                    1. It can be triggered if the license status is unsuccessful.
                    2. `{$SERVICE.LICENSE.CONTROL:"{#IFNAME}"}=1` - a user can redefine context macro to value - 0. That marks the license of this service as not important. No new trigger will be fired if this license is unsuccessful.
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: notice
            - uuid: 89eb7360f2f846aabca21c63a05866ca
              name: 'Service [{#NAME}]: Service type'
              type: DEPENDENT
              key: 'fgate.service.type["{#KEY}"]'
              value_type: CHAR
              description: 'Current type of the {#NAME} service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.type
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.service.get_data["{#KEY}"]'
              tags:
                - tag: component
                  value: service
                - tag: name
                  value: '{#KEY}'
            - uuid: 160afd9220c9445f943142e356253626
              name: 'Service [{#NAME}]: Last attempt to update'
              type: DEPENDENT
              key: 'fgate.service.update_attempt["{#KEY}"]'
              units: unixtime
              description: 'Last update attempt time of the current service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.last_update_attempt
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.service.get_data["{#KEY}"]'
              tags:
                - tag: component
                  value: service
                - tag: name
                  value: '{#KEY}'
            - uuid: 9abd3d1e858b413bb84c76a77fb0764b
              name: 'Service [{#NAME}]: Update method'
              type: DEPENDENT
              key: 'fgate.service.update_method["{#KEY}"]'
              value_type: CHAR
              description: 'Current update method of the {#NAME} service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.last_update_method_status
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.service.get_data["{#KEY}"]'
              tags:
                - tag: component
                  value: service
                - tag: name
                  value: '{#KEY}'
            - uuid: a19764a51d4941bd877a24accac2b8b3
              name: 'Service [{#NAME}]: Update result'
              type: DEPENDENT
              key: 'fgate.service.update_result["{#KEY}"]'
              value_type: CHAR
              description: 'Last update result of the {#NAME} service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.last_update_result_status
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.service.get_data["{#KEY}"]'
              tags:
                - tag: component
                  value: service
                - tag: name
                  value: '{#KEY}'
            - uuid: d31db33d6ca34264a7480dacee235081
              name: 'Service [{#NAME}]: Last update time'
              type: DEPENDENT
              key: 'fgate.service.update_time["{#KEY}"]'
              units: unixtime
              description: 'Last update time of the current service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.last_update
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.service.get_data["{#KEY}"]'
              tags:
                - tag: component
                  value: service
                - tag: name
                  value: '{#KEY}'
            - uuid: 5f395038deb643ed83823695c4475d9e
              name: 'Service [{#NAME}]: Service version'
              type: DEPENDENT
              key: 'fgate.service.version["{#KEY}"]'
              value_type: CHAR
              description: 'Current version of the {#NAME} service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.version
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              master_item:
                key: 'fgate.service.get_data["{#KEY}"]'
              tags:
                - tag: component
                  value: service
                - tag: name
                  value: '{#KEY}'
          master_item:
            key: fgate.service.get_data
          lld_macro_paths:
            - lld_macro: '{#KEY}'
              path: $.key
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#STATUS}'
              path: $.status
            - lld_macro: '{#TYPE}'
              path: $.type
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.lld
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          overrides:
            - name: 'System services'
              step: '1'
              filter:
                conditions:
                  - macro: '{#TYPE}'
                    value: ^(cloud_service_status|platform|other)$
              operations:
                - operator: LIKE
                  value: ': Expiration date'
                  discover: NO_DISCOVER
                - operator: LIKE
                  value: ': Last attempt to update'
                  discover: NO_DISCOVER
                - operator: LIKE
                  value: ': Last update time'
                  discover: NO_DISCOVER
                - operator: LIKE
                  value: ': Service version'
                  discover: NO_DISCOVER
                - operator: LIKE
                  value: ': Update method'
                  discover: NO_DISCOVER
                - operator: LIKE
                  value: ': Update result'
                  discover: NO_DISCOVER
      tags:
        - tag: class
          value: network
        - tag: subclass
          value: firewall
        - tag: subclass
          value: security
        - tag: target
          value: fortigate
        - tag: target
          value: fortinet
      macros:
        - macro: '{$CPU.UTIL.CRIT}'
          value: '95'
          description: 'Threshold of CPU utilization for critical trigger in %.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'CPU usage critical threshold (%)'
            description: 'Threshold of CPU utilization for critical trigger in %. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$CPU.UTIL.WARN}'
          value: '85'
          description: 'Threshold of CPU utilization for warning trigger in %.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'CPU usage warning threshold (%)'
            description: 'Threshold of CPU utilization for warning trigger in %. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$DISK.FREE.CRIT}'
          value: '10'
          description: 'Threshold of disk free space for critical trigger in %.'
          config:
            type: TEXT
            priority: '13'
            section_name: Thresholds
            label: 'Disk free space critical threshold (%)'
            description: 'Threshold of disk free space for critical trigger in %. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$DISK.FREE.WARN}'
          value: '20'
          description: 'Threshold of disk free space for warning trigger in %.'
          config:
            type: TEXT
            priority: '12'
            section_name: Thresholds
            label: 'Disk free space warning threshold (%)'
            description: 'Threshold of disk free space for warning trigger in %. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$FGATE.API.FQDN}'
          description: 'FortiGate API FQDN/IP (ex. ngfw.example.com).'
          config:
            type: TEXT
            priority: '2'
            label: Address
            description: 'FortiGate API FQDN/IP (ex. ngfw.example.com).'
            required: 'YES'
        - macro: '{$FGATE.API.PORT}'
          value: '80'
          description: 'The port of FortiGate API endpoint.'
          config:
            type: TEXT
            priority: '4'
            label: Port
            description: 'The port of FortiGate API endpoint. In the range from 1 to 65535 inclusive.'
            required: 'YES'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$FGATE.API.TOKEN}'
          type: SECRET_TEXT
          description: 'FortiGate API token.'
          config:
            type: TEXT
            priority: '3'
            label: Token
            description: 'FortiGate API token.'
            required: 'YES'
        - macro: '{$FGATE.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for an API.'
          config:
            type: TEXT
            priority: '5'
            section_name: Other
            label: 'API response timeout'
            description: 'Response timeout for an API.'
        - macro: '{$FGATE.HTTP.PROXY}'
          description: 'HTTP proxy for API requests. You can specify it using the format [protocol://][username[:password]@]proxy.example.com[:port]. See the documentation at https://www.zabbix.com/documentation/8.0/manual/config/items/itemtypes/http'
          config:
            type: TEXT
            priority: '6'
            section_name: Other
            label: Proxy
            description: 'HTTP proxy for API requests. You can specify it using the format [protocol://][username[:password]@]proxy.example.com[:port]. See the documentation at https://www.zabbix.com/documentation/8.0/manual/config/items/itemtypes/http'
        - macro: '{$FGATE.SCHEME}'
          value: http
          description: 'Request scheme which may be http or https.'
          config:
            type: LIST
            priority: '1'
            label: Scheme
            description: 'Request scheme which may be http or https.'
            required: 'YES'
            options:
              - value: http
                text: http
              - value: https
                text: https
        - macro: '{$FIRMWARE.UPDATES.CONTROL}'
          value: '1'
          description: 'This macro is used in "New available firmware found" trigger.'
          config:
            type: TEXT
            priority: '7'
            section_name: Other
            label: 'Firmware update trigger macro'
            description: 'This macro is used in "New available firmware found" trigger.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$FWP.FWACTION.MATCHES}'
          value: '.*'
          description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '27'
            section_name: Filters
            label: 'Firewall action filter (include)'
            description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
        - macro: '{$FWP.FWACTION.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '28'
            section_name: Filters
            label: 'Firewall action filter (exclude)'
            description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
        - macro: '{$FWP.FWNAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '31'
            section_name: Filters
            label: 'Firewall name filter (include)'
            description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
        - macro: '{$FWP.FWNAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '32'
            section_name: Filters
            label: 'Firewall name filter (exclude)'
            description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
        - macro: '{$FWP.FWTYPE.MATCHES}'
          value: '.*'
          description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '29'
            section_name: Filters
            label: 'Firewall type filter (include)'
            description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
        - macro: '{$FWP.FWTYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '30'
            section_name: Filters
            label: 'Firewall type filter (exclude)'
            description: 'This macro is used in Firewall policies discovery. Can be overridden on the host or linked template level.'
        - macro: '{$MEMORY.UTIL.CRIT}'
          value: '90'
          description: 'Threshold of memory utilization for critical trigger in %.'
          config:
            type: TEXT
            priority: '11'
            section_name: Thresholds
            label: 'Memory usage critical threshold (%)'
            description: 'Threshold of memory utilization for critical trigger in %. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$MEMORY.UTIL.WARN}'
          value: '80'
          description: 'Threshold of memory utilization for warning trigger in %.'
          config:
            type: TEXT
            priority: '10'
            section_name: Thresholds
            label: 'Memory usage warning threshold (%)'
            description: 'Threshold of memory utilization for warning trigger in %. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$NET.IF.CONTROL}'
          value: '1'
          description: 'Macro for operational state of the interface for "Link down" trigger. Can be used with interface name as context.'
          config:
            type: TEXT
            priority: '14'
            section_name: Other
            label: 'Interface operational state macro (for "Link down")'
            description: 'Macro for operational state of the interface for "Link down" trigger. Can be used with interface name as context.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$NET.IF.ERRORS.WARN}'
          value: '2'
          description: 'Threshold of error packets rate for warning trigger. Can be used with interface name as context.'
          config:
            type: TEXT
            priority: '15'
            section_name: Thresholds
            label: 'Error packet rate warning threshold (%)'
            description: 'Threshold of error packets rate for warning trigger. Can be used with interface name as context.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$NET.IF.IFALIAS.MATCHES}'
          value: '.*'
          description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '23'
            section_name: Filters
            label: 'Filter for network interfaces by alias'
            description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
        - macro: '{$NET.IF.IFALIAS.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '24'
            section_name: Filters
            label: 'Filter for network interfaces by alias (exclude)'
            description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
        - macro: '{$NET.IF.IFDESCR.MATCHES}'
          value: '.*'
          description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '17'
            section_name: Filters
            label: 'Filter for network interfaces by description'
            description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
        - macro: '{$NET.IF.IFDESCR.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '18'
            section_name: Filters
            label: 'Filter for network interfaces by description (exclude)'
            description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
        - macro: '{$NET.IF.IFNAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '19'
            section_name: Filters
            label: 'Filter for network interface by name'
            description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
        - macro: '{$NET.IF.IFNAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '20'
            section_name: Filters
            label: 'Filter for network interface by name (exclude)'
            description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
        - macro: '{$NET.IF.IFSTATUS.MATCHES}'
          value: '.*'
          description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '25'
            section_name: Filters
            label: 'Network interface status filter (include)'
            description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
        - macro: '{$NET.IF.IFSTATUS.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '26'
            section_name: Filters
            label: 'Network interface status filter (exclude)'
            description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
        - macro: '{$NET.IF.IFTYPE.MATCHES}'
          value: '.*'
          description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '21'
            section_name: Filters
            label: 'Filter for network interfaces by type'
            description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
        - macro: '{$NET.IF.IFTYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '22'
            section_name: Filters
            label: 'Filter for network interfaces by type (exclude)'
            description: 'This macro is used in Network interfaces discovery. Can be overridden on the host or linked template level.'
        - macro: '{$NET.IF.UTIL.MAX}'
          value: '95'
          description: 'Threshold of interface bandwidth utilization for warning trigger in %. Can be used with interface name as context.'
          config:
            type: TEXT
            priority: '16'
            section_name: Thresholds
            label: 'Interface bandwidth usage warning threshold (%)'
            description: 'Threshold of interface bandwidth utilization for warning trigger in %. Can be used with interface name as context. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$SDWAN.HEALTH.ID.MATCHES}'
          value: '.*'
          description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '51'
            section_name: Filters
            label: 'SD-WAN health ID filter (include)'
            description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.HEALTH.ID.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '52'
            section_name: Filters
            label: 'SD-WAN health ID filter (exclude)'
            description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.HEALTH.IF.CONTROL}'
          value: '1'
          description: 'Macro for the interface state for "Link down" trigger. Can be used with interface name as context.'
          config:
            type: TEXT
            priority: '50'
            section_name: Other
            label: 'SD-WAN health interface control'
            description: 'Macro for the interface state for "Link down" trigger. Can be used with interface name as context.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$SDWAN.HEALTH.IF.LOSS.WARN}'
          value: '20'
          description: 'Threshold of packets loss for warning trigger in %. Can be used with interface name as context.'
          config:
            type: TEXT
            priority: '59'
            section_name: Thresholds
            label: 'SD-WAN health interface loss warning'
            description: 'Threshold of packets loss for warning trigger in %. Can be used with interface name as context. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$SDWAN.HEALTH.IFNAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '55'
            section_name: Filters
            label: 'SD-WAN health interface name filter (include)'
            description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.HEALTH.IFNAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '56'
            section_name: Filters
            label: 'SD-WAN health interface name filter (exclude)'
            description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.HEALTH.NAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '53'
            section_name: Filters
            label: 'SD-WAN health name filter (include)'
            description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.HEALTH.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '54'
            section_name: Filters
            label: 'SD-WAN health name filter (exclude)'
            description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.HEALTH.STATUS.MATCHES}'
          value: '.*'
          description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '57'
            section_name: Filters
            label: 'SD-WAN health status filter (include)'
            description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.HEALTH.STATUS.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '58'
            section_name: Filters
            label: 'SD-WAN health status filter (exclude)'
            description: 'This macro is used in SD-WAN health-checks discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.MEMBER.ID.MATCHES}'
          value: '.*'
          description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '42'
            section_name: Filters
            label: 'SD-WAN member ID filter (include)'
            description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.MEMBER.ID.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '43'
            section_name: Filters
            label: 'SD-WAN member ID filter (exclude)'
            description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.MEMBER.IF.CONTROL}'
          value: '1'
          description: 'Macro for the interface state for "Link down" trigger. Can be used with interface name as context.'
          config:
            type: TEXT
            priority: '41'
            section_name: Other
            label: 'SD-WAN member interface control'
            description: 'Macro for the interface state for "Link down" trigger. Can be used with interface name as context.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$SDWAN.MEMBER.NAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '44'
            section_name: Filters
            label: 'SD-WAN member name filter (include)'
            description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.MEMBER.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '45'
            section_name: Filters
            label: 'SD-WAN member name filter (exclude)'
            description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.MEMBER.STATUS.MATCHES}'
          value: '.*'
          description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '46'
            section_name: Filters
            label: 'SD-WAN member status filter (include)'
            description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.MEMBER.STATUS.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '47'
            section_name: Filters
            label: 'SD-WAN member status filter (exclude)'
            description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.MEMBER.ZONE.MATCHES}'
          value: '.*'
          description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '48'
            section_name: Filters
            label: 'SD-WAN member zone filter (include)'
            description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SDWAN.MEMBER.ZONE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '49'
            section_name: Filters
            label: 'SD-WAN member zone filter (exclude)'
            description: 'This macro is used in SD-WAN members discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SERVICE.EXPIRY.WARN}'
          value: '7'
          description: 'Number of days until the license expires.'
          config:
            type: TEXT
            priority: '33'
            section_name: Thresholds
            label: 'Service expiry warning'
            description: 'Number of days until the license expires.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$SERVICE.KEY.MATCHES}'
          value: '.*'
          description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '35'
            section_name: Filters
            label: 'Service key filter (include)'
            description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SERVICE.KEY.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '36'
            section_name: Filters
            label: 'Service key filter (exclude)'
            description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SERVICE.LICENSE.CONTROL}'
          value: '1'
          description: 'This macro is used in Service discovery. Can be used with interface name as context.'
          config:
            type: TEXT
            priority: '34'
            section_name: Filters
            label: 'Service license control'
            description: 'This macro is used in Service discovery. Can be used with interface name as context.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$SERVICE.STATUS.MATCHES}'
          value: '.*'
          description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '37'
            section_name: Filters
            label: 'Service status filter (include)'
            description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SERVICE.STATUS.NOT_MATCHES}'
          value: (no_support|no_license)
          description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '38'
            section_name: Filters
            label: 'Service status filter (exclude)'
            description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SERVICE.TYPE.MATCHES}'
          value: '.*'
          description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '39'
            section_name: Filters
            label: 'Service type filter (include)'
            description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
        - macro: '{$SERVICE.TYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
          config:
            type: TEXT
            priority: '40'
            section_name: Filters
            label: 'Service type filter (exclude)'
            description: 'This macro is used in Service discovery. Can be overridden on the host or linked template level.'
      dashboards:
        - uuid: 9f2a0d4b3df041419067e2c10c3e8689
          name: 'FortiGate: General'
          pages:
            - name: Overview
              widgets:
                - type: item
                  name: 'Port availability'
                  width: '12'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FFCA28
                    - type: STRING
                      name: description
                      value: Port
                    - type: INTEGER
                      name: desc_bold
                      value: '1'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: 'net.tcp.service["{$FGATE.SCHEME}","{$FGATE.API.FQDN}","{$FGATE.API.PORT}"]'
                    - type: INTEGER
                      name: show.0
                      value: '1'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: thresholds.0.color
                      value: FF465C
                    - type: STRING
                      name: thresholds.0.threshold
                      value: '0'
                    - type: STRING
                      name: thresholds.1.color
                      value: 0EC9AC
                    - type: STRING
                      name: thresholds.1.threshold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_size
                      value: '35'
                - type: item
                  name: 'Number of CPUs'
                  'y': '2'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.cpu.num
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: STRING
                      name: value_color
                      value: 1E88E5
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: gauge
                  name: 'CPU utilization'
                  'y': '4'
                  width: '24'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: '{ITEM.DESCRIPTION}'
                    - type: INTEGER
                      name: desc_size
                      value: '8'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.cpu.util
                    - type: STRING
                      name: thresholds.0.color
                      value: 0EC9AC
                    - type: STRING
                      name: thresholds.0.threshold
                      value: '0'
                    - type: STRING
                      name: thresholds.1.color
                      value: FFD54F
                    - type: STRING
                      name: thresholds.1.threshold
                      value: '80'
                    - type: STRING
                      name: thresholds.2.color
                      value: FF465C
                    - type: STRING
                      name: thresholds.2.threshold
                      value: '90'
                    - type: INTEGER
                      name: th_show_arc
                      value: '1'
                    - type: INTEGER
                      name: th_show_labels
                      value: '1'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_size
                      value: '15'
                    - type: INTEGER
                      name: value_size
                      value: '15'
                - type: svggraph
                  name: 'Disk usage'
                  'y': '8'
                  width: '36'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color
                      value: 1976D2
                    - type: STRING
                      name: ds.0.items.0
                      value: fgate.item.fs_total
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '1'
                    - type: INTEGER
                      name: ds.0.width
                      value: '6'
                    - type: STRING
                      name: ds.1.color
                      value: 4CAF50
                    - type: STRING
                      name: ds.1.items.0
                      value: fgate.item.fs_free
                    - type: STRING
                      name: lefty_min
                      value: '0'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: INTEGER
                      name: legend_statistic
                      value: '1'
                    - type: STRING
                      name: reference
                      value: DEABC
                    - type: STRING
                      name: time_period.from
                      value: now-1d
                    - type: INTEGER
                      name: working_time
                      value: '1'
                - type: item
                  name: 'API availability'
                  x: '12'
                  width: '12'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: FFCA28
                    - type: STRING
                      name: description
                      value: API
                    - type: INTEGER
                      name: desc_bold
                      value: '1'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.api.status
                    - type: INTEGER
                      name: show.0
                      value: '1'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: thresholds.0.color
                      value: FF465C
                    - type: STRING
                      name: thresholds.0.threshold
                      value: '0'
                    - type: STRING
                      name: thresholds.1.color
                      value: 0EC9AC
                    - type: STRING
                      name: thresholds.1.threshold
                      value: '1'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_size
                      value: '35'
                - type: item
                  name: 'Total memory'
                  x: '12'
                  'y': '2'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '40'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.memory.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: STRING
                      name: units
                      value: B
                    - type: INTEGER
                      name: units_bold
                      value: '0'
                    - type: STRING
                      name: units_color
                      value: 1E88E5
                    - type: STRING
                      name: value_color
                      value: 1E88E5
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: item
                  name: Uptime
                  x: '24'
                  width: '12'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: bg_color
                      value: 1E88E5
                    - type: STRING
                      name: description
                      value: Uptime
                    - type: INTEGER
                      name: desc_bold
                      value: '1'
                    - type: STRING
                      name: desc_color
                      value: FFFFFF
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.uptime
                    - type: INTEGER
                      name: show.0
                      value: '1'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: INTEGER
                      name: units_bold
                      value: '0'
                    - type: STRING
                      name: value_color
                      value: FFFFFF
                    - type: INTEGER
                      name: value_size
                      value: '35'
                - type: item
                  name: 'Total disk space'
                  x: '24'
                  'y': '2'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '40'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.fs.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: STRING
                      name: units
                      value: B
                    - type: INTEGER
                      name: units_bold
                      value: '0'
                    - type: STRING
                      name: units_color
                      value: 1E88E5
                    - type: STRING
                      name: value_color
                      value: 1E88E5
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: gauge
                  name: 'Memory utilization'
                  x: '24'
                  'y': '4'
                  width: '24'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: '{ITEM.DESCRIPTION}'
                    - type: INTEGER
                      name: desc_size
                      value: '8'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.memory.util
                    - type: STRING
                      name: thresholds.0.color
                      value: 0EC9AC
                    - type: STRING
                      name: thresholds.0.threshold
                      value: '0'
                    - type: STRING
                      name: thresholds.1.color
                      value: FFD54F
                    - type: STRING
                      name: thresholds.1.threshold
                      value: '70'
                    - type: STRING
                      name: thresholds.2.color
                      value: FF465C
                    - type: STRING
                      name: thresholds.2.threshold
                      value: '90'
                    - type: INTEGER
                      name: th_show_arc
                      value: '1'
                    - type: INTEGER
                      name: th_show_labels
                      value: '1'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_size
                      value: '15'
                    - type: INTEGER
                      name: value_size
                      value: '15'
                - type: item
                  name: 'Serial Number'
                  x: '36'
                  width: '18'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '20'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.device.serialnumber
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: INTEGER
                      name: value_size
                      value: '40'
                - type: item
                  name: Name
                  x: '36'
                  'y': '2'
                  width: '18'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '20'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.name
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: INTEGER
                      name: value_size
                      value: '40'
                - type: problems
                  x: '36'
                  'y': '8'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: acknowledgement_status
                      value: '1'
                    - type: STRING
                      name: reference
                      value: BAAAA
                    - type: INTEGER
                      name: show
                      value: '3'
                    - type: INTEGER
                      name: show_opdata
                      value: '2'
                    - type: INTEGER
                      name: show_tags
                      value: '1'
                    - type: STRING
                      name: tag_priority
                      value: scope
                - type: gauge
                  name: 'Disk utilization'
                  x: '48'
                  'y': '4'
                  width: '24'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: '{ITEM.DESCRIPTION}'
                    - type: INTEGER
                      name: desc_size
                      value: '8'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.fs.util
                    - type: STRING
                      name: thresholds.0.color
                      value: 0EC9AC
                    - type: STRING
                      name: thresholds.0.threshold
                      value: '0'
                    - type: STRING
                      name: thresholds.1.color
                      value: FFD54F
                    - type: STRING
                      name: thresholds.1.threshold
                      value: '60'
                    - type: STRING
                      name: thresholds.2.color
                      value: FF465C
                    - type: STRING
                      name: thresholds.2.threshold
                      value: '80'
                    - type: INTEGER
                      name: th_show_arc
                      value: '1'
                    - type: INTEGER
                      name: th_show_labels
                      value: '1'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_size
                      value: '15'
                    - type: INTEGER
                      name: value_size
                      value: '15'
                - type: item
                  name: Firmware
                  x: '54'
                  width: '18'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '20'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.device.firmware
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: INTEGER
                      name: value_size
                      value: '40'
                - type: item
                  name: Model
                  x: '54'
                  'y': '2'
                  width: '18'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '20'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'FortiGate by HTTP'
                        key: fgate.device.model
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: units_show
                      value: '0'
                    - type: INTEGER
                      name: value_size
                      value: '40'
        - uuid: a1c7206d9312486b9d09dc9ef34ed98e
          name: 'FortiGate: Statistics'
          pages:
            - name: 'System performance'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'FortiGate: CPU utilization'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'FortiGate: Disk usage'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'FortiGate: Memory utilization'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'FortiGate: Disk utilization'
                    - type: STRING
                      name: reference
                      value: AAAAD
            - name: 'Network interfaces'
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '7'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'Interface [{#IFNAME}({#IFALIAS})]: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAE
            - name: 'SD-WAN statistics'
              widgets:
                - type: graphprototype
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graphprototype
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Packets statistics'
                    - type: STRING
                      name: reference
                      value: AAAAH
                - type: graphprototype
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'SD-WAN [{#ZONE}]:[{#NAME}]: Bandwidth'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graphprototype
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'SD-WAN [{#NAME}]:[{#IFNAME}]: Performance'
                    - type: STRING
                      name: reference
                      value: AAAAI
            - name: 'Firewall statistics'
              widgets:
                - type: graphprototype
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'FW Policy [{#FWNAME}]: Active sessions'
                    - type: STRING
                      name: reference
                      value: AAAAJ
                - type: graphprototype
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'FW Policy [{#FWNAME}]: Policy processing'
                    - type: STRING
                      name: reference
                      value: AAAAL
                - type: graphprototype
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'FortiGate by HTTP'
                        name: 'FW Policy [{#FWNAME}]: Hits into the policy'
                    - type: STRING
                      name: reference
                      value: AAAAK
      valuemaps:
        - uuid: 8b0c51b152b04ba690cd13e43a2c90d9
          name: 'Firewall policy action'
          mappings:
            - value: '0'
              newvalue: accept
            - value: '1'
              newvalue: deny
            - value: '2'
              newvalue: ipsec
            - value: '10'
              newvalue: unknown
        - uuid: 2285b34278df448ab2ba2276913c0b77
          name: 'Firewall policy status'
          mappings:
            - value: '0'
              newvalue: enable
            - value: '1'
              newvalue: disable
        - uuid: 7aa1df8cbdda4d3aa5bad0af95733a06
          name: 'Interface status'
          mappings:
            - value: '0'
              newvalue: up
            - value: '1'
              newvalue: down
            - value: '2'
              newvalue: error
            - value: '10'
              newvalue: unknown
        - uuid: 6d6a2211c6e64ecfb00838886750912b
          name: 'Interface type'
          mappings:
            - value: '0'
              newvalue: physical
            - value: '1'
              newvalue: vlan
            - value: '2'
              newvalue: aggregate
            - value: '3'
              newvalue: redundant
            - value: '4'
              newvalue: tunnel
            - value: '5'
              newvalue: vdom-link
            - value: '6'
              newvalue: loopback
            - value: '7'
              newvalue: switch
            - value: '8'
              newvalue: vap-switch
            - value: '9'
              newvalue: wl-mesh
            - value: '10'
              newvalue: fext-wan
            - value: '11'
              newvalue: vxlan
            - value: '12'
              newvalue: geneve
            - value: '13'
              newvalue: hdlc
            - value: '14'
              newvalue: switch-vlan
            - value: '15'
              newvalue: emac-vlan
            - value: '16'
              newvalue: ssl
            - value: '17'
              newvalue: lan-extension
            - value: '30'
              newvalue: unknown
        - uuid: 0e225b17b2e543f18fea31366d9b6286
          name: 'License status'
          mappings:
            - value: '0'
              newvalue: Activated
            - value: '1'
              newvalue: Licensed
            - value: '2'
              newvalue: Registered
            - value: '3'
              newvalue: 'Evaluation License'
            - value: '4'
              newvalue: 'Free License'
            - value: '5'
              newvalue: Valid
            - value: '6'
              newvalue: 'Activation Pending (View Confirmation Email)'
            - value: '7'
              newvalue: 'Error Logging In'
            - value: '8'
              newvalue: 'Not Activated'
            - value: '9'
              newvalue: 'Login in Progress'
            - value: '10'
              newvalue: Expired
            - value: '11'
              newvalue: 'Expires Soon'
            - value: '12'
              newvalue: 'Free License (exhausted)'
            - value: '13'
              newvalue: 'Licensed (exhausted)'
            - value: '14'
              newvalue: 'Not Licensed'
            - value: '15'
              newvalue: 'Not Supported'
            - value: '16'
              newvalue: 'Not Registered'
            - value: '17'
              newvalue: Pending
            - value: '18'
              newvalue: Unavailable
            - value: '19'
              newvalue: 'Manual Update'
            - value: '20'
              newvalue: 'Push Update'
            - value: '21'
              newvalue: 'Scheduled Update'
            - value: '22'
              newvalue: Expired
            - value: '23'
              newvalue: Expired
            - value: '24'
              newvalue: 'Expires Soon'
            - value: '25'
              newvalue: 'Grace Period'
            - value: '26'
              newvalue: Invalid
            - value: '27'
              newvalue: 'Validation in Progress'
            - value: '28'
              newvalue: 'Validation Overdue'
            - value: '30'
              newvalue: Unknown
        - uuid: 76ac7f91b2184689b19dc838cde49ade
          name: 'Link state'
          mappings:
            - value: '0'
              newvalue: down
            - value: '1'
              newvalue: up
        - uuid: 176db78d3aa34c92893300d56eda5737
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: down
            - value: '1'
              newvalue: up
        - uuid: 3b62f79c5a664465897a372e833af713
          name: 'Service status'
          mappings:
            - value: '0'
              newvalue: enable
            - value: '1'
              newvalue: disable
            - value: '10'
              newvalue: unknown
    - uuid: 4e1e9372a5fe4297936210bc4fc4b1c0
      template: 'GCP by HTTP'
      name: 'GCP by HTTP'
      description: |
        Discover GCP Compute Engine/Cloud SQL Instances and Compute Engine project quota metrics.
        Don't forget to read the README.md for the correct setup of the template.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Overview
        
        This template is designed to monitor Google Cloud Platform (GCP) using Zabbix.
        It works without any external scripts and uses the script item.
        
        The template currently supports the discovery of [Compute Engine](https://cloud.google.com/compute)/[Cloud SQL](https://cloud.google.com/sql)/[Cloud Run services](https://cloud.google.com/run) and Compute Engine project quota metrics.
        
        
        ## Setup
        
        1. Enable the Stackdriver Monitoring API for the GCP project you wish to monitor.
        >More on [enabling Monitoring API](https://cloud.google.com/monitoring/api/enable-api).
        2. Create a service account in Google Cloud Console for the same GCP project.
        >More on [managing service accounts](https://cloud.google.com/iam/docs/creating-managing-service-accounts).
        3. Create and download the service account key in JSON format.
        >More on [service account keys](https://cloud.google.com/iam/docs/creating-managing-service-account-keys).
        4. If you want to monitor Cloud SQL services - don't forget to activate the Cloud SQL Admin API.
        >More on [Cloud SQL Admin API](https://cloud.google.com/sql/docs/mysql/admin-api).
        5. For monitoring Cloud Run services - activate the Cloud Run Admin API.
        >More on [Cloud Run APIs](https://docs.cloud.google.com/run/docs/apis).
        6. Copy the `project_id`, `private_key_id`, `private_key`, `client_email` from the JSON key file and add them to their corresponding host wizard configuration fields `GCP project ID`, `Private key id`, `Private key data`, `Client e-mail` in host wizard configuration fields.
        
        **Notes**
        
            - Make sure that you're creating the Google Cloud Console service account using the credentials with the Project Owner/Project IAM Admin/Service Account Admin role.
        
            - The service account JSON key file can only be downloaded **once**: regenerate it if the previous key has been lost.
        
            - The service account should have Project Viewer permissions or granular permissions for the GCP Compute Engine API/GCP Cloud SQL/Cloud Run Viewer.
        
            - You can copy and paste `private_key` string data from the Service Account JSON key file as is, or replace the new line metasymbol (`\n`) with actual line breaks.
        
        >Refer to the [vendor documentation](https://cloud.google.com/iam/docs/manage-access-service-accounts) on managing access to service accounts.
        
        **IMPORTANT**
        
             - The Zabbix secret authorization token (used for GCP API authentication) is defined as a plain text in host prototype settings by default due to template export/import limitations. It is highly recommended to change the user macro `{$GCP.AUTH.TOKEN}` value type to `SECRET` for all host prototypes after importing the *GCP by HTTP* template.
        
             - All the discovered instances/quotas/metrics are related to a particular GCP project. To monitor several GCP projects, create their corresponding service accounts and Zabbix hosts.
        
             - The GCP Access Token is available for 1 hour (3600 seconds) after the generation request.
        
             - To avoid GCP token inconsistencies between the Zabbix database and Zabbix server configuration cache, do not set the Zabbix server configuration parameter `CacheUpdateFrequency` above 45 minutes, and do not set the GCP authorization item update interval above 1 hour (the maximum `CacheUpdateFrequency` value).
        
        More on metrics and used API methods:
        
          - [Compute Engine](https://docs.cloud.google.com/monitoring/api/metrics_gcp_c#gcp-compute)
        
          - [Cloud SQL](https://docs.cloud.google.com/monitoring/api/metrics_gcp_c#gcp-cloudsql)
        
          - [Cloud Run](https://docs.cloud.google.com/monitoring/api/metrics_gcp_p_z#gcp-run)
      vendor:
        name: Zabbix
        version: 8.0-3
      groups:
        - name: Templates/Cloud
      items:
        - uuid: b003e61fbede488a957b6c866ffaa9ba
          name: 'Authorization errors check'
          type: DEPENDENT
          key: gcp.auth.err.check
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
          master_item:
            key: gcp.authorization
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 74c0e16244314ab4a920e32faca50444
              expression: 'length(last(/GCP by HTTP/gcp.auth.err.check)) > 0'
              name: 'GCP: Authorization has failed'
              priority: AVERAGE
              description: |
                GCP: Authorization has failed.
                Check the authorization parameters and GCP API availability from a network segment, where Zabbix-server/proxy is located.
              tags:
                - tag: scope
                  value: availability
        - uuid: 5cc3faa82f404b38b513958f323f3d7d
          name: Authorization
          type: SCRIPT
          key: gcp.authorization
          delay: '{$GCP.AUTH.FREQUENCY}'
          history: '0'
          value_type: TEXT
          params: |
            var auth_url = 'https://oauth2.googleapis.com/token',
            	issued = Math.floor(new Date().getTime() / 1000),
            	expires = issued + 3600,
            	endpoint = 'https://www.googleapis.com/auth/',
            	scopes = ['cloud-platform', 'monitoring', 'compute.readonly', 'sqlservice.admin'],
            	scope = scopes.map(function (path) { return endpoint + path; }).join(' ');
            
            function base64url(source) {
            	encodedSource = btoa(source);
            	encodedSource = encodedSource.replace(/=+$/, '');
            	encodedSource = encodedSource.replace(/\+/g, '-');
            	encodedSource = encodedSource.replace(/\//g, '_');
            
            	return encodedSource;
            }
            
            function fromHex(hex) {
            	var utf8array = [];
            
            	if (hex.length % 2)
            		throw 'Invalid length of a hex string!';
            	for (var i = 0; i < hex.length; i += 2) {
            		utf8array.push(parseInt(hex.substr(i, 2), 16));
            	}
            	return new Uint8Array(utf8array);
            }
            
            function encodeJWT(headers, payload, secret) {
            	unsignedToken = base64url(JSON.stringify(headers)) + '.' + base64url(JSON.stringify(payload));
            	jwt = unsignedToken + '.' + base64url(fromHex(sign('sha256', secret, unsignedToken)));
            	return jwt;
            }
            
            function exchangeJwtForAccessToken(signed_jwt) {
            
            	var request = new HttpRequest(),
            		params = {
            			grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
            			assertion: signed_jwt
            		}
            	if (typeof script_params.proxy !== 'undefined' && script_params.proxy !== '') {
            		request.setProxy(script_params.proxy);
            	};
            	var response = request.post(auth_url, JSON.stringify(params));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + auth_url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            
            
            	if (typeof response.access_token !== 'undefined') {
            		return response.access_token;
            	}
            	else {
            		throw 'No access token in the JWT exchange request.';
            	}
            }
            
            function checkParams(params) {
            	['private_key_id', 'private_key', 'email'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	return params;
            }
            
            var script_params = checkParams(JSON.parse(value)),
            	headers = {
            		alg: 'RS256',
            		kid: script_params.private_key_id,
            		typ: 'JWT'
            	},
            	payload = {
            		iss: script_params.email,
            		sub: script_params.email,
            		aud: auth_url,
            		iat: issued,
            		exp: expires,
            		scope: scope
            	};
            
            try {
            	jwt = encodeJWT(headers, payload, script_params.private_key);
            	token = exchangeJwtForAccessToken(jwt);
            	return token;
            }
            catch (err) {
            	Zabbix.log(3, '[ GCP Auth] ERROR: ' + err);
            	error_msg = 'Failed to get data from API: ' + err;
            	return JSON.stringify({ error: error_msg });
            }
          description: |
            Google Cloud Platform REST authorization with service account authentication parameters and temporary-generated RSA-based JWT-token usage.
            The necessary scopes are pre-defined.
            Returns a signed authorization token with 1 hour lifetime; it is required only once, and is used for all the dependent script items.
            Check the template documentation for the details.
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: email
              value: '{$GCP.CLIENT.EMAIL}'
            - name: private_key
              value: '{$GCP.PRIVATE.KEY}'
            - name: private_key_id
              value: '{$GCP.PRIVATE.KEY.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
          tags:
            - tag: component
              value: raw
        - uuid: 3ac5c859692140c0b686e772efa05032
          name: 'Instances get'
          type: DEPENDENT
          key: gcp.cloudsql.instances.get
          history: '0'
          value_type: TEXT
          description: 'GCP Cloud SQL: Instances get.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var token = value;
                  
                  function getField(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			throw 'Required field "' + path + '" is not present in data received.';
                  		}
                  		data = data[step];
                  	}
                  	return data;
                  }
                  
                  function getFieldBool(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			return false;
                  		}
                  		data = data[step];
                  	}
                  	return true;
                  }
                  
                  function getHttpData(url, token) {
                  	var request = new HttpRequest(),
                  		proxy = '{$GCP.PROXY}';
                  
                  	if (proxy !== '{' + '$GCP.PROXY}' && proxy !== '') {
                  		request.setProxy(proxy);
                  	}
                  
                  	request.addHeader('Authorization: Bearer ' + token);
                  	request.addHeader('Content-Type: application/json');
                  
                  	var response = request.get(url);
                  
                  	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
                  
                  	if (response !== null) {
                  		try {
                  			response = JSON.parse(response);
                  		}
                  		catch (error) {
                  			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
                  		}
                  	}
                  
                  	if (typeof response !== 'object' || response === null) {
                  		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
                  	}
                  
                  	if (request.getStatus() !== 200) {
                  
                  		if (typeof (response.error && response.error.message) !== 'undefined') {
                  			throw response.error.message;
                  		}
                  		else {
                  			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
                  		}
                  	}
                  	return response;
                  }
                  
                  var project = '{$GCP.PROJECT.ID}';
                  
                  if (!project || project === '{' + '$GCP.PROJECT.ID}') {
                  	throw 'Error. Set the \{$GCP.PROJECT.ID\} macro value.';
                  }
                  
                  var inst_raw = getHttpData('https://sqladmin.googleapis.com/sql/v1beta4/projects/' + project + '/instances', token);
                  
                  if (Object.keys(inst_raw).length === 0) {
                  	return '[]';
                  }
                  
                  return JSON.stringify(getField(inst_raw, 'items').map(function (sql_inst) {
                  	obj = {
                  		name: getField(sql_inst, 'name'),
                  		token: value,
                  		zone: getField(sql_inst, 'settings.locationPreference.zone'),
                  		inst_type: getField(sql_inst, 'instanceType'),
                  		tier: getField(sql_inst, 'settings.tier'),
                  		project_id: getField(sql_inst, 'project'),
                  		db_type: getField(sql_inst, 'databaseInstalledVersion')
                  	};
                  
                  	obj.high_availability = (sql_inst.failoverReplica) ? true : false;
                  
                  	if (obj.db_type.match(/SQLSERVER*/)) {
                  		var mssql_audit = getField(sql_inst, 'settings.sqlServerAuditConfig');
                  
                  		obj.audited = (mssql_audit.bucket) ? true : false;
                  	}
                  
                  	if (obj.inst_type === 'READ_REPLICA_INSTANCE') {
                  		obj.master = getField(sql_inst, 'masterInstanceName');
                  	}
                  
                  	if (Array.isArray(sql_inst.ipAddresses)) {
                  		var int_addresses = sql_inst.ipAddresses.filter(function (addr) {
                  			return addr.type === 'PRIVATE';
                  		});
                  
                  		var ext_addresses = sql_inst.ipAddresses.filter(function (addr) {
                  			return addr.type === 'PRIMARY';
                  		});
                  
                  		obj.ip = getFieldBool(int_addresses, '0.ipAddress') ? int_addresses[0].ipAddress : '0.0.0.0';
                  		obj.ext_ip = getFieldBool(ext_addresses, '0.ipAddress') ? ext_addresses[0].ipAddress : '0.0.0.0';
                  	}
                  	else {
                  		obj.ip = '0.0.0.0';
                  		obj.ext_ip = '0.0.0.0';
                  	}
                  
                  	return obj;
                  }));
          master_item:
            key: gcp.authorization
          tags:
            - tag: component
              value: raw
        - uuid: 80687b35246b45ffa1be9d171f686e94
          name: 'MSSQL instances count'
          type: DEPENDENT
          key: gcp.cloudsql.instances.mssql_count
          description: 'GCP Cloud SQL MSSQL instances count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.db_type =~ ''SQLSERVER'')].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: 8ec94dff7a3b47998242d97a18cf0821
          name: 'MySQL instances count'
          type: DEPENDENT
          key: gcp.cloudsql.instances.mysql_count
          description: 'GCP Cloud SQL MySQL instances count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.db_type =~ ''MYSQL'')].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: de284dd30b2d4ecb9f7d0cf3ca80a094
          name: 'PostgreSQL instances count'
          type: DEPENDENT
          key: gcp.cloudsql.instances.pgsql_count
          description: 'GCP Cloud SQL PostgreSQL instances count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.db_type =~ ''POSTGRES'')].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: b926ba1901c5413396c1c071e6e76072
          name: 'Cloud SQL instances total'
          type: DEPENDENT
          key: gcp.cloudsql.instances.total
          description: 'GCP Cloud SQL instances total count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[*].length()'
          master_item:
            key: gcp.cloudsql.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: 58329c9a5b124b1990c94f15266e6edf
          name: 'Container-optimized GCE instances count'
          type: DEPENDENT
          key: gcp.gce.instances.cos_count
          description: 'GCP Compute Engine: count of instances with Container-Optimized OS used.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.i_type == ''container-optimized'')].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: 461e72fb7e104261831455ae3cc87358
          name: 'Instances get'
          type: DEPENDENT
          key: gcp.gce.instances.get
          history: '0'
          value_type: TEXT
          description: 'Get GCP Compute Engine instances.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var token = value;
                  
                  function getField(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			throw 'Required field "' + path + '" is not present in data received.';
                  		}
                  		data = data[step];
                  	}
                  	return data;
                  }
                  
                  function getFieldBool(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			return false;
                  		}
                  		data = data[step];
                  	}
                  	return true;
                  }
                  
                  function getHttpData(url, token) {
                  	var request = new HttpRequest(),
                  		proxy = '{$GCP.PROXY}';
                  
                  	if (proxy !== '{' + '$GCP.PROXY}' && proxy !== '') {
                  		request.setProxy(proxy);
                  	}
                  
                  	request.addHeader('Authorization: Bearer ' + token);
                  	request.addHeader('Content-Type: application/json');
                  
                  	var response = request.get(url);
                  
                  	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
                  
                  	if (response !== null) {
                  		try {
                  			response = JSON.parse(response);
                  		}
                  		catch (error) {
                  			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
                  		}
                  	}
                  
                  	if (typeof response !== 'object' || response === null) {
                  		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
                  	}
                  
                  	if (request.getStatus() !== 200) {
                  
                  		if (typeof (response.error && response.error.message) !== 'undefined') {
                  			throw response.error.message;
                  		}
                  		else {
                  			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
                  		}
                  	}
                  	return response;
                  }
                  
                  var project = '{$GCP.PROJECT.ID}';
                  
                  if (!project || project === '{' + '$GCP.PROJECT.ID}') {
                  	throw 'Error. Set the \{$GCP.PROJECT.ID\} macro value.';
                  }
                  
                  var result = getHttpData('https://compute.googleapis.com/compute/v1/projects/' + project + '/aggregated/instances', token),
                  	vms_raw = getField(result, 'items'),
                  	keys = Object.keys(vms_raw),
                  	arr = [];
                  
                  for (var i in keys) {
                  	if (typeof vms_raw[keys[i]].instances !== 'undefined') {
                  		var vm_prop = vms_raw[keys[i]].instances.map(function setProp(inst) {
                  			obj = {
                  				id: getField(inst, 'id'),
                  				name: getField(inst, 'name'),
                  				token: value,
                  				zone: keys[i].replace(/zones\//, ''),
                  				m_type: getField(inst, 'machineType').replace(/.*machineTypes\//g, ''),
                  				state: getField(inst, 'status'),
                  				project_id: '{$GCP.PROJECT.ID}',
                  				ip: getField(inst, 'networkInterfaces.0.networkIP'),
                  				integrity: getFieldBool(inst, 'shieldedInstanceConfig.enableIntegrityMonitoring') ? inst.shieldedInstanceConfig.enableIntegrityMonitoring : false
                  			};
                  
                  			obj.ext_ip = getFieldBool(inst, 'networkInterfaces.0.accessConfigs.0.natIP') ? inst.networkInterfaces[0].accessConfigs[0].natIP : '0.0.0.0';
                  			obj.i_type = getFieldBool(inst, 'labels.container-vm') ? 'container-optimized' : 'regular';
                  			return obj;
                  		});
                  		arr = arr.concat(vm_prop);
                  	}
                  }
                  return JSON.stringify(arr);
          master_item:
            key: gcp.authorization
          tags:
            - tag: component
              value: raw
        - uuid: a936207f9d914955b2e2140e953f22f2
          name: 'Regular GCE instances count'
          type: DEPENDENT
          key: gcp.gce.instances.regular_count
          description: 'GCP Compute Engine: Regular instances count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$[?(@.i_type == ''regular'')].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: 46eaeccd1f43466caadd44440da88568
          name: 'GCE instances total'
          type: DEPENDENT
          key: gcp.gce.instances.total
          description: 'GCP Compute Engine instances total count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[*].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.instances.get
          tags:
            - tag: component
              value: environment
        - uuid: c4f17331815345bcb0ac6ea98413b2b5
          name: 'Project quotas get'
          type: DEPENDENT
          key: gcp.gce.quotas.get
          history: '0'
          value_type: TEXT
          description: 'GCP Compute Engine resource quotas available for the particular project.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var token = value;
                  
                  function checkMacro(macro) {
                  	if (!macro || macro.match(/^\{\$.*\}$/)) {
                  		throw 'The GCP project id is not defined. Please, set the value for the \{$GCP.PROJECT.ID\} macro.';
                  	}
                  	return macro;
                  }
                  
                  function getField(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			throw 'Required field "' + path + '" is not present in data received.'
                  		}
                  		data = data[step];
                  	}
                  	return data;
                  }
                  
                  function getHttpData(url, token) {
                  	var request = new HttpRequest(),
                  		proxy = '{$GCP.PROXY}';
                  	if (proxy !== '{' + '$GCP.PROXY}' && proxy !== '') {
                  		request.setProxy(proxy);
                  	};
                  	request.addHeader('Authorization: Bearer ' + token);
                  	request.addHeader('Content-Type: application/json');
                  
                  	var response = request.get(url);
                  
                  	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
                  
                  	if (response !== null) {
                  		try {
                  			response = JSON.parse(response);
                  		}
                  		catch (error) {
                  			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
                  		}
                  	}
                  
                  	if (typeof response !== 'object' || response === null) {
                  		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
                  	}
                  
                  	if (request.getStatus() !== 200) {
                  		if (typeof (response.error && response.error.message) !== 'undefined') {
                  			throw response.error.message;
                  		}
                  		else {
                  			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
                  		}
                  	}
                  
                  	if (typeof response.quotas !== 'undefined') {
                  		return response;
                  	} else {
                  		throw 'No quotas array in API response';
                  	}
                  };
                  var project = checkMacro('{$GCP.PROJECT.ID}'),
                  	qts_raw = getHttpData('https://www.googleapis.com/compute/v1/projects/' + project, token),
                  	qts_lst = getField(qts_raw, 'quotas').map(function (qt) {
                  		obj = {
                  			metric: getField(qt, 'metric'),
                  			limit: getField(qt, 'limit'),
                  			usage: getField(qt, 'usage'),
                  			p_used: (qt.usage / qt.limit) * 100
                  		};
                  		return obj;
                  	});
                  
                  return JSON.stringify(qts_lst);
          master_item:
            key: gcp.authorization
          tags:
            - tag: component
              value: raw
        - uuid: 0cb00461c01045be989f086857baa968
          name: 'Cloud Run service total'
          type: DEPENDENT
          key: gcp.run.service.total
          description: 'GCP Cloud Run services total count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[*].length()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.run.services.get
          tags:
            - tag: component
              value: environment
        - uuid: 67d26f7e16494330ba29690da43a2a8b
          name: 'Cloud Run service get'
          type: DEPENDENT
          key: gcp.run.services.get
          history: '0'
          value_type: TEXT
          description: 'Get GCP Cloud Run services.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var token = value;
                  
                  function getField(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			throw 'Required field "' + path + '" is not present in data received.';
                  		}
                  		data = data[step];
                  	}
                  	return data;
                  }
                  
                  function getFieldBool(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			return false;
                  		}
                  		data = data[step];
                  	}
                  	return true;
                  }
                  
                  function getHttpData(url, token) {
                  	var request = new HttpRequest(),
                  		proxy = '{$GCP.PROXY}';
                  
                  	if (proxy !== '{' + '$GCP.PROXY}' && proxy !== '') {
                  		request.setProxy(proxy);
                  	}
                  
                  	request.addHeader('Authorization: Bearer ' + token);
                  	request.addHeader('Content-Type: application/json');
                  
                  	var response = request.get(url);
                  
                  	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
                  
                  	if (response !== null) {
                  		try {
                  			response = JSON.parse(response);
                  		}
                  		catch (error) {
                  			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
                  		}
                  	}
                  
                  	if (typeof response !== 'object' || response === null) {
                  		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
                  	}
                  
                  	if (request.getStatus() !== 200) {
                  
                  		if (typeof (response.error && response.error.message) !== 'undefined') {
                  			throw response.error.message;
                  		}
                  		else {
                  			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
                  		}
                  	}
                  	return response;
                  }
                  
                  var project = '{$GCP.PROJECT.ID}';
                  
                  if (!project || project === '{' + '$GCP.PROJECT.ID}') {
                  	throw 'Error. Set the \{$GCP.PROJECT.ID\} macro value.';
                  }
                  
                  var services = [],
                  	filter = '{$GCP.RUN.LOCATION.FILTER}';
                  
                  try {
                  	result = getHttpData('https://compute.googleapis.com/compute/v1/projects/' + encodeURIComponent(project) + '/regions?filter=' + encodeURIComponent(filter) + '&fields=items.name', token);
                  
                  	if (Object.keys(result).length === 0) {
                  		throw 'Cannot process filter regions. Please check the filter conditions.';
                  	}
                  
                  	locations = getField(result, 'items');
                  
                  	for (var i in locations) {
                  		location = getField(locations[i], 'name');
                  		response_run = getHttpData('https://run.googleapis.com/v2/projects/' + encodeURIComponent(project) + '/locations/' + encodeURIComponent(location) + '/services', token);
                  
                  		if (Object.keys(response_run).length !== 0 && response_run.services !== undefined) {
                  			response_run.services.forEach(function (service) {
                  				services.push({
                  					location: location,
                  					project_id: project,
                  					token: value,
                  					name: getField(service, 'name').split("/")[5],
                  					uid: getField(service, 'uid'),
                  					launch_stage: getField(service, 'launchStage'),
                  					container: getField(service, 'template.containers'),
                  					condition: getField(service, 'terminalCondition.state')
                  				});
                  			});
                  
                  		}
                  
                  	}
                  	return JSON.stringify(services);
                  }
                  catch (err) {
                  	Zabbix.log(3, '[ GCP API] ERROR: ' + err);
                  	error_msg = 'Failed to get data from GCP API: ' + err;
                  	return JSON.stringify({ error: error_msg });
                  }
          master_item:
            key: gcp.authorization
          tags:
            - tag: component
              value: raw
      discovery_rules:
        - uuid: f210e8e38c194c65b30e74610ec2b86f
          name: 'GCP Cloud SQL: MSSQL instances discovery'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.inst.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                value: 'SQLSERVER.*'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.MSSQL.INST.NAME.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.MSSQL.INST.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.MSSQL.INST.TYPE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.MSSQL.INST.TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.MSSQL.ZONE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.MSSQL.ZONE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Cloud SQL: MSSQL instances discovery.'
          host_prototypes:
            - uuid: edc6ab9314ed410b8a3cf6bfedff51ab
              host: '{#GCP.PROJECT.ID}-{#CLOUD_SQL.INSTANCE.NAME}'
              name: '{#CLOUD_SQL.INSTANCE.NAME}'
              group_links:
                - group:
                    name: Databases
              templates:
                - name: 'GCP Cloud SQL MSSQL by HTTP'
              macros:
                - macro: '{$CLOUD_SQL.HIGH.AVAILABILITY}'
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                  description: 'GCP Cloud SQL instance high availability definition. Required for metrics filtration.'
                - macro: '{$CLOUD_SQL.MSSQL.AUDITED}'
                  value: '{#MSSQL.AUDITED}'
                  description: 'GCP Cloud SQL MSSQL audit enabled definition. Required for metrics filtration.'
                - macro: '{$GCP.AUTH.TOKEN}'
                  value: '{#GCP.AUTH.TOKEN}'
                  description: 'Google Cloud Platform authorization token.'
                - macro: '{$GCP.PROJECT.ID}'
                  value: '{#GCP.PROJECT.ID}'
                  description: 'GCP Project Id.'
              tags:
                - tag: audit
                  value: '{#MSSQL.AUDITED}'
                - tag: db-version
                  value: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                - tag: high-availability
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                - tag: instance-type
                  value: '{#CLOUD_SQL.INSTANCE.TYPE}'
                - tag: project
                  value: '{#GCP.PROJECT.ID}'
                - tag: service
                  value: cloudsql
                - tag: service
                  value: gcp
                - tag: service
                  value: mssql
                - tag: tier
                  value: '{#CLOUD_SQL.INSTANCE.TIER}'
                - tag: zone
                  value: '{#CLOUD_SQL.INSTANCE.ZONE}'
              custom_interfaces: 'YES'
              interfaces:
                - default: 'NO'
                  ip: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
                  dns: external.ip
                - ip: '{#CLOUD_SQL.INSTANCE.IP}'
                  dns: internal.ip
          master_item:
            key: gcp.cloudsql.instances.get
          lld_macro_paths:
            - lld_macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
              path: $.db_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
              path: $.ext_ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
              path: $.high_availability
            - lld_macro: '{#CLOUD_SQL.INSTANCE.IP}'
              path: $.ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.NAME}'
              path: $.name
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TIER}'
              path: $.tier
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
              path: $.inst_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
              path: $.zone
            - lld_macro: '{#CLOUD_SQL.MASTER}'
              path: $.master
            - lld_macro: '{#GCP.AUTH.TOKEN}'
              path: $.token
            - lld_macro: '{#GCP.PROJECT.ID}'
              path: $.project_id
            - lld_macro: '{#MSSQL.AUDITED}'
              path: $.audited
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          overrides:
            - name: 'MSSQL replica'
              step: '1'
              filter:
                conditions:
                  - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                    value: READ_REPLICA_INSTANCE
                  - macro: '{#CLOUD_SQL.MASTER}'
                    operator: EXISTS
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  tags:
                    - tag: master_instance
                      value: '{#CLOUD_SQL.MASTER}'
                  templates:
                    - name: 'GCP Cloud SQL MSSQL Replica by HTTP'
        - uuid: 3fdd2543936a4587b1bfb5dabb30c1f6
          name: 'GCP Cloud SQL: MySQL instances discovery'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.inst.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                value: 'MYSQL.*'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.MYSQL.INST.NAME.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.MYSQL.INST.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.MYSQL.INST.TYPE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.MYSQL.INST.TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.MYSQL.ZONE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.MYSQL.ZONE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Cloud SQL: MySQL instances discovery.'
          host_prototypes:
            - uuid: 8b2556b881b14b86a98f90a447ae9734
              host: '{#GCP.PROJECT.ID}-{#CLOUD_SQL.INSTANCE.NAME}'
              name: '{#CLOUD_SQL.INSTANCE.NAME}'
              group_links:
                - group:
                    name: Databases
              templates:
                - name: 'GCP Cloud SQL MySQL by HTTP'
              macros:
                - macro: '{$CLOUD_SQL.HIGH.AVAILABILITY}'
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                  description: 'GCP Cloud SQL instance high availability definition.'
                - macro: '{$GCP.AUTH.TOKEN}'
                  value: '{#GCP.AUTH.TOKEN}'
                  description: 'Google Cloud Platform authorization token.'
                - macro: '{$GCP.PROJECT.ID}'
                  value: '{#GCP.PROJECT.ID}'
                  description: 'GCP Project Id.'
              tags:
                - tag: db-version
                  value: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                - tag: high-availability
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                - tag: instance-type
                  value: '{#CLOUD_SQL.INSTANCE.TYPE}'
                - tag: project
                  value: '{#GCP.PROJECT.ID}'
                - tag: service
                  value: cloudsql
                - tag: service
                  value: gcp
                - tag: service
                  value: mysql
                - tag: tier
                  value: '{#CLOUD_SQL.INSTANCE.TIER}'
                - tag: zone
                  value: '{#CLOUD_SQL.INSTANCE.ZONE}'
              custom_interfaces: 'YES'
              interfaces:
                - default: 'NO'
                  ip: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
                  dns: external.ip
                - ip: '{#CLOUD_SQL.INSTANCE.IP}'
                  dns: internal.ip
          master_item:
            key: gcp.cloudsql.instances.get
          lld_macro_paths:
            - lld_macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
              path: $.db_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
              path: $.ext_ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
              path: $.high_availability
            - lld_macro: '{#CLOUD_SQL.INSTANCE.IP}'
              path: $.ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.NAME}'
              path: $.name
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TIER}'
              path: $.tier
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
              path: $.inst_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
              path: $.zone
            - lld_macro: '{#CLOUD_SQL.MASTER}'
              path: $.master
            - lld_macro: '{#GCP.AUTH.TOKEN}'
              path: $.token
            - lld_macro: '{#GCP.PROJECT.ID}'
              path: $.project_id
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          overrides:
            - name: 'MySQL replica'
              step: '1'
              filter:
                conditions:
                  - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                    value: READ_REPLICA_INSTANCE
                  - macro: '{#CLOUD_SQL.MASTER}'
                    operator: EXISTS
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  tags:
                    - tag: master_instance
                      value: '{#CLOUD_SQL.MASTER}'
                  templates:
                    - name: 'GCP Cloud SQL MySQL Replica by HTTP'
        - uuid: 606ba15087894f268f4b626590b7a9d0
          name: 'GCP Cloud SQL: PostgreSQL instances discovery'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.inst.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                value: 'POSTGRES.*'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.PGSQL.INST.NAME.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.NAME}'
                value: '{$GCP.PGSQL.INST.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.PGSQL.INST.TYPE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                value: '{$GCP.PGSQL.INST.TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.PGSQL.ZONE.MATCHES}'
              - macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
                value: '{$GCP.PGSQL.ZONE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Cloud SQL: PostgreSQL instances discovery.'
          host_prototypes:
            - uuid: 0fbbc550fda448d39aad6d0710f28b6a
              host: '{#GCP.PROJECT.ID}-{#CLOUD_SQL.INSTANCE.NAME}'
              name: '{#CLOUD_SQL.INSTANCE.NAME}'
              group_links:
                - group:
                    name: Databases
              templates:
                - name: 'GCP Cloud SQL PostgreSQL by HTTP'
              macros:
                - macro: '{$CLOUD_SQL.HIGH.AVAILABILITY}'
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                  description: 'GCP Cloud SQL instance high availability definition.'
                - macro: '{$GCP.AUTH.TOKEN}'
                  value: '{#GCP.AUTH.TOKEN}'
                  description: 'Google Cloud Platform authorization token.'
                - macro: '{$GCP.PROJECT.ID}'
                  value: '{#GCP.PROJECT.ID}'
                  description: 'GCP project id.'
              tags:
                - tag: db-version
                  value: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
                - tag: high-availability
                  value: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
                - tag: instance-type
                  value: '{#CLOUD_SQL.INSTANCE.TYPE}'
                - tag: project
                  value: '{#GCP.PROJECT.ID}'
                - tag: service
                  value: cloudsql
                - tag: service
                  value: gcp
                - tag: service
                  value: pgsql
                - tag: tier
                  value: '{#CLOUD_SQL.INSTANCE.TIER}'
                - tag: zone
                  value: '{#CLOUD_SQL.INSTANCE.ZONE}'
              custom_interfaces: 'YES'
              interfaces:
                - default: 'NO'
                  ip: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
                  dns: external.ip
                - ip: '{#CLOUD_SQL.INSTANCE.IP}'
                  dns: internal.ip
          master_item:
            key: gcp.cloudsql.instances.get
          lld_macro_paths:
            - lld_macro: '{#CLOUD_SQL.INSTANCE.DB.TYPE}'
              path: $.db_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.EXT.IP}'
              path: $.ext_ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.HIGH.AVAIL}'
              path: $.high_availability
            - lld_macro: '{#CLOUD_SQL.INSTANCE.IP}'
              path: $.ip
            - lld_macro: '{#CLOUD_SQL.INSTANCE.NAME}'
              path: $.name
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TIER}'
              path: $.tier
            - lld_macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
              path: $.inst_type
            - lld_macro: '{#CLOUD_SQL.INSTANCE.ZONE}'
              path: $.zone
            - lld_macro: '{#CLOUD_SQL.MASTER}'
              path: $.master
            - lld_macro: '{#GCP.AUTH.TOKEN}'
              path: $.token
            - lld_macro: '{#GCP.PROJECT.ID}'
              path: $.project_id
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          overrides:
            - name: 'PostgreSQL replica'
              step: '1'
              filter:
                conditions:
                  - macro: '{#CLOUD_SQL.INSTANCE.TYPE}'
                    value: READ_REPLICA_INSTANCE
                  - macro: '{#CLOUD_SQL.MASTER}'
                    operator: EXISTS
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  tags:
                    - tag: master_instance
                      value: '{#CLOUD_SQL.MASTER}'
                  templates:
                    - name: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
        - uuid: 7d0226eccc5644c89fff10f7ece1c8b4
          name: 'GCP Compute Engine: Instances discovery'
          type: DEPENDENT
          key: gcp.gce.inst.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GCE.INSTANCE.NAME}'
                value: '{$GCP.GCE.INST.NAME.MATCHES}'
              - macro: '{#GCE.INSTANCE.NAME}'
                value: '{$GCP.GCE.INST.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#GCE.INSTANCE.ZONE}'
                value: '{$GCP.GCE.ZONE.MATCHES}'
              - macro: '{#GCE.INSTANCE.ZONE}'
                value: '{$GCP.GCE.ZONE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Compute Engine: Instances discovery.'
          host_prototypes:
            - uuid: cb22d82a12814afb8ba833c649d575c4
              host: '{#GCE.INSTANCE.ID}'
              name: '{#GCE.INSTANCE.NAME}'
              group_links:
                - group:
                    name: 'Virtual machines'
              templates:
                - name: 'GCP Compute Engine Instance by HTTP'
              macros:
                - macro: '{$GCE.INSTANCE.ZONE}'
                  value: '{#GCE.INSTANCE.ZONE}'
                  description: 'Instance zone (location).'
                - macro: '{$GCE.INTEGRITY.STATE}'
                  value: '{#GCE.INTEGRITY.STATE}'
                  description: 'Instance integrity metrics status.'
                - macro: '{$GCE.MACHINE.TYPE}'
                  value: '{#GCE.MACHINE.TYPE}'
                  description: 'Instance machine type.'
                - macro: '{$GCP.AUTH.TOKEN}'
                  value: '{#GCP.AUTH.TOKEN}'
                  description: 'Google Cloud Platform authorization token.'
                - macro: '{$GCP.PROJECT.ID}'
                  value: '{#GCP.PROJECT.ID}'
                  description: 'GCP project id.'
              tags:
                - tag: instance-type
                  value: '{#GCE.INSTANCE.TYPE}'
                - tag: machine-type
                  value: '{#GCE.MACHINE.TYPE}'
                - tag: project
                  value: '{#GCP.PROJECT.ID}'
                - tag: service
                  value: gce
                - tag: service
                  value: gcp
                - tag: zone
                  value: '{#GCE.INSTANCE.ZONE}'
              custom_interfaces: 'YES'
              interfaces:
                - default: 'NO'
                  ip: '{#GCE.INSTANCE.EXT.IP}'
                  dns: external.ip
                - ip: '{#GCE.INSTANCE.IP}'
                  dns: internal.ip
          master_item:
            key: gcp.gce.instances.get
          lld_macro_paths:
            - lld_macro: '{#GCE.INSTANCE.EXT.IP}'
              path: $.ext_ip
            - lld_macro: '{#GCE.INSTANCE.ID}'
              path: $.id
            - lld_macro: '{#GCE.INSTANCE.IP}'
              path: $.ip
            - lld_macro: '{#GCE.INSTANCE.NAME}'
              path: $.name
            - lld_macro: '{#GCE.INSTANCE.TYPE}'
              path: $.i_type
            - lld_macro: '{#GCE.INSTANCE.ZONE}'
              path: $.zone
            - lld_macro: '{#GCE.INTEGRITY.STATE}'
              path: $.integrity
            - lld_macro: '{#GCE.MACHINE.TYPE}'
              path: $.m_type
            - lld_macro: '{#GCP.AUTH.TOKEN}'
              path: $.token
            - lld_macro: '{#GCP.PROJECT.ID}'
              path: $.project_id
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: 1a0dc88bc40d45af90ca761dcb611bf0
          name: 'GCP Compute Engine: Project quotas discovery'
          type: DEPENDENT
          key: gcp.gce.quotas.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GCE.QUOTA.NAME}'
                value: '{$GCP.GCE.QUOTA.MATCHES}'
              - macro: '{#GCE.QUOTA.NAME}'
                value: '{$GCP.GCE.QUOTA.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Compute Engine: Quotas discovery.'
          item_prototypes:
            - uuid: 1e9a772b9a89497ba695079fc480bd0a
              name: 'Quota [{#GCE.QUOTA.NAME}]: Limit'
              type: DEPENDENT
              key: 'gcp.gce.quota.limit[{#GCE.QUOTA.NAME}]'
              description: 'GCP Compute Engine: The current limit value for [{#GCE.QUOTA.NAME}] quota.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.limit
              master_item:
                key: 'gcp.gce.quota.single.raw[{#GCE.QUOTA.NAME}]'
              tags:
                - tag: component
                  value: quota
                - tag: quota
                  value: '{#GCE.QUOTA.NAME}'
              trigger_prototypes:
                - uuid: ac0d8842f0934dcead56d41f328c10d2
                  expression: 'change(/GCP by HTTP/gcp.gce.quota.limit[{#GCE.QUOTA.NAME}]) <> 0'
                  name: 'GCP: Quota [{#GCE.QUOTA.NAME}] limit has been changed'
                  opdata: 'Current limit: {ITEM.VALUE}'
                  priority: INFO
                  description: 'GCP Compute Engine: The limit for the `{#GCE.QUOTA.NAME}` quota has been changed.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: capacity
            - uuid: 6bb3700f7c5c4c51b6a435f5c7d0e315
              name: 'Quota [{#GCE.QUOTA.NAME}]: Percentage used'
              type: DEPENDENT
              key: 'gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]'
              value_type: FLOAT
              units: '%'
              description: 'GCP Compute Engine: Percentage usage for [{#GCE.QUOTA.NAME}] quota.'
              preprocessing:
                - type: CHECK_NOT_SUPPORTED
                  parameters:
                    - '-1'
                - type: JSONPATH
                  parameters:
                    - $.p_used
              master_item:
                key: 'gcp.gce.quota.single.raw[{#GCE.QUOTA.NAME}]'
              tags:
                - tag: component
                  value: quota
                - tag: quota
                  value: '{#GCE.QUOTA.NAME}'
              trigger_prototypes:
                - uuid: ecce0204198d4edda88f84d4f25ba75c
                  expression: 'last(/GCP by HTTP/gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]) >= {$GCP.GCE.QUOTA.PUSED.MIN.WARN:"{#GCE.QUOTA.NAME}"}'
                  name: 'GCP: Quota [{#GCE.QUOTA.NAME}] usage is close to reaching the limit'
                  opdata: 'Usage: {#GCE.QUOTA.USAGE} | Limit: {#GCE.QUOTA.LIMIT} | Percentage {ITEM.VALUE}%'
                  priority: WARNING
                  description: 'GCP Compute Engine: The usage percentage for the `{#GCE.QUOTA.NAME}` quota is close to reaching the limit.'
                  manual_close: 'YES'
                  dependencies:
                    - name: 'GCP: Quota [{#GCE.QUOTA.NAME}] usage is critically close to reaching the limit'
                      expression: 'last(/GCP by HTTP/gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]) >= {$GCP.GCE.QUOTA.PUSED.MIN.CRIT:"{#GCE.QUOTA.NAME}"}'
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: bc894d5e4f694e428fcb32babe87c204
                  expression: 'last(/GCP by HTTP/gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]) >= {$GCP.GCE.QUOTA.PUSED.MIN.CRIT:"{#GCE.QUOTA.NAME}"}'
                  name: 'GCP: Quota [{#GCE.QUOTA.NAME}] usage is critically close to reaching the limit'
                  opdata: 'Usage: {#GCE.QUOTA.USAGE} | Limit: {#GCE.QUOTA.LIMIT} | Percentage {ITEM.VALUE}%'
                  priority: AVERAGE
                  description: 'GCP Compute Engine: The usage percentage for the `{#GCE.QUOTA.NAME}` quota is critically close to reaching the limit.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: capacity
                    - tag: scope
                      value: notice
            - uuid: a439501636fd49f0aaf3902300d943b8
              name: 'Quota [{#GCE.QUOTA.NAME}]: Raw data'
              type: DEPENDENT
              key: 'gcp.gce.quota.single.raw[{#GCE.QUOTA.NAME}]'
              history: '0'
              value_type: TEXT
              description: 'GCP Compute Engine: Get metrics for [{#GCE.QUOTA.NAME}] quota.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.metric == "{#GCE.QUOTA.NAME}")].first()'
              master_item:
                key: gcp.gce.quotas.get
              tags:
                - tag: component
                  value: raw
                - tag: quota
                  value: '{#GCE.QUOTA.NAME}'
            - uuid: 936c66cc59a240858f67922dcba2cbec
              name: 'Quota [{#GCE.QUOTA.NAME}]: Usage'
              type: DEPENDENT
              key: 'gcp.gce.quota.usage[{#GCE.QUOTA.NAME}]'
              description: 'GCP Compute Engine: The current usage value for [{#GCE.QUOTA.NAME}] quota.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.usage
              master_item:
                key: 'gcp.gce.quota.single.raw[{#GCE.QUOTA.NAME}]'
              tags:
                - tag: component
                  value: quota
                - tag: quota
                  value: '{#GCE.QUOTA.NAME}'
          graph_prototypes:
            - uuid: 45de6eacbed84c82bfe9175fcf84e0c3
              name: 'GCP Compute Engine: Quota [{#GCE.QUOTA.NAME}]: Usage'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'GCP by HTTP'
                    key: 'gcp.gce.quota.usage[{#GCE.QUOTA.NAME}]'
                - sortorder: '1'
                  drawtype: BOLD_LINE
                  color: F63100
                  calc_fnc: MIN
                  item:
                    host: 'GCP by HTTP'
                    key: 'gcp.gce.quota.limit[{#GCE.QUOTA.NAME}]'
          master_item:
            key: gcp.gce.quotas.get
          lld_macro_paths:
            - lld_macro: '{#GCE.QUOTA.LIMIT}'
              path: $.limit
            - lld_macro: '{#GCE.QUOTA.NAME}'
              path: $.metric
            - lld_macro: '{#GCE.QUOTA.USAGE}'
              path: $.usage
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: adca45e3f9b6401c97c5d5a274679088
          name: 'GCP Cloud Run: Service discovery'
          type: DEPENDENT
          key: gcp.run.service.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#CLOUD.RUN.SERVICE.CONDITION}'
                value: '{$GCP.CLOUD.RUN.SERVICE.CONDITION.MATCHES}'
              - macro: '{#CLOUD.RUN.SERVICE.CONDITION}'
                value: '{$GCP.CLOUD.RUN.SERVICE.CONDITION.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#CLOUD.RUN.SERVICE.NAME}'
                value: '{$GCP.CLOUD.RUN.SERVICE.NAME.MATCHES}'
              - macro: '{#CLOUD.RUN.SERVICE.NAME}'
                value: '{$GCP.CLOUD.RUN.SERVICE.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Cloud Run services discovery.'
          host_prototypes:
            - uuid: ea0d03e4f9a34edfae080832b78be985
              host: '{#CLOUD.RUN.SERVICE.UID}'
              name: '{#CLOUD.RUN.SERVICE.NAME}'
              group_links:
                - group:
                    name: 'Virtual machines'
              templates:
                - name: 'GCP Cloud Run Service by HTTP'
              macros:
                - macro: '{$CLOUD.RUN.SERVICE.CONDITION}'
                  value: '{#CLOUD.RUN.SERVICE.CONDITION}'
                  description: 'Cloud Run Service condition.'
                - macro: '{$CLOUD.RUN.SERVICE.CONTAINER}'
                  value: '{#CLOUD.RUN.SERVICE.CONTAINER}'
                  description: 'Cloud Run Service resources.'
                - macro: '{$CLOUD.RUN.SERVICE.LOCATION}'
                  value: '{#CLOUD.RUN.SERVICE.LOCATION}'
                  description: 'Cloud Run Service location.'
                - macro: '{$GCP.AUTH.TOKEN}'
                  value: '{#GCP.AUTH.TOKEN}'
                  description: 'Google Cloud Platform authorization token.'
              tags:
                - tag: launch-stage
                  value: '{#CLOUD.RUN.SERVICE.LAUNCH.STAGE}'
                - tag: location
                  value: '{#CLOUD.RUN.SERVICE.LOCATION}'
                - tag: project
                  value: '{#GCP.PROJECT.ID}'
                - tag: service
                  value: cloud-run
                - tag: service
                  value: gcp
          master_item:
            key: gcp.run.services.get
          lld_macro_paths:
            - lld_macro: '{#CLOUD.RUN.SERVICE.CONDITION}'
              path: $.condition
            - lld_macro: '{#CLOUD.RUN.SERVICE.CONTAINER}'
              path: $.container
            - lld_macro: '{#CLOUD.RUN.SERVICE.LAUNCH.STAGE}'
              path: $.launch_stage
            - lld_macro: '{#CLOUD.RUN.SERVICE.LOCATION}'
              path: $.location
            - lld_macro: '{#CLOUD.RUN.SERVICE.NAME}'
              path: $.name
            - lld_macro: '{#CLOUD.RUN.SERVICE.UID}'
              path: $.uid
            - lld_macro: '{#GCP.AUTH.TOKEN}'
              path: $.token
            - lld_macro: '{#GCP.PROJECT.ID}'
              path: $.project_id
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: automation
        - tag: subclass
          value: computing
        - tag: subclass
          value: containers
        - tag: subclass
          value: deploy
        - tag: subclass
          value: security
        - tag: subclass
          value: virtualization
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
      macros:
        - macro: '{$GCP.AUTH.FREQUENCY}'
          value: 45m
          description: |
            The update interval for the GCP Authorization item, which also equals to the access token regeneration request frequency.
            Check the template documentation notes carefully for more details.
          config:
            type: TEXT
            priority: '5'
            label: 'Token update frequency'
            description: 'Update interval for the GCP Authorization item, which also equals to the access token regeneration request frequency.'
        - macro: '{$GCP.CLIENT.EMAIL}'
          description: 'Service account client e-mail.'
          config:
            type: TEXT
            priority: '2'
            label: 'Client e-mail'
            description: 'Service account client e-mail.'
            required: 'YES'
        - macro: '{$GCP.CLOUD.RUN.SERVICE.CONDITION.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud Run services by condition.'
          config:
            type: TEXT
            priority: '37'
            section_name: Filters
            label: 'Include GCP Cloud Run service condition filter'
            description: 'Filter to include GCP Cloud Run services by condition.'
        - macro: '{$GCP.CLOUD.RUN.SERVICE.CONDITION.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud Run services by condition.'
          config:
            type: TEXT
            priority: '38'
            section_name: Filters
            label: 'Exclude GCP Cloud Run service condition filter'
            description: 'Filter to exclude GCP Cloud Run services by condition.'
        - macro: '{$GCP.CLOUD.RUN.SERVICE.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud Run services by name.'
          config:
            type: TEXT
            priority: '35'
            section_name: Filters
            label: 'Include GCP Cloud Run service name filter'
            description: 'Filter to include GCP Cloud Run services by name.'
        - macro: '{$GCP.CLOUD.RUN.SERVICE.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud Run services by name.'
          config:
            type: TEXT
            priority: '36'
            section_name: Filters
            label: 'Exclude GCP Cloud Run service name filter'
            description: 'Filter to exclude GCP Cloud Run services by name.'
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for API.'
          config:
            type: TEXT
            priority: '9'
            section_name: Other
            label: 'Response timeout'
            description: 'Response timeout for API.'
        - macro: '{$GCP.GCE.INST.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Compute Engine instances by namespace.'
          config:
            type: TEXT
            priority: '11'
            section_name: Filters
            label: 'Include GCP Compute Engine namespace filter'
            description: 'Filter to include GCP Compute Engine instances by namespace.'
        - macro: '{$GCP.GCE.INST.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Compute Engine instances by namespace.'
          config:
            type: TEXT
            priority: '12'
            section_name: Filters
            label: 'Exclude GCP Compute Engine namespace filter'
            description: 'Filter to exclude GCP Compute Engine instances by namespace.'
        - macro: '{$GCP.GCE.QUOTA.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Compute Engine project quotas by namespace.'
          config:
            type: TEXT
            priority: '33'
            section_name: Filters
            label: 'Include GCP Compute Engine project quotas by namespace filter'
            description: 'Filter to include GCP Compute Engine project quotas by namespace.'
        - macro: '{$GCP.GCE.QUOTA.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Compute Engine project quotas by namespace.'
          config:
            type: TEXT
            priority: '34'
            section_name: Filters
            label: 'Exclude GCP Compute Engine project quotas by namespace filter'
            description: 'Filter to exclude GCP Compute Engine project quotas by namespace.'
        - macro: '{$GCP.GCE.QUOTA.PUSED.MIN.CRIT}'
          value: '95'
          description: 'GCP Compute Engine project quota critical quota utilization threshold.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'GCP Compute Engine critical utilization threshold'
            description: 'GCP Compute Engine project quota critical quota utilization threshold. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$GCP.GCE.QUOTA.PUSED.MIN.WARN}'
          value: '80'
          description: 'GCP Compute Engine project quota warning utilization threshold.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'GCP Compute Engine warning utilization threshold'
            description: 'GCP Compute Engine project quota warning utilization threshold. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$GCP.GCE.ZONE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Compute Engine instances by zone.'
          config:
            type: TEXT
            priority: '13'
            section_name: Filters
            label: 'Include GCP Compute Engine zone filter'
            description: 'Filter to include GCP Compute Engine instances by zone.'
        - macro: '{$GCP.GCE.ZONE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Compute Engine instances by zone.'
          config:
            type: TEXT
            priority: '14'
            section_name: Filters
            label: 'Exclude GCP Compute Engine zone filter'
            description: 'Filter to exclude GCP Compute Engine instances by zone.'
        - macro: '{$GCP.MSSQL.INST.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL instances by namespace.'
          config:
            type: TEXT
            priority: '27'
            section_name: Filters
            label: 'Include GCP Cloud SQL MSSQL namespace filter'
            description: 'Filter to include GCP Cloud SQL MSSQL instances by namespace.'
        - macro: '{$GCP.MSSQL.INST.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MSSQL instances by namespace.'
          config:
            type: TEXT
            priority: '28'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MSSQL namespace filter'
            description: 'Filter to exclude GCP Cloud SQL MSSQL instances by namespace.'
        - macro: '{$GCP.MSSQL.INST.TYPE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL instances by type (standalone/replica).'
          config:
            type: TEXT
            priority: '31'
            section_name: Filters
            label: 'Include GCP Cloud SQL MSSQL instances by type filter'
            description: 'Filter to include GCP Cloud SQL MSSQL instances by type (standalone/replica).'
        - macro: '{$GCP.MSSQL.INST.TYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: |
            The filter to exclude GCP Cloud SQL MSSQL instances by type (standalone/replica).
            Set a macro value 'CLOUD_SQL_INSTANCE' to exclude standalone Instances or 'READ_REPLICA_INSTANCE' to exclude read-only Replicas.
          config:
            type: TEXT
            priority: '32'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MSSQL instances by type filter'
            description: 'Filter to exclude GCP Cloud SQL MSSQL instances by type (standalone/replica).'
        - macro: '{$GCP.MSSQL.ZONE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL instances by zone.'
          config:
            type: TEXT
            priority: '29'
            section_name: Filters
            label: 'Include GCP Cloud SQL MSSQL zone filter'
            description: 'Filter to include GCP Cloud SQL MSSQL instances by zone.'
        - macro: '{$GCP.MSSQL.ZONE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MSSQL instances by zone.'
          config:
            type: TEXT
            priority: '30'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MSSQL zone filter'
            description: 'Filter to exclude GCP Cloud SQL MSSQL instances by zone.'
        - macro: '{$GCP.MYSQL.INST.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MySQL instances by namespace.'
          config:
            type: TEXT
            priority: '15'
            section_name: Filters
            label: 'Include GCP Cloud SQL MySQL namespace filter'
            description: 'Filter to include GCP Cloud SQL MySQL instances by namespace.'
        - macro: '{$GCP.MYSQL.INST.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MySQL instances by namespace.'
          config:
            type: TEXT
            priority: '16'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MySQL namespace filter'
            description: 'Filter to exclude GCP Cloud SQL MySQL instances by namespace.'
        - macro: '{$GCP.MYSQL.INST.TYPE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MySQL instances by type (standalone/replica).'
          config:
            type: TEXT
            priority: '19'
            section_name: Filters
            label: 'Include GCP Cloud SQL MySQL instances by type filter'
            description: 'Filter to include GCP Cloud SQL MySQL instances by type (standalone/replica).'
        - macro: '{$GCP.MYSQL.INST.TYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: |
            The filter to exclude GCP Cloud SQL MySQL instances by type (standalone/replica).
            Set a macro value 'CLOUD_SQL_INSTANCE' to exclude standalone Instances or 'READ_REPLICA_INSTANCE' to exclude read-only Replicas.
          config:
            type: TEXT
            priority: '20'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MySQL instances by type filter'
            description: 'Filter to exclude GCP Cloud SQL MySQL instances by type (standalone/replica).'
        - macro: '{$GCP.MYSQL.ZONE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MySQL instances by zone.'
          config:
            type: TEXT
            priority: '17'
            section_name: Filters
            label: 'Include GCP Cloud SQL MySQL zone filter'
            description: 'Filter to include GCP Cloud SQL MySQL instances by zone.'
        - macro: '{$GCP.MYSQL.ZONE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MySQL instances by zone.'
          config:
            type: TEXT
            priority: '18'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL MySQL zone filter'
            description: 'Filter to exclude GCP Cloud SQL MySQL instances by zone.'
        - macro: '{$GCP.PGSQL.INST.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL PostgreSQL instances by namespace.'
          config:
            type: TEXT
            priority: '21'
            section_name: Filters
            label: 'Include GCP Cloud SQL PostgreSQL namespace filter'
            description: 'Filter to include GCP Cloud SQL PostgreSQL instances by namespace.'
        - macro: '{$GCP.PGSQL.INST.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL PostgreSQL instances by namespace.'
          config:
            type: TEXT
            priority: '22'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL PostgreSQL namespace filter'
            description: 'Filter to exclude GCP Cloud SQL PostgreSQL instances by namespace.'
        - macro: '{$GCP.PGSQL.INST.TYPE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL PostgreSQL instances by type (standalone/replica).'
          config:
            type: TEXT
            priority: '25'
            section_name: Filters
            label: 'Include GCP Cloud SQL PostgreSQL instances by type filter'
            description: 'Filter to include GCP Cloud SQL PostgreSQL instances by type (standalone/replica).'
        - macro: '{$GCP.PGSQL.INST.TYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: |
            The filter to exclude GCP Cloud SQL PostgreSQL instances by type (standalone/replica).
            Set a macro value 'CLOUD_SQL_INSTANCE' to exclude standalone Instances or 'READ_REPLICA_INSTANCE' to exclude read-only Replicas.
          config:
            type: TEXT
            priority: '26'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL PostgreSQL instances by type filter'
            description: 'Filter to exclude GCP Cloud SQL PostgreSQL instances by type (standalone/replica).'
        - macro: '{$GCP.PGSQL.ZONE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL PostgreSQL instances by zone.'
          config:
            type: TEXT
            priority: '23'
            section_name: Filters
            label: 'Include GCP Cloud SQL PostgreSQL zone filter'
            description: 'Filter to include GCP Cloud SQL PostgreSQL instances by zone.'
        - macro: '{$GCP.PGSQL.ZONE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL PostgreSQL instances by zone.'
          config:
            type: TEXT
            priority: '24'
            section_name: Filters
            label: 'Exclude GCP Cloud SQL PostgreSQL zone filter'
            description: 'Filter to exclude GCP Cloud SQL PostgreSQL instances by zone.'
        - macro: '{$GCP.PRIVATE.KEY}'
          type: SECRET_TEXT
          description: 'Service account private key data.'
          config:
            type: TEXT
            priority: '4'
            label: 'Private key data'
            description: 'Service account private key data.'
            required: 'YES'
        - macro: '{$GCP.PRIVATE.KEY.ID}'
          type: SECRET_TEXT
          description: 'Service account private key id.'
          config:
            type: TEXT
            priority: '3'
            label: 'Private key id'
            description: 'Service account private key id.'
            required: 'YES'
        - macro: '{$GCP.PROJECT.ID}'
          description: 'GCP project ID.'
          config:
            type: TEXT
            priority: '1'
            label: 'GCP project ID'
            description: 'Google Cloud Platform project ID.'
            required: 'YES'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty, then no proxy is used.'
          config:
            type: TEXT
            priority: '10'
            section_name: Other
            label: 'HTTP proxy'
            description: 'HTTP proxy to use for requests.'
        - macro: '{$GCP.RUN.LOCATION.FILTER}'
          description: |
            Cloud Run Service filter locations. If empty - all locations are monitored.
            The value must be a string. The operator must be either `=, !=, >, <, <=, >= or :`.
            Example: `name="europe-west1" OR name="europe-north1" OR name="asia-southeast2"`, `name!= "us-central1"`, `name!= "me-*`.
          config:
            type: TEXT
            priority: '6'
            section_name: Filters
            label: 'Cloud Run filter location'
            description: |
              Cloud Run service filter locations. If empty - all locations are monitored.
              The value must be a string. The operator must be either `=, !=, >, <, <=, >= or :`.
              Example: `name="europe-west1" OR name="europe-north1" OR name="asia-southeast2"`, `name!= "us-central1"`, `name!= "me-*`.
            required: 'YES'
      dashboards:
        - uuid: 71df4601171e471ea74a291242028394
          name: 'Project resources'
          pages:
            - name: 'Project resources'
              widgets:
                - type: item
                  name: 'GCE instances total'
                  width: '24'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.gce.instances.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: item
                  name: 'Cloud SQL total'
                  'y': '5'
                  width: '18'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.cloudsql.instances.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: graphprototype
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'GCP by HTTP'
                        name: 'GCP Compute Engine: Quota [{#GCE.QUOTA.NAME}]: Usage'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: item
                  name: 'Cloud SQL MySQL'
                  x: '18'
                  'y': '5'
                  width: '18'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.cloudsql.instances.mysql_count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: item
                  name: 'GCE regular instances'
                  x: '24'
                  width: '24'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.gce.instances.regular_count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: item
                  name: 'Cloud SQL PostgreSQL'
                  x: '36'
                  'y': '5'
                  width: '18'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.cloudsql.instances.pgsql_count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: graphprototype
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: ITEM_PROTOTYPE
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: 'gcp.gce.quota.pused[{#GCE.QUOTA.NAME}]'
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '3'
                - type: item
                  name: 'GCE COS instances'
                  x: '48'
                  width: '24'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.gce.instances.cos_count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                - type: item
                  name: 'Cloud SQL MSSQL'
                  x: '54'
                  'y': '5'
                  width: '18'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP by HTTP'
                        key: gcp.cloudsql.instances.mssql_count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
    - uuid: ac74c20e51854372a0db831f5f7d5f5e
      template: 'GCP Cloud Run Service by HTTP'
      name: 'GCP Cloud Run Service by HTTP'
      description: |
        Discover GCP Cloud Run services by HTTP with script item usage.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        This template is used in low-level discovery and will be auto-assigned to host prototypes. Additional configuration is not required.
      vendor:
        name: Zabbix
        version: 8.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 25b0e0b5d65f4397b2439cb8cf2c1901
          name: 'Google sent bytes per second'
          type: DEPENDENT
          key: gcp.gce.google.sent_bytes.rate
          value_type: FLOAT
          units: Bps
          description: |
            Outgoing response traffic, in bytes.
            For responses returned through Google Cloud load balancers, response traffic is classified as `google`.
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.label_value == ''google'')].sent_bytes.first()'
          master_item:
            key: gcp.run.http.traffic.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
            - tag: type
              value: google
        - uuid: 959fff2d31ce4aa8baff5e741ec67246
          name: 'Internet sent bytes per second'
          type: DEPENDENT
          key: gcp.gce.internet.sent_bytes.rate
          value_type: FLOAT
          units: Bps
          description: 'Outgoing response traffic, in bytes. Traffic is sent over network type `internet`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.label_value == ''internet'')].sent_bytes.first()'
          master_item:
            key: gcp.run.http.traffic.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
            - tag: type
              value: internet
        - uuid: 0704a471e368411893f26f11088732be
          name: 'Private sent bytes per second'
          type: DEPENDENT
          key: gcp.gce.private.sent_bytes.rate
          value_type: FLOAT
          units: Bps
          description: 'Outgoing response traffic, in bytes. Traffic is sent over network type `private`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.label_value == ''private'')].sent_bytes.first()'
          master_item:
            key: gcp.run.http.traffic.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
            - tag: type
              value: private
        - uuid: 0b38461716174016b9dfd6d50b6eb37d
          name: 'Active container instance count'
          type: DEPENDENT
          key: gcp.run.active.container.count
          description: 'Number of active container instances for the service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.state == ''active'')].value.first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.run.container.count.get
          tags:
            - tag: component
              value: container
            - tag: component
              value: environment
          triggers:
            - uuid: b7ef83334ec14be2bb0c1e36332091cf
              expression: 'max(/GCP Cloud Run Service by HTTP/gcp.run.active.container.count,15m)=0'
              name: 'GCP Cloud Run Service: No active container instances'
              event_name: 'GCP Cloud Run Service: No active container instances'
              priority: WARNING
              description: 'There are no active container instances for the service. This may indicate that the service is not receiving traffic or there is an issue with scaling.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: availability
        - uuid: f6b0e75ea5d94025937466693a2a4a31
          name: 'Billable instance time'
          type: HTTP_AGENT
          key: gcp.run.billable.instance.time
          delay: '{$GCP.TIME.WINDOW}'
          value_type: FLOAT
          units: '!s/s'
          description: 'Total billable time (time multiplied by number of running containers).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.timeSeriesData..pointData..values..doubleValue.first()
              error_handler: DISCARD_VALUE
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          posts: |
            {
              "query": "fetch cloud_run_revision
            | metric 'run.googleapis.com/container/billable_instance_time'
            | filter resource.service_name == '{HOST.NAME}'
            | align rate()
            | group_by [resource.service_name],
                [value_billable_instance_time_aggregate:
                  aggregate(value.billable_instance_time)]"
            }
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: billable
            - tag: component
              value: environment
        - uuid: dd6476e311c24f39b8c3ea3dbaccc5c0
          name: 'Max concurrent requests'
          type: DEPENDENT
          key: gcp.run.concurrent.request
          value_type: FLOAT
          units: '%'
          description: 'Distribution of the maximum number of concurrent requests being served by each container instance over a minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..requests.first()
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.run.utilization.get
          tags:
            - tag: component
              value: requests
            - tag: type
              value: concurrent
          triggers:
            - uuid: a05e5cf684be4c1bbf0440d2bb857c4a
              expression: 'min(/GCP Cloud Run Service by HTTP/gcp.run.concurrent.request,15m) >= {$GCP.CONCURRENT.REQUEST.MAX}'
              name: 'GCP Cloud Run Service: Concurrent requests too high'
              event_name: 'GCP Cloud Run Service: Concurrent request (over {$GCP.CONCURRENT.REQUEST.MAX}% for 15m)'
              opdata: 'Max concurrent request: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'Fires when concurrent requests exceed the threshold `{$GCP.CONCURRENT.REQUEST.MAX}`%.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: performance
        - uuid: 65ef21f418a9463cb3af82f8c8857db5
          name: 'Get container instance count'
          type: HTTP_AGENT
          key: gcp.run.container.count.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          description: 'Raw data of container instances that exist for the service.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const json_data = JSON.parse(value);
                  
                  function getField(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			throw 'Required field "' + path + '" is not present in data received.';
                  		}
                  		data = data[step];
                  	}
                  	return data;
                  }
                  
                  
                  var request_count = getField(json_data, 'timeSeriesData'),
                  	output_data = [];
                  
                  for (var entity in request_count) {
                  	output_data.push({
                  		state: getField(request_count[entity], 'labelValues.1.stringValue'),
                  		value: getField(request_count[entity], 'pointData.0.values.0.int64Value')
                  	});
                  }
                  
                  return JSON.stringify(output_data);
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          posts: |
            {
              "query": "fetch cloud_run_revision
            | metric 'run.googleapis.com/container/instance_count'
            | filter resource.service_name == '{HOST.NAME}'
            | group_by window(), [value_instance_count_max: max(value.instance_count)]
            | group_by [resource.service_name, metric.state],
                [value_instance_count_max_aggregate: aggregate(value_instance_count_max)]"
            }
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: raw
        - uuid: c2bcc97362a746f2916f7a60bdbb2b17
          name: 'Container CPU utilization'
          type: DEPENDENT
          key: gcp.run.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: 'Container CPU utilization in percentage distribution across all container instances.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..cpu.first()
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.run.utilization.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: f9567c7d60454b8b87c6ff490f78d43e
              expression: 'min(/GCP Cloud Run Service by HTTP/gcp.run.cpu.utilization,15m) >= {$GCP.CPU.UTIL.MAX}'
              name: 'GCP Cloud Run Service: High CPU utilization'
              event_name: 'GCP Cloud Run Service: High CPU utilization (over {$GCP.CPU.UTIL.MAX}% for 15m)'
              priority: AVERAGE
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: performance
        - uuid: aa62c4d76ff9400b88ee040da2d0815d
          name: 'End-to-end request latency'
          type: DEPENDENT
          key: gcp.run.e2e.latency
          value_type: FLOAT
          units: s
          description: 'Distribution of request latencies in milliseconds measured from when the request enters Google Cloud''s network to when Cloud Run sends the response.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.e2e_latencies_percentile
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: gcp.run.latency.get
          tags:
            - tag: component
              value: environment
            - tag: component
              value: latency
        - uuid: a381b10ee48b4f52a3efd4cbb55e51e6
          name: 'Google received bytes per second'
          type: DEPENDENT
          key: gcp.run.google.received_bytes.rate
          value_type: FLOAT
          units: Bps
          description: 'Incoming request traffic, in bytes. Traffic is received over network type `google`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.label_value == ''google'')].received_bytes.first()'
          master_item:
            key: gcp.run.http.traffic.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
            - tag: type
              value: google
        - uuid: fb62b24c213e4a48a7c595f40a8dd8c1
          name: 'Get HTTP response traffic'
          type: HTTP_AGENT
          key: gcp.run.http.traffic.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          description: 'Raw data socket and HTTP response traffic.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const json_data = JSON.parse(value);
                  
                  function getField(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			throw 'Required field "' + path + '" is not present in data received.';
                  		}
                  		data = data[step];
                  	}
                  	return data;
                  }
                  
                  
                  var network = getField(json_data, 'timeSeriesData'),
                  	output_data = [];
                  
                  for (var entity in network) {
                  	output_data.push({
                  		label_value: getField(network[entity], 'labelValues.0.stringValue'),
                  		sent_bytes: getField(network[entity], 'pointData.0.values.0.doubleValue'),
                  		received_bytes: getField(network[entity], 'pointData.0.values.1.doubleValue')
                  	});
                  }
                  
                  return JSON.stringify(output_data);
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          posts: |
            {
              "query": "fetch cloud_run_revision
            | {metric 'run.googleapis.com/container/network/sent_bytes_count';metric 'run.googleapis.com/container/network/received_bytes_count'}
            | filter resource.service_name == '{HOST.NAME}'
            | align rate({$GCP.TIME.WINDOW})
            | group_by [metric.kind]
            | join | within {$GCP.TIME.WINDOW}"
            }
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: raw
        - uuid: a14d1d5e94ed41f2bc12119532441950
          name: 'Idle container instance count'
          type: DEPENDENT
          key: gcp.run.idle.container.count
          description: 'Number of idle container instances for the service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.state == ''idle'')].value.first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.run.container.count.get
          tags:
            - tag: component
              value: container
            - tag: component
              value: environment
        - uuid: d24bd1e4a62f43a0ba8cff8c92ce14cc
          name: 'Ingress to region request latency'
          type: DEPENDENT
          key: gcp.run.ingress.region.latency
          value_type: FLOAT
          units: s
          description: 'Distribution of request latencies in milliseconds measured from when the request enters Google Cloud''s network to when the request reaches the cloud region.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ingress_to_region_percentile
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: gcp.run.latency.get
          tags:
            - tag: component
              value: environment
            - tag: component
              value: latency
        - uuid: 009836cc2772481b8c60cd55bb980039
          name: 'Internet received bytes per second'
          type: DEPENDENT
          key: gcp.run.internet.received_bytes.rate
          value_type: FLOAT
          units: Bps
          description: 'Incoming request traffic, in bytes. Traffic is received over network type `internet`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.label_value == ''internet'')].received_bytes.first()'
          master_item:
            key: gcp.run.http.traffic.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
            - tag: type
              value: internet
        - uuid: 5f4bc34eb5a14b968b5ccf85a5642222
          name: 'Get latency'
          type: HTTP_AGENT
          key: gcp.run.latency.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          description: 'Raw data of request latencies.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const json_data = JSON.parse(value);
                  
                  function getField(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			throw 'Required field "' + path + '" is not present in data received.';
                  		}
                  		data = data[step];
                  	}
                  	return data;
                  }
                  
                  
                  var output_data = {},
                  	regexp_key = /(^t_\d+\.value_)/g,
                  	keys = getField(json_data, 'timeSeriesDescriptor.pointDescriptors'),
                  	values = getField(json_data, 'timeSeriesData.0.pointData.0.values');
                  
                  for (i in keys) {
                  	output_data[getField(keys[i], 'key').replace(regexp_key, '')] = getField(values[i], 'doubleValue');
                  }
                  
                  return JSON.stringify(output_data);
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          posts: |
            {
              "query": "fetch cloud_run_revision
            | {metric 'run.googleapis.com/request_latencies';metric 'run.googleapis.com/request_latency/e2e_latencies';metric 'run.googleapis.com/request_latency/ingress_to_region';metric 'run.googleapis.com/request_latency/routing';metric 'run.googleapis.com/request_latency/pending';metric 'run.googleapis.com/request_latency/user_execution';metric 'run.googleapis.com/request_latency/response_egress'}
            | filter resource.service_name == '{HOST.NAME}'
            | align delta({$GCP.TIME.WINDOW})
            | every {$GCP.TIME.WINDOW}
            | group_by [resource.service_name], percentile(val(), 99)
            | join"
            }
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: raw
        - uuid: 934bd0440d72411093908ffd040fda03
          name: 'Container memory utilization'
          type: DEPENDENT
          key: gcp.run.memory.utilization
          value_type: FLOAT
          units: '%'
          description: 'Container memory utilization distribution across all container instances.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $..memory.first()
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.run.utilization.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 0dbe97ca846b4317abc45db1559b512b
              expression: 'min(/GCP Cloud Run Service by HTTP/gcp.run.memory.utilization,15m) >= {$GCP.MEMORY.UTIL.CRIT}'
              name: 'GCP Cloud Run Service: High memory utilization'
              event_name: 'GCP Cloud Run Service: High memory utilization (over {$GCP.MEMORY.UTIL.CRIT}% for 15m)'
              priority: AVERAGE
              description: 'Container memory utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 34c9c8f8fe5c44b78f41bb3dc01f69b3
          name: 'Pending request latency'
          type: DEPENDENT
          key: gcp.run.pending.request.latency
          value_type: FLOAT
          units: s
          description: 'Distribution of request latencies in milliseconds measured from when the request reaches Cloud Run to when the request is sent to an instance. Includes time spent waiting for a slot on an existing instance, or for a new instance to start (startup latency).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pending_percentile
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: gcp.run.latency.get
          tags:
            - tag: component
              value: environment
            - tag: component
              value: latency
        - uuid: d73f80448d494ea5be7140207555374a
          name: 'Private received bytes per second'
          type: DEPENDENT
          key: gcp.run.private.received_bytes.rate
          value_type: FLOAT
          units: Bps
          description: 'Incoming request traffic, in bytes. Traffic is received over network type `private`.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.label_value == ''private'')].received_bytes.first()'
          master_item:
            key: gcp.run.http.traffic.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
            - tag: type
              value: private
        - uuid: 8db2392400dc4908903ee887e53c709e
          name: 'Requests 2xx per second'
          type: DEPENDENT
          key: gcp.run.request.2xx.rate
          value_type: FLOAT
          description: 'Number of `2xx` requests reaching the service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.label_value == ''2xx'')].value.first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.run.request.get
          tags:
            - tag: component
              value: requests
            - tag: http-code
              value: 2xx
        - uuid: b4122b379795426882be5bc726110e3d
          name: 'Requests 3xx per second'
          type: DEPENDENT
          key: gcp.run.request.3xx.rate
          value_type: FLOAT
          description: 'Number of `3xx` requests reaching the service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.label_value == ''3xx'')].value.first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.run.request.get
          tags:
            - tag: component
              value: requests
            - tag: http-code
              value: 3xx
        - uuid: 0ce26db6ac094c3f801683affb288d13
          name: 'Requests 4xx per second'
          type: DEPENDENT
          key: gcp.run.request.4xx.rate
          value_type: FLOAT
          description: 'Number of `4xx` requests reaching the service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.label_value == ''4xx'')].value.first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.run.request.get
          tags:
            - tag: component
              value: requests
            - tag: http-code
              value: 4xx
        - uuid: b80cecd02b4f42a59d284a333eff567f
          name: 'Requests 5xx per second'
          type: DEPENDENT
          key: gcp.run.request.5xx.rate
          value_type: FLOAT
          description: 'Number of `5xx` requests reaching the service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[?(@.label_value == ''5xx'')].value.first()'
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.run.request.get
          tags:
            - tag: component
              value: requests
            - tag: http-code
              value: 5xx
          triggers:
            - uuid: 17a07402bdb54198ac8d99ddf204cf71
              expression: 'min(/GCP Cloud Run Service by HTTP/gcp.run.request.5xx.rate,5m)>{$GCP.HTTP.FAIL.MAX.WARN}'
              name: 'GCP Cloud Run Service: Too many HTTP request failures'
              event_name: 'GCP Cloud Run Service: Too many HTTP request failures (over {$GCP.HTTP.FAIL.MAX.WARN} for 5m)'
              priority: WARNING
              description: 'Too many requests failed on service with the `5xx` HTTP code.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 30c58b23cb1045fa8232c41d8756d6d2
          name: 'Get request'
          type: HTTP_AGENT
          key: gcp.run.request.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          description: 'Number of requests reaching the service.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const json_data = JSON.parse(value);
                  
                  function getField(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			throw 'Required field "' + path + '" is not present in data received.';
                  		}
                  		data = data[step];
                  	}
                  	return data;
                  }
                  
                  
                  var request_count = getField(json_data, 'timeSeriesData'),
                  	output_data = [];
                  
                  for (var entity in request_count) {
                  	output_data.push({
                  		label_value: getField(request_count[entity], 'labelValues.0.stringValue'),
                  		value: getField(request_count[entity], 'pointData.0.values.0.doubleValue')
                  	});
                  }
                  
                  return JSON.stringify(output_data);
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          posts: |
            {
              "query": "fetch cloud_run_revision
            | metric 'run.googleapis.com/request_count'
            | filter resource.service_name == '{HOST.NAME}'
            | align rate({$GCP.TIME.WINDOW})
            | every {$GCP.TIME.WINDOW}
            | group_by [metric.response_code_class],[value_request_count_aggregate: aggregate(value.request_count)]"
            }
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: raw
            - tag: component
              value: requests
        - uuid: 026dd45d97984d1282a4fe015083127d
          name: 'Request latencies'
          type: DEPENDENT
          key: gcp.run.request.latency
          value_type: FLOAT
          units: s
          description: 'Distribution of request times in milliseconds reaching the service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.request_latencies_percentile
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: gcp.run.latency.get
          tags:
            - tag: component
              value: environment
            - tag: component
              value: latency
          triggers:
            - uuid: 5d0e3e188a774e43ae372990cd49a949
              expression: 'min(/GCP Cloud Run Service by HTTP/gcp.run.request.latency,5m)>{$GCP.REQUEST.LATENCY.WARN}'
              name: 'GCP Cloud Run Service: Request latency is too high'
              event_name: 'GCP Cloud Run Service: Query latency is too high (over {$GCP.REQUEST.LATENCY.WARN}ms for 5m)'
              opdata: 'Latency: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'Fires when latency exceeds the threshold `{$GCP.REQUEST.LATENCY.WARN}`ms.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: performance
        - uuid: 5fa1e94d46004f1a929ef43529b77844
          name: 'Response egress request latency'
          type: DEPENDENT
          key: gcp.run.response_egress.request.latency
          value_type: FLOAT
          units: s
          description: 'Distribution of response latencies in milliseconds measured from when the container finished processing the request to when Cloud Run sends the response.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.response_egress_percentile
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: gcp.run.latency.get
          tags:
            - tag: component
              value: environment
            - tag: component
              value: latency
        - uuid: d6be76dd39944ec192e187bcbe499933
          name: 'Routing request latency'
          type: DEPENDENT
          key: gcp.run.routing.request.latency
          value_type: FLOAT
          units: s
          description: 'Distribution of request latencies in milliseconds measured from when the request reaches the cloud region to when the request reaches Cloud Run.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.routing_percentile
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: gcp.run.latency.get
          tags:
            - tag: component
              value: environment
            - tag: component
              value: latency
        - uuid: f88a42c143954930b7f6ad90c5352299
          name: 'User execution request latency'
          type: DEPENDENT
          key: gcp.run.user_execution.request.latency
          value_type: FLOAT
          units: s
          description: 'Distribution of request latencies in milliseconds measured from when the request reaches a running instance to when it exits. Only includes time spent in the user container.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.user_execution_percentile
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: gcp.run.latency.get
          tags:
            - tag: component
              value: environment
            - tag: component
              value: latency
        - uuid: 1a9fdee740a9440cb2e3844450b46159
          name: 'Get container utilization'
          type: HTTP_AGENT
          key: gcp.run.utilization.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          description: 'Raw data of utilization container.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  const json_data = JSON.parse(value);
                  
                  function getField(data, path) {
                  	var steps = path.split('.');
                  
                  	for (var i = 0; i < steps.length; i++) {
                  		var step = steps[i];
                  
                  		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                  			throw 'Required field "' + path + '" is not present in data received.';
                  		}
                  		data = data[step];
                  	}
                  	return data;
                  }
                  
                  
                  var utilization = getField(json_data, 'timeSeriesData'),
                  	output_data = [];
                  
                  for (var entity in utilization) {
                  	output_data.push({
                  		cpu: getField(utilization[entity], 'pointData.0.values.0.doubleValue'),
                  		memory: getField(utilization[entity], 'pointData.0.values.1.doubleValue'),
                  		requests: getField(utilization[entity], 'pointData.0.values.2.doubleValue')
                  	});
                  };
                  
                  return JSON.stringify(output_data);
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          posts: |
            {
            "query": "fetch cloud_run_revision
            | {metric 'run.googleapis.com/container/cpu/utilizations';metric 'run.googleapis.com/container/memory/utilizations';metric 'run.googleapis.com/container/max_request_concurrencies'}
            | filter resource.service_name == '{HOST.NAME}'
            | group_by {$GCP.TIME.WINDOW}
            | every {$GCP.TIME.WINDOW}
            | group_by [resource.service_name] ,percentile(val(), 100)
            | join"
            }
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: raw
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: automation
        - tag: subclass
          value: containers
        - tag: target
          value: cloud-run
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
      macros:
        - macro: '{$GCP.CONCURRENT.REQUEST.MAX}'
          value: '80'
          description: 'GCP Cloud Run max concurrent request threshold.'
          config:
            type: TEXT
            priority: '7'
            section_name: Thresholds
            label: 'Max concurrent request threshold'
            description: 'Max concurrent request threshold In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$GCP.CPU.UTIL.MAX}'
          value: '90'
          description: 'GCP Cloud Run container instance CPU utilization threshold.'
          config:
            type: TEXT
            priority: '5'
            section_name: Thresholds
            label: 'Warning CPU usage threshold'
            description: 'CPU usage threshold. In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for API.'
          config:
            type: TEXT
            priority: '2'
            section_name: Other
            label: 'Response timeout'
            description: 'Response timeout for API.'
        - macro: '{$GCP.HTTP.FAIL.MAX.WARN}'
          value: '5'
          description: 'The maximum number of HTTP request failures for trigger expression.'
          config:
            type: TEXT
            priority: '8'
            section_name: Thresholds
            label: 'Max HTTP request failures'
            description: 'The maximum number of HTTP request failures for trigger expression.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$GCP.MEMORY.UTIL.CRIT}'
          value: '90'
          description: 'GCP Cloud Run container instance memory utilization threshold.'
          config:
            type: TEXT
            priority: '6'
            section_name: Thresholds
            label: 'Warning memory usage threshold'
            description: 'Memory usage threshold In the range from 0 to 100 inclusive.'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$GCP.PROJECT.ID}'
          description: 'GCP project ID.'
          config:
            type: TEXT
            priority: '1'
            label: 'GCP project ID'
            description: 'Google Cloud Platform project ID.'
            required: 'YES'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty, then no proxy is used.'
          config:
            type: TEXT
            priority: '4'
            section_name: Other
            label: 'HTTP proxy'
            description: 'HTTP proxy to use for requests.'
        - macro: '{$GCP.REQUEST.LATENCY.WARN}'
          value: '100'
          description: 'Maximum of request latency in milliseconds for trigger expression.'
          config:
            type: TEXT
            priority: '9'
            section_name: Thresholds
            label: 'Max request latency (ms)'
            description: 'Warning threshold for request latency (in milliseconds).'
            regex: '^-?([0-9]+|(([0-9]+)\.([0-9]+)))$'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for data requests.
            Supported usage types:
            - Default update interval for most items.
            - Minimal time window for data requested in Monitoring Query Language REST API request.
      dashboards:
        - uuid: 46afdd814acb409aaacbf91d7ffa12a6
          name: 'GCP Cloud Run: Service overview'
          pages:
            - name: Overview
              widgets:
                - type: problemsbysv
                  width: '60'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: reference
                      value: DTUCV
                    - type: INTEGER
                      name: severities.0
                      value: '1'
                    - type: INTEGER
                      name: severities.1
                      value: '2'
                    - type: INTEGER
                      name: severities.2
                      value: '3'
                    - type: INTEGER
                      name: severities.3
                      value: '4'
                    - type: INTEGER
                      name: severities.4
                      value: '5'
                - type: gauge
                  'y': '2'
                  width: '12'
                  height: '4'
                  hide_header: 'YES'
                  fields:
                    - type: INTEGER
                      name: angle
                      value: '270'
                    - type: STRING
                      name: description
                      value: 'CPU utilization'
                    - type: INTEGER
                      name: desc_size
                      value: '10'
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.cpu.utilization
                    - type: INTEGER
                      name: scale_size
                      value: '10'
                    - type: STRING
                      name: thresholds.0.color
                      value: 00C48C
                    - type: STRING
                      name: thresholds.0.threshold
                      value: '0'
                    - type: STRING
                      name: thresholds.1.color
                      value: FFBF59
                    - type: STRING
                      name: thresholds.1.threshold
                      value: '70'
                    - type: STRING
                      name: thresholds.2.color
                      value: E45959
                    - type: STRING
                      name: thresholds.2.threshold
                      value: '90'
                    - type: INTEGER
                      name: th_show_arc
                      value: '1'
                    - type: INTEGER
                      name: th_show_labels
                      value: '1'
                    - type: STRING
                      name: units
                      value: '%'
                - type: svggraph
                  name: 'Request count'
                  'y': '6'
                  width: '36'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 0080FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 81C784
                    - type: STRING
                      name: ds.0.color.2
                      value: f1e061
                    - type: STRING
                      name: ds.0.color.3
                      value: E45959
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.request.2xx.rate
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.request.3xx.rate
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.request.4xx.rate
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.request.5xx.rate
                    - type: STRING
                      name: reference
                      value: GKYQO
                    - type: INTEGER
                      name: righty
                      value: '0'
                - type: gauge
                  x: '12'
                  'y': '2'
                  width: '12'
                  height: '4'
                  hide_header: 'YES'
                  fields:
                    - type: INTEGER
                      name: angle
                      value: '270'
                    - type: STRING
                      name: description
                      value: 'Memory utilization'
                    - type: INTEGER
                      name: desc_size
                      value: '10'
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.memory.utilization
                    - type: INTEGER
                      name: scale_size
                      value: '10'
                    - type: STRING
                      name: thresholds.0.color
                      value: 00C48C
                    - type: STRING
                      name: thresholds.0.threshold
                      value: '0'
                    - type: STRING
                      name: thresholds.1.color
                      value: FFBF59
                    - type: STRING
                      name: thresholds.1.threshold
                      value: '70'
                    - type: STRING
                      name: thresholds.2.color
                      value: E45959
                    - type: STRING
                      name: thresholds.2.threshold
                      value: '90'
                    - type: INTEGER
                      name: th_show_arc
                      value: '1'
                    - type: INTEGER
                      name: th_show_labels
                      value: '1'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  x: '24'
                  'y': '2'
                  width: '12'
                  height: '4'
                  hide_header: 'YES'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Active container'
                    - type: INTEGER
                      name: desc_size
                      value: '10'
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.active.container.count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: INTEGER
                      name: show.2
                      value: '1'
                    - type: STRING
                      name: thresholds.0.color
                      value: FFCA28
                    - type: STRING
                      name: thresholds.0.threshold
                      value: '0'
                    - type: STRING
                      name: thresholds.1.color
                      value: 81C784
                    - type: STRING
                      name: thresholds.1.threshold
                      value: '1'
                - type: item
                  x: '36'
                  'y': '2'
                  width: '12'
                  height: '4'
                  hide_header: 'YES'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: description
                      value: 'Idle container'
                    - type: INTEGER
                      name: desc_size
                      value: '10'
                    - type: INTEGER
                      name: desc_v_pos
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.idle.container.count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: INTEGER
                      name: show.2
                      value: '1'
                - type: svggraph
                  name: 'Request latencies'
                  x: '36'
                  'y': '6'
                  width: '36'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 9575CD
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.request.latency
                    - type: STRING
                      name: reference
                      value: QRHPT
                    - type: INTEGER
                      name: righty
                      value: '0'
                - type: hostcard
                  x: '48'
                  'y': '2'
                  width: '24'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: sections.0
                      value: '2'
                    - type: INTEGER
                      name: sections.1
                      value: '1'
                - type: clock
                  x: '60'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: clock_type
                      value: '1'
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '3'
                    - type: INTEGER
                      name: time_bold
                      value: '1'
            - name: Metrics
              widgets:
                - type: svggraph
                  name: 'Sent bytes'
                  width: '36'
                  height: '4'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 0080FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 81C784
                    - type: STRING
                      name: ds.0.color.2
                      value: 9575CD
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.gce.google.sent_bytes.rate
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.gce.internet.sent_bytes.rate
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.gce.private.sent_bytes.rate
                    - type: STRING
                      name: reference
                      value: CCPFS
                    - type: INTEGER
                      name: righty
                      value: '0'
                - type: svggraph
                  name: 'Max concurrent requests'
                  'y': '4'
                  width: '36'
                  height: '4'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: f1e061
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.concurrent.request
                    - type: STRING
                      name: reference
                      value: KVHQY
                    - type: INTEGER
                      name: righty
                      value: '0'
                - type: svggraph
                  name: 'Billable instance time'
                  'y': '8'
                  width: '36'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: ds.0.approximation
                      value: '4'
                    - type: STRING
                      name: ds.0.color.0
                      value: 0080FF
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.billable.instance.time
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '1'
                    - type: INTEGER
                      name: ds.0.transparency
                      value: '2'
                    - type: INTEGER
                      name: ds.0.type
                      value: '2'
                    - type: STRING
                      name: reference
                      value: EVXIN
                    - type: INTEGER
                      name: righty
                      value: '0'
                - type: svggraph
                  name: 'Received bytes'
                  x: '36'
                  width: '36'
                  height: '4'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 0080FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 81C784
                    - type: STRING
                      name: ds.0.color.2
                      value: 9575CD
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.google.received_bytes.rate
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.internet.received_bytes.rate
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.private.received_bytes.rate
                    - type: STRING
                      name: reference
                      value: ITMKP
                    - type: INTEGER
                      name: righty
                      value: '0'
                - type: svggraph
                  name: 'Latency breakdown'
                  x: '36'
                  'y': '4'
                  width: '36'
                  height: '4'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 9575CD
                    - type: STRING
                      name: ds.0.color.1
                      value: 81C784
                    - type: STRING
                      name: ds.0.color.2
                      value: 0080FF
                    - type: STRING
                      name: ds.0.color.3
                      value: f1e061
                    - type: STRING
                      name: ds.0.color.4
                      value: d45c52
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.ingress.region.latency
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.pending.request.latency
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.response_egress.request.latency
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.routing.request.latency
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.user_execution.request.latency
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: REFMA
                    - type: INTEGER
                      name: righty
                      value: '0'
                - type: svggraph
                  name: 'End-to-end request latency'
                  x: '36'
                  'y': '8'
                  width: '36'
                  height: '4'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 9575CD
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'GCP Cloud Run Service by HTTP'
                        key: gcp.run.e2e.latency
                    - type: STRING
                      name: reference
                      value: HTZUI
                    - type: INTEGER
                      name: righty
                      value: '0'
    - uuid: 507d70db18554a4e9ee5e09bb29bc85f
      template: 'GCP Cloud SQL MSSQL by HTTP'
      name: 'GCP Cloud SQL MSSQL by HTTP'
      description: |
        Get GCP Cloud SQL MSSQL instances monitoring with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        This template is used in low-level discovery and will be auto-assigned to host prototypes. Additional configuration is not required.
      vendor:
        name: Zabbix
        version: 8.0-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: a8d79cab89864c03a7614bd59f734942
          name: 'Audits size'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.audits_size
          units: B
          description: |
            Tracks the size in bytes of stored SQLServer audit files on an instance.
            Empty value if there are no audits enabled.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_audits_size
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: security
        - uuid: 3026bc61670c496a942a94ab50b614df
          name: 'Audits successfully uploaded'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.audits_upload_count
          description: |
            Tracks the size in bytes of stored SQLServer audit files on an instance.
            Empty value if there are no audits enabled.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_success
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: security
        - uuid: d512c542f5514681acbb11431a0a6f5a
          name: 'Connection resets'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.conn.connection_reset_count
          description: 'Total number of login operations started from the connection pool since the last restart of SQL Server service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_connection_reset_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 300a6cb53fb44176bdf99eba86a976bd
          name: 'Login attempts'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.conn.login_attempt_count
          description: |
            Total number of login attempts since the last restart of SQL Server service.
            This does not include pooled connections.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_login_attempt_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 622c237ed12e44c7b2415676ec23bd2d
          name: Logouts
          type: DEPENDENT
          key: gcp.cloudsql.mssql.conn.logout_count
          description: 'Total number of logout operations since the last restart of SQL Server service.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_logout_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 6ba672cbf4c242eb8e6fb80eba4c90d8
          name: 'Processes blocked'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.conn.processes_blocked
          description: 'Current number of blocked processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_processes_blocked
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 38de8ae591854d5fbc4ee4946a2e189a
          name: 'Reserved CPU cores'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.cpu.reserved_cores
          value_type: FLOAT
          description: 'Number of cores reserved for the database.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_reserved_cores
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: cd1f9ab326ac4694b3aeea6cb4ec56ab
          name: 'CPU usage time'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.cpu.usage_time
          value_type: FLOAT
          units: s
          description: 'Cumulative CPU usage time in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage_time
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: 42d51e38b96f472996eff1e0f9d7b931
          name: 'CPU utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: 'Current CPU utilization represented as a percentage of the reserved CPU that is currently in use.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: b8280e45fea8470e9f36f7f08e4a77e1
              expression: 'min(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.cpu.utilization,5m) >= {$CLOUD_SQL.MSSQL.CPU.UTIL.MAX}'
              name: 'GCP MSSQL: High CPU utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: ecdd1774ef744bcb93e8e4094e29772f
          name: 'Databases get'
          type: SCRIPT
          key: gcp.cloudsql.mssql.db.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/sqlserver/transactions/',
            	arr = [],
            	base_paths = [
            		'log_bytes_flushed_count',
            		'transaction_count'
            	];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            var params = checkParams(JSON.parse(value)),
            	j_filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'" + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
            	metrics = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            	time_series = getField(raw, 'timeSeriesData');
            
            for (t in time_series) {
            	data = {
            		database: getField(time_series[t], 'labelValues.3.stringValue'),
            		metrics: {}
            	};
            
            	for (i in metrics) {
            		re = /(^t_\d+\.value(_|\.))/g;
            		data['metrics'][getField(metrics[i], 'key').replace(re, '')] = getField(time_series[t], 'pointData.0.values.' + i + '.int64Value');
            	}
            	arr.push(data);
            }
            return JSON.stringify(arr);
          description: 'MSSQL databases data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 9806c645a10a4e1d8fbb39eb1d3ac993
          name: 'DB engine state'
          type: HTTP_AGENT
          key: gcp.cloudsql.mssql.db.state
          description: 'GCP Cloud SQL MSSQL DB Engine State.'
          valuemap:
            name: 'Database availability'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].int64Value'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/up | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: b3c7b8e2e38a42fe9d2ae3c84b637e53
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.db.state)=0'
              name: 'GCP MSSQL: Database engine is down'
              priority: AVERAGE
              description: |
                Database engine is down.
                If an instance experiences unplanned (non-maintenance) downtime, the instance state will still be RUNNING, but the database engine state metric will report 0.
              dependencies:
                - name: 'GCP MSSQL: Failed to get the instance state'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 10'
                - name: 'GCP MSSQL: Instance is in failed state'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 5'
                - name: 'GCP MSSQL: Instance is in maintenance'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 4'
                - name: 'GCP MSSQL: Instance is in suspended state'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 1'
                - name: 'GCP MSSQL: Instance is in unknown state'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 6'
                - name: 'GCP MSSQL: Instance is stopped by the owner'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 2'
              tags:
                - tag: scope
                  value: availability
        - uuid: cd6cf3870a514ff59bd1f40987764642
          name: 'Disk bytes used'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.disk.bytes_used
          units: B
          description: 'Data utilization in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_bytes_used
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 86bdbf20c9b4466c9ea00e26cb0f0652
          name: 'Disk size'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.disk.quota
          units: B
          description: 'Maximum data disk size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_quota
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 400a7318203f40928ebf0b023da65848
          name: 'Disk read I/O'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.disk.read_ops_count
          description: 'Delta count of data disk read I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_read_ops_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 1d0c09441d9d4333b7be32c3d69bad47
          name: 'Disk utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.disk.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the disk quota that is currently in use. 
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 2cbc7e3008f24197963df4ea920ab5a8
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.disk.utilization) >= {$CLOUD_SQL.MSSQL.DISK.UTIL.CRIT}'
              name: 'GCP MSSQL: Disk space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'Critical utilization of the disk space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 2569abbb94ca4df38cdd4f9d5a5df9fc
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.disk.utilization) >= {$CLOUD_SQL.MSSQL.DISK.UTIL.WARN}'
              name: 'GCP MSSQL: Disk space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              dependencies:
                - name: 'GCP MSSQL: Disk space is critically low'
                  expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.disk.utilization) >= {$CLOUD_SQL.MSSQL.DISK.UTIL.CRIT}'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 819078cd99af46368eb33d76dadf4861
          name: 'Disk write I/O'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.disk.write_ops_count
          description: 'Delta count of data disk write I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_write_ops_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 556c96cf1bf342f99c69dc47813f221e
          name: 'Instance state'
          type: HTTP_AGENT
          key: gcp.cloudsql.mssql.inst.state
          description: 'GCP Cloud SQL MSSQL Current instance state.'
          valuemap:
            name: 'Instance state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].stringValue'
              error_handler: CUSTOM_VALUE
              error_handler_params: '10'
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'RUNNING',
                  	'SUSPENDED',
                  	'RUNNABLE',
                  	'PENDING_CREATE',
                  	'MAINTENANCE',
                  	'FAILED',
                  	'UNKNOWN_STATE'
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/state | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: dff9067ad7de4ab1a4f83c9d482e6b71
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 10'
              name: 'GCP MSSQL: Failed to get the instance state'
              priority: AVERAGE
              description: |
                Failed to get the instance state. 
                Check access permissions to GCP API or service account.
              tags:
                - tag: scope
                  value: availability
            - uuid: 3d7e054340e94b09b085e508b9b76841
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 5'
              name: 'GCP MSSQL: Instance is in failed state'
              priority: AVERAGE
              description: 'The instance creation failed, or an operation left the instance in an own bad state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: dd395fd3003f4fce847cd72309cdf7ec
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 4'
              name: 'GCP MSSQL: Instance is in maintenance'
              priority: INFO
              description: 'The instance is down for maintenance.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 3c080bba511e44aab1139b66f00451ee
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 1'
              name: 'GCP MSSQL: Instance is in suspended state'
              priority: WARNING
              description: |
                The instance is in suspended state. 
                It is not available, for example, due to problems with billing.
              tags:
                - tag: scope
                  value: availability
            - uuid: 378b4d62582d416db7cb7fd6ed099ac9
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 6'
              name: 'GCP MSSQL: Instance is in unknown state'
              priority: AVERAGE
              description: 'The state of the instance is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 72ecba08f6424573a36b816da9695b89
              expression: 'last(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.inst.state) = 2'
              name: 'GCP MSSQL: Instance is stopped by the owner'
              priority: INFO
              description: |
                The instance has been stopped by the owner. 
                It is not currently running, but it's ready to be restarted.
              tags:
                - tag: scope
                  value: availability
        - uuid: a29584de7ab142309f0bb6f57b52af85
          name: 'Buffer cache hit ratio'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.buffer_cache_hit_ratio
          value_type: FLOAT
          units: '%'
          description: |
            Current percentage of pages found in the buffer cache without having to read from disk.
            The ratio is the total number of cache hits divided by the total number of cache lookups.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_buffer_cache_hit_ratio
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: f8460bbac21c44a98a31a49daf7f692f
          name: 'Checkpoint pages'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.checkpoint_page_count
          description: 'Total number of pages flushed to disk by a checkpoint or other operation that requires all dirty pages to be flushed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_checkpoint_page_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: cc6a5230c7a2447e8038cdbe52105da4
          name: 'Free list stalls'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.free_list_stall_count
          description: 'Total number of requests that had to wait for a free page.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_free_list_stall_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: d86e328fc5fa4c3d938a4959075299b5
          name: 'Lazy writes'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.lazy_write_count
          description: |
            Total number of buffers written by the buffer manager's lazy writer.
            The lazy writer is a system process that flushes out batches of dirty, aged buffers
            (buffers that contain changes that must be written back to disk before the buffer can be reused for a different page)
            and makes them available to user processes.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_lazy_write_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 2fa0744221884109951ce62d3bb9aaaf
          name: 'Memory grants pending'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.memory_grants_pending
          description: 'Current number of processes waiting for a workspace memory grant.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_memory_grants_pending
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 3dcad151d0c04f8eb0e8e81c00de23c8
          name: 'Page life expectancy'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.page_life_expectancy
          units: s
          description: 'Current number of seconds a page will stay in the buffer pool without references.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_page_life_expectancy
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 4d87a50d490348afbaf751857beb5b61
          name: 'Read page operations'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.page_ops.read
          description: |
            Total number of physical database page reads.
            This metric counts physical page reads across all databases.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_read
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 41654bd730b744acbc0ea6de07c992f3
          name: 'Write age operations'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.page_ops.write
          description: |
            Total number of physical database page writes.
            This metric counts physical page writes across all databases.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_write
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: db943300803847718c52d0d33988d81e
          name: 'Memory size'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.quota
          units: B
          description: 'Maximum RAM size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_quota
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 21b075a5f95d4c93888b7a0766fdcea5
          name: 'Memory used by DB engine'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.total_usage
          units: B
          description: |
            Total RAM usage in bytes. 
            This metric reports the RAM usage of the database process, including the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_total_usage
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 05d1ff573371416dad9ee028247b1cf3
          name: 'Memory usage'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.usage
          units: B
          description: |
            The RAM usage in bytes. 
            This metric reports the RAM usage of the server, excluding the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 4e11944fb7624ffdb02b5d1bb5bedf7a
          name: 'Memory utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.memory.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the memory quota that is currently in use.
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_ram_pused
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: c5003533f3524b8b868a0c2f86b1fa9b
              expression: 'min(/GCP Cloud SQL MSSQL by HTTP/gcp.cloudsql.mssql.memory.utilization,5m) >= {$CLOUD_SQL.MSSQL.RAM.UTIL.MAX}'
              name: 'GCP MSSQL: High memory utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: HIGH
              description: 'RAM utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 6de08b07cecc47a88bde22de5d1b4e5a
          name: 'Metrics get'
          type: SCRIPT
          key: gcp.cloudsql.mssql.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/',
            	mssql_path = 'cloudsql.googleapis.com/database/sqlserver/',
            	obj = {},
            	base_paths = [
            		'cpu/reserved_cores',
            		'cpu/usage_time',
            		'cpu/utilization',
            		'disk/read_ops_count',
            		'disk/write_ops_count',
            		'memory/quota',
            		'memory/total_usage',
            		'memory/usage',
            		'network/connections',
            		'network/received_bytes_count',
            		'network/sent_bytes_count | map ignore [destination]'
            	].map(function (path) { return base_path + path; }),
            	mssql_paths = [
            		'connections/connection_reset_count',
            		'connections/login_attempt_count',
            		'connections/logout_count',
            		'connections/processes_blocked',
            		'memory/buffer_cache_hit_ratio',
            		'memory/checkpoint_page_count',
            		'memory/lazy_write_count',
            		'memory/memory_grants_pending',
            		'memory/page_life_expectancy',
            		'memory/free_list_stall_count',
            		'transactions/batch_request_count',
            		'transactions/forwarded_record_count',
            		'transactions/full_scan_count',
            		'transactions/page_split_count',
            		'transactions/probe_scan_count',
            		'transactions/sql_compilation_count',
            		'transactions/sql_recompilation_count'
            	].map(function (path) { return mssql_path + path; }).concat(
            		['disk/bytes_used', 'disk/utilization', 'disk/quota'].map(function (path) { return base_path + path; })),
            	value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function getFieldBool(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			return false;
            		}
            		data = data[step];
            	}
            	return true;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token', 'audited'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	if (params.audited !== 'true' && params.audited !== 'false') {
            		throw 'Incorrect audit definition type. Valid definitions: true/false';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            function rawMap(raw, prefix) {
            	var keys = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            		values = getField(raw, 'timeSeriesData.0.pointData.0.values'),
            		re = /(^t_\d+\.value\.)/g;
            
            	for (i in keys) {
            		var key = getField(keys[i], 'key').replace(re, '');
            
            		for (v in value_types) {
            			if (typeof values[i][value_types[v]] !== 'undefined') {
            				if (prefix) {
            					obj[prefix + key] = values[i][value_types[v]];
            				}
            				else {
            					obj[key] = values[i][value_types[v]];
            				}
            
            			}
            		}
            	}
            	return obj;
            }
            
            function singleMetrics(tsd) {
            	var result = {};
            
            	for (t in tsd) {
            		for (v in value_types) {
            			if (getFieldBool(tsd[t], 'pointData.0.values.0.' + [value_types[v]])) {
            				result['mssql_' + getField(tsd[t], 'labelValues.3.stringValue').toLowerCase()] = tsd[t].pointData[0].values[0][value_types[v]];
            				break;
            			}
            		}
            	}
            	return result;
            }
            
            var params = checkParams(JSON.parse(value));
            
            if (params.audited === 'true') {
            	base_paths.push(mssql_path + 'audits_size');
            };
            
            var filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	queries = [
            		{ name: 'base_', data: { query: '{' + base_paths.join(';') + '}' + j_filter } },
            		{ name: 'mssql_', data: { query: '{' + mssql_paths.join(';') + '}' + j_filter } }
            	];
            
            for (q in queries) {
            	raw = getHttpData(url, params.token, queries[q].data);
            	obj = Object.assign(obj, rawMap(raw, queries[q].name));
            }
            
            obj.base_ram_pused = Math.floor(getField(obj, 'base_usage') / getField(obj, 'base_quota') * 100);
            
            var single_queries = [
            	{ query: mssql_path + 'memory/page_operation_count' + filter }
            ];
            
            if (params.audited === 'true') {
            	single_queries.push({ query: mssql_path + 'audits_upload_count' + filter });
            }
            
            for (q in single_queries) {
            	raw = getHttpData(url, params.token, single_queries[q]);
            	Object.assign(obj, singleMetrics(getField(raw, 'timeSeriesData')));
            }
            
            return JSON.stringify(obj);
          description: 'MSSQL metrics data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: audited
              value: '{$CLOUD_SQL.MSSQL.AUDITED}'
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 393b6117008d4925be9474afc9c7cdf9
          name: Connections
          type: DEPENDENT
          key: gcp.cloudsql.mssql.network.connections
          description: 'Number of connections to the databases on the Cloud SQL instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_connections
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 297744bfcdd84565b828e1c6912beb46
          name: 'Network: Received bytes'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.network.received_bytes_count
          units: B
          description: 'Delta count of bytes received through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_received_bytes_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: b362d14169b34f00ab3fa94b89a1b362
          name: 'Network: Sent bytes'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.network.sent_bytes_count
          units: B
          description: 'Delta count of bytes sent through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_sent_bytes_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 7ee117702e1f40faadd901faa9d333ff
          name: 'Resources get'
          type: SCRIPT
          key: gcp.cloudsql.mssql.resources.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/sqlserver/transactions/',
            	arr = [],
            	base_paths = [
            		'deadlock_count',
            		'lock_wait_count',
            		'lock_wait_time'
            	];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            var params = checkParams(JSON.parse(value)),
            	j_filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'" + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
            	metrics = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            	time_series = getField(raw, 'timeSeriesData');
            
            for (t in time_series) {
            	data = {
            		resource: getField(time_series[t], 'labelValues.3.stringValue'),
            		metrics: {}
            	};
            
            	for (i in metrics) {
            		re = /(^t_\d+\.value(_|\.))/g;
            		data['metrics'][getField(metrics[i], 'key').replace(re, '')] = getField(time_series[t], 'pointData.0.values.' + i + '.int64Value');
            	}
            	arr.push(data);
            }
            return JSON.stringify(arr);
          description: 'MSSQL resources data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 3c14882329b94b8e88ca5d85e21bb7c8
          name: 'Schedulers get'
          type: SCRIPT
          key: gcp.cloudsql.mssql.schedulers.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/sqlserver/schedulers/',
            	arr = [],
            	base_paths = ['active_workers', 'current_tasks', 'current_workers', 'pending_disk_io', 'runnable_tasks', 'work_queue'];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            var params = checkParams(JSON.parse(value)),
            	j_filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'" + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
            	metrics = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            	time_series = getField(raw, 'timeSeriesData');
            
            for (t in time_series) {
            	data = {
            		scheduler: getField(time_series[t], 'labelValues.3.stringValue'),
            		metrics: {}
            	};
            
            	for (i in metrics) {
            		re = /(^t_\d+\.value(_|\.))/g;
            		data['metrics'][getField(metrics[i], 'key').replace(re, '')] = getField(time_series[t], 'pointData.0.values.' + i + '.int64Value');
            	}
            	arr.push(data);
            }
            return JSON.stringify(arr);
          description: 'MSSQL schedulers data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 7d2c28a537e44ee284e4b5d186b935d6
          name: 'Batch requests'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.batch_request_count
          description: 'Total number of Transact-SQL command batches received.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_batch_request_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 774cffa1a1f24d778f346bea24926690
          name: 'Forwarded records'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.forwarded_record_count
          description: 'Total number of records fetched through forwarded record pointers.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_forwarded_record_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: f80a924d20c4470496202d3e32261e7d
          name: 'Full scans'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.full_scan_count
          description: |
            Total number of unrestricted full scans.
            These can be either base-table or full-index scans.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_full_scan_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: cd6f91964b7041bb929c6f6f3430cc75
          name: 'Page splits'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.page_split_count
          description: 'Total number of page splits that occur as the result of overflowing index pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_page_split_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 0b431016ca8245dea8e33c252a9a7c9b
          name: 'Probe scans'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.probe_scan_count
          description: 'Total number of probe scans that are used to find at least one single qualified row in an index or base table directly.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_probe_scan_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: bf4eb81de038452cb3af16b4efcdb4c5
          name: 'SQL compilations'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.sql_compilation_count
          description: 'Total number of SQL compilations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_sql_compilation_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 39c350f5d1f94726b03c435e9e5e3110
          name: 'SQL recompilations'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.trans.sql_recompilation_count
          description: 'Total number of SQL recompilations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mssql_sql_recompilation_count
          master_item:
            key: gcp.cloudsql.mssql.metrics.get
          tags:
            - tag: component
              value: transactions
      discovery_rules:
        - uuid: 2dad3e63931942f8937b8720c9477a66
          name: 'Databases discovery'
          type: DEPENDENT
          key: gcp.cloudsql.db.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#DB.NAME}'
                value: '{$CLOUD_SQL.MSSQL.DB.NAME.MATCHES}'
              - macro: '{#DB.NAME}'
                value: '{$CLOUD_SQL.MSSQL.DB.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Databases discovery.'
          item_prototypes:
            - uuid: 8f6deafa9efd416797ea58d1fce41c29
              name: 'Database [{#DB.NAME}]: Log bytes flushed'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.db.log_bytes_flushed_count[{#DB.NAME}]'
              units: B
              description: 'Total number of log bytes flushed for the [{#DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.log_bytes_flushed_count
              master_item:
                key: 'gcp.cloudsql.mssql.db.raw[{#DB.NAME}]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DB.NAME}'
            - uuid: b52f757bc2b341e891f60e15795088ca
              name: 'Database [{#DB.NAME}]: Raw data'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.db.raw[{#DB.NAME}]'
              history: '0'
              value_type: TEXT
              description: 'Data in raw format for the [{#DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.database == "{#DB.NAME}")].metrics.first()'
              master_item:
                key: gcp.cloudsql.mssql.db.get
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#DB.NAME}'
            - uuid: 9f8d37a25e1041c087bbea8d670cce46
              name: 'Database [{#DB.NAME}]: Transactions started'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.db.transaction_count[{#DB.NAME}]'
              description: 'Total number of transactions started for the [{#DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.transaction_count
              master_item:
                key: 'gcp.cloudsql.mssql.db.raw[{#DB.NAME}]'
              tags:
                - tag: component
                  value: database
                - tag: database
                  value: '{#DB.NAME}'
          master_item:
            key: gcp.cloudsql.mssql.db.get
          lld_macro_paths:
            - lld_macro: '{#DB.NAME}'
              path: $.database
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: d47a9164fdf54309ab96f48f6dc3c037
          name: 'Resources discovery'
          type: DEPENDENT
          key: gcp.cloudsql.resources.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#RESOURCE.NAME}'
                value: '{$CLOUD_SQL.MSSQL.RES.NAME.MATCHES}'
              - macro: '{#RESOURCE.NAME}'
                value: '{$CLOUD_SQL.MSSQL.RES.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Resources discovery.'
          item_prototypes:
            - uuid: 55bb12000dca46e096045da83a46edea
              name: 'Resource [{#RESOURCE.NAME}]: Deadlocks'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.resource.deadlock_count[{#RESOURCE.NAME}]'
              description: 'Total number of lock requests that resulted in a deadlock for the [{#RESOURCE.NAME}] resource.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.deadlock_count
              master_item:
                key: 'gcp.cloudsql.mssql.resource.raw[{#RESOURCE.NAME}]'
              tags:
                - tag: component
                  value: resource
                - tag: resource
                  value: '{#RESOURCE.NAME}'
            - uuid: 0117dba440f34461959490efaff059e2
              name: 'Resource [{#RESOURCE.NAME}]: Lock waits'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.resource.lock_wait_count[{#RESOURCE.NAME}]'
              description: 'Total number of lock requests that required the caller to wait for the [{#RESOURCE.NAME}] resource.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.lock_wait_count
              master_item:
                key: 'gcp.cloudsql.mssql.resource.raw[{#RESOURCE.NAME}]'
              tags:
                - tag: component
                  value: resource
                - tag: resource
                  value: '{#RESOURCE.NAME}'
            - uuid: 6e8b5646d70b470fa18960c7b43a9aff
              name: 'Resource [{#RESOURCE.NAME}]: Lock wait time'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.resource.lock_wait_time[{#RESOURCE.NAME}]'
              units: s
              description: 'Total time lock requests were waiting for locks for the [{#RESOURCE.NAME}] resource.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.lock_wait_time
              master_item:
                key: 'gcp.cloudsql.mssql.resource.raw[{#RESOURCE.NAME}]'
              tags:
                - tag: component
                  value: resource
                - tag: resource
                  value: '{#RESOURCE.NAME}'
            - uuid: 0cc16595d1e044db947084a44786aaaa
              name: 'Resource [{#RESOURCE.NAME}]: Raw data'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.resource.raw[{#RESOURCE.NAME}]'
              history: '0'
              value_type: TEXT
              description: 'Data in raw format for the [{#RESOURCE.NAME}] resource.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.resource == "{#RESOURCE.NAME}")].metrics.first()'
              master_item:
                key: gcp.cloudsql.mssql.resources.get
              tags:
                - tag: component
                  value: raw
                - tag: resource
                  value: '{#RESOURCE.NAME}'
          master_item:
            key: gcp.cloudsql.mssql.resources.get
          lld_macro_paths:
            - lld_macro: '{#RESOURCE.NAME}'
              path: $.resource
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
        - uuid: 31667d0e9c32458d9c895367b3ca7042
          name: 'Schedulers discovery'
          type: DEPENDENT
          key: gcp.cloudsql.schedulers.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#SCHEDULER.ID}'
                value: '{$CLOUD_SQL.MSSQL.SCHEDULER.ID.MATCHES}'
              - macro: '{#SCHEDULER.ID}'
                value: '{$CLOUD_SQL.MSSQL.SCHEDULER.ID.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Schedulers discovery.'
          item_prototypes:
            - uuid: 67bde61c128e4dfe9e47d8a3a6e3ceec
              name: 'Scheduler [{#SCHEDULER.ID}]: Active workers'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.active_workers[{#SCHEDULER.ID}]'
              description: |
                Current number of active workers associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].
                An active worker is never preemptive, must have an associated task, and is either running, runnable, or suspended.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.active_workers
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: fc5113b2b5f64205ad9d100bd480adea
              name: 'Scheduler [{#SCHEDULER.ID}]: Current tasks'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.current_tasks[{#SCHEDULER.ID}]'
              description: |
                Current number of present tasks associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].
                This count includes tasks that are waiting for a worker to execute them and tasks that are currently waiting or running (in SUSPENDED or RUNNABLE state).
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.current_tasks
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: 6602f8d26a9a46fb8ed74a40d10f36e4
              name: 'Scheduler [{#SCHEDULER.ID}]: Current workers'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.current_workers[{#SCHEDULER.ID}]'
              description: |
                Current number of workers associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].
                It includes workers that are not assigned any task.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.current_workers
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: 2022a85bb7c04e73a75136e55162084a
              name: 'Scheduler [{#SCHEDULER.ID}]: Pending I/O operations'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.pending_disk_io[{#SCHEDULER.ID}]'
              description: |
                Current number of pending I/Os waiting to be completed that are associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].
                Each scheduler has a list of pending I/Os that are checked to determine whether they have been completed every time there is a context switch.
                The count is incremented when the request is inserted.
                This count is decremented when the request is completed.
                This number does not indicate the state of the I/Os.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.pending_disk_io
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: c3e337845c344f4cb0d14a5e7d22cbb7
              name: 'Scheduler [{#SCHEDULER.ID}]: Raw data'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              history: '0'
              value_type: TEXT
              description: 'Data in raw format associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.scheduler == "{#SCHEDULER.ID}")].metrics.first()'
              master_item:
                key: gcp.cloudsql.mssql.schedulers.get
              tags:
                - tag: component
                  value: raw
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: a9852ac0cdcc423fad6b305eb57eedf1
              name: 'Scheduler [{#SCHEDULER.ID}]: Runnable tasks'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.runnable_tasks[{#SCHEDULER.ID}]'
              description: 'Current number of workers that are associated with the scheduler that goes by its ID [{#SCHEDULER.ID}] and have assigned tasks waiting to be scheduled on the runnable queue.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.runnable_tasks
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
            - uuid: eaae59fb97124471b1c7c30c601dba1f
              name: 'Scheduler [{#SCHEDULER.ID}]: Work queue'
              type: DEPENDENT
              key: 'gcp.cloudsql.mssql.scheduler.work_queue[{#SCHEDULER.ID}]'
              description: |
                Current number of tasks in the pending queue associated with the scheduler that goes by its ID [{#SCHEDULER.ID}].
                These tasks are waiting for a worker to pick them up.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.work_queue
              master_item:
                key: 'gcp.cloudsql.mssql.scheduler.raw[{#SCHEDULER.ID}]'
              tags:
                - tag: component
                  value: scheduler
                - tag: scheduler
                  value: '{#SCHEDULER.ID}'
          master_item:
            key: gcp.cloudsql.mssql.schedulers.get
          lld_macro_paths:
            - lld_macro: '{#SCHEDULER.ID}'
              path: $.scheduler
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: mssql
      macros:
        - macro: '{$CLOUD_SQL.MSSQL.CPU.UTIL.MAX}'
          value: '95'
          description: 'GCP Cloud SQL MSSQL instance CPU usage threshold.'
        - macro: '{$CLOUD_SQL.MSSQL.DB.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL databases by namespace.'
        - macro: '{$CLOUD_SQL.MSSQL.DB.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MSSQL databases by namespace.'
        - macro: '{$CLOUD_SQL.MSSQL.DISK.UTIL.CRIT}'
          value: '90'
          description: 'GCP Cloud SQL MSSQL instance critical disk usage threshold.'
        - macro: '{$CLOUD_SQL.MSSQL.DISK.UTIL.WARN}'
          value: '80'
          description: 'GCP Cloud SQL MSSQL instance warning disk usage threshold.'
        - macro: '{$CLOUD_SQL.MSSQL.RAM.UTIL.MAX}'
          value: '90'
          description: 'GCP Cloud SQL MSSQL instance RAM usage threshold.'
        - macro: '{$CLOUD_SQL.MSSQL.RES.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL resources by namespace.'
        - macro: '{$CLOUD_SQL.MSSQL.RES.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MSSQL resources by namespace.'
        - macro: '{$CLOUD_SQL.MSSQL.SCHEDULER.ID.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL MSSQL schedulers by namespace.'
        - macro: '{$CLOUD_SQL.MSSQL.SCHEDULER.ID.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL MSSQL schedulers by namespace.'
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for data requests.
            Supported usage types:
            - Default update interval for most items.
            - Minimal time window for data requested in Monitoring Query Language REST API request.
      dashboards:
        - uuid: 4233430037fc4570b3a5eb3f23ef02e6
          name: 'MSSQL instance'
          pages:
            - name: 'MSSQL instance'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.cpu.usage_time
                    - type: STRING
                      name: reference
                      value: AAAAA
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Memory usage'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.disk.utilization
                    - type: STRING
                      name: reference
                      value: AAAAE
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Transactions'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graph
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Memory workflow'
                    - type: STRING
                      name: reference
                      value: AAAAK
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.cpu.utilization
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.memory.utilization
                    - type: STRING
                      name: reference
                      value: AAAAD
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Disk read/write operations'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.network.connections
                    - type: STRING
                      name: reference
                      value: AAAAH
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        key: gcp.cloudsql.mssql.memory.buffer_cache_hit_ratio
                    - type: STRING
                      name: reference
                      value: AAAAJ
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Memory Read/Writes'
                    - type: STRING
                      name: reference
                      value: AAAAL
      valuemaps:
        - uuid: d2aa57a09cbb43e8b53b11316193f013
          name: 'Database availability'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
        - uuid: 1c26d58d111b4689a2e7acd23a38f1ca
          name: 'Instance state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Suspended
            - value: '2'
              newvalue: Runnable
            - value: '3'
              newvalue: 'Pending create'
            - value: '4'
              newvalue: Maintenance
            - value: '5'
              newvalue: Failed
            - value: '6'
              newvalue: 'Unknown state'
            - value: '10'
              newvalue: 'Data retrievement error'
    - uuid: 54f0ffb538d94a9bb8062df3e63c4cb6
      template: 'GCP Cloud SQL MSSQL Replica by HTTP'
      name: 'GCP Cloud SQL MSSQL Replica by HTTP'
      description: |
        Get GCP Cloud SQL MSSQL monitoring for read-only replicas with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        This template is used in low-level discovery and will be auto-assigned to host prototypes. Additional configuration is not required.
      vendor:
        name: Zabbix
        version: 8.0-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: e66fe8bb6f924cb088ec57b215fe21d7
          name: 'Bytes sent to replica'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.bytes_sent_to_replica_count
          units: B
          description: |
            Total number of bytes sent to the remote availability replica.
            For an async replica, returns the number of bytes before compression.
            For a sync replica without compression, returns the actual number of bytes.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.bytes_sent_to_replica_count
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 4100432768354e1ca7349a901bccbe85
          name: 'Log apply pending queue'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.log_apply_pending_queue
          description: 'Current number of log blocks that are waiting to be applied to replica.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.log_apply_pending_queue
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: d060637548af434e926ed833083d9fa0
          name: 'Log bytes received'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.log_bytes_received_count
          units: B
          description: 'Total size of log records received by the replica.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.log_bytes_received_count
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: f0d4c711863f4ca9ad76b0099a66a86d
          name: 'Replica metrics get'
          type: SCRIPT
          key: gcp.cloudsql.mssql.repl.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/sqlserver/replication/',
            	obj = {},
            	base_paths = [
            		'bytes_sent_to_replica_count | map ignore [replica_name]',
            		'resent_message_count | map ignore [replica_name]',
            		'log_apply_pending_queue',
            		'log_bytes_received_count',
            		'recovery_queue',
            		'redone_bytes_count'
            	];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            var params = checkParams(JSON.parse(value)),
            	filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	base_raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
            	keys = getField(base_raw, 'timeSeriesDescriptor.pointDescriptors'),
            	values = getField(base_raw, 'timeSeriesData.0.pointData.0.values'),
            	re = /(^t_\d+\.value\.)/g;
            
            for (i in keys) {
            	var value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            	for (v in value_types) {
            		if (typeof values[i][value_types[v]] !== 'undefined') {
            			obj[getField(keys[i], 'key').replace(re, '')] = values[i][value_types[v]];
            		}
            	}
            }
            
            return JSON.stringify(obj);
          description: 'MSSQL replica metrics data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 4ec364fea7894df29813b65c2d170367
          name: 'Recovery queue'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.recovery_queue
          units: B
          description: 'Current size of log records in bytes in the replica''s log files that have not been redone.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.recovery_queue
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 37c145777926471482ecffd1b6cca792
          name: 'Redone bytes'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.redone_bytes_count
          units: B
          description: 'Total size in bytes of redone log records.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.redone_bytes_count
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 23911902d27e4fa68435935aeeec28e1
          name: 'Resent messages'
          type: DEPENDENT
          key: gcp.cloudsql.mssql.repl.resent_message_count
          description: |
            Total count of Always On messages to resend.
            This includes messages that were attempted to be sent but failed and require resending.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.resent_message_count
          master_item:
            key: gcp.cloudsql.mssql.repl.metrics.get
          tags:
            - tag: component
              value: replication
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: mssql
        - tag: target
          value: replica
      macros:
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for data requests.
            Supported usage types:
            - Default update interval for most items.
            - Minimal time window for data requested in Monitoring Query Language REST API request.
      dashboards:
        - uuid: f50d9889ca3c4f6b91dd9e40902e37fb
          name: 'MSSQL replica'
          pages:
            - name: 'MSSQL replica'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL Replica by HTTP'
                        name: 'GCP Cloud SQL MSSQL: Replication data'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MSSQL Replica by HTTP'
                        key: gcp.cloudsql.mssql.repl.log_apply_pending_queue
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '1'
    - uuid: 38456af4aedd4b168ec3fa4ad2acb256
      template: 'GCP Cloud SQL MySQL by HTTP'
      name: 'GCP Cloud SQL MySQL by HTTP'
      description: |
        Get GCP Cloud SQL MySQL instances monitoring with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        This template is used in low-level discovery and will be auto-assigned to host prototypes. Additional configuration is not required.
      vendor:
        name: Zabbix
        version: 8.0-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 83e36c61e8ce4d06a395ea7b06c5877b
          name: 'Reserved CPU cores'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.cpu.reserved_cores
          value_type: FLOAT
          description: 'Number of cores reserved for the database.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_reserved_cores
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: a39ba253dbf24110af48fd49572976fd
          name: 'CPU usage time'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.cpu.usage_time
          value_type: FLOAT
          units: s
          description: 'Cumulative CPU usage time in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage_time
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: df7469e3c76c4286846c27003c9785cc
          name: 'CPU utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: 'Current CPU utilization represented as a percentage of the reserved CPU that is currently in use.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 5bf54c01665549c8a05f49db34c86191
              expression: 'min(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.cpu.utilization,5m) >= {$CLOUD_SQL.MYSQL.CPU.UTIL.MAX}'
              name: 'GCP MySQL: High CPU utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 948dac37023c4efcaf5f830ba5d4fafe
          name: 'DB engine state'
          type: HTTP_AGENT
          key: gcp.cloudsql.mysql.db.state
          description: 'GCP Cloud SQL MySQL DB Engine State.'
          valuemap:
            name: 'Database availability'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].int64Value'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/up | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: a3eff8c422f5427e9b1c6abb9854f73c
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.db.state)=0'
              name: 'GCP MySQL: Database engine is down'
              priority: AVERAGE
              description: |
                Database engine is down.
                If an instance experiences unplanned (non-maintenance) downtime, the instance state will still be RUNNING, but the database engine state metric will report 0.
              dependencies:
                - name: 'GCP MySQL: Failed to get the instance state'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 10'
                - name: 'GCP MySQL: Instance is in failed state'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 5'
                - name: 'GCP MySQL: Instance is in maintenance'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 4'
                - name: 'GCP MySQL: Instance is in suspended state'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 1'
                - name: 'GCP MySQL: Instance is in unknown state'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 6'
                - name: 'GCP MySQL: Instance is stopped by the owner'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 2'
              tags:
                - tag: scope
                  value: availability
        - uuid: 76c37760145d43f3927f1a9548dea8a5
          name: 'Disk bytes used'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.disk.bytes_used
          units: B
          description: 'Data utilization in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_bytes_used
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 464fecbbedd64e988739c93736d2b824
          name: 'Disk size'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.disk.quota
          units: B
          description: 'Maximum data disk size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_quota
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: d426d282d2ee43fe9c9b64dcb6d0c4c9
          name: 'Disk read I/O'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.disk.read_ops_count
          description: 'Delta count of data disk read I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_read_ops_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: b2274d47be5041b493b00fd55172c0e9
          name: 'Disk utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.disk.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the disk quota that is currently in use. 
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: d5ade16fb0494ca6af61100a2e643702
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.disk.utilization) >= {$CLOUD_SQL.MYSQL.DISK.UTIL.CRIT}'
              name: 'GCP MySQL: Disk space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'Critical utilization of the disk space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 3b5c84fee47f4376b19d0738b261c01b
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.disk.utilization) >= {$CLOUD_SQL.MYSQL.DISK.UTIL.WARN}'
              name: 'GCP MySQL: Disk space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              dependencies:
                - name: 'GCP MySQL: Disk space is critically low'
                  expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.disk.utilization) >= {$CLOUD_SQL.MYSQL.DISK.UTIL.CRIT}'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 7a44187c6a404defb0dc83fa22f89d96
          name: 'Disk write I/O'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.disk.write_ops_count
          description: 'Delta count of data disk write I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_write_ops_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 5e5b9cdfa7f2455b881cceface136e65
          name: 'InnoDB dirty pages'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_dirty
          description: 'Number of unflushed pages in the InnoDB buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_buffer_pool_pages_dirty
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 75835c8326e6461d8f25fb7d55271f16
          name: 'InnoDB free pages'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_free
          description: 'Number of unused pages in the InnoDB buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_buffer_pool_pages_free
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 080d5304c0e346808bd70b125a27be4b
          name: 'InnoDB total pages'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_total
          description: 'Total number of pages in the InnoDB buffer pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_buffer_pool_pages_total
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 19e259f61fc24e29a189c35121878eb3
          name: 'InnoDB fsync calls'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_data_fsyncs
          description: 'Delta count of InnoDB fsync() calls.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_data_fsyncs
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: storage
        - uuid: c4a4ffa274974041bccbd25643ff9f70
          name: 'InnoDB log fsync calls'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_os_log_fsyncs
          description: 'Delta count of InnoDB fsync() calls to the log file.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_os_log_fsyncs
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: storage
        - uuid: 4a9154e235e84c0d9dbf0abf44479f49
          name: 'InnoDB pages read'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_pages_read
          description: 'Delta count of InnoDB pages read.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_pages_read
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 584714b219034bbebbc24edad36704c9
          name: 'InnoDB pages written'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.innodb_pages_written
          description: 'Delta count of InnoDB pages written.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_innodb_pages_written
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: innodb
            - tag: component
              value: memory
        - uuid: 71559008ad444772b0b1212f715980ed
          name: 'Instance state'
          type: HTTP_AGENT
          key: gcp.cloudsql.mysql.inst.state
          description: 'GCP Cloud SQL MySQL Current instance state.'
          valuemap:
            name: 'Instance state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].stringValue'
              error_handler: CUSTOM_VALUE
              error_handler_params: '10'
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'RUNNING',
                  	'SUSPENDED',
                  	'RUNNABLE',
                  	'PENDING_CREATE',
                  	'MAINTENANCE',
                  	'FAILED',
                  	'UNKNOWN_STATE'
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/state | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 3b3adc89e0bb45a79a824121f49d2d02
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 10'
              name: 'GCP MySQL: Failed to get the instance state'
              priority: AVERAGE
              description: |
                Failed to get the instance state. 
                Check access permissions to GCP API or service account.
              tags:
                - tag: scope
                  value: availability
            - uuid: 65831fed3d19425c86933db4034ed565
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 5'
              name: 'GCP MySQL: Instance is in failed state'
              priority: AVERAGE
              description: 'The instance creation failed, or an operation left the instance in an own bad state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: fae15d1ab46c418ebfdfdd73fb698b51
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 4'
              name: 'GCP MySQL: Instance is in maintenance'
              priority: INFO
              description: 'The instance is down for maintenance.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 347215d307c8465cad41198f12b5ff68
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 1'
              name: 'GCP MySQL: Instance is in suspended state'
              priority: WARNING
              description: |
                The instance is in suspended state. 
                It is not available, for example, due to problems with billing.
              tags:
                - tag: scope
                  value: availability
            - uuid: 1387f9a2ef194d5bb5d1e548fc4eb8d3
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 6'
              name: 'GCP MySQL: Instance is in unknown state'
              priority: AVERAGE
              description: 'The state of the instance is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 9c66317433a24be985559fdb11907c70
              expression: 'last(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.inst.state) = 2'
              name: 'GCP MySQL: Instance is stopped by the owner'
              priority: INFO
              description: |
                The instance has been stopped by the owner. 
                It is not currently running, but it's ready to be restarted.
              tags:
                - tag: scope
                  value: availability
        - uuid: cc09f5591b0242b3b99199b267a1c527
          name: 'Memory size'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.memory.quota
          units: B
          description: 'Maximum RAM size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_quota
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 13868b9408c9489296531bf1fd927084
          name: 'Memory used by DB engine'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.memory.total_usage
          units: B
          description: |
            Total RAM usage in bytes. 
            This metric reports the RAM usage of the database process, including the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_total_usage
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 995d07fc814f4d12a9c9bdc6bb52481d
          name: 'Memory usage'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.memory.usage
          units: B
          description: |
            The RAM usage in bytes. 
            This metric reports the RAM usage of the server, excluding the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: efe4357a63ec43f799b2303a952c1378
          name: 'Memory utilization'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.memory.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the memory quota that is currently in use.
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_ram_pused
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 82e3af43d3104b4ba641e0be56d11662
              expression: 'min(/GCP Cloud SQL MySQL by HTTP/gcp.cloudsql.mysql.memory.utilization,5m) >= {$CLOUD_SQL.MYSQL.RAM.UTIL.MAX}'
              name: 'GCP MySQL: High memory utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: HIGH
              description: 'RAM utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 682484eaf1db4a239c69566a5cd492e2
          name: 'Metrics get'
          type: SCRIPT
          key: gcp.cloudsql.mysql.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/',
            	mysql_path = 'cloudsql.googleapis.com/database/mysql/',
            	obj = {},
            	base_paths = [
            		'cpu/reserved_cores',
            		'cpu/usage_time',
            		'cpu/utilization',
            		'disk/read_ops_count',
            		'disk/write_ops_count',
            		'memory/quota',
            		'memory/total_usage',
            		'memory/usage',
            		'network/connections',
            		'network/received_bytes_count',
            		'network/sent_bytes_count  | map ignore [destination]'
            	].map(function (path) { return base_path + path; }),
            	mysql_paths = [
            		'innodb_buffer_pool_pages_dirty',
            		'innodb_buffer_pool_pages_free',
            		'innodb_buffer_pool_pages_total',
            		'innodb_data_fsyncs',
            		'innodb_os_log_fsyncs',
            		'innodb_pages_read',
            		'innodb_pages_written',
            		'queries',
            		'questions',
            		'received_bytes_count',
            		'sent_bytes_count',
            		'open_tables',
            		'open_table_definitions'
            	].map(function (path) { return mysql_path + path; }).concat(
            		['disk/bytes_used', 'disk/utilization', 'disk/quota'].map(function (path) { return base_path + path; }));
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            function rawMap(raw, prefix) {
            	var keys = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            		values = getField(raw, 'timeSeriesData.0.pointData.0.values'),
            		re = /(^t_\d+\.value\.)/g;
            
            	for (i in keys) {
            		var key = getField(keys[i], 'key').replace(re, ''),
            			value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            		for (v in value_types) {
            			if (typeof values[i][value_types[v]] !== 'undefined') {
            				if (prefix) {
            					obj[prefix + key] = values[i][value_types[v]];
            				}
            				else {
            					obj[key] = values[i][value_types[v]];
            				}
            
            			}
            		}
            	}
            	return obj;
            }
            
            var params = checkParams(JSON.parse(value)),
            	j_filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'" + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	queries = [
            		{ name: 'base_', data: { query: '{' + base_paths.join(';') + '}' + j_filter } },
            		{ name: 'mysql_', data: { query: '{' + mysql_paths.join(';') + '}' + j_filter } }
            	];
            
            for (q in queries) {
            	raw = getHttpData(url, params.token, queries[q].data);
            	obj = Object.assign(obj, rawMap(raw, queries[q].name));
            }
            
            obj.base_ram_pused = Math.floor(getField(obj, 'base_usage') / getField(obj, 'base_quota') * 100);
            
            return JSON.stringify(obj);
          description: 'MySQL metrics in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: 9ddae405a9b343759d03b5b29c469d18
          name: Connections
          type: DEPENDENT
          key: gcp.cloudsql.mysql.network.connections
          description: 'Number of connections to the databases on the Cloud SQL instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_connections
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: d970d8e209df4b2a810c2e59f39fa429
          name: 'Network: Received bytes'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.network.received_bytes_count
          units: B
          description: 'Delta count of bytes received through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_received_bytes_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 977e4e22ebfc4a19a228a8935d9a342c
          name: 'Network: Sent bytes'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.network.sent_bytes_count
          units: B
          description: 'Delta count of bytes sent through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_sent_bytes_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 1d651976f70944acb31cd0430e70d422
          name: 'Open tables'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.open_tables
          description: 'The number of tables that are currently open.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_open_tables
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: tables
        - uuid: 1606766c63bf4aa1ade24a34650eef05
          name: 'Open table definitions'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.open_table_definitions
          description: 'The number of table definitions that are currently cached.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_open_table_definitions
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: tables
        - uuid: 3d3ec2e37bf94fb68c40967b56dfd95c
          name: 'Network: Bytes received by MySQL'
          type: DEPENDENT
          key: gcp.cloudsql.mysql_received_bytes_count
          units: B
          description: 'Delta count of bytes received by MySQL process.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_received_bytes_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: f926beb31be44dc0bfb30c571fac280a
          name: 'Network: Bytes sent by MySQL'
          type: DEPENDENT
          key: gcp.cloudsql.mysql_sent_bytes_count
          units: B
          description: 'Delta count of bytes sent by MySQL process.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_sent_bytes_count
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: bbdeb595ab1b44d7a332fbf0c2637403
          name: Queries
          type: DEPENDENT
          key: gcp.cloudsql.queries
          description: 'Delta of statements executed by the server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_queries
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: queries
        - uuid: 114fb26dcdc1441c84c150c7809b3400
          name: Questions
          type: DEPENDENT
          key: gcp.cloudsql.questions
          description: 'Delta of statements executed by the server sent by the client.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mysql_questions
          master_item:
            key: gcp.cloudsql.mysql.metrics.get
          tags:
            - tag: component
              value: queries
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: mysql
      macros:
        - macro: '{$CLOUD_SQL.MYSQL.CPU.UTIL.MAX}'
          value: '95'
          description: 'GCP Cloud SQL MySQL instance CPU usage threshold.'
        - macro: '{$CLOUD_SQL.MYSQL.DISK.UTIL.CRIT}'
          value: '90'
          description: 'GCP Cloud SQL MySQL instance critical disk usage threshold.'
        - macro: '{$CLOUD_SQL.MYSQL.DISK.UTIL.WARN}'
          value: '80'
          description: 'GCP Cloud SQL MySQL instance warning disk usage threshold.'
        - macro: '{$CLOUD_SQL.MYSQL.RAM.UTIL.MAX}'
          value: '90'
          description: 'GCP Cloud SQL MySQL instance RAM usage threshold.'
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for data requests.
            Supported usage types:
            - Default update interval for most items.
            - Minimal time window for data requested in Monitoring Query Language REST API request.
      dashboards:
        - uuid: 5932cc56f6f146db8fac121b3817a407
          name: 'MySQL instance'
          pages:
            - name: 'MySQL instance'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        key: gcp.cloudsql.mysql.cpu.usage_time
                    - type: STRING
                      name: reference
                      value: AAAAA
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        name: 'GCP Cloud SQL MySQL: Memory usage'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        key: gcp.cloudsql.mysql.disk.utilization
                    - type: STRING
                      name: reference
                      value: AAAAE
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        name: 'GCP Cloud SQL MySQL: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        name: 'GCP Cloud SQL MySQL: pages'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        key: gcp.cloudsql.mysql.cpu.utilization
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        key: gcp.cloudsql.mysql.memory.utilization
                    - type: STRING
                      name: reference
                      value: AAAAD
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        name: 'GCP Cloud SQL MySQL: Disk read/write operations'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        key: gcp.cloudsql.mysql.network.connections
                    - type: STRING
                      name: reference
                      value: AAAAH
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL by HTTP'
                        name: 'GCP Cloud SQL MySQL: Queries'
                    - type: STRING
                      name: reference
                      value: AAAAJ
      valuemaps:
        - uuid: 8aa36f0f6a0b42a3b5e0eabfb700e8db
          name: 'Database availability'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
        - uuid: 9adad9dad34646d79bcc6c414ddf8afe
          name: 'Instance state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Suspended
            - value: '2'
              newvalue: Runnable
            - value: '3'
              newvalue: 'Pending create'
            - value: '4'
              newvalue: Maintenance
            - value: '5'
              newvalue: Failed
            - value: '6'
              newvalue: 'Unknown state'
            - value: '10'
              newvalue: 'Data retrievement error'
    - uuid: 9d7871c093f9489293421396b9fea668
      template: 'GCP Cloud SQL MySQL Replica by HTTP'
      name: 'GCP Cloud SQL MySQL Replica by HTTP'
      description: |
        Get GCP Cloud SQL MySQL monitoring for read-only replicas with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        This template is used in low-level discovery and will be auto-assigned to host prototypes. Additional configuration is not required.
      vendor:
        name: Zabbix
        version: 8.0-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 17aa9eb4749e46be9b0b0f93ef011fca
          name: 'Last I/O thread error number'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.last_io_errno
          description: 'The error number of the most recent error that caused the I/O thread to stop.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.last_io_errno
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 52c11965a2fc4d37a97ebccc04ee7b80
          name: 'Last SQL thread error number'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.last_sql_errno
          description: 'The error number of the most recent error that caused the SQL thread to stop.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.last_sql_errno
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 470200d2cca348bb8a670a2be3a270e3
          name: 'Replica metrics get'
          type: SCRIPT
          key: gcp.cloudsql.mysql.repl.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/replication/',
            	mysql_path = 'cloudsql.googleapis.com/database/mysql/replication/',
            	raw_metrics,
            	obj = {},
            	base_paths = ['network_lag', 'replica_lag'].map(function (path) { return base_path + path; }),
            	mysql_paths = [
            		'last_io_errno',
            		'last_sql_errno',
            		'slave_io_running',
            		'slave_sql_running'].map(function (path) { return mysql_path + path; }).concat(
            			['network_lag', 'replica_lag'].map(function (path) { return base_path + path; }));
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            var params = checkParams(JSON.parse(value)),
            	filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	metric_raw = getHttpData(url, params.token, { query: '{' + mysql_paths.join(';') + '}' + j_filter }),
            	metric_keys = getField(metric_raw, 'timeSeriesDescriptor.pointDescriptors'),
            	metric_values = getField(metric_raw, 'timeSeriesData.0.pointData.0.values'),
            	re = /(^t_\d+\.value\.)/g;
            
            for (i in metric_keys) {
            	var value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            	for (v in value_types) {
            		if (typeof metric_values[i][value_types[v]] !== 'undefined') {
            			obj[getField(metric_keys[i], 'key').replace(re, "")] = metric_values[i][value_types[v]];
            		}
            	}
            }
            
            var state_raw = getHttpData(url, params.token, { query: base_path + 'state' + filter }),
            	state_keys = getField(state_raw, 'timeSeriesDescriptor.pointDescriptors'),
            	state_tsd = getField(state_raw, 'timeSeriesData');
            
            for (i in state_keys) {
            	var state_key = getField(state_keys[i], 'key').replace(/value\./g, '');
            
            	obj[state_key] = 'undefined';
            	for (t in state_tsd) {
            		if (getField(state_tsd[t], 'pointData.0.values.' + i + '.boolValue') == true) {
            			obj[state_key] = getField(state_tsd[t], 'labelValues.3.stringValue');
            			break;
            		}
            	}
            }
            
            return JSON.stringify(obj);
          description: 'MySQL replication metrics data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: e84ac3a2537848b29024659ab5e3a0e9
          name: 'Network lag'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.network_lag
          units: s
          description: 'Indicates time taken from primary binary log to IO thread on replica.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.network_lag
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: b5f9960de9414975ac48357844a15860
          name: 'Replication lag'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.replica_lag
          units: s
          description: 'Number of seconds the read replica is behind its primary (approximation).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.replica_lag
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 0c093a0416f24afb96fc28a7abb283d4
          name: 'Slave I/O thread running'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.slave_io_running
          description: |
            Indicates whether the I/O thread for reading the primary's binary log is running.
            Possible values are Yes, No and Connecting.
          valuemap:
            name: 'Thread state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.slave_io_running
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'No',
                  	'Yes',
                  	'Connecting',
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 994d92340dd146a381f2e6bbebd1c3f2
          name: 'Slave SQL thread running'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.slave_sql_running
          description: 'Indicates whether the SQL thread for executing events in the relay log is running.'
          valuemap:
            name: 'Thread state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.slave_sql_running
            - type: BOOL_TO_DECIMAL
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 90a9154072164b5c89d715fa77e7e2b0
          name: 'Replication state'
          type: DEPENDENT
          key: gcp.cloudsql.mysql.repl.state
          description: |
            The current serving state of replication.
            This metric is only available for the MySQL/PostgreSQL instances.
          valuemap:
            name: 'Replication state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.state
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'Running',
                  	'Syncing',
                  	'Unsynced',
                  	'Stopped',
                  	'Error',
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
          master_item:
            key: gcp.cloudsql.mysql.repl.metrics.get
          tags:
            - tag: component
              value: replication
            - tag: component
              value: status
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: mysql
        - tag: target
          value: replica
      macros:
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for data requests.
            Supported usage types:
            - Default update interval for most items.
            - Minimal time window for data requested in Monitoring Query Language REST API request.
      dashboards:
        - uuid: 76eda12212f045388bef22cb382eff6b
          name: 'MySQL replica'
          pages:
            - name: 'MySQL replica'
              widgets:
                - type: graph
                  width: '72'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL MySQL Replica by HTTP'
                        name: 'GCP Cloud SQL MySQL: Lags'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: item
                  name: 'I/O Thread State'
                  'y': '5'
                  width: '18'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL Replica by HTTP'
                        key: gcp.cloudsql.mysql.repl.slave_io_running
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: 'I/O Thread Error'
                  x: '18'
                  'y': '5'
                  width: '18'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '1'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL Replica by HTTP'
                        key: gcp.cloudsql.mysql.repl.last_io_errno
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: 'SQL Thread State'
                  x: '36'
                  'y': '5'
                  width: '18'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '1'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL Replica by HTTP'
                        key: gcp.cloudsql.mysql.repl.slave_sql_running
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: 'SQL Thread Error'
                  x: '54'
                  'y': '5'
                  width: '18'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: decimal_size
                      value: '1'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL MySQL Replica by HTTP'
                        key: gcp.cloudsql.mysql.repl.last_sql_errno
                    - type: INTEGER
                      name: show.0
                      value: '2'
      valuemaps:
        - uuid: ea83090a16d94eb3bb643009c784d820
          name: 'Replication state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Syncing
            - value: '2'
              newvalue: Unsynced
            - value: '3'
              newvalue: Stopped
            - value: '4'
              newvalue: Error
            - value: '10'
              newvalue: Unknown
        - uuid: b1acfa66a401499cae56777db6c7750b
          name: 'Thread state'
          mappings:
            - value: '0'
              newvalue: 'No'
            - value: '1'
              newvalue: 'Yes'
            - value: '2'
              newvalue: Connecting
            - value: '10'
              newvalue: Unknown
    - uuid: e74c1e12f82e4d9880a368b53f5e65a4
      template: 'GCP Cloud SQL PostgreSQL by HTTP'
      name: 'GCP Cloud SQL PostgreSQL by HTTP'
      description: |
        Get GCP Cloud SQL PostgreSQL instances monitoring with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        This template is used in low-level discovery and will be auto-assigned to host prototypes. Additional configuration is not required.
      vendor:
        name: Zabbix
        version: 8.0-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 396a555958514890af339f4504a96cc6
          name: 'Reserved CPU cores'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.cpu.reserved_cores
          value_type: FLOAT
          description: 'Number of cores reserved for the database.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_reserved_cores
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: aa2e6d9118ed4b198ed9a28932ea8539
          name: 'CPU usage time'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.cpu.usage_time
          value_type: FLOAT
          units: s
          description: 'Cumulative CPU usage time in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage_time
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: cb7cd1b74e4944d88334f22d25b985fa
          name: 'CPU utilization'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: 'Current CPU utilization represented as a percentage of the reserved CPU that is currently in use.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 3ca3942121bd41029645a19fd3947416
              expression: 'min(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.cpu.utilization,5m) >= {$CLOUD_SQL.PGSQL.CPU.UTIL.MAX}'
              name: 'GCP PostgreSQL: High CPU utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 27ad9640bf734dd49548c19241cc4838
          name: 'DB engine state'
          type: HTTP_AGENT
          key: gcp.cloudsql.pgsql.db.state
          description: 'GCP Cloud SQL PostgreSQL DB Engine State.'
          valuemap:
            name: 'Database availability'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].int64Value'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/up | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: f7b0fc21edcf489ab174eb06dee4fabe
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.db.state)=0'
              name: 'GCP PostgreSQL: Database engine is down'
              priority: AVERAGE
              description: |
                Database engine is down.
                If an instance experiences unplanned (non-maintenance) downtime, the instance state will still be RUNNING, but the database engine state metric will report 0.
              dependencies:
                - name: 'GCP PostgreSQL: Failed to get the instance state'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 10'
                - name: 'GCP PostgreSQL: Instance is in failed state'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 5'
                - name: 'GCP PostgreSQL: Instance is in maintenance'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 4'
                - name: 'GCP PostgreSQL: Instance is in suspended state'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 1'
                - name: 'GCP PostgreSQL: Instance is in unknown state'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 6'
                - name: 'GCP PostgreSQL: Instance is stopped by the owner'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 2'
              tags:
                - tag: scope
                  value: availability
        - uuid: 799cad827e8b44d98b8285b08153842d
          name: 'Disk bytes used'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.disk.bytes_used
          units: B
          description: 'Data utilization in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_bytes_used
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 470510bf76fb47fbbddfc8c4a711a335
          name: 'Disk size'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.disk.quota
          units: B
          description: 'Maximum data disk size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_quota
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: f12ba5129c2d435389f4fb6964294381
          name: 'Disk read I/O'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.disk.read_ops_count
          description: 'Delta count of data disk read I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_read_ops_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: e2d6702514b941cb9586cb98786c6a01
          name: 'Disk utilization'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.disk.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the disk quota that is currently in use. 
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: c4fa1d580ffd4546b82605f94da5d2ba
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.disk.utilization) >= {$CLOUD_SQL.PGSQL.DISK.UTIL.CRIT}'
              name: 'GCP PostgreSQL: Disk space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: AVERAGE
              description: 'Critical utilization of the disk space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 186a707ca3194c32a894ae809177a7e2
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.disk.utilization) >= {$CLOUD_SQL.PGSQL.DISK.UTIL.WARN}'
              name: 'GCP PostgreSQL: Disk space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              dependencies:
                - name: 'GCP PostgreSQL: Disk space is critically low'
                  expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.disk.utilization) >= {$CLOUD_SQL.PGSQL.DISK.UTIL.CRIT}'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 8d8d6c13cdb244cb80c03226b7c14a90
          name: 'Disk write I/O'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.disk.write_ops_count
          description: 'Delta count of data disk write I/O operations.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_write_ops_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 88fd41960538460ebfd2ed9194677cd1
          name: 'Instance state'
          type: HTTP_AGENT
          key: gcp.cloudsql.pgsql.inst.state
          description: 'GCP Cloud SQL PostgreSQL Current instance state.'
          valuemap:
            name: 'Instance state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.timeSeriesData[0].pointData[0].values[0].stringValue'
              error_handler: CUSTOM_VALUE
              error_handler_params: '10'
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'RUNNING',
                  	'SUSPENDED',
                  	'RUNNABLE',
                  	'PENDING_CREATE',
                  	'MAINTENANCE',
                  	'FAILED',
                  	'UNKNOWN_STATE'
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://monitoring.googleapis.com/v3/projects/{$GCP.PROJECT.ID}/timeSeries:query'
          status_codes: ''
          posts: '{"query":"cloudsql.googleapis.com/database/state | within 5m | filter database_id = ''{$GCP.PROJECT.ID}:{HOST.NAME}''"}'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          request_method: POST
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 596020e32d0c4193a6626c960b4b5be8
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 10'
              name: 'GCP PostgreSQL: Failed to get the instance state'
              priority: AVERAGE
              description: |
                Failed to get the instance state. 
                Check access permissions to GCP API or service account.
              tags:
                - tag: scope
                  value: availability
            - uuid: 1a2efb6f755444c0bab85d2778018eb1
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 5'
              name: 'GCP PostgreSQL: Instance is in failed state'
              priority: AVERAGE
              description: 'The instance creation failed, or an operation left the instance in an own bad state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: aad6fb2d86c84e33868aacbf160c3d65
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 4'
              name: 'GCP PostgreSQL: Instance is in maintenance'
              priority: INFO
              description: 'The instance is down for maintenance.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 959072ed00c4461196bef71618799b82
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 1'
              name: 'GCP PostgreSQL: Instance is in suspended state'
              priority: WARNING
              description: |
                The instance is in suspended state. 
                It is not available, for example, due to problems with billing.
              tags:
                - tag: scope
                  value: availability
            - uuid: 5f1084f744b444f3b803110baf703973
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 6'
              name: 'GCP PostgreSQL: Instance is in unknown state'
              priority: AVERAGE
              description: 'The state of the instance is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: fb0df2eb001649febb6fc6513e056fcc
              expression: 'last(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.inst.state) = 2'
              name: 'GCP PostgreSQL: Instance is stopped by the owner'
              priority: INFO
              description: |
                The instance has been stopped by the owner. 
                It is not currently running, but it's ready to be restarted.
              tags:
                - tag: scope
                  value: availability
        - uuid: 014d96156a364f2c8eac6a47de3eddfe
          name: 'Memory size'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.memory.quota
          units: B
          description: 'Maximum RAM size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_quota
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: e73876fa0728402db7688a41938f4a12
          name: 'Memory used by DB engine'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.memory.total_usage
          units: B
          description: |
            Total RAM usage in bytes. 
            This metric reports the RAM usage of the database process, including the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_total_usage
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 2a5daa0300564b97a5e744e576a217cb
          name: 'Memory usage'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.memory.usage
          units: B
          description: |
            The RAM usage in bytes. 
            This metric reports the RAM usage of the server, excluding the buffer/cache.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_usage
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 4c524a81bf3b4a6bbc87d23b60c4f74c
          name: 'Memory utilization'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.memory.utilization
          value_type: FLOAT
          units: '%'
          description: |
            The fraction of the memory quota that is currently in use.
            Shown as percentage.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_ram_pused
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: bbbdbd9c3c5b407491b359f98e4e3fa9
              expression: 'min(/GCP Cloud SQL PostgreSQL by HTTP/gcp.cloudsql.pgsql.memory.utilization,5m) >= {$CLOUD_SQL.PGSQL.RAM.UTIL.MAX}'
              name: 'GCP PostgreSQL: High memory utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE}'
              priority: HIGH
              description: 'RAM utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 9bf09a42ddd64f7eabf6bbc011eda689
          name: 'Metrics get'
          type: SCRIPT
          key: gcp.cloudsql.pgsql.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/',
            	pgsql_path = 'cloudsql.googleapis.com/database/postgresql/',
            	obj = {},
            	value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            function rawMap(raw, prefix) {
            	var keys = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            		values = getField(raw, 'timeSeriesData.0.pointData.0.values'),
            		re = /(^t_\d+\.value(_|\.)|_sum$)/g;
            
            	for (i in keys) {
            		var key = getField(keys[i], 'key').replace(re, '');
            
            		for (v in value_types) {
            			if (typeof values[i][value_types[v]] !== 'undefined') {
            				if (prefix) {
            					obj[prefix + key] = values[i][value_types[v]];
            				} else {
            					obj[key] = values[i][value_types[v]];
            				}
            
            			}
            		}
            	}
            	return obj;
            }
            
            function singleMetrics(tsd) {
            	result = {};
            	for (t in tsd) {
            		for (v in value_types) {
            			if (typeof tsd[t].pointData[0].values[0][value_types[v]] !== 'undefined') {
            				result['pgsql_' + getField(tsd[t], 'labelValues.3.stringValue').toLowerCase()] = tsd[t].pointData[0].values[0][value_types[v]];
            			}
            		}
            	}
            	return result;
            }
            
            var params = checkParams(JSON.parse(value)),
            	filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	base_paths = [
            		'cpu/reserved_cores',
            		'cpu/usage_time',
            		'cpu/utilization',
            		'disk/read_ops_count',
            		'disk/write_ops_count',
            		'memory/quota',
            		'memory/total_usage',
            		'memory/usage',
            		'network/received_bytes_count',
            		'network/sent_bytes_count | map ignore [destination]'
            	].map(function (path) { return base_path + path; }),
            	pgsql_paths = [
            		'transaction_id_utilization ' + filter,
            		'temp_bytes_written_count' + filter + ' | sum',
            		'temp_files_written_count' + filter + ' | sum',
            		'num_backends' + filter + ' | sum'
            	].map(function (path) { return pgsql_path + path; }).concat(
            		['disk/bytes_used', 'disk/utilization', 'disk/quota'].map(function (path) { return base_path + path; })),
            	queries = [
            		{ name: 'base_', data: { query: '{' + base_paths.join(';') + '}' + j_filter } },
            		{ name: 'pgsql_', data: { query: '{' + pgsql_paths.join(';') + '}' + '| within ' + params.time_window + '| join' } }
            	];
            
            for (q in queries) {
            	raw = getHttpData(url, params.token, queries[q].data);
            	obj = Object.assign(obj, rawMap(raw, queries[q].name));
            }
            
            obj.base_ram_pused = Math.floor((getField(obj, 'base_usage') / getField(obj, 'base_quota')) * 100);
            
            var single_paths = ['transaction_id_count', 'vacuum/oldest_transaction_age'],
            	single_queries = single_paths.map(function (path) { return { query: pgsql_path + path + filter }; });
            
            for (q in single_queries) {
            	raw = getHttpData(url, params.token, single_queries[q]);
            	Object.assign(obj, singleMetrics(getField(raw, 'timeSeriesData')));
            }
            
            return JSON.stringify(obj);
          description: 'PostgreSQL metrics data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: f2d00c86eedd4a1e8efce7661c3da18d
          name: 'Network: Received bytes'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.network.received_bytes_count
          units: B
          description: 'Delta count of bytes received through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_received_bytes_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: dc67deac1a2f4cc993406028d6cc8c3b
          name: 'Network: Sent bytes'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.network.sent_bytes_count
          units: B
          description: 'Delta count of bytes sent through the network.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.base_sent_bytes_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 512c5d8156fb4d5299284f708e64dffc
          name: Connections
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.num_backends
          description: |
            The number of the connections to the Cloud SQL PostgreSQL instance.
            Includes connections to the system databases, which aren't visible by default.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_num_backends
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: connections
            - tag: component
              value: network
        - uuid: 88603b1881114551ba23e8f12d5ab47f
          name: 'Oldest prepared transaction age'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.oldest_transaction.prepared
          description: |
            Age of the oldest prepared transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
            Empty value when there is no such transaction type.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_prepared
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 50df8067afcb42a9ac44fe963ee635d2
          name: 'Oldest replica transaction age'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.oldest_transaction.replica
          description: |
            Age of the oldest replica transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
            Empty value when there is no such transaction type.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_replica
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: fee3d72f615c479389c5fdb46f32229f
          name: 'Oldest replication slot transaction age'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.oldest_transaction.replication_slot
          description: |
            Age of the oldest replication slot transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
            Empty value when there is no such transaction type.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_replication_slot
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 6d51c4865cd04607986ef4e02bc43fb6
          name: 'Oldest running transaction age'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.oldest_transaction.running
          description: |
            Age of the oldest running transaction yet to be vacuumed in the Cloud SQL PostgreSQL instance, measured in number of transactions that have happened since the oldest transaction.
            Empty value when there is no such transaction type.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_running
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 75bc8d76a59a465fb66a434e13de107d
          name: 'Data written to temporary'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.temp_bytes_written_count
          units: B
          description: 'Total data size (in bytes) written to temporary files by the queries.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_temp_bytes_written_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: bd10ec6251c444a79878e82e3ebe9ac0
          name: 'Temporary files used for writing data'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.temp_files_written_count
          description: 'Total number of temporary files used for writing data while performing algorithms such as join and sort.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_temp_files_written_count
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: storage
        - uuid: 2498b066f4964aa7be03f4cc43eab95e
          name: 'Assigned transactions'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.transaction_id_count_assigned
          description: 'Delta count of assigned transaction IDs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_assigned
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 23d1b88571d347db9672596ec13580cc
          name: 'Frozen transactions'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.transaction_id_count_frozen
          description: 'Delta count of frozen transaction IDs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_frozen
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
        - uuid: 004042d342d0478ea8f826466353454d
          name: 'Transaction ID utilization'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.transaction_id_utilization
          value_type: FLOAT
          units: '%'
          description: 'Current utilization represented as a percentage of transaction IDs consumed by the Cloud SQL PostgreSQL instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pgsql_transaction_id_utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.cloudsql.pgsql.metrics.get
          tags:
            - tag: component
              value: transactions
      discovery_rules:
        - uuid: 090d05a647384858a8b9efe5502c0a76
          name: 'GCP Cloud SQL PostgreSQL: Databases discovery'
          type: HTTP_AGENT
          key: gcp.cloudsql.pgsql.db.discovery
          delay: 1h
          filter:
            evaltype: AND
            conditions:
              - macro: '{#PGSQL.DB.NAME}'
                value: '{$GCP.CLOUD_SQL.DB.NAME.MATCHES}'
              - macro: '{#PGSQL.DB.NAME}'
                value: '{$GCP.CLOUD_SQL.DB.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Databases discovery for the particular PostgreSQL instance.'
          item_prototypes:
            - uuid: 997bdb03ba0b437ca2705f28dcc651ed
              name: 'Database [{#PGSQL.DB.NAME}]: Buffer cache blocks read.'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.blocks_read_count_buffer_cache[{#PGSQL.DB.NAME}]'
              description: 'Number of buffer cache blocks read by the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.buffer_cache
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: memory
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: b35c4a888743448688a8c5233ed165e7
              name: 'Database [{#PGSQL.DB.NAME}]: Disk blocks read.'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.blocks_read_count_disk[{#PGSQL.DB.NAME}]'
              description: 'Number of disk blocks read by the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.disk
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: storage
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 7a1df30ae0c443839fe625142aea61b2
              name: 'Database [{#PGSQL.DB.NAME}]: Metrics raw'
              type: SCRIPT
              key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              delay: '{$GCP.TIME.WINDOW}'
              history: '0'
              value_type: TEXT
              params: |
                var base_path = 'cloudsql.googleapis.com/database/postgresql/',
                	obj = {};
                
                function checkParams(params) {
                	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
                		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
                			throw 'Required param is not set: ' + field + '.';
                		}
                	});
                	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
                		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
                	}
                	return params;
                }
                
                function getField(data, path) {
                	var steps = path.split('.');
                
                	for (var i = 0; i < steps.length; i++) {
                		var step = steps[i];
                
                		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                			throw 'Required field "' + path + '" is not present in data received.';
                		}
                		data = data[step];
                	}
                	return data;
                }
                
                function getHttpData(url, token, body) {
                	var request = new HttpRequest();
                	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
                		request.setProxy(params.proxy);
                	};
                	request.addHeader('Authorization: Bearer ' + token);
                	request.addHeader('Content-Type: application/json');
                
                	var response = request.post(url, JSON.stringify(body));
                
                	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
                
                	if (response !== null) {
                		try {
                			response = JSON.parse(response);
                		}
                		catch (error) {
                			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
                		}
                	}
                
                	if (typeof response !== 'object' || response === null) {
                		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
                	}
                
                	if (request.getStatus() !== 200) {
                		if (typeof (response.error && response.error.message) !== 'undefined') {
                			throw response.error.message;
                		}
                		else {
                			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
                		}
                	}
                	return response;
                };
                
                function singleMetrics(tsd) {
                	var result = {};
                
                	for (i in tsd) {
                		result[getField(tsd[i], 'labelValues.4.stringValue')] = getField(tsd[i], 'pointData.0.values.0.int64Value');
                	}
                	return result;
                }
                
                var params = checkParams(JSON.parse(value)),
                	filter = ' | within ' + params.time_window + " | filter database_id ='" + params.database_id + "'" + " | filter database ='" + params.database_name + "'",
                	j_filter = filter + ' | join',
                	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
                	common_paths = ['deadlock_count', 'tuples_returned_count', 'tuples_fetched_count'],
                	common_raw = getHttpData(url, params.token, { query: '{' + common_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
                	keys = getField(common_raw, 'timeSeriesDescriptor.pointDescriptors'),
                	values = getField(common_raw, 'timeSeriesData.0.pointData.0.values'),
                	re = /(^t_\d+\.value\.)/g;
                
                for (i in keys) {
                	var value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
                
                	for (v in value_types) {
                		if (typeof values[i][value_types[v]] !== 'undefined') {
                			obj[getField(keys[i], 'key').replace(re, '')] = values[i][value_types[v]];
                		}
                	}
                }
                
                var single_paths = ['transaction_count', 'blocks_read_count', 'tuples_processed_count', 'tuple_size'],
                	single_queries = single_paths.map(function (path) { return { query: base_path + path + filter }; });
                
                for (q in single_queries) {
                	raw = getHttpData(url, params.token, single_queries[q]);
                	obj = Object.assign(obj, singleMetrics(getField(raw, 'timeSeriesData')));
                }
                
                return JSON.stringify(obj);
              description: 'PostgreSQL metrics in raw format.'
              preprocessing:
                - type: CHECK_NOT_SUPPORTED
                  parameters:
                    - '-1'
              timeout: '{$GCP.DATA.TIMEOUT}'
              parameters:
                - name: database_id
                  value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
                - name: database_name
                  value: '{#PGSQL.DB.NAME}'
                - name: project_id
                  value: '{$GCP.PROJECT.ID}'
                - name: proxy
                  value: '{$GCP.PROXY}'
                - name: time_window
                  value: '{$GCP.TIME.WINDOW}'
                - name: token
                  value: '{$GCP.AUTH.TOKEN}'
              tags:
                - tag: component
                  value: raw
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: d5632c60593749209a6e681b396f4cc7
              name: 'Database [{#PGSQL.DB.NAME}]: Deadlocks count'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.deadlock_count[{#PGSQL.DB.NAME}]'
              description: 'Number of deadlocks detected in the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.deadlock_count
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: deadlock
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 6d846507fbc24cbb9fb4ad59167552db
              name: 'Database [{#PGSQL.DB.NAME}]: Committed transactions'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.transaction_count_commit[{#PGSQL.DB.NAME}]'
              description: 'Delta count of number of committed transactions to the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.commit
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 4751ef5e498e4ce184bd07aadc831d2b
              name: 'Database [{#PGSQL.DB.NAME}]: Rolled-back transactions'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.transaction_count_rollback[{#PGSQL.DB.NAME}]'
              description: 'Delta count of number of rolled-back transactions in the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.rollback
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: transactions
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: a7451a61e0b04be8b1f85b47c44107e2
              name: 'Database [{#PGSQL.DB.NAME}]: Tuples fetched'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuples_fetched_count[{#PGSQL.DB.NAME}]'
              description: 'Total number of rows fetched as a result of queries to the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tuples_fetched_count
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 7daca0b14f5843669bc5b0823cd4d44f
              name: 'Database [{#PGSQL.DB.NAME}]: Deleted rows processed'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuples_processed_count_delete[{#PGSQL.DB.NAME}]'
              description: 'Number of tuples(rows) processed for delete operations for the database with the name [{#PGSQL.DB.NAME}].'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.delete
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 48a7613fa611410b8353d03d87af0f8d
              name: 'Database [{#PGSQL.DB.NAME}]: Inserted rows processed.'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuples_processed_count_insert[{#PGSQL.DB.NAME}]'
              description: 'Number of tuples(rows) processed for insert operations for the database with the name [{#PGSQL.DB.NAME}].'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.insert
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: e159cc28aec6448b9162f780479f5aab
              name: 'Database [{#PGSQL.DB.NAME}]: Updated rows processed'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuples_processed_count_update[{#PGSQL.DB.NAME}]'
              description: 'Number of tuples(rows) processed for update operations for the database with the name [{#PGSQL.DB.NAME}].'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.update
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: ee6fad5b2fb44a14a29c7cd662b1f5d2
              name: 'Database [{#PGSQL.DB.NAME}]: Tuples returned'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuples_returned_count[{#PGSQL.DB.NAME}]'
              description: 'Total number of rows scanned while processing the queries of the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tuples_returned_count
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: f7a58601a3384b8ba24c89b3693ddb88
              name: 'Database [{#PGSQL.DB.NAME}]: Dead tuples'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuple_size_dead[{#PGSQL.DB.NAME}]'
              description: 'Number of live tuples(rows) in the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.dead
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
            - uuid: 16e88225cd41406285b3237ee1e61bb4
              name: 'Database [{#PGSQL.DB.NAME}]: Live tuples'
              type: DEPENDENT
              key: 'gcp.cloudsql.pgsql.tuple_size_live[{#PGSQL.DB.NAME}]'
              description: 'Number of live tuples(rows) in the [{#PGSQL.DB.NAME}] database.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.live
              master_item:
                key: 'gcp.cloudsql.pgsql.db.metrics.get[{#PGSQL.DB.NAME}]'
              tags:
                - tag: component
                  value: tuples
                - tag: database
                  value: '{#PGSQL.DB.NAME}'
          graph_prototypes:
            - uuid: 8ba7dd12152243b4a5a438bd649f96c1
              name: 'GCP Cloud SQL PostgreSQL: Database [{#PGSQL.DB.NAME}]: Tuples'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'GCP Cloud SQL PostgreSQL by HTTP'
                    key: 'gcp.cloudsql.pgsql.tuple_size_dead[{#PGSQL.DB.NAME}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'GCP Cloud SQL PostgreSQL by HTTP'
                    key: 'gcp.cloudsql.pgsql.tuple_size_live[{#PGSQL.DB.NAME}]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'GCP Cloud SQL PostgreSQL by HTTP'
                    key: 'gcp.cloudsql.pgsql.tuples_processed_count_insert[{#PGSQL.DB.NAME}]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'GCP Cloud SQL PostgreSQL by HTTP'
                    key: 'gcp.cloudsql.pgsql.tuples_processed_count_update[{#PGSQL.DB.NAME}]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'GCP Cloud SQL PostgreSQL by HTTP'
                    key: 'gcp.cloudsql.pgsql.tuples_processed_count_delete[{#PGSQL.DB.NAME}]'
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://sqladmin.googleapis.com/sql/v1beta4/projects/{$GCP.PROJECT.ID}/instances/{HOST.NAME}/databases'
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          lld_macro_paths:
            - lld_macro: '{#PGSQL.DB.NAME}'
              path: $.name
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.items
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: postgresql
      macros:
        - macro: '{$CLOUD_SQL.PGSQL.CPU.UTIL.MAX}'
          value: '95'
          description: 'GCP Cloud SQL PostgreSQL instance CPU usage threshold.'
        - macro: '{$CLOUD_SQL.PGSQL.DISK.UTIL.CRIT}'
          value: '90'
          description: 'GCP Cloud SQL PostgreSQL instance critical disk usage threshold.'
        - macro: '{$CLOUD_SQL.PGSQL.DISK.UTIL.WARN}'
          value: '80'
          description: 'GCP Cloud SQL PostgreSQL instance warning disk usage threshold.'
        - macro: '{$CLOUD_SQL.PGSQL.RAM.UTIL.MAX}'
          value: '90'
          description: 'GCP Cloud SQL PostgreSQL instance RAM usage threshold.'
        - macro: '{$GCP.CLOUD_SQL.DB.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Cloud SQL PostgreSQL databases by namespace.'
        - macro: '{$GCP.CLOUD_SQL.DB.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Cloud SQL PostgreSQL databases by namespace.'
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for data requests.
            Supported usage types:
            - Default update interval for most items.
            - Minimal time window for data requested in Monitoring Query Language REST API request.
      dashboards:
        - uuid: 21636cfe7d2f4de28d07af09c9812075
          name: 'PostgreSQL instance'
          pages:
            - name: 'PostgreSQL instance'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: gcp.cloudsql.pgsql.cpu.usage_time
                    - type: STRING
                      name: reference
                      value: AAAAA
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Memory usage'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: gcp.cloudsql.pgsql.disk.utilization
                    - type: STRING
                      name: reference
                      value: AAAAE
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Transactions count'
                    - type: STRING
                      name: reference
                      value: AAAAI
                - type: graphprototype
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Database [{#PGSQL.DB.NAME}]: Tuples'
                    - type: STRING
                      name: reference
                      value: AAAAK
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: gcp.cloudsql.pgsql.cpu.utilization
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '5'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: gcp.cloudsql.pgsql.memory.utilization
                    - type: STRING
                      name: reference
                      value: AAAAD
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Disk read/write operations'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  x: '36'
                  'y': '15'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: gcp.cloudsql.pgsql.transaction_id_utilization
                    - type: STRING
                      name: reference
                      value: AAAAH
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  'y': '20'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Transaction age'
                    - type: STRING
                      name: reference
                      value: AAAAJ
                - type: graphprototype
                  x: '36'
                  'y': '25'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: ITEM_PROTOTYPE
                      name: itemid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL by HTTP'
                        key: 'gcp.cloudsql.pgsql.deadlock_count[{#PGSQL.DB.NAME}]'
                    - type: STRING
                      name: reference
                      value: AAAAL
                    - type: INTEGER
                      name: source_type
                      value: '3'
      valuemaps:
        - uuid: c783556dfa214e73b676ca187648c5df
          name: 'Database availability'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
        - uuid: bc3b08ca201d438689678a29e3575823
          name: 'Instance state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Suspended
            - value: '2'
              newvalue: Runnable
            - value: '3'
              newvalue: 'Pending create'
            - value: '4'
              newvalue: Maintenance
            - value: '5'
              newvalue: Failed
            - value: '6'
              newvalue: 'Unknown state'
            - value: '10'
              newvalue: 'Data retrievement error'
    - uuid: b43a7c5f1d1d43d28e2eb8f0a9f6f16f
      template: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
      name: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
      description: |
        Get GCP Cloud SQL PostgreSQL  monitoring for read-only replicas with script item usage to perform HTTP requests to Google Cloud Platform Monitoring API.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        This template is used in low-level discovery and will be auto-assigned to host prototypes. Additional configuration is not required.
      vendor:
        name: Zabbix
        version: 8.0-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: c67dd812c7784948bad5dfa0d9a6cc66
          name: 'Flush location lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.flush_location
          units: B
          description: 'Flush location replication lag in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.flush_location
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 2b8b51f0266049ffbfb7ece2f944fb68
          name: 'Number of log archival failures'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.log_archive_failure_count
          description: 'Number of failed attempts for archiving replication log files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.log_archive_failure_count
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 4657c4bb904b437598b68410e47f7194
          name: 'Number of log archival successes'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.log_archive_success_count
          description: 'Number of failed attempts for archiving replication log files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.log_archive_success_count
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: cb9c5aff913e4deeb29dfa1a20b5ff04
          name: 'Replica metrics get'
          type: SCRIPT
          key: gcp.cloudsql.pgsql.repl.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'cloudsql.googleapis.com/database/replication/',
            	pgsql_path = 'cloudsql.googleapis.com/database/postgresql/replication/',
            	obj = {},
            	base_paths = ['network_lag', 'replica_lag', 'log_archive_failure_count', 'log_archive_success_count'];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'database_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            var params = checkParams(JSON.parse(value)),
            	filter = ' | within ' + params.time_window + " | filter database_id = '" + params.database_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	metric_raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
            	metric_keys = getField(metric_raw, 'timeSeriesDescriptor.pointDescriptors'),
            	metric_values = getField(metric_raw, 'timeSeriesData.0.pointData.0.values'),
            	re = /(^t_\d+\.value\.)/g;
            
            for (i in metric_keys) {
            	var value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'];
            
            	for (v in value_types) {
            		if (typeof metric_values[i][value_types[v]] !== 'undefined') {
            			obj[getField(metric_keys[i], 'key').replace(re, '')] = metric_values[i][value_types[v]];
            		}
            	}
            }
            
            var state_raw = getHttpData(url, params.token, { query: base_path + 'state' + filter }),
            	state_keys = getField(state_raw, 'timeSeriesDescriptor.pointDescriptors'),
            	state_tsd = getField(state_raw, 'timeSeriesData');
            
            for (i in state_keys) {
            	var state_key = getField(state_keys[i], 'key').replace(/value\./g, '');
            
            	obj[state_key] = 'undefined';
            	for (t in state_tsd) {
            		if (getField(state_tsd[t], 'pointData.0.values.' + i + '.boolValue') == true) {
            			obj[state_key] = getField(state_tsd[t], 'labelValues.3.stringValue');
            			break;
            		}
            	}
            }
            
            var lag_raw = getHttpData(url, params.token, { query: pgsql_path + 'replica_byte_lag' + '| within ' + params.time_window + " | filter replica_name = '" + params.database_id + "'" }),
            	lag_tsd = getField(lag_raw, 'timeSeriesData');
            
            for (t in lag_tsd) {
            	obj[getField(lag_tsd[t], 'labelValues.3.stringValue')] = getField(lag_tsd[t], 'pointData.0.values.0.int64Value');
            }
            
            return JSON.stringify(obj);
          description: 'PostgreSQL replica metrics data in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: database_id
              value: '{$GCP.PROJECT.ID}:{HOST.NAME}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: e43272210c45425d871d70a5bb91cdd1
          name: 'Network lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.network_lag
          units: s
          description: 'Indicates time taken from primary binary log to IO thread on replica.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.network_lag
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 7d74736aa2804c899de35634bc072edf
          name: 'Replay location lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.replay_location
          units: B
          description: 'Replay location replication lag in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.replay_location
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 192e0bb3ac744f8eb38a760ee3f7c623
          name: 'Replication lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.replica_lag
          units: s
          description: 'Number of seconds the read replica is behind its primary (approximation).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.replica_lag
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: 379c8bc0cfe847d1819ab96aceee5efe
          name: 'Sent location lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.sent_location
          units: B
          description: 'Sent location replication lag in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.sent_location
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
        - uuid: a7f785dbe4954d77a82e6384620b5d6e
          name: 'Replication state'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.state
          description: |
            The current serving state of replication.
            This metric is only available for the MySQL/PostgreSQL instances.
          valuemap:
            name: 'Replication state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.state
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'Running',
                  	'Syncing',
                  	'Unsynced',
                  	'Stopped',
                  	'Error',
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
            - tag: component
              value: status
        - uuid: 10af15bc71ed446eb4e614c2cb6029d5
          name: 'Write location lag'
          type: DEPENDENT
          key: gcp.cloudsql.pgsql.repl.write_location
          units: B
          description: 'Write location replication lag in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.write_location
          master_item:
            key: gcp.cloudsql.pgsql.repl.metrics.get
          tags:
            - tag: component
              value: replication
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: sql
        - tag: target
          value: cloudsql
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
        - tag: target
          value: postgresql
        - tag: target
          value: replica
      macros:
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for data requests.
            Supported usage types:
            - Default update interval for most items.
            - Minimal time window for data requested in Monitoring Query Language REST API request.
      dashboards:
        - uuid: acb71f4a818d43e0b045ba87c2daa989
          name: 'PostgreSQL replica'
          pages:
            - name: 'PostgreSQL replica'
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: WAL archiving'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
                        name: 'GCP Cloud SQL PostgreSQL: Lags'
                    - type: STRING
                      name: reference
                      value: AAAAB
      valuemaps:
        - uuid: af111e6b9e5a47cd9c3933b8ce35076c
          name: 'Replication state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Syncing
            - value: '2'
              newvalue: Unsynced
            - value: '3'
              newvalue: Stopped
            - value: '4'
              newvalue: Error
            - value: '10'
              newvalue: Unknown
    - uuid: 6d2443db49e54d59a82b9b525f2424ef
      template: 'GCP Compute Engine Instance by HTTP'
      name: 'GCP Compute Engine Instance by HTTP'
      description: |
        Discover GCP Compute Engine instances by HTTP with script item usage.
        This template will be automatically connected to discovered entities with all their required parameters pre-defined.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback.
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Setup
        
        This template is used in low-level discovery and will be auto-assigned to host prototypes. Additional configuration is not required.
      vendor:
        name: Zabbix
        version: 8.0-2
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 3de05ba490644a62ba4a700ffe439c98
          name: 'Guest visible vCPUs'
          type: DEPENDENT
          key: gcp.gce.cpu.guest_visible_vcpus
          value_type: FLOAT
          description: |
            Number of vCPUs visible inside the guest.
            For many GCE machine types, the number of vCPUs visible inside the guest is equal to the `compute.googleapis.com/instance/cpu/reserved_cores` metric.
            For shared-core machine types, the number of guest-visible vCPUs differs from the number of reserved cores.
            For example, e2-small instances have two vCPUs visible inside the guest and 0.5 fractional vCPUs reserved.
            Therefore, for an e2-small instance, `compute.googleapis.com/instance/cpu/guest_visible_vcpus` has a value of 2 and `compute.googleapis.com/instance/cpu/reserved_cores` has a value of 0.5.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.guest_visible_vcpus
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: 2fa7a2aa15a242cc826248ebe96bb173
          name: 'Reserved vCPUs'
          type: DEPENDENT
          key: gcp.gce.cpu.reserved_cores
          value_type: FLOAT
          description: 'Number of vCPUs reserved on the host of the instance.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.reserved_cores
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: f6c9c633f514416189ba85d2015251ba
          name: 'Scheduler wait time'
          type: DEPENDENT
          key: gcp.gce.cpu.scheduler_wait_time
          value_type: FLOAT
          units: s
          description: |
            Wait time is the time a vCPU is ready to run, but unexpectedly not scheduled to run.
            The wait time returned here is the accumulated value for all vCPUs.
            The time interval for which the value was measured is returned by Monitoring in whole seconds as start_time and end_time.
            This metric is only available for VMs that belong to the e2 family or to overcommitted VMs on sole-tenant nodes.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.scheduler_wait_time
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: daf4d0d23ccf4633aad6405bd1f09dc3
          name: 'CPU usage time'
          type: DEPENDENT
          key: gcp.gce.cpu.usage_time
          value_type: FLOAT
          units: s
          description: |
            Delta vCPU usage for all vCPUs, in vCPU-seconds.
            To compute the per-vCPU utilization fraction, divide this value by (end-start)*N, where end and start define this value's time interval and N is `compute.googleapis.com/instance/cpu/reserved_cores` at the end of the interval.
            This value is reported by the hypervisor for the VM and can differ from `agent.googleapis.com/cpu/usage_time`, which is reported from inside the VM.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.usage_time
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: cpu
        - uuid: 666cd3e9f21d4ede9d4bcc16bc95347c
          name: 'CPU utilization'
          type: DEPENDENT
          key: gcp.gce.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: |
            Fractional utilization of allocated CPU on this instance.
            This metric is reported by the hypervisor for the VM and can differ from `agent.googleapis.com/cpu/utilization`, which is reported from inside the VM.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.utilization
            - type: MULTIPLIER
              parameters:
                - '100'
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: fb8e28649b4947e9a11d891e3126a3a1
              expression: 'min(/GCP Compute Engine Instance by HTTP/gcp.gce.cpu.utilization,15m) >= {$GCE.CPU.UTIL.MAX}'
              name: 'GCP Compute Engine Instance: High CPU utilization'
              event_name: 'GCP Compute Engine Instance: High CPU utilization (over {$GCE.CPU.UTIL.MAX}% for 15m)'
              priority: AVERAGE
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: performance
        - uuid: 4bdd3662247749a69bb59e6643ba7b9a
          name: 'Disks get'
          type: SCRIPT
          key: gcp.gce.disks.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'compute.googleapis.com/instance/disk/',
            	base_paths = ['read_ops_count', 'read_bytes_count', 'write_bytes_count', 'write_ops_count'];
            
            function checkParams(params) {
            	['project_id', 'time_window', 'instance_id', 'token'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	return params;
            }
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            var params = checkParams(JSON.parse(value)),
            	j_filter = ' | within ' + params.time_window + " | filter instance_id = '" + params.instance_id + "'" + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	raw = getHttpData(url, params.token, { query: '{' + base_paths.map(function (path) { return base_path + path; }).join(';') + '}' + j_filter }),
            	metrics = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            	time_series = getField(raw, 'timeSeriesData'),
            	arr = [];
            
            for (t in time_series) {
            	data = {
            		disk_name: getField(time_series[t], 'labelValues.3.stringValue'),
            		device_type: getField(time_series[t], 'labelValues.4.stringValue'),
            		storage_type: getField(time_series[t], 'labelValues.6.stringValue'),
            		metrics: {}
            	};
            
            	for (i in metrics) {
            		re = /(^t_\d+\.value(_|\.))/g;
            		data['metrics'][getField(metrics[i], 'key').replace(re, '')] = getField(time_series[t], 'pointData.0.values.' + i + '.int64Value');
            	}
            	arr.push(data);
            }
            return JSON.stringify(arr);
          description: 'Disk entities and metrics related to a particular instance.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: instance_id
              value: '{HOST.HOST}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: e1cd503d86f7487db023e2fd3cea5385
          name: 'Firewall: Dropped bytes'
          type: DEPENDENT
          key: gcp.gce.firewall.dropped_bytes_count
          units: B
          description: 'Count of incoming bytes dropped by the firewall.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.dropped_bytes_count
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: firewall
            - tag: component
              value: network
        - uuid: 25002706c5164c43a345a8ce594615c7
          name: 'Firewall: Dropped packets'
          type: DEPENDENT
          key: gcp.gce.firewall.dropped_packets_count
          description: 'Count of incoming packets dropped by the firewall.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.dropped_packets_count
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: firewall
            - tag: component
              value: network
        - uuid: 3f82955d43694b25b1e96c9b8f4f6ffb
          name: 'Instance state'
          type: HTTP_AGENT
          key: gcp.gce.instance.state
          description: 'GCP Compute Engine instance state.'
          valuemap:
            name: 'Instance state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.status
              error_handler: CUSTOM_VALUE
              error_handler_params: '10'
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'RUNNING',
                  	'PROVISIONING',
                  	'STAGING',
                  	'STOPPING',
                  	'REPAIRING',
                  	'TERMINATED',
                  	'SUSPENDING',
                  	'SUSPENDED'
                  ].indexOf(value);
                  return idx !== -1 ? idx : 10;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          timeout: '{$GCP.DATA.TIMEOUT}'
          url: 'https://compute.googleapis.com/compute/v1/projects/{$GCP.PROJECT.ID}/zones/{$GCE.INSTANCE.ZONE}/instances/{HOST.NAME}'
          status_codes: ''
          headers:
            - name: Content-Type
              value: application/json
            - name: Authorization
              value: 'Bearer {$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 96abd48a3e684e1b9b95fdd96d095188
              expression: 'last(/GCP Compute Engine Instance by HTTP/gcp.gce.instance.state) = 10'
              name: 'GCP Compute Engine Instance: Failed to get the instance state'
              priority: AVERAGE
              description: |
                Failed to get the instance state.
                Check access permissions to GCP API or service account.
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: availability
            - uuid: 1223f00a5e4b4bc8aa9e8ec08253c4cc
              expression: 'last(/GCP Compute Engine Instance by HTTP/gcp.gce.instance.state) = 7'
              name: 'GCP Compute Engine Instance: Instance is in suspended state'
              priority: INFO
              description: 'The VM is in a suspended state. You can resume the VM or delete it.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: availability
                - tag: scope
                  value: notice
            - uuid: d2144e2277ec458c80d2b948364f1924
              expression: 'last(/GCP Compute Engine Instance by HTTP/gcp.gce.instance.state) = 4'
              name: 'GCP Compute Engine Instance: The instance is in repairing state'
              priority: WARNING
              description: |
                The VM is being repaired.
                Repairing occurs when the VM encounters an internal error or the underlying machine is unavailable due to maintenance.
                During this time, the VM is unusable.
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: availability
            - uuid: 4a010c2b1e6f4ec88dbbe97255b9bac4
              expression: 'last(/GCP Compute Engine Instance by HTTP/gcp.gce.instance.state) = 5'
              name: 'GCP Compute Engine Instance: The instance is in terminated state'
              priority: AVERAGE
              description: 'The VM is stopped. You stopped the VM, or the VM encountered a failure.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: availability
        - uuid: f075482578ec475385cdfc57346d1570
          name: 'Instance uptime'
          type: DEPENDENT
          key: gcp.gce.instance.uptime
          value_type: FLOAT
          units: s
          description: 'Elapsed time since the VM was started, in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.uptime_total
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: uptime
        - uuid: 744f3f821847473d9cef1236580bda38
          name: 'Integrity: Early boot validation status'
          type: DEPENDENT
          key: gcp.gce.integrity.early_boot_validation_status
          description: |
            The validation status of early boot integrity policy.
            Empty value if integrity monitoring isn't enabled.
          valuemap:
            name: 'Integrity validation status'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.early_boot_validation_status
              error_handler: DISCARD_VALUE
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'passed',
                  	'failed',
                  	'unknown',
                  ].indexOf(value);
                  return idx !== -1 ? idx : "";
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: security
        - uuid: aa334c3a0faf4f36bcbbf51d87ef9186
          name: 'Integrity: Late boot validation status'
          type: DEPENDENT
          key: gcp.gce.integrity.late_boot_validation_status
          description: |
            The validation status of late boot integrity policy.
            Empty value if integrity monitoring isn't enabled.
          valuemap:
            name: 'Integrity validation status'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.late_boot_validation_status
              error_handler: DISCARD_VALUE
            - type: JAVASCRIPT
              parameters:
                - |
                  const idx = [
                  	'passed',
                  	'failed',
                  	'unknown',
                  ].indexOf(value);
                  return idx !== -1 ? idx : "";
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: security
        - uuid: 1b14fefa6b0f4abc98f6ddf3164074b3
          name: 'Memory usage percentage'
          type: DEPENDENT
          key: gcp.gce.memory.ram_pused
          value_type: FLOAT
          units: '%'
          description: |
            Memory usage Percentage.
            This metric is only available for VMs that belong to the e2 family; returns empty value for different instance types.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ram_pused
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: fa918889bcb84d3886254f00f0df288c
              expression: 'min(/GCP Compute Engine Instance by HTTP/gcp.gce.memory.ram_pused,15m) >= {$GCE.RAM.UTIL.MAX}'
              name: 'GCP Compute Engine Instance: High memory utilization'
              event_name: 'GCP Compute Engine Instance: High memory utilization (over {$GCE.RAM.UTIL.MAX}% for 15m)'
              priority: AVERAGE
              description: 'RAM utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 10d63d2c01dc481380bf386af7af7f97
          name: 'Memory size'
          type: DEPENDENT
          key: gcp.gce.memory.ram_size
          units: B
          description: |
            Total VM memory size.
            This metric is only available for VMs that belong to the e2 family; returns empty value for different instance types.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ram_size
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 20dc9e49a60d46b4b6d855eb74a60d5e
          name: 'Memory used'
          type: DEPENDENT
          key: gcp.gce.memory.ram_used
          units: B
          description: |
            Memory currently used in the VM.
            This metric is only available for VMs that belong to the e2 family; returns empty value for different instance types.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ram_used
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: b043128882254e9492c7436521bf994a
          name: 'VM swap in'
          type: DEPENDENT
          key: gcp.gce.memory.swap_in_bytes_count
          units: B
          description: |
            The amount of memory read into the guest from its own swap space.
            This metric is only available for VMs that belong to the e2 family; returns empty value for different instance types.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.swap_in_bytes_count
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 7166423bbcf0456ab0fcc7c852d89125
          name: 'VM swap out'
          type: DEPENDENT
          key: gcp.gce.memory.swap_out_bytes_count
          units: B
          description: |
            The amount of memory written from the guest to its own swap space.
            This metric is only available for VMs that belong to the e2 family; returns empty value for different instance types.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.swap_out_bytes_count
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: memory
        - uuid: 723fbff060ab41a39322bc0d6d8b1f84
          name: 'Metrics get'
          type: SCRIPT
          key: gcp.gce.metrics.get
          delay: '{$GCP.TIME.WINDOW}'
          history: '0'
          value_type: TEXT
          params: |
            var base_path = 'compute.googleapis.com/',
            	value_types = ['int64Value', 'doubleValue', 'stringValue', 'boolValue'],
            	re = /(^t_\d+\.value\.)/g,
            	obj = {},
            	base_paths = [
            		'instance/uptime_total',
            		'firewall/dropped_packets_count',
            		'firewall/dropped_bytes_count',
            		'instance/cpu/guest_visible_vcpus',
            		'instance/cpu/reserved_cores',
            		'instance/cpu/usage_time',
            		'instance/cpu/utilization',
            		'mirroring/mirrored_bytes_count',
            		'mirroring/mirrored_packets_count'
            	],
            	e2_paths = [
            		'instance/cpu/scheduler_wait_time',
            		'instance/memory/balloon/ram_size',
            		'instance/memory/balloon/ram_used',
            		'instance/memory/balloon/swap_in_bytes_count',
            		'instance/memory/balloon/swap_out_bytes_count',
            	],
            	net_paths = [
            		'instance/network/received_packets_count',
            		'instance/network/received_bytes_count',
            		'instance/network/sent_bytes_count',
            		'instance/network/sent_packets_count'
            	],
            	integrity_paths = [
            		'instance/integrity/late_boot_validation_status',
            		'instance/integrity/early_boot_validation_status'
            	];
            
            function getField(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			throw 'Required field "' + path + '" is not present in data received.';
            		}
            		data = data[step];
            	}
            	return data;
            }
            
            function getFieldBool(data, path) {
            	var steps = path.split('.');
            
            	for (var i = 0; i < steps.length; i++) {
            		var step = steps[i];
            
            		if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            			return false;
            		}
            		data = data[step];
            	}
            	return true;
            }
            
            function queryMap(array, path, filter) {
            	var query_params = '{' + array.map(function (element) { return path + element; }).join(';') + '}';
            	return { query: query_params + filter }
            }
            
            function checkParams(params) {
            	['project_id', 'time_window', 'instance_id', 'token', 'machine_type', 'integrity'].forEach(function (field) {
            		if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '' || params[field].match(/^\{\$.*\}$/)) {
            			throw 'Required param is not set: ' + field + '.';
            		}
            	});
            	if (!params.time_window.match(/^[0-9]+(m|h)$/)) {
            		throw 'Incorrect update interval for parameter  time_window. Valid ranges 1m-23h.';
            	}
            	if (params.integrity !== 'true' && params.integrity !== 'false') {
            		throw 'Incorrect integrity state definition type. Valid definitions: true/false';
            	}
            	return params;
            }
            
            function getHttpData(url, token, body) {
            	var request = new HttpRequest();
            	if (typeof params.proxy !== 'undefined' && params.proxy !== '') {
            		request.setProxy(params.proxy);
            	};
            	request.addHeader('Authorization: Bearer ' + token);
            	request.addHeader('Content-Type: application/json');
            
            	var response = request.post(url, JSON.stringify(body));
            
            	Zabbix.log(4, '[ GCP API ] [ ' + url + ' ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            	if (response !== null) {
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from GCP API. Check debug log for more information.';
            		}
            	}
            
            	if (typeof response !== 'object' || response === null) {
            		throw 'Cannot process response data: received data is not an object. Check debug log for more information.';
            	}
            
            	if (request.getStatus() !== 200) {
            		if (typeof (response.error && response.error.message) !== 'undefined') {
            			throw response.error.message;
            		}
            		else {
            			throw 'Failed to receive data: invalid response status code. Check debug log for more information.';
            		}
            	}
            	return response;
            };
            
            function nestedMap(raw) {
            	var ids = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            		ltsd = getField(raw, 'timeSeriesData'),
            		result = {};
            
            	for (i in ids) {
            		var id = getField(ids[i], 'key').replace(re, '');
            		result[id] = {};
            		for (t in ltsd) {
            			for (v in value_types) {
            				if (getFieldBool(ltsd[t], 'pointData.0.values.' + [i] + '.' + [value_types[v]])) {
            					['stringValue', 'boolValue'].forEach(function (type) {
            						if (getFieldBool(ltsd[t], 'labelValues.4.' + [type])) {
            							result[id][ltsd[t].labelValues[4][type]] = ltsd[t].pointData[0].values[i][value_types[v]];
            						}
            					});
            
            				}
            			}
            		}
            	}
            	return result;
            }
            
            var params = checkParams(JSON.parse(value));
            
            if (params.machine_type.match(/e2.*/)) {
            	base_paths = base_paths.concat(e2_paths);
            }
            
            var filter = ' | within ' + params.time_window + " | filter instance_id = '" + params.instance_id + "'",
            	j_filter = filter + ' | join',
            	url = 'https://monitoring.googleapis.com/v3/projects/' + params.project_id + '/timeSeries:query',
            	raw = getHttpData(url, params.token, queryMap(base_paths, base_path, j_filter)),
            	keys = getField(raw, 'timeSeriesDescriptor.pointDescriptors'),
            	values = getField(raw, 'timeSeriesData.0.pointData.0.values');
            
            for (i in keys) {
            	for (v in value_types) {
            		if (typeof values[i][value_types[v]] !== 'undefined') {
            			obj[getField(keys[i], 'key').replace(re, '')] = values[i][value_types[v]];
            		}
            	}
            }
            
            if (params.machine_type.match(/e2.*/)) {
            	obj.ram_pused = Math.floor((getField(obj, 'ram_used') / getField(obj, 'ram_size')) * 100);
            }
            
            var mirr_raw = getHttpData(url, params.token, { query: base_path + 'mirroring/dropped_packets_count' + filter }),
            	tsd = getField(mirr_raw, 'timeSeriesData');
            
            for (t in tsd) {
            	for (v in value_types) {
            		if (getFieldBool(tsd[t], 'pointData.0.values.0.' + [value_types[v]])) {
            			obj[getField(tsd[t], 'labelValues.3.stringValue')] = getField(tsd[t], 'pointData.0.values.0.' + [value_types[v]]);
            		}
            	}
            }
            
            var net_metrics = getHttpData(url, params.token, queryMap(net_paths, base_path, j_filter));
            
            Object.assign(obj, nestedMap(net_metrics));
            
            if (params.integrity === 'true') {
            	integrity_metrics = getHttpData(url, params.token, queryMap(integrity_paths, base_path, j_filter));
            
            	var keys = getField(integrity_metrics, 'timeSeriesDescriptor.pointDescriptors'),
            		tsd = getField(integrity_metrics, 'timeSeriesData');
            
            	for (i in keys) {
            		var key = getField(keys[i], 'key').replace(re, '');
            
            		obj[key] = 'undefined';
            		for (t in tsd) {
            			if (getField(tsd[t], 'pointData.0.values.' + i + '.int64Value') == 1) {
            				obj[key] = getField(tsd[t], 'labelValues.4.stringValue');
            				break;
            			}
            		}
            	}
            }
            
            return JSON.stringify(obj);
          description: 'GCP Compute Engine metrics get in raw format.'
          preprocessing:
            - type: CHECK_NOT_SUPPORTED
              parameters:
                - '-1'
          timeout: '{$GCP.DATA.TIMEOUT}'
          parameters:
            - name: instance_id
              value: '{HOST.HOST}'
            - name: integrity
              value: '{$GCE.INTEGRITY.STATE}'
            - name: machine_type
              value: '{$GCE.MACHINE.TYPE}'
            - name: project_id
              value: '{$GCP.PROJECT.ID}'
            - name: proxy
              value: '{$GCP.PROXY}'
            - name: time_window
              value: '{$GCP.TIME.WINDOW}'
            - name: token
              value: '{$GCP.AUTH.TOKEN}'
          tags:
            - tag: component
              value: raw
        - uuid: faf1c3ccbcc24b9eb52be355f2f782e6
          name: 'Network: Received bytes'
          type: DEPENDENT
          key: gcp.gce.network.lb.received_bytes_count.false
          units: B
          description: 'Count of bytes received from the network without load-balancing.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.received_bytes_count.false
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 91ef1b33d7ae479999302cdec227eb3e
          name: 'Network: Received bytes: Load-balanced'
          type: DEPENDENT
          key: gcp.gce.network.lb.received_bytes_count.true
          units: B
          description: |
            Whether traffic was received by an L3 loadbalanced IP address assigned to the VM.
            Traffic that is externally routed to the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric.
            The value is empty when load-balancing is not used.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.received_bytes_count.true
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 84dec0cb32ea434a9d6f29f402d337a0
          name: 'Network: Received packets'
          type: DEPENDENT
          key: gcp.gce.network.lb.received_packets_count.false
          description: 'Count of packets received from the network without load-balancing.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.received_packets_count.false
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 148fe8aaa01e4863bbe2ca4c0226ce80
          name: 'Network: Received packets: Load-balanced'
          type: DEPENDENT
          key: gcp.gce.network.lb.received_packets_count.true
          description: |
            Whether traffic was received by an L3 loadbalanced IP address assigned to the VM.
            Traffic that is externally routed to the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric.
            The value is empty when load-balancing is not used.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.received_packets_count.true
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: b8ea22b00a254ee5a2484fd833421b12
          name: 'Network: Sent bytes'
          type: DEPENDENT
          key: gcp.gce.network.lb.sent_bytes_count.false
          units: B
          description: 'Count of bytes sent over the network without load-balancing.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.sent_bytes_count.false
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 77bd252194764837bc71b031e4d7e2b8
          name: 'Network: Sent bytes: Load-balanced'
          type: DEPENDENT
          key: gcp.gce.network.lb.sent_bytes_count.true
          units: B
          description: |
            Whether traffic was received by an L3 loadbalanced IP address assigned to the VM.
            Traffic that is externally routed to the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric.
            The value is empty when load-balancing is not used.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.sent_bytes_count.true
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 44032903b7da4d72b2dff35e81e787d3
          name: 'Network: Sent packets'
          type: DEPENDENT
          key: gcp.gce.network.lb.sent_packets_count.false
          description: 'Count of packets sent over the network without load-balancing.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.sent_packets_count.false
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 2aef5ad0f3704550b4920ce36614b52d
          name: 'Network: Sent packets: Load-balanced'
          type: DEPENDENT
          key: gcp.gce.network.lb.sent_packets_count.true
          description: |
            Whether traffic was received by an L3 loadbalanced IP address assigned to the VM.
            Traffic that is externally routed to the VM's standard internal or external IP address, such as L7 loadbalanced traffic, is not considered to be loadbalanced in this metric.
            The value is empty when load-balancing is not used.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.sent_packets_count.true
              error_handler: DISCARD_VALUE
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 199fb1f4278848138ef8cfd8fc3e07ee
          name: 'Network: Mirrored bytes'
          type: DEPENDENT
          key: gcp.gce.network.mirrored_bytes_count
          units: B
          description: 'The count of mirrored bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mirrored_bytes_count
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: f0add3d3853d4d8c9993b1603fd7b542
          name: 'Network: Mirrored packets'
          type: DEPENDENT
          key: gcp.gce.network.mirrored_packets_count
          description: 'The count of mirrored packets.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.mirrored_packets_count
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 6ca64c0fa39e4587a2987cd607058b54
          name: 'Network: Mirrored packets dropped: Invalid'
          type: DEPENDENT
          key: gcp.gce.network.mirr_dropped_packets.invalid
          description: |
            The count of mirrored packets dropped.
            Reason - invalid.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.invalid
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 3cf438aa0225428385d30c5be30ea3e6
          name: 'Network: Mirrored packets dropped: Out of quota'
          type: DEPENDENT
          key: gcp.gce.network.mirr_dropped_packets.out_of_quota
          description: |
            The count of mirrored packets dropped.
            Reason - out of quota.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.out_of_quota
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
        - uuid: 5303badcf26641f1af85366fbaecdd77
          name: 'Network: Mirrored packets dropped: Unknown'
          type: DEPENDENT
          key: gcp.gce.network.mirr_dropped_packets.unknown
          description: |
            The count of mirrored packets dropped.
            Reason - unknown.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.unknown
          master_item:
            key: gcp.gce.metrics.get
          tags:
            - tag: component
              value: network
            - tag: component
              value: traffic
      discovery_rules:
        - uuid: 260e06bfe28e46f4a726dd4a6d7fa523
          name: 'GCP Compute Engine: Physical disks discovery'
          type: DEPENDENT
          key: gcp.gce.phys.disks.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GCE.DISK.DEV_TYPE}'
                value: '{$GCE.DISK.DEV_TYPE.MATCHES}'
              - macro: '{#GCE.DISK.DEV_TYPE}'
                value: '{$GCE.DISK.DEV_TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#GCE.DISK.NAME}'
                value: '{$GCE.DISK.NAME.MATCHES}'
              - macro: '{#GCE.DISK.NAME}'
                value: '{$GCE.DISK.NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#GCE.DISK.STOR_TYPE}'
                value: '{$GCE.DISK.STOR_TYPE.MATCHES}'
              - macro: '{#GCE.DISK.STOR_TYPE}'
                value: '{$GCE.DISK.STOR_TYPE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'GCP Compute Engine: Physical disks discovery.'
          item_prototypes:
            - uuid: dda10a0535c04fdb92092efeff020b2c
              name: 'Disk [{#GCE.DISK.NAME}]: Read bytes'
              type: DEPENDENT
              key: 'gcp.gce.disk.read_bytes_count[{#GCE.DISK.NAME}]'
              units: B
              description: 'Count of bytes read from [{#GCE.DISK.NAME}] disk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.read_bytes_count
              master_item:
                key: 'gcp.gce.quota.single.raw[{#GCE.DISK.NAME}]'
              tags:
                - tag: component
                  value: storage
                - tag: device-type
                  value: '{#GCE.DISK.DEV_TYPE}'
                - tag: disk
                  value: '{#GCE.DISK.NAME}'
                - tag: storage-type
                  value: '{#GCE.DISK.STOR_TYPE}'
            - uuid: e166d3dfeb404111bcd143415070a0af
              name: 'Disk [{#GCE.DISK.NAME}]: Read operations'
              type: DEPENDENT
              key: 'gcp.gce.disk.read_ops_count[{#GCE.DISK.NAME}]'
              description: 'Count of read IO operations from [{#GCE.DISK.NAME}] disk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.read_ops_count
              master_item:
                key: 'gcp.gce.quota.single.raw[{#GCE.DISK.NAME}]'
              tags:
                - tag: component
                  value: storage
                - tag: device-type
                  value: '{#GCE.DISK.DEV_TYPE}'
                - tag: disk
                  value: '{#GCE.DISK.NAME}'
                - tag: storage-type
                  value: '{#GCE.DISK.STOR_TYPE}'
            - uuid: cf21b2bf6dc74ed28bc55a2c567b3dae
              name: 'Disk [{#GCE.DISK.NAME}]: Write bytes'
              type: DEPENDENT
              key: 'gcp.gce.disk.write_bytes_count[{#GCE.DISK.NAME}]'
              units: B
              description: 'Count of bytes written to {#GCE.DISK.NAME}] disk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.write_bytes_count
              master_item:
                key: 'gcp.gce.quota.single.raw[{#GCE.DISK.NAME}]'
              tags:
                - tag: component
                  value: storage
                - tag: device-type
                  value: '{#GCE.DISK.DEV_TYPE}'
                - tag: disk
                  value: '{#GCE.DISK.NAME}'
                - tag: storage-type
                  value: '{#GCE.DISK.STOR_TYPE}'
            - uuid: 602255b7df004129b5a3e0e1d2fba920
              name: 'Disk [{#GCE.DISK.NAME}]: Write operations'
              type: DEPENDENT
              key: 'gcp.gce.disk.write_ops_count[{#GCE.DISK.NAME}]'
              description: 'Count of write IO operations to [{#GCE.DISK.NAME}] disk.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.write_ops_count
              master_item:
                key: 'gcp.gce.quota.single.raw[{#GCE.DISK.NAME}]'
              tags:
                - tag: component
                  value: storage
                - tag: device-type
                  value: '{#GCE.DISK.DEV_TYPE}'
                - tag: disk
                  value: '{#GCE.DISK.NAME}'
                - tag: storage-type
                  value: '{#GCE.DISK.STOR_TYPE}'
            - uuid: 7fc27a6630664e2fbac8fe64ac40985a
              name: 'Disk [{#GCE.DISK.NAME}]: Raw data'
              type: DEPENDENT
              key: 'gcp.gce.quota.single.raw[{#GCE.DISK.NAME}]'
              history: '0'
              value_type: TEXT
              description: 'Data in raw format for the disk with the name [{#GCE.DISK.NAME}].'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.disk_name == "{#GCE.DISK.NAME}")].metrics.first()'
              master_item:
                key: gcp.gce.disks.get
              tags:
                - tag: component
                  value: raw
                - tag: component
                  value: storage
                - tag: disk
                  value: '{#GCE.DISK.NAME}'
          graph_prototypes:
            - uuid: 9af0456af3d74041b678ceeccbc036fc
              name: 'GCP Compute Engine: Disk [{#GCE.DISK.NAME}]: Read/Write bytes'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'GCP Compute Engine Instance by HTTP'
                    key: 'gcp.gce.disk.read_bytes_count[{#GCE.DISK.NAME}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'GCP Compute Engine Instance by HTTP'
                    key: 'gcp.gce.disk.write_bytes_count[{#GCE.DISK.NAME}]'
            - uuid: 542185ffc8b3485f8955b63c46a50b83
              name: 'GCP Compute Engine: Disk [{#GCE.DISK.NAME}]: Read/Write operations'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'GCP Compute Engine Instance by HTTP'
                    key: 'gcp.gce.disk.read_ops_count[{#GCE.DISK.NAME}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'GCP Compute Engine Instance by HTTP'
                    key: 'gcp.gce.disk.write_ops_count[{#GCE.DISK.NAME}]'
          master_item:
            key: gcp.gce.disks.get
          lld_macro_paths:
            - lld_macro: '{#GCE.DISK.DEV_TYPE}'
              path: $.device_type
            - lld_macro: '{#GCE.DISK.NAME}'
              path: $.disk_name
            - lld_macro: '{#GCE.DISK.STOR_TYPE}'
              path: $.storage_type
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
      tags:
        - tag: class
          value: cloud
        - tag: subclass
          value: automation
        - tag: subclass
          value: computing
        - tag: target
          value: compute-engine
        - tag: target
          value: gce
        - tag: target
          value: gcp
        - tag: target
          value: google-cloud-platform
      macros:
        - macro: '{$GCE.CPU.UTIL.MAX}'
          value: '95'
          description: 'GCP Compute Engine instance CPU utilization threshold.'
        - macro: '{$GCE.DISK.DEV_TYPE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Compute Engine disks by device type.'
        - macro: '{$GCE.DISK.DEV_TYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Compute Engine disks by device type.'
        - macro: '{$GCE.DISK.NAME.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Compute Engine disks by namespace.'
        - macro: '{$GCE.DISK.NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Compute Engine disks by namespace.'
        - macro: '{$GCE.DISK.STOR_TYPE.MATCHES}'
          value: '.*'
          description: 'The filter to include GCP Compute Engine disks by storage type.'
        - macro: '{$GCE.DISK.STOR_TYPE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'The filter to exclude GCP Compute Engine disks by storage type.'
        - macro: '{$GCE.RAM.UTIL.MAX}'
          value: '90'
          description: 'GCP Compute Engine instance RAM utilization threshold.'
        - macro: '{$GCP.DATA.TIMEOUT}'
          value: 15s
          description: 'Response timeout for API.'
        - macro: '{$GCP.PROXY}'
          description: 'Sets HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$GCP.TIME.WINDOW}'
          value: 5m
          description: |
            Time interval for data requests.
            Supported usage types:
            - Default update interval for most items.
            - Minimal time window for data requested in Monitoring Query Language REST API request.
      dashboards:
        - uuid: b8b09f6833ec4ea78c4ac7d15cdb0cc5
          name: Hardware
          pages:
            - name: Hardware
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Compute Engine Instance by HTTP'
                        name: 'GCP Compute Engine: CPU usage'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  'y': '5'
                  width: '24'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Compute Engine Instance by HTTP'
                        name: 'GCP Compute Engine: Memory usage'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graphprototype
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'GCP Compute Engine Instance by HTTP'
                        name: 'GCP Compute Engine: Disk [{#GCE.DISK.NAME}]: Read/Write bytes'
                    - type: STRING
                      name: reference
                      value: AAAAF
                - type: graph
                  'y': '15'
                  width: '72'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Compute Engine Instance by HTTP'
                        name: 'GCP Compute Engine: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAH
                - type: graph
                  x: '24'
                  'y': '5'
                  width: '24'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Compute Engine Instance by HTTP'
                        key: gcp.gce.memory.ram_pused
                    - type: STRING
                      name: reference
                      value: AAAAD
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'GCP Compute Engine Instance by HTTP'
                        key: gcp.gce.cpu.utilization
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: source_type
                      value: '1'
                - type: graphprototype
                  x: '36'
                  'y': '10'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'GCP Compute Engine Instance by HTTP'
                        name: 'GCP Compute Engine: Disk [{#GCE.DISK.NAME}]: Read/Write operations'
                    - type: STRING
                      name: reference
                      value: AAAAG
                - type: graph
                  x: '48'
                  'y': '5'
                  width: '24'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'GCP Compute Engine Instance by HTTP'
                        name: 'GCP Compute Engine: Memory swapping'
                    - type: STRING
                      name: reference
                      value: AAAAE
      valuemaps:
        - uuid: d5f19327f8b74b44a40950d9d4f9410f
          name: 'Instance state'
          mappings:
            - value: '0'
              newvalue: Running
            - value: '1'
              newvalue: Provisioning
            - value: '2'
              newvalue: Staging
            - value: '3'
              newvalue: Stopping
            - value: '4'
              newvalue: Repairing
            - value: '5'
              newvalue: Terminated
            - value: '6'
              newvalue: Suspending
            - value: '7'
              newvalue: Suspended
            - value: '10'
              newvalue: 'Data retrievement error'
        - uuid: 1e17bce361f9486dae764fc195561703
          name: 'Integrity validation status'
          mappings:
            - value: '0'
              newvalue: Passed
            - value: '1'
              newvalue: Failed
            - value: '2'
              newvalue: Unknown
    - uuid: 03e93dc9a8194a17958544a056d02316
      template: 'Microsoft 365 reports by HTTP'
      name: 'Microsoft 365 reports by HTTP'
      description: |
        This template is designed to monitor Microsoft 365 reports by HTTP. It works without any external scripts and uses script items.
        The template uses endpoints in the Microsoft Graph API to gather daily metrics from weekly reports.
        The template is meant to be used as a long-term trend monitoring tool.
        
        Setup:
          1. Register the app with Microsoft Entra ID.
          2. Configure Microsoft Graph application permissions on the app ID:
            `Reports.Read.All` - required for app usage and activity metrics
            `ServiceHealth.Read.All` - required for service discovery and service status metrics
          3. Request administrator consent.
          4. Configure the macros: `{$MS365.APP.ID}`, `{$MS365.PASSWORD}`, `{$MS365.TENANT.ID}`.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/
        
        Generated by official Zabbix template tool "Templator"
      wizard_ready: 'YES'
      readme: |
        ## Overview
        
        - This template is designed to monitor Microsoft 365 by HTTP. It works without any external scripts and uses script items.
        - The template uses endpoints in the Microsoft Graph API to gather daily metrics from weekly reports.
        - The template is meant to be used as a long-term trend monitoring tool.
        
        ## Setup
        
        1. Register the app with your Microsoft Entra ID.
        2. Configure Microsoft Graph application permissions on the app ID:
            - `Reports.Read.All` - required for app usage and activity metrics
            - `ServiceHealth.Read.All` - required for service discovery and service status metrics
        3. Request administrator consent.
        4. Configure the host wizard configuration fields: `Application ID`, `Password`, `Tenant ID`.
      vendor:
        name: Zabbix
        version: 8.0-3
      groups:
        - name: Templates/Applications
      items:
        - uuid: 33f44ece510247938a7ccc79b5209b9f
          name: 'Apps: Activity, Exchange active users'
          type: DEPENDENT
          key: ms365.apps.activity.exchange.users.active
          trends: '0'
          description: 'The number of active Exchange users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].exchangeActive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 43b10a8d427647ae9a82f6d71560bedd
          name: 'Apps: Activity, Exchange inactive users'
          type: DEPENDENT
          key: ms365.apps.activity.exchange.users.inactive
          trends: '0'
          description: 'The number of inactive Exchange users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].exchangeInactive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 004104d830b9440e9fb92fb0d289426a
          name: 'Apps: Activity, Office 365 active users'
          type: DEPENDENT
          key: ms365.apps.activity.office365.users.active
          trends: '0'
          description: 'The number of active Office 365 users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].office365Active'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: dd05d33806a74a54a7640ab639a004a3
          name: 'Apps: Activity, Office 365 inactive users'
          type: DEPENDENT
          key: ms365.apps.activity.office365.users.inactive
          trends: '0'
          description: 'The number of inactive Office 365 users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].office365Inactive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: f9b84bbc76eb4f278d32913fdcece5f4
          name: 'Apps: Activity, OneDrive active users'
          type: DEPENDENT
          key: ms365.apps.activity.onedrive.users.active
          trends: '0'
          description: 'The number of active OneDrive users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].oneDriveActive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 699122d921a046c2a652139cc982225c
          name: 'Apps: Activity, OneDrive inactive users'
          type: DEPENDENT
          key: ms365.apps.activity.onedrive.users.inactive
          trends: '0'
          description: 'The number of inactive OneDrive users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].oneDriveInactive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 245c30401bd64ba8a4dbbda7eaeab608
          name: 'Apps: Activity, report date'
          type: DEPENDENT
          key: ms365.apps.activity.report_date
          value_type: CHAR
          description: 'The date of the report of the user count by activity.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].reportRefreshDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: date
        - uuid: 6546281eff194c048f9aaaf1cd1d2a8c
          name: 'Apps: Activity, SharePoint active users'
          type: DEPENDENT
          key: ms365.apps.activity.sharepoint.users.active
          trends: '0'
          description: 'The number of active SharePoint users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].sharePointActive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 0fdf0c1e5f1c4e94962ef76dd7377635
          name: 'Apps: Activity, SharePoint inactive users'
          type: DEPENDENT
          key: ms365.apps.activity.sharepoint.users.inactive
          trends: '0'
          description: 'The number of inactive SharePoint users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].sharePointInactive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: a977a7e3b51d42efb2c93c2269c64c91
          name: 'Apps: Activity, Skype for Business active users'
          type: DEPENDENT
          key: ms365.apps.activity.skypeforbusiness.users.active
          trends: '0'
          description: 'The number of active Skype for Business users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].skypeForBusinessActive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 04f4507608b940d7a51990586cb034cd
          name: 'Apps: Activity, Skype for Business inactive users'
          type: DEPENDENT
          key: ms365.apps.activity.skypeforbusiness.users.inactive
          trends: '0'
          description: 'The number of inactive Skype for Business users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].skypeForBusinessInactive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 3a424ddd198d4cef9357daabba9937aa
          name: 'Apps: Activity, Teams active users'
          type: DEPENDENT
          key: ms365.apps.activity.teams.users.active
          trends: '0'
          description: 'The number of active Teams users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].teamsActive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: f14f9730db914c7ba9162bb13c2a0882
          name: 'Apps: Activity, Teams inactive users'
          type: DEPENDENT
          key: ms365.apps.activity.teams.users.inactive
          trends: '0'
          description: 'The number of inactive Teams users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].teamsInactive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 5c3a5ebbc416479884252b1fbd787ba4
          name: 'Apps: Activity, Yammer active users'
          type: DEPENDENT
          key: ms365.apps.activity.yammer.users.active
          trends: '0'
          description: 'The number of active Yammer users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].yammerActive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: fe91f316df80446993e1eab32320582e
          name: 'Apps: Activity, Yammer inactive users'
          type: DEPENDENT
          key: ms365.apps.activity.yammer.users.inactive
          trends: '0'
          description: 'The number of inactive Yammer users during the week before the report date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ServicesUserCounts[0].yammerInactive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 02333e83fd734a7b8cf699784e325242
          name: 'Apps: Get errors'
          type: DEPENDENT
          key: ms365.apps.errors
          value_type: TEXT
          description: 'A list of errors from API requests for Apps metrics.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: error
          triggers:
            - uuid: eab5ac8df92f43398ad62a2dacb53e98
              expression: 'length(last(/Microsoft 365 reports by HTTP/ms365.apps.errors))>0'
              name: 'Microsoft 365: Apps: There are errors in requests to API'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Zabbix has received errors in response to API requests.'
              tags:
                - tag: scope
                  value: availability
        - uuid: d1a7d542fb44426b87a6835bb0d7990f
          name: 'Apps: Office, Excel user count'
          type: DEPENDENT
          key: ms365.apps.office.user_count.excel
          trends: '0'
          description: 'The number of active Excel users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppUserCounts[0].userCounts[0].excel'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: excel
        - uuid: b82c96446428497f906820ac786be412
          name: 'Apps: Office, OneNote user count'
          type: DEPENDENT
          key: ms365.apps.office.user_count.onenote
          trends: '0'
          description: 'The number of active OneNote users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppUserCounts[0].userCounts[0].oneNote'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: onenote
        - uuid: 09555143c7874e2fa69671501d10c0c5
          name: 'Apps: Office, Outlook user count'
          type: DEPENDENT
          key: ms365.apps.office.user_count.outlook
          trends: '0'
          description: 'The number of active Outlook users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppUserCounts[0].userCounts[0].outlook'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: outlook
        - uuid: 3f195401fb4241c2bea951e9cae2a6b1
          name: 'Apps: Office, PowerPoint user count'
          type: DEPENDENT
          key: ms365.apps.office.user_count.powerpoint
          trends: '0'
          description: 'The number of active PowerPoint users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppUserCounts[0].userCounts[0].powerPoint'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: powerpoint
        - uuid: 69134417295047fb9e70d6285fa7a336
          name: 'Apps: Office, user count report date'
          type: DEPENDENT
          key: ms365.apps.office.user_count.report_date
          value_type: CHAR
          description: 'The date of the report of the number of active users for each app.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppUserCounts[0].userCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: date
        - uuid: facc876f75db491a983cf985dfd9285d
          name: 'Apps: Office, Teams user count'
          type: DEPENDENT
          key: ms365.apps.office.user_count.teams
          trends: '0'
          description: 'The number of active Teams users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppUserCounts[0].userCounts[0].teams'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: teams
        - uuid: 6d3fbb21ab084ca6a8795098048fbd11
          name: 'Apps: Office, Word user count'
          type: DEPENDENT
          key: ms365.apps.office.user_count.word
          trends: '0'
          description: 'The number of active Word users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppUserCounts[0].userCounts[0].word'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: word
        - uuid: c78a87d0d84845d6939126af05b83d95
          name: 'Apps: Platform, Mac user count'
          type: DEPENDENT
          key: ms365.apps.platform.user_count.mac
          trends: '0'
          description: 'The number of active users on the Mac platform.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppPlatformUserCounts[0].userCounts[0].mac'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 694ebc5c063d4a24b1faf7787c49e270
          name: 'Apps: Platform, mobile user count'
          type: DEPENDENT
          key: ms365.apps.platform.user_count.mobile
          trends: '0'
          description: 'The number of active users on the mobile platform.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppPlatformUserCounts[0].userCounts[0].mobile'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 41f2b5c5140846619592e7dc8ccc3c32
          name: 'Apps: Platform, user count report date'
          type: DEPENDENT
          key: ms365.apps.platform.user_count.report_date
          value_type: CHAR
          description: 'The date of the report of the number of active users per platform.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppPlatformUserCounts[0].userCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: date
        - uuid: cbba35c140dc4505806b74682f30c02b
          name: 'Apps: Platform, web user count'
          type: DEPENDENT
          key: ms365.apps.platform.user_count.web
          trends: '0'
          description: 'The number of active users on the web platform.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppPlatformUserCounts[0].userCounts[0].web'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: f8e8f4f7b1954307b2cc178367a1a8c0
          name: 'Apps: Platform, Windows user count'
          type: DEPENDENT
          key: ms365.apps.platform.user_count.windows
          trends: '0'
          description: 'The number of active users on the Windows platform.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getM365AppPlatformUserCounts[0].userCounts[0].windows'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: f694dc8e49084d3a961c7124cb712c43
          name: 'Apps: Get reports'
          type: SCRIPT
          key: ms365.apps.reports.get
          delay: 6h
          history: '0'
          value_type: TEXT
          params: |
            const ms365 = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'api_version'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		ms365.params = params;
            	},
            
            	login: function () {
            		const response = new HttpRequest(),
            			login = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			login.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(ms365.params.tenant_id) + '/oauth2/v2.0/token',
            			'grant_type=client_credentials&scope=https://graph.microsoft.com/.default&client_id=' + encodeURIComponent(ms365.params.app_id) + '&client_secret=' + encodeURIComponent(ms365.params.password)
            		);
            
            		if (login.getStatus() < 200 || login.getStatus() >= 300) {
            			throw 'Login failed with status code ' + login.getStatus() + ': ' + response;
            		}
            
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse login session response.';
            		}
            
            		if (!response.hasOwnProperty('access_token')) {
            			throw 'Authentication response does not contain access token.';
            		}
            
            		ms365.token = response['access_token'];
            	},
            
            	request: function (url) {
            		const response = new HttpRequest(),
            			request = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			request.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		if (!ms365.token) {
            			throw 'Request does not contain access token.';
            		}
            
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + ms365.token);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Request url: ' + url);
            
            		response = request.get(url);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() < 200 || request.getStatus() >= 300) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	},
            
            	getField: function (data, path) {
            		const 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 ms365.nullToZero(data);
            	},
            
            	nullToZero: function (data) {
            		Object.keys(data).forEach(function (key) {
            			if (data[key] === null) {
            				data[key] = 0;
            			} else if (typeof data[key] === 'object') {
            				ms365.nullToZero(data[key]);
            			}
            		});
            
            		return data;
            	},
            
            	getMetricsData: function (endpoints) {
            		const data = {};
            
            		data.metrics = {};
            		endpoints.forEach(function (field) {
            			link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/reports/' + field + '(period=\'D7\')?$format=application/json';
            			answer = ms365.getField(ms365.request(link), 'value');
            
            			data.metrics[field] = answer;
            		});
            
            		return data;
            	},
            
            	getServiceData: function () {
            		var data = {},
            
            		link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/admin/serviceAnnouncement/healthOverviews/';
            		data.services = ms365.request(link);
            
            		return data;
            	}
            };
            
            
            endpoints = [
            	'getOffice365ActiveUserCounts',
            	'getOffice365ServicesUserCounts',
            	'getM365AppUserCounts',
            	'getM365AppPlatformUserCounts'
            ];
            
            try {
            	ms365.setParams(JSON.parse(value));
            	ms365.login();
            	return JSON.stringify(ms365.getMetricsData(endpoints));
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Microsoft 365 ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
          description: |
            Accumulated data from the Microsoft Graph API "reports" endpoints.
            More information:
            https://learn.microsoft.com/en-us/graph/api/resources/report?view=graph-rest-beta
          timeout: '{$MS365.API.TIMEOUT}'
          parameters:
            - name: api_version
              value: '{$MS365.API.VERSION}'
            - name: app_id
              value: '{$MS365.APP.ID}'
            - name: http_proxy
              value: '{$MS365.HTTP.PROXY}'
            - name: password
              value: '{$MS365.PASSWORD}'
            - name: tenant_id
              value: '{$MS365.TENANT.ID}'
          tags:
            - tag: component
              value: apps
            - tag: component
              value: raw
        - uuid: 229db8688139475bbb61dee9567f07a0
          name: 'Apps: Users, Exchange'
          type: DEPENDENT
          key: ms365.apps.users.exchange
          trends: '0'
          description: 'The number of daily Exchange users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ActiveUserCounts[6].exchange'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 2f7a16de43c24f3f89e62606f3a2c900
          name: 'Apps: Users, Office 365'
          type: DEPENDENT
          key: ms365.apps.users.office365
          trends: '0'
          description: 'The number of daily Office 365 users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ActiveUserCounts[6].office365'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: c0108adb522245bda915ce523624091d
          name: 'Apps: Users, OneDrive'
          type: DEPENDENT
          key: ms365.apps.users.onedrive
          trends: '0'
          description: 'The number of daily OneDrive users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ActiveUserCounts[6].oneDrive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: baf254f6a7d34ebc89824a6b9631025a
          name: 'Apps: Users, report date'
          type: DEPENDENT
          key: ms365.apps.users.report_date
          value_type: CHAR
          description: 'The date of the active user count report.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ActiveUserCounts[6].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
            - tag: component
              value: date
        - uuid: 855d1296c4a2470f9e1c56d0b887b5bc
          name: 'Apps: Users, SharePoint'
          type: DEPENDENT
          key: ms365.apps.users.sharepoint
          trends: '0'
          description: 'The number of daily SharePoint users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ActiveUserCounts[6].sharePoint'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 8de7670a3d57464897db996620638edd
          name: 'Apps: Users, Skype for Business'
          type: DEPENDENT
          key: ms365.apps.users.skype
          trends: '0'
          description: 'The number of daily Skype for Business users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ActiveUserCounts[6].skypeForBusiness'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: 27ea23488a6f4660a5335a802995071d
          name: 'Apps: Users, Teams'
          type: DEPENDENT
          key: ms365.apps.users.teams
          trends: '0'
          description: 'The number of daily Teams users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ActiveUserCounts[6].teams'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: a9212ec491ac4b57ae1d1242abd5fa29
          name: 'Apps: Users, Yammer'
          type: DEPENDENT
          key: ms365.apps.users.yammer
          trends: '0'
          description: 'The number of daily Yammer users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOffice365ActiveUserCounts[6].yammer'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.apps.reports.get
          tags:
            - tag: component
              value: apps
        - uuid: f73b124151a1491da39a96327fb5470d
          name: 'Copilot: User count, active in chat'
          type: DEPENDENT
          key: ms365.copilot.active_user_count.chat
          trends: '0'
          description: 'The number of users using Copilot Chat.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].copilotChatActiveUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
        - uuid: d56f0e7a6bc34800bc9f7ed0e8ce312f
          name: 'Copilot: User count, active in Excel'
          type: DEPENDENT
          key: ms365.copilot.active_user_count.excel
          trends: '0'
          description: 'The number of users using Copilot in Excel.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].excelActiveUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: excel
        - uuid: 5af18c6856fb4d979db64a7bb908d11d
          name: 'Copilot: User count, active in Loop'
          type: DEPENDENT
          key: ms365.copilot.active_user_count.loop
          trends: '0'
          description: 'The number of users using Copilot in Loop.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].loopActiveUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: loop
        - uuid: 79901554e7f342528de64a69e4d47a0d
          name: 'Copilot: User count, active in OneNote'
          type: DEPENDENT
          key: ms365.copilot.active_user_count.onenote
          trends: '0'
          description: 'The number of users using Copilot in OneNote.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].oneNoteActiveUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: onenote
        - uuid: 90f0dd2173e447a3b11989aaeb858b51
          name: 'Copilot: User count, active in Outlook'
          type: DEPENDENT
          key: ms365.copilot.active_user_count.outlook
          trends: '0'
          description: 'The number of users using Copilot in Outlook.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].outlookActiveUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: outlook
        - uuid: 8da9d8552fc148ef8bae10abd4d3d086
          name: 'Copilot: User count, active in PowerPoint'
          type: DEPENDENT
          key: ms365.copilot.active_user_count.powerpoint
          trends: '0'
          description: 'The number of users using Copilot in PowerPoint.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].powerPointActiveUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: powerpoint
        - uuid: 96400b0df847450b9e6364447ea8ff07
          name: 'Copilot: User count, active in Teams'
          type: DEPENDENT
          key: ms365.copilot.active_user_count.teams
          trends: '0'
          description: 'The number of users using Copilot in Teams.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].microsoftTeamsActiveUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: teams
        - uuid: 1adb3e6ee7114eb1998b640ec771411f
          name: 'Copilot: User count, active in Word'
          type: DEPENDENT
          key: ms365.copilot.active_user_count.word
          trends: '0'
          description: 'The number of users using Copilot in Word.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].wordActiveUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: word
        - uuid: 5bedba43a08f4905bf0139d75cf0e1fd
          name: 'Copilot: Get errors'
          type: DEPENDENT
          key: ms365.copilot.errors
          value_type: TEXT
          description: 'A list of errors from API requests for Copilot metrics.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: error
          triggers:
            - uuid: cc46d736d62b4d06b15a0522375ec916
              expression: 'length(last(/Microsoft 365 reports by HTTP/ms365.copilot.errors))>0'
              name: 'Microsoft 365: Copilot: There are errors in requests to API'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Zabbix has received errors in response to API requests.'
              tags:
                - tag: scope
                  value: availability
        - uuid: fb252bfc5d0244da9bd31a297d7a2396
          name: 'Copilot: Get reports'
          type: SCRIPT
          key: ms365.copilot.reports.get
          delay: 6h
          history: '0'
          value_type: TEXT
          params: |
            const ms365 = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'api_version'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		ms365.params = params;
            	},
            
            	login: function () {
            		const response = new HttpRequest(),
            			login = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			login.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(ms365.params.tenant_id) + '/oauth2/v2.0/token',
            			'grant_type=client_credentials&scope=https://graph.microsoft.com/.default&client_id=' + encodeURIComponent(ms365.params.app_id) + '&client_secret=' + encodeURIComponent(ms365.params.password)
            		);
            
            		if (login.getStatus() < 200 || login.getStatus() >= 300) {
            			throw 'Login failed with status code ' + login.getStatus() + ': ' + response;
            		}
            
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse login session response.';
            		}
            
            		if (!response.hasOwnProperty('access_token')) {
            			throw 'Authentication response does not contain access token.';
            		}
            
            		ms365.token = response['access_token'];
            	},
            
            	request: function (url) {
            		const response = new HttpRequest(),
            			request = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			request.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		if (!ms365.token) {
            			throw 'Request does not contain access token.';
            		}
            
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + ms365.token);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Request url: ' + url);
            
            		response = request.get(url);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() < 200 || request.getStatus() >= 300) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	},
            
            	getField: function (data, path) {
            		const 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 ms365.nullToZero(data);
            	},
            
            	nullToZero: function (data) {
            		Object.keys(data).forEach(function (key) {
            			if (data[key] === null) {
            				data[key] = 0;
            			} else if (typeof data[key] === 'object') {
            				ms365.nullToZero(data[key]);
            			}
            		});
            
            		return data;
            	},
            
            	getMetricsData: function (endpoints) {
            		const data = {};
            
            		data.metrics = {};
            		endpoints.forEach(function (field) {
            			link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/reports/' + field + '(period=\'D7\')?$format=application/json';
            			answer = ms365.getField(ms365.request(link), 'value');
            
            			data.metrics[field] = answer;
            		});
            
            		return data;
            	},
            
            	getServiceData: function () {
            		var data = {},
            
            		link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/admin/serviceAnnouncement/healthOverviews/';
            		data.services = ms365.request(link);
            
            		return data;
            	}
            };
            
            
            endpoints = [
            	'getMicrosoft365CopilotUsageUserDetail',
            	'getMicrosoft365CopilotUserCountSummary'
            ];
            
            try {
            	ms365.setParams(JSON.parse(value));
            	ms365.login();
            	return JSON.stringify(ms365.getMetricsData(endpoints));
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Microsoft 365 ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
          description: |
            Accumulated data from the Microsoft Graph API "reports" endpoints.
            More information:
            https://learn.microsoft.com/en-us/graph/api/resources/report?view=graph-rest-beta
          timeout: '{$MS365.API.TIMEOUT}'
          parameters:
            - name: api_version
              value: '{$MS365.API.VERSION}'
            - name: app_id
              value: '{$MS365.APP.ID}'
            - name: http_proxy
              value: '{$MS365.HTTP.PROXY}'
            - name: password
              value: '{$MS365.PASSWORD}'
            - name: tenant_id
              value: '{$MS365.TENANT.ID}'
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: raw
        - uuid: af840d91ea184b4d86e1be53d04e8d3a
          name: 'Copilot: Users, report date'
          type: DEPENDENT
          key: ms365.copilot.users.report_date
          value_type: CHAR
          description: 'The date of the report about users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].reportRefreshDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
        - uuid: 775c0133ac624f25b50e11fc573a1c02
          name: 'Copilot: User count, enabled in chat'
          type: DEPENDENT
          key: ms365.copilot.user_count.chat
          trends: '0'
          description: 'The number of users allowed to use Copilot Chat.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].copilotChatEnabledUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
        - uuid: ee659809a5c14fcabefdcf591cdde11e
          name: 'Copilot: User count, enabled in Excel'
          type: DEPENDENT
          key: ms365.copilot.user_count.excel
          trends: '0'
          description: 'The number of users allowed to use Copilot in Excel.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].excelEnabledUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: excel
        - uuid: fa12cd5e48544996924c8e08043da0c2
          name: 'Copilot: User count, enabled in Loop'
          type: DEPENDENT
          key: ms365.copilot.user_count.loop
          trends: '0'
          description: 'The number of users allowed to use Copilot in Loop.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].loopEnabledUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: loop
        - uuid: 49ceaf0c176c4f2499f5c359aa2fc72c
          name: 'Copilot: User count, enabled in OneNote'
          type: DEPENDENT
          key: ms365.copilot.user_count.onenote
          trends: '0'
          description: 'The number of users allowed to use Copilot in OneNote.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].oneNoteEnabledUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: onenote
        - uuid: 0c708d13d55441a683fb855b65bdfcde
          name: 'Copilot: User count, enabled in Outlook'
          type: DEPENDENT
          key: ms365.copilot.user_count.outlook
          trends: '0'
          description: 'The number of users allowed to use Copilot in Outlook.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].outlookEnabledUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: outlook
        - uuid: 44fcabc3d520413f8dd953c61b314c55
          name: 'Copilot: User count, enabled in PowerPoint'
          type: DEPENDENT
          key: ms365.copilot.user_count.powerpoint
          trends: '0'
          description: 'The number of users allowed to use Copilot in PowerPoint.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].powerPointEnabledUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: powerpoint
        - uuid: 03db2ff6604e44d8b15b1f3e5c7c9b9d
          name: 'Copilot: User count, enabled in Teams'
          type: DEPENDENT
          key: ms365.copilot.user_count.teams
          trends: '0'
          description: 'The number of users allowed to use Copilot in Teams.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].microsoftTeamsEnabledUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: teams
        - uuid: c60c4432ba334dd39f6b7c9464875ddf
          name: 'Copilot: User count, enabled in Word'
          type: DEPENDENT
          key: ms365.copilot.user_count.word
          trends: '0'
          description: 'The number of users allowed to use Copilot in Word.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMicrosoft365CopilotUserCountSummary[0].adoptionByProduct[0].wordEnabledUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.copilot.reports.get
          tags:
            - tag: component
              value: copilot
            - tag: component
              value: word
        - uuid: 8ed3af9876f94f138a0f6e19ea02235a
          name: 'OneDrive: Get errors'
          type: DEPENDENT
          key: ms365.onedrive.errors
          value_type: TEXT
          description: 'A list of errors from API requests for OneDrive metrics.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: error
            - tag: component
              value: onedrive
          triggers:
            - uuid: b526cc91e49041a1ba4fac76b8f464c2
              expression: 'length(last(/Microsoft 365 reports by HTTP/ms365.onedrive.errors))>0'
              name: 'Microsoft 365: OneDrive: There are errors in requests to API'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Zabbix has received errors in response to API requests.'
              tags:
                - tag: scope
                  value: availability
        - uuid: e7e2570b2b124cd08b21b065f95ae8d7
          name: 'OneDrive: Files, activity, report date'
          type: DEPENDENT
          key: ms365.onedrive.files.report_date
          value_type: CHAR
          description: 'The date of report of the number of active OneDrive files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveActivityFileCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: onedrive
        - uuid: ee6d3acbdd674f479cd6c99a2f113e2e
          name: 'OneDrive: Files, shared externally'
          type: DEPENDENT
          key: ms365.onedrive.files.shared_externally
          trends: '0'
          description: 'The number of externally shared OneDrive files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveActivityFileCounts[0].sharedExternally'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: b94ba3d65ebd4bcca434c54a7252739c
          name: 'OneDrive: Files, shared internally'
          type: DEPENDENT
          key: ms365.onedrive.files.shared_internally
          trends: '0'
          description: 'The number of internally shared OneDrive files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveActivityFileCounts[0].sharedInternally'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: 35327a7d610a442d87b1672532b9ada3
          name: 'OneDrive: Files, synced'
          type: DEPENDENT
          key: ms365.onedrive.files.synced
          trends: '0'
          description: 'The number of synced OneDrive files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveActivityFileCounts[0].synced'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: 86e92424c4a946768f48fe757ea1883e
          name: 'OneDrive: Files, viewed or edited'
          type: DEPENDENT
          key: ms365.onedrive.files.viewed_or_edited
          trends: '0'
          description: 'The number of viewed or edited OneDrive files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveActivityFileCounts[0].viewedOrEdited'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: e6a94bc310e142ccaa398533c2161e43
          name: 'OneDrive: File count, active'
          type: DEPENDENT
          key: ms365.onedrive.file_count.active
          trends: '0'
          description: 'The total number of active files across all sites. A file is considered active if it has been saved, synced, modified, or shared.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveUsageFileCounts[0].active'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: 24d396224317427080e538897d7bdc81
          name: 'OneDrive: File count, report date'
          type: DEPENDENT
          key: ms365.onedrive.file_count.report_date
          value_type: CHAR
          description: 'The date of the OneDrive file count report.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveUsageFileCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: onedrive
        - uuid: 4413b1514364430f9846aa952893b2d4
          name: 'OneDrive: File count, total'
          type: DEPENDENT
          key: ms365.onedrive.file_count.total
          trends: '0'
          description: 'The total number of files across all sites.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveUsageFileCounts[0].total'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: 31b78185119446f397404ae7abf05684
          name: 'OneDrive: Get reports'
          type: SCRIPT
          key: ms365.onedrive.reports.get
          delay: 6h
          history: '0'
          value_type: TEXT
          params: |
            const ms365 = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'api_version'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		ms365.params = params;
            	},
            
            	login: function () {
            		const response = new HttpRequest(),
            			login = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			login.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(ms365.params.tenant_id) + '/oauth2/v2.0/token',
            			'grant_type=client_credentials&scope=https://graph.microsoft.com/.default&client_id=' + encodeURIComponent(ms365.params.app_id) + '&client_secret=' + encodeURIComponent(ms365.params.password)
            		);
            
            		if (login.getStatus() < 200 || login.getStatus() >= 300) {
            			throw 'Login failed with status code ' + login.getStatus() + ': ' + response;
            		}
            
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse login session response.';
            		}
            
            		if (!response.hasOwnProperty('access_token')) {
            			throw 'Authentication response does not contain access token.';
            		}
            
            		ms365.token = response['access_token'];
            	},
            
            	request: function (url) {
            		const response = new HttpRequest(),
            			request = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			request.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		if (!ms365.token) {
            			throw 'Request does not contain access token.';
            		}
            
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + ms365.token);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Request url: ' + url);
            
            		response = request.get(url);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() < 200 || request.getStatus() >= 300) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	},
            
            	getField: function (data, path) {
            		const 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 ms365.nullToZero(data);
            	},
            
            	nullToZero: function (data) {
            		Object.keys(data).forEach(function (key) {
            			if (data[key] === null) {
            				data[key] = 0;
            			} else if (typeof data[key] === 'object') {
            				ms365.nullToZero(data[key]);
            			}
            		});
            
            		return data;
            	},
            
            	getMetricsData: function (endpoints) {
            		const data = {};
            
            		data.metrics = {};
            		endpoints.forEach(function (field) {
            			link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/reports/' + field + '(period=\'D7\')?$format=application/json';
            			answer = ms365.getField(ms365.request(link), 'value');
            
            			data.metrics[field] = answer;
            		});
            
            		return data;
            	},
            
            	getServiceData: function () {
            		var data = {},
            
            		link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/admin/serviceAnnouncement/healthOverviews/';
            		data.services = ms365.request(link);
            
            		return data;
            	}
            };
            
            
            const endpoints = [
            	'getOneDriveActivityUserCounts',
            	'getOneDriveActivityFileCounts',
            	'getOneDriveUsageAccountCounts',
            	'getOneDriveUsageFileCounts',
            	'getOneDriveUsageStorage'
            ];
            
            try {
            	ms365.setParams(JSON.parse(value));
            	ms365.login();
            	return JSON.stringify(ms365.getMetricsData(endpoints));
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Microsoft 365 ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
          description: |
            Accumulated data from the Microsoft Graph API "reports" endpoints.
            More information:
            https://learn.microsoft.com/en-us/graph/api/resources/report?view=graph-rest-beta
          timeout: '{$MS365.API.TIMEOUT}'
          parameters:
            - name: api_version
              value: '{$MS365.API.VERSION}'
            - name: app_id
              value: '{$MS365.APP.ID}'
            - name: http_proxy
              value: '{$MS365.HTTP.PROXY}'
            - name: password
              value: '{$MS365.PASSWORD}'
            - name: tenant_id
              value: '{$MS365.TENANT.ID}'
          tags:
            - tag: component
              value: onedrive
            - tag: component
              value: raw
        - uuid: b32aba6af3444230b9bd06ba8544c906
          name: 'OneDrive: Business sites, active'
          type: DEPENDENT
          key: ms365.onedrive.sites.active
          trends: '0'
          description: 'The number of active OneDrive for Business sites. Any site on which users have viewed, modified, uploaded, downloaded, shared, or synced files is considered an active site.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveUsageAccountCounts[0].active'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: 023d27c3fbbc4228b374ddec9cc8e35b
          name: 'OneDrive: Business sites, report date'
          type: DEPENDENT
          key: ms365.onedrive.sites.report_date
          value_type: CHAR
          description: 'The date of the number of OneDrive for Business sites report.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveUsageAccountCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: onedrive
        - uuid: c15eff389f904d9798fe7935d8ce9328
          name: 'OneDrive: Business sites, total'
          type: DEPENDENT
          key: ms365.onedrive.sites.total
          trends: '0'
          description: 'The number of OneDrive for Business sites.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveUsageAccountCounts[0].total'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: 4482652327664e8fab8301ec559fa897
          name: 'OneDrive: Storage, report date'
          type: DEPENDENT
          key: ms365.onedrive.storage.report_date
          value_type: CHAR
          description: 'The date of the report of the amount of storage used in OneDrive for Business.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveUsageStorage[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: onedrive
        - uuid: dfcbbd4b82f549fb926ddabef52317ca
          name: 'OneDrive: Storage, total'
          type: DEPENDENT
          key: ms365.onedrive.storage.total
          trends: '0'
          units: B
          description: 'The total amount of storage used in OneDrive for Business.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveUsageStorage[?(@.siteType == "All")].storageUsedInBytes.first()'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: 5bd03a64dfa94cfe9f279219fdca22ff
          name: 'OneDrive: Users, report date'
          type: DEPENDENT
          key: ms365.onedrive.users.report_date
          value_type: CHAR
          description: 'The date of the report of the number of active OneDrive users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveActivityUserCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: onedrive
        - uuid: 36ed7c38f7d544968830e876e6e6b24d
          name: 'OneDrive: Users, shared externally'
          type: DEPENDENT
          key: ms365.onedrive.users.shared_externally
          trends: '0'
          description: 'The number of users who have shared OneDrive files externally.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveActivityUserCounts[0].sharedExternally'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: d393a09d304a4cb2b4bc4faa75361962
          name: 'OneDrive: Users, shared internally'
          type: DEPENDENT
          key: ms365.onedrive.users.shared_internally
          trends: '0'
          description: 'The number of users who have shared OneDrive files internally.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveActivityUserCounts[0].sharedInternally'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: 463d39ac2dee4bd09bd9547d269fc0cd
          name: 'OneDrive: Users, synced'
          type: DEPENDENT
          key: ms365.onedrive.users.synced
          trends: '0'
          description: 'The number of users who have synced OneDrive files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveActivityUserCounts[0].synced'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: 5e68a062cb2e40508f7d65bc5c07e5f6
          name: 'OneDrive: Users, viewed or edited'
          type: DEPENDENT
          key: ms365.onedrive.users.viewed_or_edited
          trends: '0'
          description: 'The number of users who have viewed or edited OneDrive files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getOneDriveActivityUserCounts[0].viewedOrEdited'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.onedrive.reports.get
          tags:
            - tag: component
              value: onedrive
        - uuid: b1e7a98c1fd04a6da30b2572e440a90f
          name: 'Outlook: Activity, meetings created'
          type: DEPENDENT
          key: ms365.outlook.activity.meetings_created
          trends: '0'
          description: 'The number of times a "Meeting request sent" action was recorded.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityCounts[0].meetingCreated'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 0b6090e26675480eadffb518685398a7
          name: 'Outlook: Activity, meetings interacted'
          type: DEPENDENT
          key: ms365.outlook.activity.meetings_interacted
          trends: '0'
          description: 'The number of times a meeting request accept, tentative, decline, or cancel action was recorded.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityCounts[0].meetingInteracted'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: c8692fab4c5e4af1860beca648a5fa7e
          name: 'Outlook: Activity, emails read'
          type: DEPENDENT
          key: ms365.outlook.activity.read
          trends: '0'
          description: 'The number of times an "Email read" action was recorded.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityCounts[0].read'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 0e205e2458f047399e682bfa68881395
          name: 'Outlook: Activity, emails received'
          type: DEPENDENT
          key: ms365.outlook.activity.received
          trends: '0'
          description: 'The number of times an "Email received" action was recorded.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityCounts[0].receive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 6eb5581fba9e4613b1e966852bb166cc
          name: 'Outlook: Activity, report date'
          type: DEPENDENT
          key: ms365.outlook.activity.report_date
          value_type: CHAR
          description: 'The date of the Outlook activity count report.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityCounts[0].reportRefreshDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: outlook
        - uuid: b090b886df704dc3baf0d6e7eb4d08f8
          name: 'Outlook: Activity, emails sent'
          type: DEPENDENT
          key: ms365.outlook.activity.sent
          trends: '0'
          description: 'The number of times an "Email sent" action was recorded.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityCounts[0].send'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 2acaed1cc8fc4111ad71a38d4ae2f004
          name: 'Outlook: Get errors'
          type: DEPENDENT
          key: ms365.outlook.errors
          value_type: TEXT
          description: 'A list of errors from API requests for Outlook metrics.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: error
            - tag: component
              value: outlook
          triggers:
            - uuid: 79d0d9d9622347e2a7c937b7831ac01b
              expression: 'length(last(/Microsoft 365 reports by HTTP/ms365.outlook.errors))>0'
              name: 'Microsoft 365: Outlook: There are errors in requests to API'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Zabbix has received errors in response to API requests.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 37e6321c075945c5b06bc77783bd5b73
          name: 'Outlook: Mailbox, active'
          type: DEPENDENT
          key: ms365.outlook.mailbox.active
          trends: '0'
          description: 'The number of active user mailboxes in your organization. A mailbox is considered active if the user has sent or read any emails.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMailboxUsageMailboxCounts[0].active'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 637165130fc44abcafcc84366929f74e
          name: 'Outlook: Mailbox, active in %'
          type: DEPENDENT
          key: ms365.outlook.mailbox.active.percentage
          trends: '0'
          units: '%'
          description: 'Percentage of active user mailboxes in your organization. A mailbox is considered active if the user has sent or read any emails.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getMailboxUsageMailboxCounts[0].active * 100 / data.metrics.getMailboxUsageMailboxCounts[0].total;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 292361cb20a84d028003732027405882
          name: 'Outlook: Mailbox, report date'
          type: DEPENDENT
          key: ms365.outlook.mailbox.report_date
          value_type: CHAR
          description: 'The date of the report of the unique user count per app.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMailboxUsageMailboxCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: outlook
        - uuid: 5eec6999430b4dcb87fdf54162839e42
          name: 'Outlook: Mailbox, total'
          type: DEPENDENT
          key: ms365.outlook.mailbox.total
          trends: '0'
          description: 'The total number of user mailboxes in your organization.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMailboxUsageMailboxCounts[0].total'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 4e4d78bd44db421a908288031489c3d4
          name: 'Outlook: Get reports'
          type: SCRIPT
          key: ms365.outlook.reports.get
          delay: 6h
          history: '0'
          value_type: TEXT
          params: |
            const ms365 = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'api_version'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		ms365.params = params;
            	},
            
            	login: function () {
            		const response = new HttpRequest(),
            			login = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			login.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(ms365.params.tenant_id) + '/oauth2/v2.0/token',
            			'grant_type=client_credentials&scope=https://graph.microsoft.com/.default&client_id=' + encodeURIComponent(ms365.params.app_id) + '&client_secret=' + encodeURIComponent(ms365.params.password)
            		);
            
            		if (login.getStatus() < 200 || login.getStatus() >= 300) {
            			throw 'Login failed with status code ' + login.getStatus() + ': ' + response;
            		}
            
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse login session response.';
            		}
            
            		if (!response.hasOwnProperty('access_token')) {
            			throw 'Authentication response does not contain access token.';
            		}
            
            		ms365.token = response['access_token'];
            	},
            
            	request: function (url) {
            		const response = new HttpRequest(),
            			request = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			request.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		if (!ms365.token) {
            			throw 'Request does not contain access token.';
            		}
            
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + ms365.token);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Request url: ' + url);
            
            		response = request.get(url);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() < 200 || request.getStatus() >= 300) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	},
            
            	getField: function (data, path) {
            		const 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 ms365.nullToZero(data);
            	},
            
            	nullToZero: function (data) {
            		Object.keys(data).forEach(function (key) {
            			if (data[key] === null) {
            				data[key] = 0;
            			} else if (typeof data[key] === 'object') {
            				ms365.nullToZero(data[key]);
            			}
            		});
            
            		return data;
            	},
            
            	getMetricsData: function (endpoints) {
            		const data = {};
            
            		data.metrics = {};
            		endpoints.forEach(function (field) {
            			link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/reports/' + field + '(period=\'D7\')?$format=application/json';
            			answer = ms365.getField(ms365.request(link), 'value');
            
            			data.metrics[field] = answer;
            		});
            
            		return data;
            	},
            
            	getServiceData: function () {
            		var data = {},
            
            		link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/admin/serviceAnnouncement/healthOverviews/';
            		data.services = ms365.request(link);
            
            		return data;
            	}
            };
            
            
            endpoints = [
            	'getEmailActivityCounts',
            	'getEmailActivityUserCounts',
            	'getEmailAppUsageUserCounts',
            	'getMailboxUsageMailboxCounts',
            	'getMailboxUsageStorage'
            ];
            
            try {
            	ms365.setParams(JSON.parse(value));
            	ms365.login();
            	return JSON.stringify(ms365.getMetricsData(endpoints));
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Microsoft 365 ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
          description: |
            Accumulated data from the Microsoft Graph API "reports" endpoints.
            More information:
            https://learn.microsoft.com/en-us/graph/api/resources/report?view=graph-rest-beta
          timeout: '{$MS365.API.TIMEOUT}'
          parameters:
            - name: api_version
              value: '{$MS365.API.VERSION}'
            - name: app_id
              value: '{$MS365.APP.ID}'
            - name: http_proxy
              value: '{$MS365.HTTP.PROXY}'
            - name: password
              value: '{$MS365.PASSWORD}'
            - name: tenant_id
              value: '{$MS365.TENANT.ID}'
          tags:
            - tag: component
              value: outlook
            - tag: component
              value: raw
        - uuid: d633c87e65574b2a9453c48efc899368
          name: 'Outlook: Mailbox, storage, report date'
          type: DEPENDENT
          key: ms365.outlook.storage.report_date
          value_type: CHAR
          description: 'The date of the mailbox storage report.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMailboxUsageStorage[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: outlook
        - uuid: e57fc3c97fca4fb2ac806be8548c69c2
          name: 'Outlook: Mailbox, storage used'
          type: DEPENDENT
          key: ms365.outlook.storage.used
          trends: '0'
          units: B
          description: 'The amount of mailbox storage used in your organization.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getMailboxUsageStorage[0].storageUsedInBytes'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 866cc243422f4494a53f731189de97b0
          name: 'Outlook: User count, IMAP4 applications'
          type: DEPENDENT
          key: ms365.outlook.user_count.imap4app
          trends: '0'
          description: 'The number of unique users of other IMAP4 applications.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailAppUsageUserCounts[6].imap4App'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 7cafa2052df1426d8ca136b02d517166
          name: 'Outlook: User count, Outlook for Mac'
          type: DEPENDENT
          key: ms365.outlook.user_count.mac
          trends: '0'
          description: 'The number of unique users of Outlook for Mac.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailAppUsageUserCounts[6].outlookForMac'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: b0192e926ec44808a89423ed0231d858
          name: 'Outlook: User count, mail for Mac'
          type: DEPENDENT
          key: ms365.outlook.user_count.mail_for_mac
          trends: '0'
          description: 'The number of unique users of mail for Mac.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailAppUsageUserCounts[6].mailForMac'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 3df9660d9f764c26bf281041aae2466e
          name: 'Outlook: User count, meetings created'
          type: DEPENDENT
          key: ms365.outlook.user_count.meetings_created
          trends: '0'
          description: 'The number of users a "Meeting request sent" action was recorded for.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityUserCounts[0].meetingCreated'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 50703e1aec3d47218d08495f2c7112c2
          name: 'Outlook: User count, meetings interacted'
          type: DEPENDENT
          key: ms365.outlook.user_count.meetings_interacted
          trends: '0'
          description: 'The number of users a meeting request accept, tentative, decline, or cancel action was recorded for.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityUserCounts[0].meetingInteracted'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 9afd7131c46043dbac392b22f042edcc
          name: 'Outlook: User count, Outlook for mobile'
          type: DEPENDENT
          key: ms365.outlook.user_count.mobile
          trends: '0'
          description: 'The number of unique users of Outlook for mobile.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailAppUsageUserCounts[6].outlookForMobile'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: c832f65eb47d4fe69824296994bd39e7
          name: 'Outlook: User count, POP3 applications'
          type: DEPENDENT
          key: ms365.outlook.user_count.pop3app
          trends: '0'
          description: 'The number of unique users of other POP3 applications.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailAppUsageUserCounts[6].pop3App'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 9f612d7d0f3c45c6a12bab26609a31ba
          name: 'Outlook: User count, emails read'
          type: DEPENDENT
          key: ms365.outlook.user_count.read
          trends: '0'
          description: 'The number of users an "Email read" action was recorded for.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityUserCounts[0].read'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 2f6ca8ba75da45d2ac91af9e526e411d
          name: 'Outlook: User count, emails received'
          type: DEPENDENT
          key: ms365.outlook.user_count.received
          trends: '0'
          description: 'The number of users an "Email received" action was recorded for.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityUserCounts[0].receive'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 9798b94176294350a4c6f9de40839c3f
          name: 'Outlook: User count, report date'
          type: DEPENDENT
          key: ms365.outlook.user_count.report_date
          value_type: CHAR
          description: 'The date of the Outlook activity user count report.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityUserCounts[0].reportRefreshDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: outlook
        - uuid: d4835c7b293845c9a28d7c4ee4d25d01
          name: 'Outlook: User count, app usage, report date'
          type: DEPENDENT
          key: ms365.outlook.user_count.report_date.app
          value_type: CHAR
          description: 'The date of the report of the unique user count per app.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailAppUsageUserCounts[6].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: outlook
        - uuid: 176af3cbc220429dbed826714cf4374d
          name: 'Outlook: User count, emails sent'
          type: DEPENDENT
          key: ms365.outlook.user_count.sent
          trends: '0'
          description: 'The number of users an "Email sent" action was recorded for.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailActivityUserCounts[0].send'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 48e8bcbc05bb488784da9630a8a05565
          name: 'Outlook: User count, SMTP applications'
          type: DEPENDENT
          key: ms365.outlook.user_count.smtpapp
          trends: '0'
          description: 'The number of unique users of other SMTP applications.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailAppUsageUserCounts[6].smtpApp'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 031244dc15cc4eccb75be311a84d2c74
          name: 'Outlook: User count, Outlook for web'
          type: DEPENDENT
          key: ms365.outlook.user_count.web
          trends: '0'
          description: 'The number of unique users of Outlook for web.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailAppUsageUserCounts[6].outlookForWeb'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: 01f6f3d0946548e086df06ea90a16c84
          name: 'Outlook: User count, Outlook for Windows'
          type: DEPENDENT
          key: ms365.outlook.user_count.windows
          trends: '0'
          description: 'The number of unique users of Outlook for Windows.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getEmailAppUsageUserCounts[6].outlookForWindows'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.outlook.reports.get
          tags:
            - tag: component
              value: outlook
        - uuid: b547935175f441f2a3a2bf41c8abc99b
          name: 'Services: Get errors'
          type: DEPENDENT
          key: ms365.services.errors
          value_type: TEXT
          description: 'A list of errors from API requests for Services metrics.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: ms365.services.get
          tags:
            - tag: component
              value: error
            - tag: component
              value: service
          triggers:
            - uuid: 54c11aad4113433a866272988a64c2bf
              expression: 'length(last(/Microsoft 365 reports by HTTP/ms365.services.errors))>0'
              name: 'Microsoft 365: Services: There are errors in requests to API'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Zabbix has received errors in response to API requests.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 53c72fa948454b998f612c4d099dd440
          name: 'Services: Get services'
          type: SCRIPT
          key: ms365.services.get
          delay: 6h
          history: '0'
          value_type: TEXT
          params: |
            const ms365 = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'api_version'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		ms365.params = params;
            	},
            
            	login: function () {
            		const response = new HttpRequest(),
            			login = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			login.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(ms365.params.tenant_id) + '/oauth2/v2.0/token',
            			'grant_type=client_credentials&scope=https://graph.microsoft.com/.default&client_id=' + encodeURIComponent(ms365.params.app_id) + '&client_secret=' + encodeURIComponent(ms365.params.password)
            		);
            
            		if (login.getStatus() < 200 || login.getStatus() >= 300) {
            			throw 'Login failed with status code ' + login.getStatus() + ': ' + response;
            		}
            
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse login session response.';
            		}
            
            		if (!response.hasOwnProperty('access_token')) {
            			throw 'Authentication response does not contain access token.';
            		}
            
            		ms365.token = response['access_token'];
            	},
            
            	request: function (url) {
            		const response = new HttpRequest(),
            			request = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			request.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		if (!ms365.token) {
            			throw 'Request does not contain access token.';
            		}
            
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + ms365.token);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Request url: ' + url);
            
            		response = request.get(url);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() < 200 || request.getStatus() >= 300) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	},
            
            	getField: function (data, path) {
            		const 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 ms365.nullToZero(data);
            	},
            
            	nullToZero: function (data) {
            		Object.keys(data).forEach(function (key) {
            			if (data[key] === null) {
            				data[key] = 0;
            			} else if (typeof data[key] === 'object') {
            				ms365.nullToZero(data[key]);
            			}
            		});
            
            		return data;
            	},
            
            	getMetricsData: function (endpoints) {
            		const data = {};
            
            		data.metrics = {};
            		endpoints.forEach(function (field) {
            			link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/reports/' + field + '(period=\'D7\')?$format=application/json';
            			answer = ms365.getField(ms365.request(link), 'value');
            
            			data.metrics[field] = answer;
            		});
            
            		return data;
            	},
            
            	getServiceData: function () {
            		var data = {},
            
            		link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/admin/serviceAnnouncement/healthOverviews/';
            		data.services = ms365.request(link);
            
            		return data;
            	}
            };
            
            
            try {
            	ms365.setParams(JSON.parse(value));
            	ms365.login();
            	return JSON.stringify(ms365.getServiceData());
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Microsoft 365 ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
          description: |
            The list of Microsoft cloud services and their health statuses subscribed by a tenant.
            More information:
            https://learn.microsoft.com/en-us/graph/api/servicehealth-get?view=graph-rest-beta&tabs=http
          timeout: '{$MS365.API.TIMEOUT}'
          parameters:
            - name: api_version
              value: '{$MS365.API.VERSION}'
            - name: app_id
              value: '{$MS365.APP.ID}'
            - name: http_proxy
              value: '{$MS365.HTTP.PROXY}'
            - name: password
              value: '{$MS365.PASSWORD}'
            - name: tenant_id
              value: '{$MS365.TENANT.ID}'
          tags:
            - tag: component
              value: raw
            - tag: component
              value: service
        - uuid: d4256e411ced4566b9abea622acbbf6d
          name: 'SharePoint: Get errors'
          type: DEPENDENT
          key: ms365.sharepoint.errors
          value_type: TEXT
          description: 'A list of errors from API requests for SharePoint metrics.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: error
            - tag: component
              value: sharepoint
          triggers:
            - uuid: af3d4e3b2ca84ad39780d6d5e13afdee
              expression: 'length(last(/Microsoft 365 reports by HTTP/ms365.sharepoint.errors))>0'
              name: 'Microsoft 365: SharePoint: There are errors in requests to API'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Zabbix has received errors in response to API requests.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 2d9db2f1db4741a6a2afb9088cf31218
          name: 'SharePoint: Files, activity, report date'
          type: DEPENDENT
          key: ms365.sharepoint.files.report_date
          value_type: CHAR
          description: 'The date of the report of the number of active SharePoint files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityFileCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: sharepoint
        - uuid: 0fa7e6c2f6eb46da8ee577fd88d502b2
          name: 'SharePoint: Files, shared externally'
          type: DEPENDENT
          key: ms365.sharepoint.files.shared_externally
          trends: '0'
          description: 'The number of externally shared SharePoint files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityFileCounts[0].sharedExternally'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: dba7c4e8e1244edfa2e227d5db8f89cc
          name: 'SharePoint: Files, shared internally'
          type: DEPENDENT
          key: ms365.sharepoint.files.shared_internally
          trends: '0'
          description: 'The number of internally shared SharePoint files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityFileCounts[0].sharedInternally'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: 72cdf53a7fc04b01ac47f7fad3dc1973
          name: 'SharePoint: Files, synced'
          type: DEPENDENT
          key: ms365.sharepoint.files.synced
          trends: '0'
          description: 'The number of files synced to a SharePoint site.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityFileCounts[0].synced'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: 8a26811f0bdc4f7baab93a87e76bfd78
          name: 'SharePoint: Files, viewed or edited'
          type: DEPENDENT
          key: ms365.sharepoint.files.viewed_or_edited
          trends: '0'
          description: 'The number of viewed or edited SharePoint files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityFileCounts[0].viewedOrEdited'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: ef4edb2188b244858f2f052a5880877d
          name: 'SharePoint: File count, active'
          type: DEPENDENT
          key: ms365.sharepoint.file_count.active
          trends: '0'
          description: 'The total number of active files across all sites. A file is considered active if it has been saved, synced, modified, or shared.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointSiteUsageFileCounts[0].active'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: 0f919b2dba8c42a1b14425fe0d28a27f
          name: 'SharePoint: File count, report date'
          type: DEPENDENT
          key: ms365.sharepoint.file_count.report_date
          value_type: CHAR
          description: 'The date of the SharePoint file count report.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointSiteUsageFileCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: sharepoint
        - uuid: 9a79514b201a4c6b9721ef9188d234e1
          name: 'SharePoint: File count, total'
          type: DEPENDENT
          key: ms365.sharepoint.file_count.total
          trends: '0'
          description: 'The total number of files across all sites.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointSiteUsageFileCounts[0].total'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: 05e43c1b8a7d4d4abe773c3129c0100a
          name: 'SharePoint: Pages, view count'
          type: DEPENDENT
          key: ms365.sharepoint.pages_viewed.count
          trends: '0'
          description: 'The number of pages viewed across all sites.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointSiteUsagePages[0].pageViewCount'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: 58cb9338fa684f9f9631a6f3f8736469
          name: 'SharePoint: Pages, viewed, report date'
          type: DEPENDENT
          key: ms365.sharepoint.pages_viewed.report_date
          value_type: CHAR
          description: 'The date of the report of the number of pages viewed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointSiteUsagePages[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: sharepoint
        - uuid: 71f0ccd4e8a846009dd9b81392f3330c
          name: 'SharePoint: Pages, visited'
          type: DEPENDENT
          key: ms365.sharepoint.pages_visited.count
          trends: '0'
          description: 'The number of unique pages visited by users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityPages[0].visitedPageCount'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: de53a4cec0fb42c4bdee64a1539876c7
          name: 'SharePoint: Pages, visited, report date'
          type: DEPENDENT
          key: ms365.sharepoint.pages_visited.report_date
          value_type: CHAR
          description: 'The date of the report of the number of pages visited.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityPages[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: sharepoint
        - uuid: fd2cb544cfd744c1a94a1d32243978e6
          name: 'SharePoint: Get reports'
          type: SCRIPT
          key: ms365.sharepoint.reports.get
          delay: 6h
          history: '0'
          value_type: TEXT
          params: |
            const ms365 = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'api_version'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		ms365.params = params;
            	},
            
            	login: function () {
            		const response = new HttpRequest(),
            			login = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			login.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(ms365.params.tenant_id) + '/oauth2/v2.0/token',
            			'grant_type=client_credentials&scope=https://graph.microsoft.com/.default&client_id=' + encodeURIComponent(ms365.params.app_id) + '&client_secret=' + encodeURIComponent(ms365.params.password)
            		);
            
            		if (login.getStatus() < 200 || login.getStatus() >= 300) {
            			throw 'Login failed with status code ' + login.getStatus() + ': ' + response;
            		}
            
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse login session response.';
            		}
            
            		if (!response.hasOwnProperty('access_token')) {
            			throw 'Authentication response does not contain access token.';
            		}
            
            		ms365.token = response['access_token'];
            	},
            
            	request: function (url) {
            		const response = new HttpRequest(),
            			request = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			request.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		if (!ms365.token) {
            			throw 'Request does not contain access token.';
            		}
            
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + ms365.token);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Request url: ' + url);
            
            		response = request.get(url);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() < 200 || request.getStatus() >= 300) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	},
            
            	getField: function (data, path) {
            		const 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 ms365.nullToZero(data);
            	},
            
            	nullToZero: function (data) {
            		Object.keys(data).forEach(function (key) {
            			if (data[key] === null) {
            				data[key] = 0;
            			} else if (typeof data[key] === 'object') {
            				ms365.nullToZero(data[key]);
            			}
            		});
            
            		return data;
            	},
            
            	getMetricsData: function (endpoints) {
            		const data = {};
            
            		data.metrics = {};
            		endpoints.forEach(function (field) {
            			link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/reports/' + field + '(period=\'D7\')?$format=application/json';
            			answer = ms365.getField(ms365.request(link), 'value');
            
            			data.metrics[field] = answer;
            		});
            
            		return data;
            	},
            
            	getServiceData: function () {
            		var data = {},
            
            		link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/admin/serviceAnnouncement/healthOverviews/';
            		data.services = ms365.request(link);
            
            		return data;
            	}
            };
            
            
            endpoints = [
            	'getSharePointActivityFileCounts',
            	'getSharePointActivityUserCounts',
            	'getSharePointActivityPages',
            	'getSharePointSiteUsageFileCounts',
            	'getSharePointSiteUsageSiteCounts',
            	'getSharePointSiteUsageStorage',
            	'getSharePointSiteUsagePages'
            ];
            
            try {
            	ms365.setParams(JSON.parse(value));
            	ms365.login();
            	return JSON.stringify(ms365.getMetricsData(endpoints));
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Microsoft 365 ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
          description: |
            Accumulated data from the Microsoft Graph API "reports" endpoints.
            More information:
            https://learn.microsoft.com/en-us/graph/api/resources/report?view=graph-rest-beta
          timeout: '{$MS365.API.TIMEOUT}'
          parameters:
            - name: api_version
              value: '{$MS365.API.VERSION}'
            - name: app_id
              value: '{$MS365.APP.ID}'
            - name: http_proxy
              value: '{$MS365.HTTP.PROXY}'
            - name: password
              value: '{$MS365.PASSWORD}'
            - name: tenant_id
              value: '{$MS365.TENANT.ID}'
          tags:
            - tag: component
              value: raw
            - tag: component
              value: sharepoint
        - uuid: e17280ef24ff426fb2dbf3fb0c7beaa4
          name: 'SharePoint: Sites, report date'
          type: DEPENDENT
          key: ms365.sharepoint.site.report_date
          value_type: CHAR
          description: 'The date of the report of the number of SharePoint sites.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointSiteUsageSiteCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: sharepoint
        - uuid: 92930bce83b449b4963ea8e27ed4bb33
          name: 'SharePoint: Sites, active'
          type: DEPENDENT
          key: ms365.sharepoint.sites.active
          trends: '0'
          description: 'The number of active SharePoint sites.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointSiteUsageSiteCounts[0].active'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: ea038226a3c34a8eada1836f08a9a17b
          name: 'SharePoint: Sites, total'
          type: DEPENDENT
          key: ms365.sharepoint.sites.total
          trends: '0'
          description: 'The number of SharePoint sites.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointSiteUsageSiteCounts[0].total'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: 2feda0c4073445bcbe6a99e1eed1b838
          name: 'SharePoint: Storage, report date'
          type: DEPENDENT
          key: ms365.sharepoint.storage.report_date
          value_type: CHAR
          description: 'The date of the report of the amount of storage used in SharePoint.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointSiteUsageStorage[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: sharepoint
        - uuid: 18e892b6167442ec9c385cee5b1d919c
          name: 'SharePoint: Storage, total'
          type: DEPENDENT
          key: ms365.sharepoint.storage.total
          trends: '0'
          units: B
          description: 'The total amount of storage used in SharePoint.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointSiteUsageStorage[0].storageUsedInBytes'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: 9cffe16ecb9347ddb59afd577996e676
          name: 'SharePoint: Users, report date'
          type: DEPENDENT
          key: ms365.sharepoint.user_count.report_date
          value_type: CHAR
          description: 'The date of the report of the number of active SharePoint users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityUserCounts[0].reportDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: sharepoint
        - uuid: 11bd113ce58b4d95a4b75965ede4f7f3
          name: 'SharePoint: Users, shared externally'
          type: DEPENDENT
          key: ms365.sharepoint.user_count.shared_externally
          trends: '0'
          description: 'The number of users who have shared SharePoint files externally.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityUserCounts[0].sharedExternally'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: 08ad2690bc3c4c2eb88094754a7b3044
          name: 'SharePoint: Users, shared internally'
          type: DEPENDENT
          key: ms365.sharepoint.user_count.shared_internally
          trends: '0'
          description: 'The number of users who have shared SharePoint files internally.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityUserCounts[0].sharedInternally'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: a632ededd9794a1f97c8d06caefb6965
          name: 'SharePoint: Users, synced'
          type: DEPENDENT
          key: ms365.sharepoint.user_count.synced
          trends: '0'
          description: 'The number of users who have synced SharePoint files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityUserCounts[0].synced'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: 234db342146044399cb243376b81f571
          name: 'SharePoint: Users, viewed or edited'
          type: DEPENDENT
          key: ms365.sharepoint.user_count.viewed_or_edited
          trends: '0'
          description: 'The number of users who have viewed or edited SharePoint files.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityUserCounts[0].viewedOrEdited'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: f6883d5517054554b3553e3497925c58
          name: 'SharePoint: Users, pages visited'
          type: DEPENDENT
          key: ms365.sharepoint.user_count.visited_page
          trends: '0'
          description: 'The number of users who have visited unique pages.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getSharePointActivityUserCounts[0].visitedPage'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.sharepoint.reports.get
          tags:
            - tag: component
              value: sharepoint
        - uuid: 34bfd72749ec4b8d9e6bb305a6d105b5
          name: 'Teams: Team activity, active channels'
          type: DEPENDENT
          key: ms365.teams.activity.team.active_channels
          trends: '0'
          description: 'The number of active channels across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].activeChannels'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 8b87fb80bc274241861d2d4683deb16a
          name: 'Teams: Team activity, active external users'
          type: DEPENDENT
          key: ms365.teams.activity.team.active_external_users
          trends: '0'
          description: 'The number of active external users across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].activeExternalUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 329e2462f6c3461aa839d234e69137d1
          name: 'Teams: Team activity, active shared channels'
          type: DEPENDENT
          key: ms365.teams.activity.team.active_shared_channels
          trends: '0'
          description: 'The number of active shared channels across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].activeSharedChannels'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 9297ac6f704249b189a826ca113624dd
          name: 'Teams: Team activity, active users'
          type: DEPENDENT
          key: ms365.teams.activity.team.active_users
          trends: '0'
          description: 'The number of active users across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].activeUsers'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 88e359b530424573ab9ffa9703648886
          name: 'Teams: Team activity, channel messages'
          type: DEPENDENT
          key: ms365.teams.activity.team.channel_messages
          trends: '0'
          description: 'The number of channel messages across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].channelMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: ba3d03da9c184f9fb4451eda4b9fb013
          name: 'Teams: Team activity, guests'
          type: DEPENDENT
          key: ms365.teams.activity.team.guests
          trends: '0'
          description: 'The number of guests across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].guests'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: e46f6cc21cdd479581f52d34fba062b9
          name: 'Teams: Team activity, meetings organized'
          type: DEPENDENT
          key: ms365.teams.activity.team.meetings_organized
          trends: '0'
          description: 'The number of organized meetings across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].meetingsOrganized'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 49f96c1827e744158c70654b0a1d9933
          name: 'Teams: Team activity, mentions'
          type: DEPENDENT
          key: ms365.teams.activity.team.mentions
          trends: '0'
          description: 'The number of mentions across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].mentions'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 222be36f3ef84bc281d125ef0609ec82
          name: 'Teams: Team activity, post messages'
          type: DEPENDENT
          key: ms365.teams.activity.team.messages.posts
          trends: '0'
          description: 'The number of post messages across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].postMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 823acbc537544d89a8411025d1624715
          name: 'Teams: Team activity, reply messages'
          type: DEPENDENT
          key: ms365.teams.activity.team.messages.replies
          trends: '0'
          description: 'The number of reply messages across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].replyMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 0f9ae923e0694e149e441c7c48c5e13d
          name: 'Teams: Team activity, reactions'
          type: DEPENDENT
          key: ms365.teams.activity.team.reactions
          trends: '0'
          description: 'The number of reactions across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].reactions'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 83f8432b7ab246e59da295fa50294c78
          name: 'Teams: Team activity, report date'
          type: DEPENDENT
          key: ms365.teams.activity.team.report_date
          value_type: CHAR
          description: 'The date of the report of the number of team activities.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].reportRefreshDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: teams
        - uuid: 3d76b28d9ce048f59ab49e722a576cbe
          name: 'Teams: Team activity, urgent messages'
          type: DEPENDENT
          key: ms365.teams.activity.team.urgent_messages
          trends: '0'
          description: 'The number of urgent messages across Microsoft Teams over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsTeamActivityDistributionCounts[0].activityDistributions[0].urgentMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: ba7e5388f43b40c1bd63516c1edb995d
          name: 'Teams: User activity, calls'
          type: DEPENDENT
          key: ms365.teams.activity.user.calls
          trends: '0'
          description: 'The number of 1:1 calls licensed or non-licensed Microsoft Teams users participated in during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].calls'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: e17c33e6ea724db1884ba8b8519050e5
          name: 'Teams: User activity, audio duration'
          type: DEPENDENT
          key: ms365.teams.activity.user.duration.audio
          trends: '0'
          units: s
          description: 'The sum of the audio duration of licensed or non-licensed Microsoft Teams users during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].audioDuration'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
            - type: JAVASCRIPT
              parameters:
                - |
                  function iso8601DurationToSeconds(iso8601Duration) {
                  	const iso8601DurationRegex = /(-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?(?:T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)?)?/;
                  	const matches = iso8601Duration.match(iso8601DurationRegex);
                  
                  	duration = 0;
                  	matches.forEach( function (field, index) {
                  		if (field != undefined) {
                  			switch(index) {
                  				case 2: duration += parseInt(field) * daysInThisYear() * 86400; break;
                  				case 3: duration += parseInt(field) * daysInThisMonth() * 86400; break;
                  				case 4: duration += parseInt(field) * 604800; break;
                  				case 5: duration += parseInt(field) * 86400; break;
                  				case 6: duration += parseInt(field) * 3600; break;
                  				case 7: duration += parseInt(field) * 60; break;
                  				case 8: duration += parseInt(field);
                  			}
                  		}
                  	});
                  
                  	return duration;
                  };
                  
                  function daysInThisMonth() {
                  	const now = new Date();
                  
                  	return new Date(now.getFullYear(), now.getMonth()+1, 0).getDate();
                  };
                  
                  function daysInThisYear() {
                  	const now = new Date();
                  
                  	return new Date(now.getFullYear(), 2, 0).getDate() + 337;
                  };
                  
                  return iso8601DurationToSeconds(value);
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: ab085552326c4e51847ec6f51377601e
          name: 'Teams: User activity, screen share duration'
          type: DEPENDENT
          key: ms365.teams.activity.user.duration.screen_share
          trends: '0'
          units: s
          description: 'The sum of the screen share duration of licensed or non-licensed Microsoft Teams users during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].screenShareDuration'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
            - type: JAVASCRIPT
              parameters:
                - |
                  function iso8601DurationToSeconds(iso8601Duration) {
                  	const iso8601DurationRegex = /(-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?(?:T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)?)?/;
                  	const matches = iso8601Duration.match(iso8601DurationRegex);
                  
                  	duration = 0;
                  	matches.forEach( function (field, index) {
                  		if (field != undefined) {
                  			switch(index) {
                  				case 2: duration += parseInt(field) * daysInThisYear() * 86400; break;
                  				case 3: duration += parseInt(field) * daysInThisMonth() * 86400; break;
                  				case 4: duration += parseInt(field) * 604800; break;
                  				case 5: duration += parseInt(field) * 86400; break;
                  				case 6: duration += parseInt(field) * 3600; break;
                  				case 7: duration += parseInt(field) * 60; break;
                  				case 8: duration += parseInt(field);
                  			}
                  		}
                  	});
                  
                  	return duration;
                  };
                  
                  function daysInThisMonth() {
                  	const now = new Date();
                  
                  	return new Date(now.getFullYear(), now.getMonth()+1, 0).getDate();
                  };
                  
                  function daysInThisYear() {
                  	const now = new Date();
                  
                  	return new Date(now.getFullYear(), 2, 0).getDate() + 337;
                  };
                  
                  return iso8601DurationToSeconds(value);
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 50d50c7daccc4eafb3d98fd5de233ba2
          name: 'Teams: User activity, video duration'
          type: DEPENDENT
          key: ms365.teams.activity.user.duration.video
          trends: '0'
          units: s
          description: 'The sum of the video duration of licensed or non-licensed Microsoft Teams users during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].videoDuration'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
            - type: JAVASCRIPT
              parameters:
                - |
                  function iso8601DurationToSeconds(iso8601Duration) {
                  	const iso8601DurationRegex = /(-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?(?:T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)?)?/;
                  	const matches = iso8601Duration.match(iso8601DurationRegex);
                  
                  	duration = 0;
                  	matches.forEach( function (field, index) {
                  		if (field != undefined) {
                  			switch(index) {
                  				case 2: duration += parseInt(field) * daysInThisYear() * 86400; break;
                  				case 3: duration += parseInt(field) * daysInThisMonth() * 86400; break;
                  				case 4: duration += parseInt(field) * 604800; break;
                  				case 5: duration += parseInt(field) * 86400; break;
                  				case 6: duration += parseInt(field) * 3600; break;
                  				case 7: duration += parseInt(field) * 60; break;
                  				case 8: duration += parseInt(field);
                  			}
                  		}
                  	});
                  
                  	return duration;
                  };
                  
                  function daysInThisMonth() {
                  	const now = new Date();
                  
                  	return new Date(now.getFullYear(), now.getMonth()+1, 0).getDate();
                  };
                  
                  function daysInThisYear() {
                  	const now = new Date();
                  
                  	return new Date(now.getFullYear(), 2, 0).getDate() + 337;
                  };
                  
                  return iso8601DurationToSeconds(value);
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 580aa03b32364b648e2068ac2db70400
          name: 'Teams: User activity, attended meetings'
          type: DEPENDENT
          key: ms365.teams.activity.user.meetings.attended
          trends: '0'
          description: 'The sum of the scheduled one-time and recurring, ad-hoc, and unclassified meetings attended by licensed or non-licensed Microsoft Teams users during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].meetingsAttended'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: eb8bef4579a44ad381808574be6d20e9
          name: 'Teams: User activity, organized meetings'
          type: DEPENDENT
          key: ms365.teams.activity.user.meetings.organized
          trends: '0'
          description: 'The sum of the scheduled one-time and recurring, ad-hoc, and unclassified meetings organized by licensed or non-licensed Microsoft Teams users during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].meetingsOrganized'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 72a82b9a3b594f2abda27e21718cc937
          name: 'Teams: User activity, meetings'
          type: DEPENDENT
          key: ms365.teams.activity.user.meetings.total
          trends: '0'
          description: 'The sum of the scheduled one-time and recurring, ad-hoc, and unclassified meetings licensed or non-licensed Microsoft Teams users participated in during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].meetings'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 1c667ffc4f744a838ba4a82664507b8a
          name: 'Teams: User activity, team chat messages'
          type: DEPENDENT
          key: ms365.teams.activity.user.messages.in_team
          trends: '0'
          description: 'The number of unique messages that were posted in team chats by licensed or non-licensed Microsoft Teams users during the week before the report refresh date. This includes original posts and replies.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].teamChatMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 7b21ea233e5242a0bdafe3c9d190b2a1
          name: 'Teams: User activity, post messages'
          type: DEPENDENT
          key: ms365.teams.activity.user.messages.posts
          trends: '0'
          description: 'The number of post messages in all channels made by licensed or non-licensed Microsoft Teams users during the week before the report refresh date. A post is the original message in a teams chat.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].postMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: b833bc817058414fa44ee68b91cb729d
          name: 'Teams: User activity, private chat messages'
          type: DEPENDENT
          key: ms365.teams.activity.user.messages.private
          trends: '0'
          description: 'The number of unique messages that were posted in private chats by licensed or non-licensed Microsoft Teams users during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].privateChatMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: ef4c68446d674310aebdc8da9d20002e
          name: 'Teams: User activity, reply messages'
          type: DEPENDENT
          key: ms365.teams.activity.user.messages.replies
          trends: '0'
          description: 'The number of reply messages in all channels made by licensed or non-licensed Microsoft Teams users during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].userCounts[0].replyMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 16098eacf17a4fa4a1704b0b87ee4f5e
          name: 'Teams: User activity, report date'
          type: DEPENDENT
          key: ms365.teams.activity.user.report_date
          value_type: CHAR
          description: 'The date of the report of the number of activities by all users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityTotalDistributionCounts[0].reportRefreshDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: teams
        - uuid: dec6dfcf6d1040999633356029597861
          name: 'Teams: Device usage (guests), Android'
          type: DEPENDENT
          key: ms365.teams.device.guests.android
          trends: '0'
          description: 'The number of unique non-licensed Microsoft Teams users (guests) recorded via the Teams mobile client for Android over the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].androidPhone - data.metrics.getTeamsDeviceUsageDistributionUserCounts[0].androidPhone;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: f69460d4a5b64cdfb1d46d108ee0f703
          name: 'Teams: Device usage (guests), Chrome OS'
          type: DEPENDENT
          key: ms365.teams.device.guests.chromeos
          trends: '0'
          description: 'The number of unique non-licensed Microsoft Teams users (guests) recorded via the Teams desktop client on a ChromeOS computer over the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].chromeOS - data.metrics.getTeamsDeviceUsageDistributionUserCounts[0].chromeOS;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: c425439d85834854b702dcca49c84579
          name: 'Teams: Device usage (guests), iOS'
          type: DEPENDENT
          key: ms365.teams.device.guests.ios
          trends: '0'
          description: 'The number of unique non-licensed Microsoft Teams users (guests) recorded via the Teams mobile client for iOS over the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].ios - data.metrics.getTeamsDeviceUsageDistributionUserCounts[0].ios;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: 90b8cfc7f64944599cf756fc4e8cb72c
          name: 'Teams: Device usage (guests), Linux'
          type: DEPENDENT
          key: ms365.teams.device.guests.linux
          trends: '0'
          description: 'The number of unique non-licensed Microsoft Teams users (guests) recorded via the Teams desktop client on a Linux computer over the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].linux - data.metrics.getTeamsDeviceUsageDistributionUserCounts[0].linux;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: 60b11d13d4e74476a0e48832d6bc9f79
          name: 'Teams: Device usage (guests), Mac'
          type: DEPENDENT
          key: ms365.teams.device.guests.mac
          trends: '0'
          description: 'The number of unique non-licensed Microsoft Teams users (guests) recorded via the Teams desktop client on a macOS computer over the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].mac - data.metrics.getTeamsDeviceUsageDistributionUserCounts[0].mac;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: bda18a4088f940c1b36510fd135819aa
          name: 'Teams: Device usage (guests), web client'
          type: DEPENDENT
          key: ms365.teams.device.guests.web
          trends: '0'
          description: 'The number of unique non-licensed Microsoft Teams users (guests) recorded via the Teams web client over the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].web - data.metrics.getTeamsDeviceUsageDistributionUserCounts[0].web;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: d62bfc1f1a7b4480bbf10659782c3ea2
          name: 'Teams: Device usage (guests), Windows'
          type: DEPENDENT
          key: ms365.teams.device.guests.windows
          trends: '0'
          description: 'The number of unique non-licensed Microsoft Teams users (guests) recorded via the Teams desktop client on a Windows-based computer over the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].windows - data.metrics.getTeamsDeviceUsageDistributionUserCounts[0].windows;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: b7b407ce61984b5ba717dfb0ff50c369
          name: 'Teams: Device usage (total), Android'
          type: DEPENDENT
          key: ms365.teams.device.total.android
          trends: '0'
          description: 'The number of unique Microsoft Teams users (licensed or non-licensed) recorded via the Teams mobile client for Android over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].androidPhone'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: 5bef589815d241b49456676c8fa065f8
          name: 'Teams: Device usage (total), Chrome OS'
          type: DEPENDENT
          key: ms365.teams.device.total.chromeos
          trends: '0'
          description: 'The number of unique Microsoft Teams users (licensed or non-licensed) recorded via the Teams desktop client on a ChromeOS computer over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].chromeOS'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: 063563a9f8964f6f8c7a518a4ebbec4d
          name: 'Teams: Device usage (total), iOS'
          type: DEPENDENT
          key: ms365.teams.device.total.ios
          trends: '0'
          description: 'The number of unique Microsoft Teams users (licensed or non-licensed) recorded via the Teams mobile client for iOS over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].ios'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: aeb3d4065bc34d74a592daa8bc72f353
          name: 'Teams: Device usage (total), Linux'
          type: DEPENDENT
          key: ms365.teams.device.total.linux
          trends: '0'
          description: 'The number of unique Microsoft Teams users (licensed or non-licensed) recorded via the Teams desktop client on a Linux computer over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].linux'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: 090671fa6fc945a391080eb44df88223
          name: 'Teams: Device usage (total), Mac'
          type: DEPENDENT
          key: ms365.teams.device.total.mac
          trends: '0'
          description: 'The number of unique Microsoft Teams users (licensed or non-licensed) recorded via the Teams desktop client on a macOS computer over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].mac'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: 5b7f0955910a46e8996614c52df16792
          name: 'Teams: Device usage (total), report date'
          type: DEPENDENT
          key: ms365.teams.device.total.report_date
          value_type: CHAR
          description: 'The date of the report of device usage of both licensed and non-licensed users.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].reportRefreshDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: teams
        - uuid: a71fb7e8da9e4882bcb5440b5b475a31
          name: 'Teams: Device usage (total), web client'
          type: DEPENDENT
          key: ms365.teams.device.total.web
          trends: '0'
          description: 'The number of unique Microsoft Teams users (licensed or non-licensed) recorded via the Teams web client over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].web'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: 68c3b651d315491db16222fd8aa96237
          name: 'Teams: Device usage (total), Windows'
          type: DEPENDENT
          key: ms365.teams.device.total.windows
          trends: '0'
          description: 'The number of unique Microsoft Teams users (licensed or non-licensed) recorded via the Teams desktop client on a Windows-based computer over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionTotalUserCounts[0].windows'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: d25d13138a7f4690825549476a32d3ec
          name: 'Teams: Device usage (users), Android'
          type: DEPENDENT
          key: ms365.teams.device.users.android
          trends: '0'
          description: 'The number of unique licensed Microsoft Teams users recorded via the Teams mobile client for Android over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionUserCounts[0].androidPhone'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: fbdad9980995479da7d5413a55c18ef3
          name: 'Teams: Device usage (users), Chrome OS'
          type: DEPENDENT
          key: ms365.teams.device.users.chromeos
          trends: '0'
          description: 'The number of unique licensed Microsoft Teams users recorded via the Teams desktop client on a ChromeOS computer over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionUserCounts[0].chromeOS'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: b8274b598bb34488b6bd8f1bb9e3dbca
          name: 'Teams: Device usage (users), iOS'
          type: DEPENDENT
          key: ms365.teams.device.users.ios
          trends: '0'
          description: 'The number of unique licensed Microsoft Teams users recorded via the Teams mobile client for iOS over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionUserCounts[0].ios'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: 24de6354c4b04c7aa5ad12bfb8858800
          name: 'Teams: Device usage (users), Linux'
          type: DEPENDENT
          key: ms365.teams.device.users.linux
          trends: '0'
          description: 'The number of unique licensed Microsoft Teams users recorded via the Teams desktop client on a Linux computer over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionUserCounts[0].linux'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: 1037aa5c3bf14114b6f1aaf61c3a4ea3
          name: 'Teams: Device usage (users), Mac'
          type: DEPENDENT
          key: ms365.teams.device.users.mac
          trends: '0'
          description: 'The number of unique licensed Microsoft Teams users recorded via the Teams desktop client on a macOS computer over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionUserCounts[0].mac'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: e95474426572429cb795648aeae3881a
          name: 'Teams: Device usage (users), web client'
          type: DEPENDENT
          key: ms365.teams.device.users.web
          trends: '0'
          description: 'The number of unique licensed Microsoft Teams users recorded via the Teams web client over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionUserCounts[0].web'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: c7d6439dbb394b66949050e00205995e
          name: 'Teams: Device usage (users), Windows'
          type: DEPENDENT
          key: ms365.teams.device.users.windows
          trends: '0'
          description: 'The number of unique licensed Microsoft Teams users recorded via the Teams desktop client on a Windows-based computer over the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsDeviceUsageDistributionUserCounts[0].windows'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: device
            - tag: component
              value: teams
        - uuid: aca93ce9a84d4cd5a2465dd43ce47156
          name: 'Teams: Get errors'
          type: DEPENDENT
          key: ms365.teams.errors
          value_type: TEXT
          description: 'A list of errors from API requests for Teams metrics.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: error
            - tag: component
              value: teams
          triggers:
            - uuid: 18c8af3eea6f49b1ba795b476e218ab9
              expression: 'length(last(/Microsoft 365 reports by HTTP/ms365.teams.errors))>0'
              name: 'Microsoft 365: Teams: There are errors in requests to API'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Zabbix has received errors in response to API requests.'
              tags:
                - tag: scope
                  value: availability
        - uuid: a77e654c05ec44ed991a36c6b1df472f
          name: 'Teams: Get reports'
          type: SCRIPT
          key: ms365.teams.reports.get
          delay: 6h
          history: '0'
          value_type: TEXT
          params: |
            const ms365 = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'api_version'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		ms365.params = params;
            	},
            
            	login: function () {
            		const response = new HttpRequest(),
            			login = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			login.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(ms365.params.tenant_id) + '/oauth2/v2.0/token',
            			'grant_type=client_credentials&scope=https://graph.microsoft.com/.default&client_id=' + encodeURIComponent(ms365.params.app_id) + '&client_secret=' + encodeURIComponent(ms365.params.password)
            		);
            
            		if (login.getStatus() < 200 || login.getStatus() >= 300) {
            			throw 'Login failed with status code ' + login.getStatus() + ': ' + response;
            		}
            
            		try {
            			response = JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse login session response.';
            		}
            
            		if (!response.hasOwnProperty('access_token')) {
            			throw 'Authentication response does not contain access token.';
            		}
            
            		ms365.token = response['access_token'];
            	},
            
            	request: function (url) {
            		const response = new HttpRequest(),
            			request = new HttpRequest();
            
            		if (typeof ms365.params.http_proxy !== 'undefined' && ms365.params.http_proxy !== '') {
            			request.setProxy(ms365.params.http_proxy);
            			Zabbix.log(4, '[ Microsoft 365 ] Using HTTP proxy: ' + ms365.params.http_proxy);
            		}
            
            		if (!ms365.token) {
            			throw 'Request does not contain access token.';
            		}
            
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + ms365.token);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Request url: ' + url);
            
            		response = request.get(url);
            
            		Zabbix.log(4, '[ Microsoft 365 ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() < 200 || request.getStatus() >= 300) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	},
            
            	getField: function (data, path) {
            		const 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 ms365.nullToZero(data);
            	},
            
            	nullToZero: function (data) {
            		Object.keys(data).forEach(function (key) {
            			if (data[key] === null) {
            				data[key] = 0;
            			} else if (typeof data[key] === 'object') {
            				ms365.nullToZero(data[key]);
            			}
            		});
            
            		return data;
            	},
            
            	getMetricsData: function (endpoints) {
            		const data = {};
            
            		data.metrics = {};
            		endpoints.forEach(function (field) {
            			link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/reports/' + field + '(period=\'D7\')?$format=application/json';
            			answer = ms365.getField(ms365.request(link), 'value');
            
            			data.metrics[field] = answer;
            		});
            
            		return data;
            	},
            
            	getServiceData: function () {
            		var data = {},
            
            		link = 'https://graph.microsoft.com/' + encodeURIComponent(ms365.params.api_version) + '/admin/serviceAnnouncement/healthOverviews/';
            		data.services = ms365.request(link);
            
            		return data;
            	}
            };
            
            
            endpoints = [
            	'getTeamsDeviceUsageDistributionUserCounts',
            	'getTeamsDeviceUsageDistributionTotalUserCounts',
            	'getTeamsUserActivityTotalDistributionCounts',
            	'getTeamsUserActivityDistributionUserCounts',
            	'getTeamsUserActivityDistributionTotalUserCounts',
            	'getTeamsTeamActivityDistributionCounts'
            ];
            
            try {
            	ms365.setParams(JSON.parse(value));
            	ms365.login();
            	return JSON.stringify(ms365.getMetricsData(endpoints));
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Microsoft 365 ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
          description: |
            Accumulated data from the Microsoft Graph API "reports" endpoints.
            More information:
            https://learn.microsoft.com/en-us/graph/api/resources/report?view=graph-rest-beta
          timeout: '{$MS365.API.TIMEOUT}'
          parameters:
            - name: api_version
              value: '{$MS365.API.VERSION}'
            - name: app_id
              value: '{$MS365.APP.ID}'
            - name: http_proxy
              value: '{$MS365.HTTP.PROXY}'
            - name: password
              value: '{$MS365.PASSWORD}'
            - name: tenant_id
              value: '{$MS365.TENANT.ID}'
          tags:
            - tag: component
              value: raw
            - tag: component
              value: teams
        - uuid: 7e67ccc2a42c4d5abbc3e0d0d7984d05
          name: 'Teams: User count (guests), calls'
          type: DEPENDENT
          key: ms365.teams.user_count.guests.calls
          trends: '0'
          description: 'The number of non-licensed Microsoft Teams users (guests) who participated in calls during the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsUserActivityDistributionTotalUserCounts[0].calls - data.metrics.getTeamsUserActivityDistributionUserCounts[0].calls;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: ddc63a611a24420db83976ccd1a6c8a0
          name: 'Teams: User count (guests), meetings'
          type: DEPENDENT
          key: ms365.teams.user_count.guests.meetings
          trends: '0'
          description: 'The number of non-licensed Microsoft Teams users (guests) who participated in meetings during the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsUserActivityDistributionTotalUserCounts[0].meetings - data.metrics.getTeamsUserActivityDistributionUserCounts[0].meetings;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 6907e19e2e8042faaf60b55fd7298e22
          name: 'Teams: User count (guests), team chat messages'
          type: DEPENDENT
          key: ms365.teams.user_count.guests.messages.in_team
          trends: '0'
          description: 'The number of non-licensed Microsoft Teams users (guests) who posted or replied in team chats during the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsUserActivityDistributionTotalUserCounts[0].teamChatMessages - data.metrics.getTeamsUserActivityDistributionUserCounts[0].teamChatMessages;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: f91e43ecd3874b0ba51d0bca9c2a4bd2
          name: 'Teams: User count (guests), private chat messages'
          type: DEPENDENT
          key: ms365.teams.user_count.guests.messages.private
          trends: '0'
          description: 'The number of non-licensed Microsoft Teams users (guests) who posted or replied in private chats during the week before the report refresh date.'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var data=JSON.parse(value);
                  
                  return data.metrics.getTeamsUserActivityDistributionTotalUserCounts[0].privateChatMessages - data.metrics.getTeamsUserActivityDistributionUserCounts[0].privateChatMessages;
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 79caf6821ff84df5b20ab9c56e25423c
          name: 'Teams: User count (total), calls'
          type: DEPENDENT
          key: ms365.teams.user_count.total.calls
          trends: '0'
          description: 'The number of licensed or non-licensed Microsoft Teams users who participated in calls during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityDistributionTotalUserCounts[0].calls'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 6d1c327b01ec44188f2693aac595a4d9
          name: 'Teams: User count (total), meetings'
          type: DEPENDENT
          key: ms365.teams.user_count.total.meetings
          trends: '0'
          description: 'The number of licensed or non-licensed Microsoft Teams users who participated in meetings during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityDistributionTotalUserCounts[0].meetings'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: e594430f98cd442d8ca7705320c35ff9
          name: 'Teams: User count (total), team chat messages'
          type: DEPENDENT
          key: ms365.teams.user_count.total.messages.in_team
          trends: '0'
          description: 'The number of licensed or non-licensed Microsoft Teams users who posted or replied in team chats during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityDistributionTotalUserCounts[0].teamChatMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: b83cb233a3464734873ac5c1fb62c3c2
          name: 'Teams: User count (total), private chat messages'
          type: DEPENDENT
          key: ms365.teams.user_count.total.messages.private
          trends: '0'
          description: 'The number of licensed or non-licensed Microsoft Teams users who posted or replied in private chats during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityDistributionTotalUserCounts[0].privateChatMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 34dcf8e943644be8b82691d845ea2f40
          name: 'Teams: User count (total), report date'
          type: DEPENDENT
          key: ms365.teams.user_count.total.report_date
          value_type: CHAR
          description: 'The date of the report of the number of licensed or non-licensed Microsoft Teams users in activity.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityDistributionTotalUserCounts[0].reportRefreshDate'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: date
            - tag: component
              value: teams
        - uuid: 47348e11d1d646c88330853b8e002143
          name: 'Teams: User count (users), calls'
          type: DEPENDENT
          key: ms365.teams.user_count.users.calls
          trends: '0'
          description: 'The number of licensed Microsoft Teams users who participated in calls during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityDistributionUserCounts[0].calls'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 68b1c4eaf0864acd81cc7f79f41eeec6
          name: 'Teams: User count (users), meetings'
          type: DEPENDENT
          key: ms365.teams.user_count.users.meetings
          trends: '0'
          description: 'The number of licensed Microsoft Teams users who participated in meetings during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityDistributionUserCounts[0].meetings'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 0f9486c175254cbf9a1b3f7cdd98b594
          name: 'Teams: User count (users), team chat messages'
          type: DEPENDENT
          key: ms365.teams.user_count.users.messages.in_team
          trends: '0'
          description: 'The number of licensed Microsoft Teams users who posted or replied in team chats during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityDistributionUserCounts[0].teamChatMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
        - uuid: 86ebe049e2264190b166c71189e6183d
          name: 'Teams: User count (users), private chat messages'
          type: DEPENDENT
          key: ms365.teams.user_count.users.messages.private
          trends: '0'
          description: 'The number of licensed Microsoft Teams users who posted or replied in private chats during the week before the report refresh date.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.metrics.getTeamsUserActivityDistributionUserCounts[0].privateChatMessages'
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: ms365.teams.reports.get
          tags:
            - tag: component
              value: teams
      discovery_rules:
        - uuid: ef6cab6b162d4a178d34391f2088b239
          name: 'Microsoft Copilot user discovery'
          type: DEPENDENT
          key: ms365.copilot.user.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#KEY}'
                value: '{$MS365.COPILOT.USER.KEY.MATCHES}'
              - macro: '{#KEY}'
                value: '{$MS365.COPILOT.USER.KEY.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'The list of Microsoft Copilot users.'
          item_prototypes:
            - uuid: f152b822a93f4229bf09866b86e36eea
              name: 'User [{#NAME}]: Get data'
              type: DEPENDENT
              key: 'ms365.copilot.user.get[{#KEY}]'
              value_type: TEXT
              description: 'Item for gathering Copilot users.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.metrics.getMicrosoft365CopilotUsageUserDetail.[?(@.userPrincipalName == "{#KEY}")].first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: ms365.copilot.reports.get
              tags:
                - tag: component
                  value: raw
                - tag: user
                  value: '{#NAME}'
            - uuid: a4eed1cea9424c98bf5072277441adf8
              name: 'User [{#NAME}]: Copilot Activity, last chat use'
              type: DEPENDENT
              key: 'ms365.copilot.user_activity.chat[{#KEY}]'
              value_type: CHAR
              description: 'Last date of Copilot Chat use.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.copilotChatLastActivityDate
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'ms365.copilot.user.get[{#KEY}]'
              tags:
                - tag: component
                  value: copilot
                - tag: user
                  value: '{#NAME}'
            - uuid: c7f5470c18004e9096debd2b3c275b75
              name: 'User [{#NAME}]: Copilot Activity, last Excel use'
              type: DEPENDENT
              key: 'ms365.copilot.user_activity.excel[{#KEY}]'
              value_type: CHAR
              description: 'Last date of Copilot use in Microsoft Excel.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.excelCopilotLastActivityDate
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'ms365.copilot.user.get[{#KEY}]'
              tags:
                - tag: component
                  value: copilot
                - tag: component
                  value: excel
                - tag: user
                  value: '{#NAME}'
            - uuid: d71be4d6285f427780dbb8f21e82476d
              name: 'User [{#NAME}]: Copilot Activity, last Loop use'
              type: DEPENDENT
              key: 'ms365.copilot.user_activity.loop[{#KEY}]'
              value_type: CHAR
              description: 'Last date of Copilot use in Microsoft Loop.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.loopCopilotLastActivityDate
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'ms365.copilot.user.get[{#KEY}]'
              tags:
                - tag: component
                  value: copilot
                - tag: component
                  value: loop
                - tag: user
                  value: '{#NAME}'
            - uuid: e4f10ea46783495182c24e6598ca6b76
              name: 'User [{#NAME}]: Copilot Activity, last OneNote use'
              type: DEPENDENT
              key: 'ms365.copilot.user_activity.onenote[{#KEY}]'
              value_type: CHAR
              description: 'Last date of Copilot use in Microsoft OneNote.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.oneNoteCopilotLastActivityDate
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'ms365.copilot.user.get[{#KEY}]'
              tags:
                - tag: component
                  value: copilot
                - tag: component
                  value: onenote
                - tag: user
                  value: '{#NAME}'
            - uuid: 1a67409aa9e94fbcbadf89127b8d3cc6
              name: 'User [{#NAME}]: Copilot Activity, last Outlook use'
              type: DEPENDENT
              key: 'ms365.copilot.user_activity.outlook[{#KEY}]'
              value_type: CHAR
              description: 'Last date of Copilot use in Microsoft Outlook.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.outlookCopilotLastActivityDate
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'ms365.copilot.user.get[{#KEY}]'
              tags:
                - tag: component
                  value: copilot
                - tag: component
                  value: outlook
                - tag: user
                  value: '{#NAME}'
            - uuid: 4e420a2dc0e5439cb27d7a3268243c8a
              name: 'User [{#NAME}]: Copilot Activity, last PowerPoint use'
              type: DEPENDENT
              key: 'ms365.copilot.user_activity.powerpoint[{#KEY}]'
              value_type: CHAR
              description: 'Last date of Copilot use in Microsoft PowerPoint.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.powerPointCopilotLastActivityDate
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'ms365.copilot.user.get[{#KEY}]'
              tags:
                - tag: component
                  value: copilot
                - tag: component
                  value: powerpoint
                - tag: user
                  value: '{#NAME}'
            - uuid: 46405049bc514990b8897024854dcfde
              name: 'User [{#NAME}]: Copilot Activity, report date'
              type: DEPENDENT
              key: 'ms365.copilot.user_activity.report_date[{#KEY}]'
              value_type: CHAR
              description: 'The date of the report of user activity.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.reportRefreshDate
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'ms365.copilot.user.get[{#KEY}]'
              tags:
                - tag: component
                  value: copilot
                - tag: user
                  value: '{#NAME}'
            - uuid: 24e8f8b7d71e42a786930a2174f056cc
              name: 'User [{#NAME}]: Copilot Activity, last Teams use'
              type: DEPENDENT
              key: 'ms365.copilot.user_activity.teams[{#KEY}]'
              value_type: CHAR
              description: 'Last date of Copilot use in Microsoft Teams.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.microsoftTeamsCopilotLastActivityDate
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'ms365.copilot.user.get[{#KEY}]'
              tags:
                - tag: component
                  value: copilot
                - tag: component
                  value: teams
                - tag: user
                  value: '{#NAME}'
            - uuid: d60df5fb4287450b8999c2552393264d
              name: 'User [{#NAME}]: Copilot Activity, last Word use'
              type: DEPENDENT
              key: 'ms365.copilot.user_activity.word[{#KEY}]'
              value_type: CHAR
              description: 'Last date of Copilot use in Microsoft Word.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.wordCopilotLastActivityDate
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: 'ms365.copilot.user.get[{#KEY}]'
              tags:
                - tag: component
                  value: copilot
                - tag: component
                  value: word
                - tag: user
                  value: '{#NAME}'
          master_item:
            key: ms365.copilot.reports.get
          lld_macro_paths:
            - lld_macro: '{#KEY}'
              path: $.userPrincipalName
            - lld_macro: '{#NAME}'
              path: $.displayName
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.getMicrosoft365CopilotUsageUserDetail
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
        - uuid: f28e588e81fa4fbdaeb65463843c2c1d
          name: 'Microsoft cloud service discovery'
          type: DEPENDENT
          key: ms365.service.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#NAME}'
                value: '{$MS365.SERVICE.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$MS365.SERVICE.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'The list of Microsoft cloud services subscribed by a tenant.'
          item_prototypes:
            - uuid: 0cfd7176865a4c3c8c78c536a792c336
              name: 'Services: {#NAME} health status'
              type: DEPENDENT
              key: 'ms365.service.health[{#NAME}]'
              trends: '0'
              description: |
                Overall service health status of `[{#NAME}]`.
                More information about health status values can be found here:
                https://learn.microsoft.com/en-us/graph/api/resources/servicehealthissue?view=graph-rest-beta#servicehealthstatus-values
              valuemap:
                name: 'Services health status'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.services.value[?(@.service == ''{#NAME}'')].status.first()'
                - type: JAVASCRIPT
                  parameters:
                    - |
                      if (value !== 'null') {
                        const idx = [
                      	'serviceOperational',
                      	'investigating',
                      	'restoringService',
                      	'verifyingService',
                      	'serviceRestored',
                      	'postIncidentReviewPublished',
                      	'serviceDegradation',
                      	'serviceInterruption',
                      	'extendedRecovery',
                      	'falsePositive',
                      	'investigationSuspended',
                      	].indexOf(value);
                      
                      	return idx !== -1 ? idx : 11;
                      	}
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1d
              master_item:
                key: ms365.services.get
              tags:
                - tag: component
                  value: health
                - tag: component
                  value: service
                - tag: service
                  value: '{#NAME}'
              trigger_prototypes:
                - uuid: eaf40afe3cbf402f8148913e9b7baf98
                  expression: 'last(/Microsoft 365 reports by HTTP/ms365.service.health[{#NAME}])=6'
                  name: 'Microsoft 365: Services: {#NAME} is degraded.'
                  opdata: '{ITEM.LASTVALUE1}'
                  priority: WARNING
                  description: |
                    The service has the "Degraded" health status.
                    An issue is confirmed that may affect the use of a service or feature. You might see this status if a service is performing slower than usual, there are intermittent interruptions, or if a feature isn't working.
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: health
                - uuid: 312dc15bd57b49dfb86a5185b6c2cefa
                  expression: 'last(/Microsoft 365 reports by HTTP/ms365.service.health[{#NAME}])=7'
                  name: 'Microsoft 365: Services: {#NAME} is interrupted.'
                  opdata: '{ITEM.LASTVALUE1}'
                  priority: AVERAGE
                  description: |
                    The service has the "Interruption" health status.
                    An issue was determined that affects users being able to access the service. In this case, the issue is significant and can be reproduced consistently.
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: health
          master_item:
            key: ms365.services.get
          lld_macro_paths:
            - lld_macro: '{#NAME}'
              path: $.service
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.services.value
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
      tags:
        - tag: class
          value: cloud
        - tag: class
          value: software
        - tag: subclass
          value: communication
        - tag: subclass
          value: fileshare
        - tag: subclass
          value: messaging
        - tag: subclass
          value: social
        - tag: target
          value: ms365
      macros:
        - macro: '{$MS365.API.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
          config:
            type: TEXT
            priority: '10'
            section_name: Other
            label: 'API response timeout'
            description: 'API response timeout.'
        - macro: '{$MS365.API.VERSION}'
          value: beta
          description: 'Microsoft Graph API version.'
          config:
            type: TEXT
            priority: '9'
            section_name: Other
            label: 'API version'
            description: 'Microsoft Graph API version.'
        - macro: '{$MS365.APP.ID}'
          description: 'Microsoft application ID.'
          config:
            type: TEXT
            priority: '1'
            label: 'Application ID'
            description: 'Microsoft application ID.'
            required: 'YES'
        - macro: '{$MS365.COPILOT.USER.KEY.MATCHES}'
          value: '.*'
          description: 'This macro is used in the Microsoft Copilot user discovery rule.'
          config:
            type: TEXT
            priority: '6'
            section_name: Filters
            label: 'Copilot usernames (include)'
            description: 'This macro is used in the Microsoft Copilot user discovery rule.'
        - macro: '{$MS365.COPILOT.USER.KEY.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in the Microsoft Copilot user discovery rule.'
          config:
            type: TEXT
            priority: '7'
            section_name: Filters
            label: 'Copilot usernames (exclude)'
            description: 'This macro is used in the Microsoft Copilot user discovery rule.'
        - macro: '{$MS365.HTTP.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
          config:
            type: TEXT
            priority: '8'
            section_name: Other
            label: 'HTTP proxy'
            description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$MS365.PASSWORD}'
          type: SECRET_TEXT
          description: 'The secret for the registered Microsoft application.'
          config:
            type: TEXT
            priority: '2'
            label: Password
            description: 'The secret for the registered Microsoft application.'
            required: 'YES'
        - macro: '{$MS365.SERVICE.NAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in the Microsoft cloud service discovery rule.'
          config:
            type: TEXT
            priority: '4'
            section_name: Filters
            label: 'Service names filter (include)'
            description: 'This macro is used in the Microsoft cloud service discovery rule.'
        - macro: '{$MS365.SERVICE.NAME.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in the Microsoft cloud service discovery rule.'
          config:
            type: TEXT
            priority: '5'
            section_name: Filters
            label: 'Service names filter (exclude)'
            description: 'This macro is used in the Microsoft cloud service discovery rule.'
        - macro: '{$MS365.TENANT.ID}'
          description: 'Microsoft tenant ID.'
          config:
            type: TEXT
            priority: '3'
            label: 'Tenant ID'
            description: 'Microsoft tenant ID.'
            required: 'YES'
      dashboards:
        - uuid: 8c376826b58546b184f03415a5fedd46
          name: 'Microsoft 365'
          display_period: '120'
          pages:
            - name: Apps
              widgets:
                - type: item
                  name: 'Report date'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'User count, by app'
                  'y': '2'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FFD54F
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.exchange
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.office365
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.onedrive
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.sharepoint
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.skype
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.teams
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.yammer
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.6
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '5'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.platform.user_count.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'User count, by platform'
                  'y': '7'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: B4B400
                    - type: STRING
                      name: ds.0.color.1
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.2
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.3
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.platform.user_count.mac
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.platform.user_count.mobile
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.platform.user_count.web
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.platform.user_count.windows
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '10'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'User count, by office app'
                  'y': '12'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.1
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.2
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.3
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.4
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.5
                      value: FFD54F
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.word
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.excel
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.powerpoint
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.outlook
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.teams
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.onenote
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '15'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Weekly active user count, by app'
                  'y': '17'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FFD54F
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.exchange.users.active
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.office365.users.active
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.onedrive.users.active
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.sharepoint.users.active
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.skypeforbusiness.users.active
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.teams.users.active
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.yammer.users.active
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.6
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '20'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Weekly inactive user count, by app'
                  'y': '22'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FFD54F
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.exchange.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.office365.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.onedrive.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.sharepoint.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.skypeforbusiness.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.teams.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.yammer.users.inactive
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.6
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: svggraph
                  name: 'User count, by app'
                  x: '12'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FFD54F
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.exchange
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.office365
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.onedrive
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.sharepoint
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.skype
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.teams
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.users.yammer
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '3'
                    - type: STRING
                      name: reference
                      value: FAADC
                - type: svggraph
                  name: 'User count, by platform'
                  x: '12'
                  'y': '5'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: B4B400
                    - type: STRING
                      name: ds.0.color.1
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.2
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.3
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.platform.user_count.mac
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.platform.user_count.mobile
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.platform.user_count.web
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.platform.user_count.windows
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '2'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: ADFEF
                - type: svggraph
                  name: 'User count, by office app'
                  x: '12'
                  'y': '10'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.1
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.2
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.3
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.4
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.5
                      value: FFD54F
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.word
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.excel
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.powerpoint
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.outlook
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.teams
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.office.user_count.onenote
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: BCCED
                - type: svggraph
                  name: 'Weekly active user count, by app'
                  x: '12'
                  'y': '15'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FFD54F
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.exchange.users.active
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.office365.users.active
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.onedrive.users.active
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.sharepoint.users.active
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.skypeforbusiness.users.active
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.teams.users.active
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.yammer.users.active
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '3'
                    - type: STRING
                      name: reference
                      value: FCADE
                - type: svggraph
                  name: 'Weekly inactive user count, by app'
                  x: '12'
                  'y': '20'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FFD54F
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.exchange.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.office365.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.onedrive.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.sharepoint.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.skypeforbusiness.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.teams.users.inactive
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.apps.activity.yammer.users.inactive
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '3'
                    - type: STRING
                      name: reference
                      value: FBFFA
            - name: Teams
              widgets:
                - type: item
                  name: 'Report date'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Weekly user activity count'
                  'y': '2'
                  width: '12'
                  height: '4'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.1
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.2
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.3
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.4
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.calls
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.meetings.total
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.messages.in_team
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.messages.replies
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.messages.posts
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.meetings.organized
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.meetings.attended
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.6
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '6'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Weekly unique users, by device type'
                  'y': '8'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.1
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.2
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.3
                      value: B4B400
                    - type: STRING
                      name: ds.0.color.4
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FF465C
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.web
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.android
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.ios
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.mac
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.chromeos
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.windows
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.linux
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.6
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '11'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.user_count.total.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Weekly unique users, by action'
                  'y': '13'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.1
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.2
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.3
                      value: 2AB5FF
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.user_count.total.calls
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.user_count.total.meetings
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.user_count.total.messages.private
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.user_count.total.messages.in_team
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '16'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Weekly team activity count'
                  'y': '18'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.2
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.3
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.4
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.5
                      value: FF465C
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.channel_messages
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.mentions
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.messages.posts
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.reactions
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.messages.replies
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.urgent_messages
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '21'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Weekly team activity count'
                  'y': '23'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.3
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.4
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.active_channels
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.active_external_users
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.active_shared_channels
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.active_users
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.guests
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.meetings_organized
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Weekly private messages'
                  x: '12'
                  width: '15'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.messages.private
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: svggraph
                  name: 'Weekly user activity count'
                  x: '12'
                  'y': '2'
                  width: '60'
                  height: '4'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.1
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.2
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.3
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.4
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.calls
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.meetings.total
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.messages.in_team
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.messages.replies
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.messages.posts
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.meetings.organized
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.meetings.attended
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '3'
                    - type: STRING
                      name: reference
                      value: EAADC
                - type: svggraph
                  name: 'Weekly unique users, by device type'
                  x: '12'
                  'y': '6'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.1
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.2
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.3
                      value: B4B400
                    - type: STRING
                      name: ds.0.color.4
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FF465C
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.web
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.android
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.ios
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.mac
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.chromeos
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.windows
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.device.total.linux
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '3'
                    - type: STRING
                      name: reference
                      value: FBCAB
                - type: svggraph
                  name: 'Weekly unique users, by action'
                  x: '12'
                  'y': '11'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.1
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.2
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.3
                      value: 2AB5FF
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.user_count.total.calls
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.user_count.total.meetings
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.user_count.total.messages.private
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.user_count.total.messages.in_team
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '2'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: CBDDE
                - type: svggraph
                  name: 'Weekly team activity count'
                  x: '12'
                  'y': '16'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.2
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.3
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.4
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.5
                      value: FF465C
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.channel_messages
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.mentions
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.messages.posts
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.reactions
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.messages.replies
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.urgent_messages
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: ADEDE
                - type: svggraph
                  name: 'Weekly team activity count'
                  x: '12'
                  'y': '21'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.3
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.4
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.active_channels
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.active_external_users
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.active_shared_channels
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.active_users
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.guests
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.team.meetings_organized
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: DCCAD
                - type: item
                  name: 'Weekly audio duration'
                  x: '27'
                  width: '15'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.duration.audio
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: item
                  name: 'Weekly video duration'
                  x: '42'
                  width: '15'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.duration.video
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: item
                  name: 'Weekly screen share duration'
                  x: '57'
                  width: '15'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.teams.activity.user.duration.screen_share
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '50'
            - name: Outlook
              widgets:
                - type: item
                  name: 'Report date'
                  'y': '3'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Emails sent/received/read'
                  'y': '5'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.1
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.2
                      value: 2AB5FF
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.read
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.received
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.sent
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '8'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Meetings created/interacted'
                  'y': '10'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.meetings_created
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.meetings_interacted
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '13'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.report_date.app
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'User count, by app/platform'
                  'y': '15'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.1
                      value: B4B400
                    - type: STRING
                      name: ds.0.color.2
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.3
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.5
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.6
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.7
                      value: 2AB5FF
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.mac
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.mail_for_mac
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.mobile
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.web
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.windows
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.imap4app
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.pop3app
                    - type: ITEM
                      name: ds.0.itemids.7
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.smtpapp
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.6
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.7
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '18'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'User count, by activity'
                  'y': '20'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.1
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.2
                      value: 2AB5FF
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.read
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.received
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.sent
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '23'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'User count, meetings'
                  'y': '25'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.meetings_created
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.meetings_interacted
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  x: '12'
                  width: '24'
                  height: '1'
                  hide_header: 'YES'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.mailbox.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '80'
                - type: gauge
                  name: 'Active mailboxes'
                  x: '12'
                  'y': '1'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.mailbox.active.percentage
                    - type: INTEGER
                      name: show.0
                      value: '3'
                    - type: INTEGER
                      name: show.1
                      value: '5'
                    - type: INTEGER
                      name: show.2
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: INTEGER
                      name: units_bold
                      value: '1'
                    - type: INTEGER
                      name: units_size
                      value: '30'
                    - type: INTEGER
                      name: value_arc_size
                      value: '35'
                    - type: INTEGER
                      name: value_bold
                      value: '1'
                    - type: INTEGER
                      name: value_size
                      value: '30'
                - type: svggraph
                  name: 'Emails sent/received/read'
                  x: '12'
                  'y': '3'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.1
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.2
                      value: 2AB5FF
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.read
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.received
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.sent
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: STRING
                      name: reference
                      value: DEEEF
                - type: svggraph
                  name: 'Meetings created/interacted'
                  x: '12'
                  'y': '8'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.meetings_created
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.activity.meetings_interacted
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: STRING
                      name: reference
                      value: EBAAE
                - type: svggraph
                  name: 'User count, by app/platform'
                  x: '12'
                  'y': '13'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.1
                      value: B4B400
                    - type: STRING
                      name: ds.0.color.2
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.3
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.5
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.6
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.7
                      value: 2AB5FF
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.mac
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.mail_for_mac
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.mobile
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.web
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.windows
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.imap4app
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.pop3app
                    - type: ITEM
                      name: ds.0.itemids.7
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.smtpapp
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '3'
                    - type: STRING
                      name: reference
                      value: EFCAF
                - type: svggraph
                  name: 'User count, by activity'
                  x: '12'
                  'y': '18'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.1
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.2
                      value: 2AB5FF
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.read
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.received
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.sent
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: STRING
                      name: reference
                      value: DFFFC
                - type: svggraph
                  name: 'User count, meetings'
                  x: '12'
                  'y': '23'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.meetings_created
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.user_count.meetings_interacted
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: STRING
                      name: reference
                      value: EDCBE
                - type: item
                  name: 'Total mailboxes'
                  x: '24'
                  'y': '1'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.mailbox.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: item
                  name: 'Report date'
                  x: '36'
                  width: '12'
                  height: '1'
                  hide_header: 'YES'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.storage.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '80'
                - type: item
                  name: 'Total storage used'
                  x: '36'
                  'y': '1'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.outlook.storage.used
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
            - name: OneDrive
              widgets:
                - type: item
                  name: 'Report date'
                  'y': '3'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.files.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Files shared/synced/viewed or edited'
                  'y': '5'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.files.shared_externally
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.files.shared_internally
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.files.synced
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.files.viewed_or_edited
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '8'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.users.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'User count, file activity'
                  'y': '10'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.users.shared_externally
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.users.shared_internally
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.users.synced
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.users.viewed_or_edited
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  x: '12'
                  width: '24'
                  height: '1'
                  hide_header: 'YES'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.sites.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '80'
                - type: item
                  name: 'Business site count (active)'
                  x: '12'
                  'y': '1'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.sites.active
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: svggraph
                  name: 'Files shared/synced/viewed or edited'
                  x: '12'
                  'y': '3'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.files.shared_externally
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.files.shared_internally
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.files.synced
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.files.viewed_or_edited
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '2'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: FDFEC
                - type: svggraph
                  name: 'User count, file activity'
                  x: '12'
                  'y': '8'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.users.shared_externally
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.users.shared_internally
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.users.synced
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.users.viewed_or_edited
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '2'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: FDEAF
                - type: item
                  name: 'Business site count (total)'
                  x: '24'
                  'y': '1'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.sites.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: item
                  name: 'Report date'
                  x: '36'
                  width: '24'
                  height: '1'
                  hide_header: 'YES'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.file_count.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '80'
                - type: item
                  name: 'File count (active)'
                  x: '36'
                  'y': '1'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.file_count.active
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: item
                  name: 'File count (total)'
                  x: '48'
                  'y': '1'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.file_count.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: item
                  name: 'Report date'
                  x: '60'
                  width: '12'
                  height: '1'
                  hide_header: 'YES'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.storage.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '80'
                - type: item
                  name: 'Total storage used'
                  x: '60'
                  'y': '1'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.onedrive.storage.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
            - name: SharePoint
              widgets:
                - type: item
                  name: 'Report date'
                  width: '10'
                  height: '1'
                  hide_header: 'YES'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.pages_viewed.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '80'
                - type: item
                  name: 'Pages, view count'
                  'y': '1'
                  width: '10'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.pages_viewed.count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: item
                  name: 'Report date'
                  'y': '3'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.files.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'File count, by action'
                  'y': '5'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.files.shared_externally
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.files.shared_internally
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.files.synced
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.files.viewed_or_edited
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.file_count.active
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '8'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'User count, by action'
                  'y': '10'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.shared_externally
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.shared_internally
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.synced
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.viewed_or_edited
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.visited_page
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  x: '10'
                  width: '10'
                  height: '1'
                  hide_header: 'YES'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.pages_visited.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '80'
                - type: item
                  name: 'Pages, visited'
                  x: '10'
                  'y': '1'
                  width: '10'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.pages_visited.count
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: svggraph
                  name: 'File count, by action'
                  x: '12'
                  'y': '3'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.files.shared_externally
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.files.shared_internally
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.files.synced
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.files.viewed_or_edited
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.file_count.active
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: FCADE
                - type: svggraph
                  name: 'User count, by action'
                  x: '12'
                  'y': '8'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.1
                      value: 6AC8FF
                    - type: STRING
                      name: ds.0.color.2
                      value: BAE37D
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 385CC7
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.shared_externally
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.shared_internally
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.synced
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.viewed_or_edited
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.user_count.visited_page
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_columns
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: AFEEC
                - type: item
                  name: 'Report date'
                  x: '20'
                  width: '20'
                  height: '1'
                  hide_header: 'YES'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.site.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '80'
                - type: item
                  name: 'Business site count (active)'
                  x: '20'
                  'y': '1'
                  width: '10'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.sites.active
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: item
                  name: 'Business site count (total)'
                  x: '30'
                  'y': '1'
                  width: '10'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.sites.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: item
                  name: 'Report date'
                  x: '40'
                  width: '20'
                  height: '1'
                  hide_header: 'YES'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.file_count.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '80'
                - type: item
                  name: 'File count (active)'
                  x: '40'
                  'y': '1'
                  width: '10'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.file_count.active
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: item
                  name: 'File count (total)'
                  x: '50'
                  'y': '1'
                  width: '10'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.file_count.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
                - type: item
                  name: 'Report date'
                  x: '60'
                  width: '12'
                  height: '1'
                  hide_header: 'YES'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.storage.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '80'
                - type: item
                  name: 'Total storage used'
                  x: '60'
                  'y': '1'
                  width: '12'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF465C
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.sharepoint.storage.total
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: updown_color
                      value: FFD54F
                    - type: STRING
                      name: up_color
                      value: 0EC9AC
                    - type: INTEGER
                      name: value_size
                      value: '70'
            - name: Copilot
              widgets:
                - type: item
                  name: 'Report date'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.users.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Users by app'
                  'y': '2'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: ED1248
                    - type: STRING
                      name: ds.0.color.1
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.2
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.7
                      value: BAE37D
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.chat
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.word
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.excel
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.powerpoint
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.outlook
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.teams
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.onenote
                    - type: ITEM
                      name: ds.0.itemids.7
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.loop
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.6
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.7
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: item
                  name: 'Report date'
                  'y': '5'
                  width: '12'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.users.report_date
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: value_size
                      value: '50'
                - type: piechart
                  name: 'Users by app'
                  'y': '7'
                  width: '12'
                  height: '3'
                  hide_header: 'YES'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: ED1248
                    - type: STRING
                      name: ds.0.color.1
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.2
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.7
                      value: BAE37D
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.chat
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.word
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.excel
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.powerpoint
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.outlook
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.teams
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.onenote
                    - type: ITEM
                      name: ds.0.itemids.7
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.loop
                    - type: INTEGER
                      name: ds.0.type.0
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.1
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.2
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.3
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.4
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.5
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.6
                      value: '0'
                    - type: INTEGER
                      name: ds.0.type.7
                      value: '0'
                    - type: INTEGER
                      name: legend
                      value: '0'
                - type: svggraph
                  name: 'User count, enabled by app'
                  x: '12'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: ED1248
                    - type: STRING
                      name: ds.0.color.1
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.2
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.7
                      value: BAE37D
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.chat
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.word
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.excel
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.powerpoint
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.outlook
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.teams
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.onenote
                    - type: ITEM
                      name: ds.0.itemids.7
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.user_count.loop
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: FDFEC
                - type: svggraph
                  name: 'User count, active by app'
                  x: '12'
                  'y': '5'
                  width: '60'
                  height: '5'
                  fields:
                    - type: STRING
                      name: ds.0.color.0
                      value: ED1248
                    - type: STRING
                      name: ds.0.color.1
                      value: 385CC7
                    - type: STRING
                      name: ds.0.color.2
                      value: 0EC9AC
                    - type: STRING
                      name: ds.0.color.3
                      value: FF465C
                    - type: STRING
                      name: ds.0.color.4
                      value: 2AB5FF
                    - type: STRING
                      name: ds.0.color.5
                      value: 524BBC
                    - type: STRING
                      name: ds.0.color.6
                      value: FFD54F
                    - type: STRING
                      name: ds.0.color.7
                      value: BAE37D
                    - type: INTEGER
                      name: ds.0.dataset_type
                      value: '0'
                    - type: INTEGER
                      name: ds.0.fill
                      value: '0'
                    - type: ITEM
                      name: ds.0.itemids.0
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.chat
                    - type: ITEM
                      name: ds.0.itemids.1
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.word
                    - type: ITEM
                      name: ds.0.itemids.2
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.excel
                    - type: ITEM
                      name: ds.0.itemids.3
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.powerpoint
                    - type: ITEM
                      name: ds.0.itemids.4
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.outlook
                    - type: ITEM
                      name: ds.0.itemids.5
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.teams
                    - type: ITEM
                      name: ds.0.itemids.6
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.onenote
                    - type: ITEM
                      name: ds.0.itemids.7
                      value:
                        host: 'Microsoft 365 reports by HTTP'
                        key: ms365.copilot.active_user_count.loop
                    - type: INTEGER
                      name: ds.0.missingdatafunc
                      value: '3'
                    - type: INTEGER
                      name: ds.0.width
                      value: '3'
                    - type: INTEGER
                      name: legend_lines
                      value: '2'
                    - type: STRING
                      name: reference
                      value: FDEAF
            - name: Services
              widgets:
                - type: honeycomb
                  name: 'Microsoft 365 Services health statuses'
                  width: '72'
                  height: '6'
                  fields:
                    - type: STRING
                      name: items.0
                      value: '*health status'
                    - type: STRING
                      name: primary_label
                      value: '{{ITEM.NAME}.regsub("(Services: )(Microsoft)?(.*)(health status)","\3")}'
                    - type: STRING
                      name: reference
                      value: AAAAF
                    - type: STRING
                      name: thresholds.0.color
                      value: 0EC9AC
                    - type: STRING
                      name: thresholds.0.threshold
                      value: '0'
                    - type: STRING
                      name: thresholds.1.color
                      value: FFD54F
                    - type: STRING
                      name: thresholds.1.threshold
                      value: '1'
                    - type: STRING
                      name: thresholds.2.color
                      value: 2AB5FF
                    - type: STRING
                      name: thresholds.2.threshold
                      value: '2'
                    - type: STRING
                      name: thresholds.3.color
                      value: BAE37D
                    - type: STRING
                      name: thresholds.3.threshold
                      value: '3'
                    - type: STRING
                      name: thresholds.4.color
                      value: 6AC8FF
                    - type: STRING
                      name: thresholds.4.threshold
                      value: '4'
                    - type: STRING
                      name: thresholds.5.color
                      value: 385CC7
                    - type: STRING
                      name: thresholds.5.threshold
                      value: '5'
                    - type: STRING
                      name: thresholds.6.color
                      value: FF465C
                    - type: STRING
                      name: thresholds.6.threshold
                      value: '6'
                    - type: STRING
                      name: thresholds.7.color
                      value: ED1248
                    - type: STRING
                      name: thresholds.7.threshold
                      value: '7'
                    - type: STRING
                      name: thresholds.8.color
                      value: B4B400
                    - type: STRING
                      name: thresholds.8.threshold
                      value: '8'
                    - type: STRING
                      name: thresholds.9.color
                      value: 524BBC
                    - type: STRING
                      name: thresholds.9.threshold
                      value: '9'
                    - type: STRING
                      name: thresholds.10.color
                      value: DC0000
                    - type: STRING
                      name: thresholds.10.threshold
                      value: '10'
      valuemaps:
        - uuid: cb431f0185884aabae7d46890926e724
          name: 'Services health status'
          mappings:
            - value: '0'
              newvalue: Operational
            - value: '1'
              newvalue: Investigating
            - value: '2'
              newvalue: Restoring
            - value: '3'
              newvalue: Verifying
            - value: '4'
              newvalue: Restored
            - value: '5'
              newvalue: 'Review published'
            - value: '6'
              newvalue: Degraded
            - value: '7'
              newvalue: Interruption
            - value: '8'
              newvalue: 'Extended recovery'
            - value: '9'
              newvalue: 'False positive'
            - value: '10'
              newvalue: 'Investigation suspended'
            - value: '11'
              newvalue: Unknown
  graphs:
    - uuid: 31bda44b06aa4776b9827c07c084be32
      name: 'Apps: Office, user count'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.office.user_count.outlook
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.office.user_count.word
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.office.user_count.excel
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.office.user_count.powerpoint
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.office.user_count.onenote
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.office.user_count.teams
    - uuid: 0d20b6626d4e4a99ac7822d2d5bbb0fa
      name: 'Apps: Platform, user count'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.platform.user_count.windows
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.platform.user_count.mac
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.platform.user_count.mobile
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.platform.user_count.web
    - uuid: ce9d576ef0c04c6a80a00b4095b2ed44
      name: 'Apps: Users, by app'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.users.office365
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.users.exchange
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.users.onedrive
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.users.sharepoint
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.users.skype
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.users.yammer
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.apps.users.teams
    - uuid: 26864e4e51db47fa888d70427dc3b48e
      name: 'Copilot: User count, active by app'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.active_user_count.chat
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.active_user_count.outlook
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.active_user_count.word
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.active_user_count.excel
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.active_user_count.powerpoint
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.active_user_count.onenote
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.active_user_count.teams
        - sortorder: '7'
          color: BA2A5D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.active_user_count.loop
    - uuid: 11cfb04aec324542a7b19ebfaf3716ba
      name: 'Copilot: User count, total by app'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.user_count.chat
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.user_count.outlook
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.user_count.word
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.user_count.excel
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.user_count.powerpoint
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.user_count.onenote
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.user_count.teams
        - sortorder: '7'
          color: BA2A5D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.copilot.user_count.loop
    - uuid: e7cf2dc608fb463594298f1c710ba435
      name: 'FortiGate: CPU utilization'
      ymin_type_1: FIXED
      ymax_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'FortiGate by HTTP'
            key: fgate.cpu.util
    - uuid: 1f88c77c5e7f4886af17fa7f3fea69b9
      name: 'FortiGate: Disk usage'
      graph_items:
        - color: 199C0D
          item:
            host: 'FortiGate by HTTP'
            key: fgate.fs.total
        - sortorder: '1'
          color: F63100
          item:
            host: 'FortiGate by HTTP'
            key: fgate.fs.used
        - sortorder: '2'
          color: 00611C
          item:
            host: 'FortiGate by HTTP'
            key: fgate.fs.free
    - uuid: d2419e09ca7a46388a3b7876e1eea09f
      name: 'FortiGate: Disk utilization'
      ymin_type_1: FIXED
      ymax_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'FortiGate by HTTP'
            key: fgate.fs.util
    - uuid: 25a31e8022864e8e95cb6587f3eefdb3
      name: 'FortiGate: Memory utilization'
      ymin_type_1: FIXED
      ymax_type_1: FIXED
      graph_items:
        - color: 199C0D
          item:
            host: 'FortiGate by HTTP'
            key: fgate.memory.util
    - uuid: 1ff7d04868284c07829382c44301fe0e
      name: 'GCP Cloud SQL MSSQL: Disk read/write operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.disk.read_ops_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.disk.write_ops_count
    - uuid: 0ef4b456168d4ecd87c3dc68092c673d
      name: 'GCP Cloud SQL MSSQL: Disk usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.disk.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.disk.bytes_used
    - uuid: 09b009aa17f1410bb926043b4c7c39e4
      name: 'GCP Cloud SQL MSSQL: Memory Read/Writes'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.page_ops.read
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.page_ops.write
    - uuid: 3273bee668e84b26911307ea4c1f620f
      name: 'GCP Cloud SQL MSSQL: Memory usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.usage
    - uuid: 4d5afffa67804f4da73474d2ee26bd5d
      name: 'GCP Cloud SQL MSSQL: Memory workflow'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.checkpoint_page_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.free_list_stall_count
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.lazy_write_count
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.memory.memory_grants_pending
    - uuid: 558283815ab2414f8da6387724a784a3
      name: 'GCP Cloud SQL MSSQL: Network traffic'
      type: STACKED
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.network.received_bytes_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.network.sent_bytes_count
    - uuid: 0bfd3e8be20c4b5a88b23f16aff4eb82
      name: 'GCP Cloud SQL MSSQL: Replication data'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL Replica by HTTP'
            key: gcp.cloudsql.mssql.repl.bytes_sent_to_replica_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL Replica by HTTP'
            key: gcp.cloudsql.mssql.repl.log_bytes_received_count
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL MSSQL Replica by HTTP'
            key: gcp.cloudsql.mssql.repl.redone_bytes_count
    - uuid: 922d35bf685b473ca9848a9b9e7e34c3
      name: 'GCP Cloud SQL MSSQL: Transactions'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.batch_request_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.forwarded_record_count
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.full_scan_count
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.page_split_count
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.probe_scan_count
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.sql_compilation_count
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'GCP Cloud SQL MSSQL by HTTP'
            key: gcp.cloudsql.mssql.trans.sql_recompilation_count
    - uuid: 935c2f388185469f82100541d9efb2c7
      name: 'GCP Cloud SQL MySQL: Disk read/write operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.disk.read_ops_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.disk.write_ops_count
    - uuid: 1b0ea2b38fe740b197ecbcfdd7464b02
      name: 'GCP Cloud SQL MySQL: Disk usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.disk.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.disk.bytes_used
    - uuid: e94b7e8241b544e2beb4ea95db3e139f
      name: 'GCP Cloud SQL MySQL: Lags'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MySQL Replica by HTTP'
            key: gcp.cloudsql.mysql.repl.network_lag
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL Replica by HTTP'
            key: gcp.cloudsql.mysql.repl.replica_lag
    - uuid: 4378be58ccff4592a1b54838b90e9ea8
      name: 'GCP Cloud SQL MySQL: Memory usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.memory.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.memory.usage
    - uuid: c23964e5e54541ccb3c8b7b5f5a4b24d
      name: 'GCP Cloud SQL MySQL: Network traffic'
      type: STACKED
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.network.received_bytes_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.network.sent_bytes_count
    - uuid: e680755183ec4927893e03f8d83bc0f2
      name: 'GCP Cloud SQL MySQL: pages'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_free
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_dirty
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.innodb_buffer_pool_pages_total
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.innodb_pages_read
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.mysql.innodb_pages_written
    - uuid: e447dd13336446b1a965e92d7ddeaf96
      name: 'GCP Cloud SQL MySQL: Queries'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.queries
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL MySQL by HTTP'
            key: gcp.cloudsql.questions
    - uuid: e2e4ef0a2c1a43d68ae9f4ee881f070e
      name: 'GCP Cloud SQL PostgreSQL: Disk read/write operations'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.disk.read_ops_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.disk.write_ops_count
    - uuid: 707d5cca2ba349f18088d00ef7657eef
      name: 'GCP Cloud SQL PostgreSQL: Disk usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.disk.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.disk.bytes_used
    - uuid: 30fe61bafae64ae6b29dacd68e9a6b3b
      name: 'GCP Cloud SQL PostgreSQL: Lags'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.network_lag
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.replica_lag
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.flush_location
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.replay_location
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.sent_location
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.write_location
    - uuid: 897843c1fef540c2ab033c9bad0e9de1
      name: 'GCP Cloud SQL PostgreSQL: Memory usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          calc_fnc: MIN
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.memory.quota
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.memory.usage
    - uuid: 8a61208f44c94cf5bfcb851c4de6412a
      name: 'GCP Cloud SQL PostgreSQL: Network traffic'
      type: STACKED
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.network.received_bytes_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.network.sent_bytes_count
    - uuid: bf09992b7f324703b3d51250e47d37f4
      name: 'GCP Cloud SQL PostgreSQL: Transaction age'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.oldest_transaction.prepared
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.oldest_transaction.replication_slot
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.oldest_transaction.replica
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.oldest_transaction.running
    - uuid: 5c567b9d1ef14fcb93eef332fccbe198
      name: 'GCP Cloud SQL PostgreSQL: Transactions count'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.transaction_id_count_assigned
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL by HTTP'
            key: gcp.cloudsql.pgsql.transaction_id_count_frozen
    - uuid: e96be84efaf7445fbfd8cf707b585fe7
      name: 'GCP Cloud SQL PostgreSQL: WAL archiving'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.log_archive_failure_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Cloud SQL PostgreSQL Replica by HTTP'
            key: gcp.cloudsql.pgsql.repl.log_archive_success_count
    - uuid: aa6edbd13ec74ee4b30de2c68823e6aa
      name: 'GCP Compute Engine: CPU usage'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.cpu.scheduler_wait_time
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.cpu.usage_time
    - uuid: a87f4b9849e34f96b7026f4abc8499a1
      name: 'GCP Compute Engine: Memory swapping'
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.memory.swap_in_bytes_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.memory.swap_out_bytes_count
    - uuid: 5aef2c89a0fa41cd889d87a618cc10bd
      name: 'GCP Compute Engine: Memory usage'
      graph_items:
        - drawtype: BOLD_LINE
          color: 199C0D
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.memory.ram_size
        - sortorder: '1'
          drawtype: GRADIENT_LINE
          color: F63100
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.memory.ram_used
    - uuid: c1c8ebb71d9542ea8b59cef775a6bd65
      name: 'GCP Compute Engine: Network traffic'
      type: STACKED
      graph_items:
        - color: 199C0D
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.firewall.dropped_bytes_count
        - sortorder: '1'
          color: F63100
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.network.lb.received_bytes_count.false
        - sortorder: '2'
          color: 00611C
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.network.lb.received_bytes_count.true
        - sortorder: '3'
          color: F7941D
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.network.lb.sent_bytes_count.false
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.network.lb.sent_bytes_count.true
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'GCP Compute Engine Instance by HTTP'
            key: gcp.gce.network.mirrored_bytes_count
    - uuid: d7ba1bdfe6534c27a0d01cf9a84c7eb6
      name: 'OneDrive: Business sites, active/total'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.sites.total
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.sites.active
    - uuid: 88b75a01c7b541eca8480d821508e9db
      name: 'OneDrive: File count, active/total'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.file_count.total
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.file_count.active
    - uuid: 4d7df5535bf24a3bbe69b823be31bbcf
      name: 'OneDrive: Files, activity'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.files.viewed_or_edited
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.files.synced
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.files.shared_internally
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.files.shared_externally
    - uuid: 6975a23a719f40f2928468331f004617
      name: 'OneDrive: Users, activity'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.users.viewed_or_edited
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.users.synced
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.users.shared_internally
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.onedrive.users.shared_externally
    - uuid: 167557c1299e42d4bf514544ca248bab
      name: 'Outlook: Activity, emails sent/receive/read'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.activity.sent
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.activity.received
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.activity.read
    - uuid: 62ecec3ead3b4fbda519e34cd2f7e59f
      name: 'Outlook: Activity, meetings created/interacted'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.activity.meetings_created
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.activity.meetings_interacted
    - uuid: 410245360e6b4b8abc5578a9fea9aed9
      name: 'Outlook: Mailbox, active/total'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.mailbox.total
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.mailbox.active
    - uuid: e5495197b747402f840a0a36fc2d3822
      name: 'Outlook: User count, app usage'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.mail_for_mac
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.mac
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.windows
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.mobile
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.web
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.pop3app
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.imap4app
        - sortorder: '7'
          color: BA2A5D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.smtpapp
    - uuid: 1820edb683844f5ba7aab911314f9148
      name: 'Outlook: User count, emails sent/receive/read'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.sent
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.received
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.read
    - uuid: 2bc072171a974632ac16f17c55a6e6db
      name: 'Outlook: User count, meetings created/interacted'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.meetings_created
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.outlook.user_count.meetings_interacted
    - uuid: 368ccbec6efc4be0acafc376bed02c86
      name: 'SharePoint: File count, active/total'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.file_count.total
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.file_count.active
    - uuid: 8b74bc9ef37f4126b5c2e570c674c101
      name: 'SharePoint: Files, activity'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.files.viewed_or_edited
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.files.synced
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.files.shared_internally
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.files.shared_externally
    - uuid: d56dec11b20d40adb288f54799d52626
      name: 'SharePoint: Sites, active/total'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.sites.total
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.sites.active
    - uuid: e904e8075548406c8eea9a5576817ef1
      name: 'SharePoint: Users, activity'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.user_count.viewed_or_edited
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.user_count.synced
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.user_count.shared_internally
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.user_count.shared_externally
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.sharepoint.user_count.visited_page
    - uuid: 2c9b134db13844f59054cc81b2135edc
      name: 'Teams: Device usage (guests), by device type'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.guests.web
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.guests.android
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.guests.ios
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.guests.mac
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.guests.windows
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.guests.chromeos
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.guests.linux
    - uuid: e2c59d05b05c4a32aa027cfb6d2c2f67
      name: 'Teams: Device usage (total), by device type'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.total.web
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.total.android
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.total.ios
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.total.mac
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.total.windows
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.total.chromeos
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.total.linux
    - uuid: 072347b5896d477ea875520211e7d71b
      name: 'Teams: Device usage (users), by device type'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.users.web
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.users.android
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.users.ios
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.users.mac
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.users.windows
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.users.chromeos
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.device.users.linux
    - uuid: 7535ecb32e0147d686562ba988d3c655
      name: 'Teams: User activity, audio/video/screen share duration'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.activity.user.duration.audio
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.activity.user.duration.video
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.activity.user.duration.screen_share
    - uuid: fcb3abcbd08b48db85b065ebf90ae9b8
      name: 'Teams: User count (total), by activity'
      graph_items:
        - color: 199C0D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.user_count.total.messages.in_team
        - sortorder: '1'
          color: F63100
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.user_count.total.messages.private
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.user_count.total.calls
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Microsoft 365 reports by HTTP'
            key: ms365.teams.user_count.total.meetings
