zabbix_export:
  version: '7.0'
  template_groups:
    - uuid: c2c162144c2d4c5491c8801193af4945
      name: Templates/Cloud
  host_groups:
    - uuid: 748ad4d098d447d492bb935c907f652f
      name: Databases
    - uuid: 137f19e6e2dc4219b33553b812627bc2
      name: 'Virtual machines'
  templates:
    - uuid: fa58228fee8a4e34a7c6503950d1c615
      template: 'Azure by HTTP'
      name: 'Azure by HTTP'
      description: |
        This template is designed to monitor Microsoft Azure by HTTP.
        It works without any external scripts and uses the script item.
        Currently the template supports the discovery of virtual machines (VMs), Cosmos DB for MongoDB, storage accounts, Microsoft SQL, MySQL, and PostgreSQL servers.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: `{$AZURE.APP.ID}`, `{$AZURE.PASSWORD}`, `{$AZURE.TENANT.ID}`, and `{$AZURE.SUBSCRIPTION.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 7b2fe9a7ee164718933eb456b0068fea
          name: 'Get errors'
          type: DEPENDENT
          key: azure.get.errors
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.errors
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.get.resources
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: 502cb582546046a29267715763c46bff
              expression: 'length(last(/Azure by HTTP/azure.get.errors))>0'
              name: '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: fb6abf3631b240b08357ea9ce9ba89a4
          name: 'Get resources'
          type: SCRIPT
          key: azure.get.resources
          delay: 10m
          history: '0'
          value_type: TEXT
          params: |
            var Azure = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		Azure.params = params;
            	},
            
            	request: function (url, data) {
            		if (typeof data === 'undefined' || data === null) {
            			data = '';
            		}
            		var response, request = new HttpRequest();
            		if (typeof Azure.params.proxy !== 'undefined' && Azure.params.proxy !== '') {
            			request.setProxy(Azure.params.proxy);
            		}
            		if (Azure.token) {
            			request.addHeader('Accept: application/json');
            			request.addHeader('Authorization: Bearer ' + Azure.token);
            		}
            
            		Zabbix.log(4, '[ Azure ] Sending request: ' + url);
            
            		if (data !== '') {
            			request.addHeader('Content-Type: application/x-www-form-urlencoded');
            			response = request.post(url, data);
            		}
            		else {
            			response = request.get(url);
            		}
            
            		Zabbix.log(4, '[ Azure ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200 || response === null) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	},
            
            	nextlink: function (data) {
            		next_data = data;
            		while ('nextLink' in next_data) {
            			next_data = Azure.request(next_data.nextLink);
            			next_data.value.forEach(function (value) {
            				data.value.push(value);
            			});
            		}
            
            		return data;
            	}
            };
            
            var result,
            	data = {},
            	types = [
            		{"method": "Microsoft.Compute/virtualMachines", "version": "2022-03-01"},
            		{"method": "Microsoft.DBforMySQL/flexibleServers", "version": "2021-05-01"},
            		{"method": "Microsoft.DBforMySQL/servers", "version": "2017-12-01"},
            		{"method": "Microsoft.DBforPostgreSQL/flexibleServers", "version": "2021-06-01"},
            		{"method": "Microsoft.DBforPostgreSQL/servers", "version": "2017-12-01"},
            		{"method": "Microsoft.Sql/servers", "version": "2022-05-01-preview"},
            		{"method": "Microsoft.DocumentDB/databaseAccounts", "version": "2022-11-15-preview"},
            		{"method": "Microsoft.Compute/virtualMachineScaleSets", "version": "2024-03-01"}
            	];
            	data['errors'] = {},
            	data['resources'] = {};
            	data.resources.value = [];
            
            try {
            	Azure.setParams(JSON.parse(value));
            
            	try {
            		result = Azure.request(
            			'https://login.microsoftonline.com/' + encodeURIComponent(Azure.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(Azure.params.app_id) + '&client_secret=' + encodeURIComponent(Azure.params.password)
            		);
            
            		if ('access_token' in result) {
            			Azure.token = result['access_token'];
            		} else {
            			throw 'Auth response does not contain access token.';
            		}
            	}
            	catch (error) {
            		data.errors.auth = error.toString();
            	}
            
            	if (!('auth' in data.errors)) {
            		try {
            			for (var i in types) {
            				if (types[i].method === "Microsoft.Sql/servers") {
            					mssql_servers = Azure.request('https://management.azure.com/subscriptions/' + encodeURIComponent(Azure.params.subscription_id) + '/providers/' + types[i].method + '?api-version=' + types[i].version);
            
            					if ('nextLink' in mssql_servers) {
            						mssql_servers = Azure.nextlink(mssql_servers);
            					}
            
            					if ('value' in mssql_servers && mssql_servers.value.length > 0) {
            						for (j in mssql_servers.value) {
            							mssql_dbs = Azure.request('https://management.azure.com' + mssql_servers.value[j].id + '/databases?api-version=' + types[i].version);
            
            							if ('nextLink' in mssql_dbs) {
            								mssql_dbs = Azure.nextlink(mssql_dbs);
            							}
            
            							mssql_dbs.value.forEach(function (value) {
            								raw_data.value.push(value);
            							});
            						}
            					}
            				}
            				else {
            					raw_data = Azure.request('https://management.azure.com/subscriptions/' + encodeURIComponent(Azure.params.subscription_id) + '/providers/' + types[i].method + '?api-version=' + types[i].version);
            
            					if ('nextLink' in raw_data) {
            						raw_data = Azure.nextlink(raw_data);
            					}
            				}
            
            				raw_data.value.forEach(function (value) {
            					value.resourceGroup = value.id.split("/")[4];
            					data.resources.value.push(value);
            				});
            			}
            		}
            		catch (error) {
            			data.errors.resources = error.toString();
            		}
            	}
            }
            catch (error) {
            	data.errors.params = error.toString();
            }
            
            if (Object.keys(data.errors).length !== 0) {
            	errors = 'Failed to receive data:';
            	for (var error in data.errors) {
            		errors += '\n' + error + ' : ' + data.errors[error];
            	}
            	data.errors = errors;
            }
            else {
            	data.errors = '';
            }
            
            return JSON.stringify(data);
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: 91b2290d65b949ad9ea801763c35cf40
          name: 'Get storage accounts'
          type: SCRIPT
          key: azure.get.storage.acc
          delay: 10m
          history: '0'
          value_type: TEXT
          params: |
            var Azure = {
            	params: {},
            	token: '',
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		Azure.params = params;
            	},
            
            	login: function () {
            		var response, login = new HttpRequest();
            		if (typeof Azure.params.proxy !== 'undefined' && Azure.params.proxy !== '') {
            			login.setProxy(Azure.params.proxy);
            		}
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(Azure.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(Azure.params.app_id) + '&client_secret=' + encodeURIComponent(Azure.params.password)
            		);
            
            		if (login.getStatus() !== 200) {
            			throw 'Login failed with status code ' + login.getStatus() + ': ' + response;
            		}
            		try {
            			response = JSON.parse(response);
            			if (!response.hasOwnProperty('access_token')) {
            				throw null;
            			}
            		}
            		catch (error) {
            			throw 'Authentication response does not contain access token.';
            		}
            
            		Azure.token = response['access_token'];
            	},
            
            	request: function (url) {
            		var response, request = new HttpRequest();
            		if (typeof Azure.params.proxy !== 'undefined' && Azure.params.proxy !== '') {
            			request.setProxy(Azure.params.proxy);
            		}
            		if (!Azure.token) {
            			throw 'Request does not contain access token.';
            		}
            		request.addHeader('Accept: application/json');
            		request.addHeader('Authorization: Bearer ' + Azure.token);
            		response = request.get(url);
            
            		if (request.getStatus() !== 200) {
            			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) {
            		var steps = path.split('.');
            		for (var i = 0; i < steps.length; i++) {
            			var step = steps[i];
            			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            				throw 'Required field was not found: ' + path;
            			}
            
            			data = data[step];
            		}
            
            		return data;
            	},
            
            	getMetricsData: function () {
            		var metric = Azure.request('https://management.azure.com/subscriptions/' + encodeURIComponent(Azure.params.subscription_id) + '/providers/Microsoft.Storage/storageAccounts?api-version=2021-05-01'),
            			data = [];
            
            		if (!metric.hasOwnProperty('value')) {
            			throw 'Failed getting required field. Check debug log for more information.';
            		}
            		for (k in metric.value) {
            			id = Azure.getField(metric.value[k], 'id');
            			json = {};
            			input = id.split('/');
            			for (var i = 1; i < input.length; i += 2) {
            				json[input[i]] = input[i + 1];
            			}
            			data.push({
            				'name': Azure.getField(metric.value[k], 'name'),
            				'id': id,
            				'resourceGroup': Azure.getField(json, 'resourceGroups'),
            				'location': Azure.getField(metric.value[k], 'location'),
            				'token': Azure.token
            			});
            		}
            
            		return data;
            	}
            };
            
            try {
            	Azure.setParams(JSON.parse(value));
            	Azure.login();
            	return JSON.stringify(Azure.getMetricsData());
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ Azure ] ERROR: ' + error);
            	return JSON.stringify({'error': error});
            }
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: 2e425a9ef8d34ea68f7998ceed30ebc4
          name: 'Get storage accounts errors'
          type: DEPENDENT
          key: azure.get.storage.acc.errors
          value_type: TEXT
          description: 'The errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.get.storage.acc
          tags:
            - tag: component
              value: status
          triggers:
            - uuid: 253f0835cd134d2591bb2be1b9dc9b29
              expression: 'length(last(/Azure by HTTP/azure.get.storage.acc.errors))>0'
              name: 'There are errors in storages requests to API'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Zabbix has received errors in response to API requests.'
              dependencies:
                - name: 'There are errors in requests to API'
                  expression: 'length(last(/Azure by HTTP/azure.get.errors))>0'
              tags:
                - tag: scope
                  value: availability
      discovery_rules:
        - uuid: 3bfbfc8d770a4c77a17d62aaebb55e64
          name: 'Cosmos DB account discovery'
          type: DEPENDENT
          key: azure.cosmos.mongo.db.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#LOCATION}'
                value: '{$AZURE.COSMOS.MONGO.DB.LOCATION.MATCHES}'
              - macro: '{#LOCATION}'
                value: '{$AZURE.COSMOS.MONGO.DB.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#NAME}'
                value: '{$AZURE.COSMOS.MONGO.DB.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$AZURE.COSMOS.MONGO.DB.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#TYPE}'
                value: ^Microsoft.DocumentDB/databaseAccounts
          description: 'The list of the Cosmos databases is provided by the subscription.'
          host_prototypes:
            - uuid: 16eec30e921e4627b3599b4d06e48072
              host: 'Azure Cosmos DB {#NAME}'
              name: 'Azure Cosmos DB {#NAME}'
              group_links:
                - group:
                    name: Databases
              macros:
                - macro: '{$AZURE.RESOURCE.ID}'
                  value: '{#ID}'
              tags:
                - tag: location
                  value: '{#LOCATION}'
                - tag: resource-group
                  value: '{#GROUP}'
                - tag: version
                  value: '{#VERSION}'
          master_item:
            key: azure.get.resources
          lld_macro_paths:
            - lld_macro: '{#GROUP}'
              path: $.resourceGroup
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#LOCATION}'
              path: $.location
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#TYPE}'
              path: $.type
            - lld_macro: '{#VERSION}'
              path: $.kind
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.resources.value
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          overrides:
            - name: MongoDB
              step: '1'
              filter:
                conditions:
                  - macro: '{#VERSION}'
                    value: ^MongoDB$
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  templates:
                    - name: 'Azure Cosmos DB for MongoDB by HTTP'
        - uuid: c875a410ddd84ccfbc5b407cd6e34803
          name: 'Microsoft SQL databases discovery'
          type: DEPENDENT
          key: azure.mssql.databases.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#LOCATION}'
                value: '{$AZURE.MSSQL.DB.LOCATION.MATCHES}'
              - macro: '{#LOCATION}'
                value: '{$AZURE.MSSQL.DB.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#NAME}'
                value: '{$AZURE.MSSQL.DB.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$AZURE.MSSQL.DB.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#SIZE}'
                value: '{$AZURE.MSSQL.DB.SIZE.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#TYPE}'
                value: ^Microsoft.Sql/servers/databases
          description: 'The list of the Microsoft SQL databases is provided by the subscription.'
          host_prototypes:
            - uuid: 2aaf7dc7e9f04ccf9dd91fcd803fa076
              host: 'Azure Microsoft SQL database {#NAME}'
              name: 'Azure Microsoft SQL database {#NAME}'
              group_links:
                - group:
                    name: Databases
              macros:
                - macro: '{$AZURE.RESOURCE.ID}'
                  value: '{#ID}'
              tags:
                - tag: location
                  value: '{#LOCATION}'
                - tag: resource-group
                  value: '{#GROUP}'
                - tag: size
                  value: '{#SIZE}'
                - tag: version
                  value: '{#VERSION}'
          master_item:
            key: azure.get.resources
          lld_macro_paths:
            - lld_macro: '{#GROUP}'
              path: $.resourceGroup
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#LOCATION}'
              path: $.location
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#SIZE}'
              path: $.sku.name
            - lld_macro: '{#TYPE}'
              path: $.type
            - lld_macro: '{#VERSION}'
              path: $.kind
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.resources.value
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          overrides:
            - name: Serverless
              step: '1'
              filter:
                conditions:
                  - macro: '{#VERSION}'
                    value: '^.*serverless$'
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  templates:
                    - name: 'Azure Microsoft SQL Serverless Database by HTTP'
            - name: Server
              step: '2'
              filter:
                conditions:
                  - macro: '{#VERSION}'
                    value: '^((?!serverless).)*$'
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  templates:
                    - name: 'Azure Microsoft SQL Database by HTTP'
        - uuid: 7fafbef68f8b46d083eb43da7cd1e2cc
          name: 'MySQL servers discovery'
          type: DEPENDENT
          key: azure.mysql.servers.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#LOCATION}'
                value: '{$AZURE.MYSQL.DB.LOCATION.MATCHES}'
              - macro: '{#LOCATION}'
                value: '{$AZURE.MYSQL.DB.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#NAME}'
                value: '{$AZURE.MYSQL.DB.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$AZURE.MYSQL.DB.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#TYPE}'
                value: ^Microsoft.DBforMySQL
          description: 'The list of the MySQL servers is provided by the subscription.'
          host_prototypes:
            - uuid: 55b87078c14c4561b53e64af5ed77d61
              host: 'Azure MySQL server {#NAME}'
              name: 'Azure MySQL server {#NAME}'
              group_links:
                - group:
                    name: Databases
              macros:
                - macro: '{$AZURE.RESOURCE.ID}'
                  value: '{#ID}'
              tags:
                - tag: location
                  value: '{#LOCATION}'
                - tag: resource-group
                  value: '{#GROUP}'
                - tag: size
                  value: '{#SIZE}'
                - tag: version
                  value: '{#VERSION}'
          master_item:
            key: azure.get.resources
          lld_macro_paths:
            - lld_macro: '{#GROUP}'
              path: $.resourceGroup
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#LOCATION}'
              path: $.location
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#SIZE}'
              path: $.sku.name
            - lld_macro: '{#TYPE}'
              path: $.type
            - lld_macro: '{#VERSION}'
              path: $.properties.version
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.resources.value
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          overrides:
            - name: 'Flexible server'
              step: '1'
              filter:
                conditions:
                  - macro: '{#TYPE}'
                    value: Microsoft.DBforMySQL/flexibleServers
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  templates:
                    - name: 'Azure MySQL Flexible Server by HTTP'
            - name: 'Single server'
              step: '2'
              filter:
                conditions:
                  - macro: '{#TYPE}'
                    value: Microsoft.DBforMySQL/servers
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  templates:
                    - name: 'Azure MySQL Single Server by HTTP'
        - uuid: a4b35b5fe8c04b52a9640f2f41013230
          name: 'PostgreSQL servers discovery'
          type: DEPENDENT
          key: azure.pgsql.servers.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#LOCATION}'
                value: '{$AZURE.PGSQL.DB.LOCATION.MATCHES}'
              - macro: '{#LOCATION}'
                value: '{$AZURE.PGSQL.DB.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#NAME}'
                value: '{$AZURE.PGSQL.DB.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$AZURE.PGSQL.DB.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#TYPE}'
                value: ^Microsoft.DBforPostgreSQL
          description: 'The list of the PostgreSQL servers is provided by the subscription.'
          host_prototypes:
            - uuid: 54f0e0ec288f4feb9a2dc58a8726bd1d
              host: 'Azure PostgreSQL server {#NAME}'
              name: 'Azure PostgreSQL server {#NAME}'
              group_links:
                - group:
                    name: Databases
              macros:
                - macro: '{$AZURE.RESOURCE.ID}'
                  value: '{#ID}'
              tags:
                - tag: location
                  value: '{#LOCATION}'
                - tag: resource-group
                  value: '{#GROUP}'
                - tag: size
                  value: '{#SIZE}'
                - tag: version
                  value: '{#VERSION}'
          master_item:
            key: azure.get.resources
          lld_macro_paths:
            - lld_macro: '{#GROUP}'
              path: $.resourceGroup
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#LOCATION}'
              path: $.location
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#SIZE}'
              path: $.sku.name
            - lld_macro: '{#TYPE}'
              path: $.type
            - lld_macro: '{#VERSION}'
              path: $.properties.version
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.resources.value
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
          overrides:
            - name: 'Flexible server'
              step: '1'
              filter:
                conditions:
                  - macro: '{#TYPE}'
                    value: Microsoft.DBforPostgreSQL/flexibleServers
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  templates:
                    - name: 'Azure PostgreSQL Flexible Server by HTTP'
            - name: 'Single server'
              step: '2'
              filter:
                conditions:
                  - macro: '{#TYPE}'
                    value: Microsoft.DBforPostgreSQL/servers
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  templates:
                    - name: 'Azure PostgreSQL Single Server by HTTP'
        - uuid: 006fc1e9e61d45c5a795a251a3237983
          name: 'Virtual machine scale set discovery'
          type: DEPENDENT
          key: azure.scaleset.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#LOCATION}'
                value: '{$AZURE.SCALESET.LOCATION.MATCHES}'
              - macro: '{#LOCATION}'
                value: '{$AZURE.SCALESET.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#NAME}'
                value: '{$AZURE.SCALESET.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$AZURE.SCALESET.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#TYPE}'
                value: ^Microsoft.Compute/virtualMachineScaleSets$
          description: 'The list of the virtual machine scale sets provided by the subscription.'
          host_prototypes:
            - uuid: 1cbeb513fe3648b6829836800952c9c7
              host: 'Azure VM scale set {#NAME}'
              name: 'Azure VM scale set {#NAME}'
              group_links:
                - group:
                    name: 'Virtual machines'
              templates:
                - name: 'Azure VM Scale Set by HTTP'
              macros:
                - macro: '{$AZURE.RESOURCE.ID}'
                  value: '{#ID}'
              tags:
                - tag: location
                  value: '{#LOCATION}'
                - tag: orchestration
                  value: '{#ORCHESTRATION}'
                - tag: os
                  value: '{#OS}'
                - tag: resource-group
                  value: '{#GROUP}'
          master_item:
            key: azure.get.resources
          lld_macro_paths:
            - lld_macro: '{#GROUP}'
              path: $.resourceGroup
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#LOCATION}'
              path: $.location
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#ORCHESTRATION}'
              path: $.properties.orchestrationMode
            - lld_macro: '{#OS}'
              path: $.properties.virtualMachineProfile.storageProfile.osDisk.osType
            - lld_macro: '{#TYPE}'
              path: $.type
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.resources.value
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
        - uuid: 3b9bde32dd6b4e3aa2dd8d7949f655e9
          name: 'Storage accounts discovery'
          type: DEPENDENT
          key: azure.storage.acc.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#LOCATION}'
                value: '{$AZURE.STORAGE.ACC.LOCATION.MATCHES}'
              - macro: '{#LOCATION}'
                value: '{$AZURE.STORAGE.ACC.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#NAME}'
                value: '{$AZURE.STORAGE.ACC.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$AZURE.STORAGE.ACC.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'The list of all storage accounts available under the subscription.'
          item_prototypes:
            - uuid: 3361508a601748f5aca339f952430889
              name: 'Storage account [{#NAME}]: Get data'
              type: SCRIPT
              key: 'azure.get.storage.acc[{#NAME}]'
              history: '0'
              value_type: TEXT
              params: |
                var AzureStorage = {
                	params: {},
                
                	setParams: function (params) {
                		['token', 'id'].forEach(function (field) {
                			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
                				throw 'Required param is not set: ' + field + '.';
                			}
                		});
                
                		AzureStorage.params = params;
                	},
                
                	request: function (url) {
                		var response, request = new HttpRequest();
                		if (typeof AzureStorage.params.proxy !== 'undefined' && AzureStorage.params.proxy !== '') {
                			request.setProxy(AzureStorage.params.proxy);
                		}
                		request.addHeader('Accept: application/json');
                		request.addHeader('Authorization: Bearer ' + AzureStorage.params.token);
                		Zabbix.log(4, '[ Azure ] Sending request: ' + url);
                		response = request.get(url);
                		if (request.getStatus() !== 200) {
                			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) {
                		var steps = path.split('.');
                		for (var i = 0; i < steps.length; i++) {
                			var step = steps[i];
                			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
                				throw 'Required field was not found: ' + path + ' input data: ' + JSON.stringify(data);
                			}
                
                			data = data[step];
                		}
                
                		return data;
                	},
                
                	getMetricsData: function () {
                		var data = {};
                		start_date = new Date((new Date().getTime()) - 4200000).toISOString().replace(/\.\d+/, '');
                		end_date = new Date((new Date().getTime()) - 600000).toISOString().replace(/\.\d+/, '');
                		endpoints = {
                			'tableServices': '/tableServices/default/providers/Microsoft.Insights/metrics?metricnames=TableCapacity,TableCount,TableEntityCount,Transactions,Ingress,Egress,SuccessServerLatency,SuccessE2ELatency,Availability&api-version=2021-05-01&interval=PT1H&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date),
                			'blobServices': '/blobServices/default/providers/Microsoft.Insights/metrics?metricnames=BlobCapacity,BlobCount,ContainerCount,IndexCapacity,Transactions,Ingress,Egress,SuccessServerLatency,SuccessE2ELatency,Availability&api-version=2021-05-01&interval=PT1H&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date),
                			'fileServices': '/fileServices/default/providers/Microsoft.Insights/metrics?metricnames=FileCapacity,FileCount,FileShareCount,FileShareSnapshotCount,FileShareSnapshotSize,FileShareCapacityQuota,Transactions,Ingress,Egress,SuccessServerLatency,SuccessE2ELatency,Availability&api-version=2021-05-01&interval=PT1H&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date),
                			'storageAccount': '/providers/Microsoft.Insights/metrics?metricnames=UsedCapacity,Transactions,Ingress,Egress,SuccessServerLatency,SuccessE2ELatency,Availability&api-version=2021-05-01&interval=PT1H&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date),
                			'queueServices': '/queueServices/default/providers/Microsoft.Insights/metrics?metricnames=QueueCapacity,QueueCount,QueueMessageCount,Transactions,Ingress,Egress,SuccessServerLatency,SuccessE2ELatency,Availability&api-version=2021-05-01&interval=PT1H&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date)
                		};
                
                		Object.keys(endpoints).forEach(function (field) {
                			data[field] = {};
                			metrics = AzureStorage.request('https://management.azure.com' + AzureStorage.params.id + endpoints[field]);
                
                			if (!metrics.hasOwnProperty('value')) {
                				throw 'Failed getting required field. Check debug log for more information.';
                			}
                
                			for (k in metrics.value) {
                				key = AzureStorage.getField(metrics.value[k], 'name.value')
                				if (metrics.value[k].timeseries.length === 0) {
                					metrics.value[k].timeseries.push({ 'data': ['nodata'] })
                				}
                				data[field][key] = AzureStorage.getField(metrics.value[k], 'timeseries.0.data.0');
                			}
                		});
                		return data
                	}
                
                };
                
                try {
                	AzureStorage.setParams(JSON.parse(value));
                	return JSON.stringify(AzureStorage.getMetricsData());
                }
                catch (error) {
                	error += (String(error).endsWith('.')) ? '' : '.';
                	Zabbix.log(3, '[ Azure ] ERROR: ' + error);
                	return JSON.stringify({ 'error': error });
                }
              description: 'The HTTP API endpoint that returns storage metrics with the name `[{#NAME}]`.'
              timeout: '{$AZURE.DATA.TIMEOUT}'
              parameters:
                - name: id
                  value: '{#ID}'
                - name: proxy
                  value: '{$AZURE.PROXY}'
                - name: token
                  value: '{#TOKEN}'
              tags:
                - tag: component
                  value: raw
                - tag: component
                  value: storages
                - tag: storage
                  value: '{#NAME}'
            - uuid: 08ce66b39b084182bdb60a5556b88c88
              name: 'Storage account [{#NAME}]: Availability'
              type: DEPENDENT
              key: 'azure.storage.availability[{#NAME}]'
              value_type: FLOAT
              units: '%'
              description: |
                The percentage of availability for the storage service or a specified API operation.
                Availability is calculated by taking the `TotalBillableRequests` value and dividing it by the number of applicable requests, including those that produced unexpected errors.
                All unexpected errors result in reduced availability for the storage service or the specified API operation.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.storageAccount.Availability.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: common
                - tag: storage
                  value: '{#NAME}'
              trigger_prototypes:
                - uuid: 6a0b3edebded4d848ad76f86f8152377
                  expression: '(min(/Azure by HTTP/azure.storage.availability[{#NAME}],#3))<{$AZURE.STORAGE.ACC.AVAILABILITY:"{#NAME}"}'
                  name: 'Storage account [{#NAME}]: Availability is low'
                  event_name: 'Storage account [{#NAME} availability is too low (less than {$AZURE.STORAGE.ACC.AVAILABILITY:"{#NAME}"}%)'
                  opdata: '{ITEM.LASTVALUE1}'
                  priority: WARNING
                  tags:
                    - tag: scope
                      value: availability
            - uuid: 9ae0af76a37047f5ba84de2f43dfb5c4
              name: 'Storage account [{#NAME}]: Blob Availability'
              type: DEPENDENT
              key: 'azure.storage.blob.availability[{#NAME}]'
              value_type: FLOAT
              units: '%'
              description: |
                The percentage of availability for the storage service or a specified API operation.
                Availability is calculated by taking the `TotalBillableRequests` value and dividing it by the number of applicable requests, including those that produced unexpected errors.
                All unexpected errors result in reduced availability for the storage service or the specified API operation.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blobServices.Availability.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: blob
                - tag: storage
                  value: '{#NAME}'
              trigger_prototypes:
                - uuid: 4cd8ac56b50c4120bf9de56bb1f06245
                  expression: '(min(/Azure by HTTP/azure.storage.blob.availability[{#NAME}],#3))<{$AZURE.STORAGE.ACC.BLOB.AVAILABILITY:"{#NAME}"}'
                  name: 'Storage account [{#NAME}]: Blob Availability is low'
                  event_name: 'Storage account [{#NAME} blob availability are too low (less than {$AZURE.STORAGE.ACC.BLOB.AVAILABILITY:"{#NAME}"}%)'
                  opdata: '{ITEM.LASTVALUE1}'
                  priority: WARNING
                  tags:
                    - tag: scope
                      value: availability
            - uuid: c6437ade4fee44f783ab379fb179508d
              name: 'Storage account [{#NAME}]: Blob Capacity'
              type: DEPENDENT
              key: 'azure.storage.blob.capacity[{#NAME}]'
              value_type: FLOAT
              units: B
              description: 'The amount of storage used by the blob service of the storage account with the name `[{#NAME}]`, expressed in bytes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blobServices.BlobCapacity.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: blob
                - tag: storage
                  value: '{#NAME}'
            - uuid: 707be15f02a141548ce5f89097c303a0
              name: 'Storage account [{#NAME}]: Blob Container Count'
              type: DEPENDENT
              key: 'azure.storage.blob.container.count[{#NAME}]'
              description: 'The number of containers in the storage account with the name `[{#NAME}]`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blobServices.ContainerCount.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: blob
                - tag: storage
                  value: '{#NAME}'
            - uuid: 9bd8b8f1b5844298a245d449548de46e
              name: 'Storage account [{#NAME}]: Blob Count'
              type: DEPENDENT
              key: 'azure.storage.blob.count[{#NAME}]'
              description: 'The number of blob objects stored in the storage account with the name `[{#NAME}]`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blobServices.BlobCount.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: blob
                - tag: storage
                  value: '{#NAME}'
            - uuid: ae28bbd289644619b20b1907212d8293
              name: 'Storage account [{#NAME}]: Blob Egress'
              type: DEPENDENT
              key: 'azure.storage.blob.engress[{#NAME}]'
              value_type: FLOAT
              units: B
              description: |
                The amount of egress data. This number includes egress to external client from Azure Storage and also egress within Azure.
                As a result, this number does not reflect billable egress.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blobServices.Egress.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: blob
                - tag: storage
                  value: '{#NAME}'
            - uuid: 8e73a2aba92444dd9c02c6f94227a4e5
              name: 'Storage account [{#NAME}]: Blob Index Capacity'
              type: DEPENDENT
              key: 'azure.storage.blob.index.capacity[{#NAME}]'
              value_type: FLOAT
              units: B
              description: 'The amount of storage with the name `[{#NAME}]` used by the Azure Data Lake Storage Gen2 hierarchical index.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blobServices.IndexCapacity.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: blob
                - tag: storage
                  value: '{#NAME}'
            - uuid: ff40325efb174839bef7bc775049837e
              name: 'Storage account [{#NAME}]: Blob Ingress'
              type: DEPENDENT
              key: 'azure.storage.blob.ingress[{#NAME}]'
              value_type: FLOAT
              units: B
              description: 'The amount of ingress data, expressed in bytes. This number includes ingress from an external client into Azure Storage and also ingress within Azure.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blobServices.Ingress.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: blob
                - tag: storage
                  value: '{#NAME}'
            - uuid: e17d6f2ed79c4b5eaa54730c82d6840f
              name: 'Storage account [{#NAME}]: Blob Success E2E Latency'
              type: DEPENDENT
              key: 'azure.storage.blob.success.e2e.latency[{#NAME}]'
              value_type: FLOAT
              units: s
              description: |
                The average end-to-end latency of successful requests made to a storage service or the specified API operation, expressed in milliseconds.
                This value includes the required processing time within Azure Storage to read the request, send the response, and receive acknowledgment of the response.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blobServices.SuccessE2ELatency.average
                  error_handler: DISCARD_VALUE
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: blob
                - tag: storage
                  value: '{#NAME}'
            - uuid: 727fb792fe5c4229995f7aa5bbb681ed
              name: 'Storage account [{#NAME}]: Blob Success Server Latency'
              type: DEPENDENT
              key: 'azure.storage.blob.success.server.latency[{#NAME}]'
              value_type: FLOAT
              units: s
              description: |
                The average time used to process a successful request by Azure Storage.
                This value does not include the network latency specified in `SuccessE2ELatency`.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blobServices.SuccessServerLatency.average
                  error_handler: DISCARD_VALUE
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: blob
                - tag: storage
                  value: '{#NAME}'
            - uuid: 48ecb880def34474b73a03eb895db3ea
              name: 'Storage account [{#NAME}]: Blob Transactions'
              type: DEPENDENT
              key: 'azure.storage.blob.transactions[{#NAME}]'
              description: |
                The number of requests made to the storage service or a specified API operation.
                This number includes successful and failed requests and also requests that produced errors.
                Use `ResponseType` dimension for the number of different types of responses.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.blobServices.Transactions.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: blob
                - tag: storage
                  value: '{#NAME}'
            - uuid: 4198807e1e08439a9009481ddcfd3bab
              name: 'Storage account [{#NAME}]: Egress'
              type: DEPENDENT
              key: 'azure.storage.engress[{#NAME}]'
              value_type: FLOAT
              units: B
              description: |
                The amount of egress data. This number includes egress to external client from Azure Storage and also egress within Azure.
                As a result, this number does not reflect billable egress.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.storageAccount.Egress.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: common
                - tag: storage
                  value: '{#NAME}'
            - uuid: 43069f165849449d8403d1a8c82fe634
              name: 'Storage account [{#NAME}]: File Capacity'
              type: DEPENDENT
              key: 'azure.storage.file.capacity[{#NAME}]'
              value_type: FLOAT
              units: B
              description: 'The amount of file storage used by the storage account with the name `[{#NAME}]`, expressed in bytes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.FileCapacity.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: 3483741c11a141c2866ea58a74a91135
              name: 'Storage account [{#NAME}]: File Count'
              type: DEPENDENT
              key: 'azure.storage.file.count[{#NAME}]'
              description: 'The number of files in the storage account with the name `[{#NAME}]`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.FileCount.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: 7f6d01573bf24d9889f41a14cb581075
              name: 'Storage account [{#NAME}]: File Egress'
              type: DEPENDENT
              key: 'azure.storage.file.engress[{#NAME}]'
              value_type: FLOAT
              units: B
              description: |
                The amount of egress data. This number includes egress to external client from Azure Storage and also egress within Azure.
                As a result, this number does not reflect billable egress.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.Egress.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: 9f9b6772f9d9478ba3be3a93c5408ba2
              name: 'Storage account [{#NAME}]: File Ingress'
              type: DEPENDENT
              key: 'azure.storage.file.ingress[{#NAME}]'
              value_type: FLOAT
              units: B
              description: 'The amount of ingress data, expressed in bytes. This number includes ingress from an external client into Azure Storage and also ingress within Azure.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.Ingress.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: 4cb60e5473ce46a08bc962dc97c1f4db
              name: 'Storage account [{#NAME}]: File Share Capacity Quota'
              type: DEPENDENT
              key: 'azure.storage.file.share.capacity.quota[{#NAME}]'
              units: B
              description: 'The upper limit on the amount of storage that can be used by Azure Files Service, in bytes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.FileShareCapacityQuota.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: 220673a2e99a4108b034d04d79108231
              name: 'Storage account [{#NAME}]: File Share Count'
              type: DEPENDENT
              key: 'azure.storage.file.share.count[{#NAME}]'
              description: 'The number of file shares in the storage account.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.FileShareCount.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: 47c48f39b9744a92ac13e9db69f6e629
              name: 'Storage account [{#NAME}]: File Share Snapshot Size'
              type: DEPENDENT
              key: 'azure.storage.file.share.snapshot.size[{#NAME}]'
              units: B
              description: 'The amount of storage used by the snapshots in storage account''s File service, in bytes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.FileShareSnapshotSize.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: f0394f8f2d55471c8ab557045349a6ec
              name: 'Storage account [{#NAME}]: File Share Snapshot Count'
              type: DEPENDENT
              key: 'azure.storage.file.shares.snapshot.count[{#NAME}]'
              description: 'The number of snapshots present on the share in storage account''s Files Service.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.FileShareSnapshotCount.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: 431a6c51418d401697d105a0d9b62d23
              name: 'Storage account [{#NAME}]: File Success E2E Latency'
              type: DEPENDENT
              key: 'azure.storage.file.success.e2e.latency[{#NAME}]'
              value_type: FLOAT
              units: s
              description: |
                The average end-to-end latency of successful requests made to a storage service or the specified API operation, expressed in milliseconds.
                This value includes the required processing time within Azure Storage to read the request, send the response, and receive acknowledgment of the response.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.file.SuccessE2ELatency.average
                  error_handler: DISCARD_VALUE
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: 43b6c0b948f64d9daada7aaac520c839
              name: 'Storage account [{#NAME}]: File Success Server Latency'
              type: DEPENDENT
              key: 'azure.storage.file.success.server.latency[{#NAME}]'
              value_type: FLOAT
              units: s
              description: |
                The average time used to process a successful request by Azure Storage.
                This value does not include the network latency specified in `SuccessE2ELatency`.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.SuccessServerLatency.average
                  error_handler: DISCARD_VALUE
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: ed4b7ac10368493ba01c7cbeffba3042
              name: 'Storage account [{#NAME}]: File Transactions'
              type: DEPENDENT
              key: 'azure.storage.file.transactions[{#NAME}]'
              description: |
                The number of requests made to the storage service or a specified API operation.
                This number includes successful and failed requests and also requests that produced errors.
                Use `ResponseType` dimension for the number of different types of responses.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.fileServices.Transactions.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: file
                - tag: storage
                  value: '{#NAME}'
            - uuid: caeaa6805904471a8b18480f34ef9807
              name: 'Storage account [{#NAME}]: Ingress'
              type: DEPENDENT
              key: 'azure.storage.ingress[{#NAME}]'
              value_type: FLOAT
              units: B
              description: 'The amount of ingress data, expressed in bytes. This number includes ingress from an external client into Azure Storage and also ingress within Azure.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.storageAccount.Ingress.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: common
                - tag: storage
                  value: '{#NAME}'
            - uuid: be8b82396ff243e8a52864069b192dea
              name: 'Storage account [{#NAME}]: Queue Capacity'
              type: DEPENDENT
              key: 'azure.storage.queue.capacity[{#NAME}]'
              value_type: FLOAT
              units: B
              description: 'The amount of queue storage used by the storage account with the name `[{#NAME}]`, expressed in bytes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.queueServices.QueueCapacity.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: queue
                - tag: storage
                  value: '{#NAME}'
            - uuid: 9174d372235e4d14a4896a79ddcbc051
              name: 'Storage account [{#NAME}]: Queue Count'
              type: DEPENDENT
              key: 'azure.storage.queue.count[{#NAME}]'
              description: 'The number of queues in the storage account with the name `[{#NAME}]`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.queueServices.QueueCount.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: queue
                - tag: storage
                  value: '{#NAME}'
            - uuid: b8cff599c4194b4abd74f4a27ca93284
              name: 'Storage account [{#NAME}]: Queue Egress'
              type: DEPENDENT
              key: 'azure.storage.queue.engress[{#NAME}]'
              value_type: FLOAT
              units: B
              description: |
                The amount of egress data. This number includes egress to external client from Azure Storage and also egress within Azure.
                As a result, this number does not reflect billable egress.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.queueServices.Egress.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: queue
                - tag: storage
                  value: '{#NAME}'
            - uuid: 599f612c3cc64e81a53d507ae0078ab1
              name: 'Storage account [{#NAME}]: Queue Ingress'
              type: DEPENDENT
              key: 'azure.storage.queue.ingress[{#NAME}]'
              value_type: FLOAT
              units: B
              description: 'The amount of ingress data, expressed in bytes. This number includes ingress from an external client into Azure Storage and also ingress within Azure.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.queueServices.Ingress.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: queue
                - tag: storage
                  value: '{#NAME}'
            - uuid: 70c7b436a03145c5ab694b3a20ac52b1
              name: 'Storage account [{#NAME}]: Queue Message Count'
              type: DEPENDENT
              key: 'azure.storage.queue.message.count[{#NAME}]'
              description: 'The number of unexpired queue messages in the storage account with the name `[{#NAME}]`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.queueServices.QueueMessageCount.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: queue
                - tag: storage
                  value: '{#NAME}'
            - uuid: eccdbf48412e4c28afc3bbf87c545cc2
              name: 'Storage account [{#NAME}]: Queue Success E2E Latency'
              type: DEPENDENT
              key: 'azure.storage.queue.success.e2e.latency[{#NAME}]'
              value_type: FLOAT
              units: s
              description: |
                The average end-to-end latency of successful requests made to a storage service or the specified API operation, expressed in milliseconds.
                This value includes the required processing time within Azure Storage to read the request, send the response, and receive acknowledgment of the response.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.queueServices.queue.SuccessE2ELatency.average
                  error_handler: DISCARD_VALUE
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: queue
                - tag: storage
                  value: '{#NAME}'
            - uuid: 4d9aa2753d944690b01a23bcd44fd52d
              name: 'Storage account [{#NAME}]: Queue Success Server Latency'
              type: DEPENDENT
              key: 'azure.storage.queue.success.server.latency[{#NAME}]'
              value_type: FLOAT
              units: s
              description: |
                The average time used to process a successful request by Azure Storage.
                This value does not include the network latency specified in `SuccessE2ELatency`.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.queueServices.SuccessServerLatency.average
                  error_handler: DISCARD_VALUE
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: queue
                - tag: storage
                  value: '{#NAME}'
            - uuid: e472739df4634b55be2466bd91af9886
              name: 'Storage account [{#NAME}]: Queue Transactions'
              type: DEPENDENT
              key: 'azure.storage.queue.transactions[{#NAME}]'
              description: |
                The number of requests made to the storage service or a specified API operation.
                This number includes successful and failed requests and also requests that produced errors.
                Use `ResponseType` dimension for the number of different types of responses.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.queueServices.Transactions.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: queue
                - tag: storage
                  value: '{#NAME}'
            - uuid: 48437de0bdca4f5392c295ca8b82bd0a
              name: 'Storage account [{#NAME}]: Success E2E Latency'
              type: DEPENDENT
              key: 'azure.storage.success.e2e.latency[{#NAME}]'
              value_type: FLOAT
              units: s
              description: |
                The average end-to-end latency of successful requests made to a storage service or the specified API operation, expressed in milliseconds.
                This value includes the required processing time within Azure Storage to read the request, send the response, and receive acknowledgment of the response.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.storageAccount.SuccessE2ELatency.average
                  error_handler: DISCARD_VALUE
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: common
                - tag: storage
                  value: '{#NAME}'
            - uuid: 7076dbfb45cd49828b96064aa892e8e4
              name: 'Storage account [{#NAME}]: Success Server Latency'
              type: DEPENDENT
              key: 'azure.storage.success.server.latency[{#NAME}]'
              value_type: FLOAT
              units: s
              description: |
                The average time used to process a successful request by Azure Storage.
                This value does not include the network latency specified in `SuccessE2ELatency`.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.storageAccount.SuccessServerLatency.average
                  error_handler: DISCARD_VALUE
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: common
                - tag: storage
                  value: '{#NAME}'
            - uuid: 918f1d1c70964e7c9f5521cf99bbb21d
              name: 'Storage account [{#NAME}]: Table Availability'
              type: DEPENDENT
              key: 'azure.storage.table.availability[{#NAME}]'
              value_type: FLOAT
              units: '%'
              description: |
                The percentage of availability for the storage service or a specified API operation.
                Availability is calculated by taking the `TotalBillableRequests` value and dividing it by the number of applicable requests, including those that produced unexpected errors.
                All unexpected errors result in reduced availability for the storage service or the specified API operation.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tableServices.Availability.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: table
                - tag: storage
                  value: '{#NAME}'
              trigger_prototypes:
                - uuid: bfb1e82685224048ba8082447cad57ca
                  expression: '(min(/Azure by HTTP/azure.storage.table.availability[{#NAME}],#3))<{$AZURE.STORAGE.ACC.TABLE.AVAILABILITY:"{#NAME}"}'
                  name: 'Storage account [{#NAME}]: Table Availability is low'
                  event_name: 'Storage account [{#NAME} table availability is too low (less than {$AZURE.STORAGE.ACC.TABLE.AVAILABILITY:"{#NAME}"}%)'
                  opdata: '{ITEM.LASTVALUE1}'
                  priority: WARNING
                  tags:
                    - tag: scope
                      value: availability
            - uuid: ee19a3857a7a4650952eb855193991ee
              name: 'Storage account [{#NAME}]: Table Capacity'
              type: DEPENDENT
              key: 'azure.storage.table.capacity[{#NAME}]'
              value_type: FLOAT
              units: B
              description: 'The amount of storage used by the table service of the storage account with the name `[{#NAME}]`, expressed in bytes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tableServices.TableCapacity.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: table
                - tag: storage
                  value: '{#NAME}'
            - uuid: a3d11321b1cc4c1b9c322c0a7162e76e
              name: 'Storage account [{#NAME}]: Table Count'
              type: DEPENDENT
              key: 'azure.storage.table.count[{#NAME}]'
              description: 'The number of tables in the storage account with the name `[{#NAME}]`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tableServices.TableCount.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: table
                - tag: storage
                  value: '{#NAME}'
            - uuid: d75bd57fdd9f4377aea7c1e52a109c18
              name: 'Storage account [{#NAME}]: Table Egress'
              type: DEPENDENT
              key: 'azure.storage.table.engress[{#NAME}]'
              value_type: FLOAT
              units: B
              description: |
                The amount of egress data. This number includes egress to external client from Azure Storage and also egress within Azure.
                As a result, this number does not reflect billable egress.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tableServices.Egress.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: table
                - tag: storage
                  value: '{#NAME}'
            - uuid: f2911504457b4d329ae7cf7d7a24594a
              name: 'Storage account [{#NAME}]: Table Entity Count'
              type: DEPENDENT
              key: 'azure.storage.table.entity.count[{#NAME}]'
              description: 'The number of table entities in the storage account with the name `[{#NAME}]`.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tableServices.TableEntityCount.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: table
                - tag: storage
                  value: '{#NAME}'
            - uuid: 993ca2e5bcd74d27b19998d77f0abec8
              name: 'Storage account [{#NAME}]: Table Ingress'
              type: DEPENDENT
              key: 'azure.storage.table.ingress[{#NAME}]'
              value_type: FLOAT
              units: B
              description: 'The amount of ingress data, expressed in bytes. This number includes ingress from an external client into Azure Storage and also ingress within Azure.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tableServices.Ingress.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: table
                - tag: storage
                  value: '{#NAME}'
            - uuid: 00c441cc77f4447584d4bffbefc304e0
              name: 'Storage account [{#NAME}]: Table Success E2E Latency'
              type: DEPENDENT
              key: 'azure.storage.table.success.e2e.latency[{#NAME}]'
              value_type: FLOAT
              units: s
              description: |
                The average end-to-end latency of successful requests made to a storage service or the specified API operation, expressed in milliseconds.
                This value includes the required processing time within Azure Storage to read the request, send the response, and receive acknowledgment of the response.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tableServices.SuccessE2ELatency.average
                  error_handler: DISCARD_VALUE
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: table
                - tag: storage
                  value: '{#NAME}'
            - uuid: f29e3ad4be034f38932cb85654397926
              name: 'Storage account [{#NAME}]: Table Success Server Latency'
              type: DEPENDENT
              key: 'azure.storage.table.success.server.latency[{#NAME}]'
              value_type: FLOAT
              units: s
              description: |
                The average time used to process a successful request by Azure Storage.
                This value does not include the network latency specified in `SuccessE2ELatency`.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tableServices.SuccessServerLatency.average
                  error_handler: DISCARD_VALUE
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: table
                - tag: storage
                  value: '{#NAME}'
            - uuid: 9ba25e87c5bb466a99855a9fb893283d
              name: 'Storage account [{#NAME}]: Table Transactions'
              type: DEPENDENT
              key: 'azure.storage.table.transactions[{#NAME}]'
              description: |
                The number of requests made to the storage service or a specified API operation.
                This number includes successful and failed requests and also requests that produced errors.
                Use `ResponseType` dimension for the number of different types of responses.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.tableServices.Transactions.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: table
                - tag: storage
                  value: '{#NAME}'
            - uuid: 6f68f0d8a63640ffa549fde44e8fe56c
              name: 'Storage account [{#NAME}]: Transactions'
              type: DEPENDENT
              key: 'azure.storage.transactions[{#NAME}]'
              description: |
                The number of requests made to the storage service or a specified API operation.
                This number includes successful and failed requests and also requests that produced errors.
                Use `ResponseType` dimension for the number of different types of responses.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.storageAccount.Transactions.total
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: common
                - tag: storage
                  value: '{#NAME}'
            - uuid: 08ef07d874db4823bd167482bf049916
              name: 'Storage account [{#NAME}]: Used Capacity'
              type: DEPENDENT
              key: 'azure.storage.used.capacity[{#NAME}]'
              value_type: FLOAT
              units: B
              description: |
                The amount of storage used by the storage account with the name `[{#NAME}]`, expressed in bytes.
                For standard storage accounts, it's the sum of capacity used by blob, table, file, and queue.
                For premium storage accounts and blob storage accounts, it is the same as BlobCapacity or FileCapacity.
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.storageAccount.UsedCapacity.average
                  error_handler: DISCARD_VALUE
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 3h
              master_item:
                key: 'azure.get.storage.acc[{#NAME}]'
              tags:
                - tag: component
                  value: storages
                - tag: metrics
                  value: common
                - tag: storage
                  value: '{#NAME}'
          graph_prototypes:
            - uuid: d569e0daf1974df58584432805f95557
              name: 'Azure: Capacity by storage [{#NAME}]'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.used.capacity[{#NAME}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.blob.capacity[{#NAME}]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.table.capacity[{#NAME}]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.file.capacity[{#NAME}]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.queue.capacity[{#NAME}]'
            - uuid: 6bae0cf983104e0fada61468902949e1
              name: 'Azure: Storage account [{#NAME}] egress'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.engress[{#NAME}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.blob.engress[{#NAME}]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.table.engress[{#NAME}]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.file.engress[{#NAME}]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.queue.engress[{#NAME}]'
            - uuid: 8860c37426104045a7f9feb6cc370db4
              name: 'Azure: Storage account [{#NAME}] ingress'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.ingress[{#NAME}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.blob.ingress[{#NAME}]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.table.ingress[{#NAME}]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.file.ingress[{#NAME}]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.queue.ingress[{#NAME}]'
            - uuid: 9c87dfb9ed7e4c1ea32c8e35c6e23381
              name: 'Azure: Transactions by storage [{#NAME}]'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.transactions[{#NAME}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.blob.transactions[{#NAME}]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.table.transactions[{#NAME}]'
                - sortorder: '3'
                  color: F7941D
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.file.transactions[{#NAME}]'
                - sortorder: '4'
                  color: FC6EA3
                  item:
                    host: 'Azure by HTTP'
                    key: 'azure.storage.queue.transactions[{#NAME}]'
          master_item:
            key: azure.get.storage.acc
          lld_macro_paths:
            - lld_macro: '{#GROUP}'
              path: $.resourceGroup
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#LOCATION}'
              path: $.location
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#TOKEN}'
              path: $.token
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
        - uuid: f9386233186648ce828f406c52972ce5
          name: 'Virtual machines discovery'
          type: DEPENDENT
          key: azure.vm.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#LOCATION}'
                value: '{$AZURE.VM.LOCATION.MATCHES}'
              - macro: '{#LOCATION}'
                value: '{$AZURE.VM.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#NAME}'
                value: '{$AZURE.VM.NAME.MATCHES}'
              - macro: '{#NAME}'
                value: '{$AZURE.VM.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#SCALESET}'
                operator: NOT_EXISTS
              - macro: '{#TYPE}'
                value: ^Microsoft.Compute/virtualMachines$
          description: 'The list of the virtual machines is provided by the subscription.'
          host_prototypes:
            - uuid: d08c0ee33c924b28bf1fed571da6c7f4
              host: 'Azure virtual machine {#NAME}'
              name: 'Azure virtual machine {#NAME}'
              group_links:
                - group:
                    name: 'Virtual machines'
              templates:
                - name: 'Azure Virtual Machine by HTTP'
              macros:
                - macro: '{$AZURE.RESOURCE.ID}'
                  value: '{#ID}'
              tags:
                - tag: location
                  value: '{#LOCATION}'
                - tag: os
                  value: '{#OS}'
                - tag: resource-group
                  value: '{#GROUP}'
                - tag: size
                  value: '{#SIZE}'
          master_item:
            key: azure.get.resources
          lld_macro_paths:
            - lld_macro: '{#GROUP}'
              path: $.resourceGroup
            - lld_macro: '{#ID}'
              path: $.id
            - lld_macro: '{#LOCATION}'
              path: $.location
            - lld_macro: '{#NAME}'
              path: $.name
            - lld_macro: '{#OS}'
              path: $.properties.storageProfile.osDisk.osType
            - lld_macro: '{#SCALESET}'
              path: $.properties.virtualMachineScaleSet
            - lld_macro: '{#SIZE}'
              path: $.properties.hardwareProfile.vmSize
            - lld_macro: '{#TYPE}'
              path: $.type
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.resources.value
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 6h
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.COSMOS.MONGO.DB.LOCATION.MATCHES}'
          value: '.*'
          description: 'This macro is used in Microsoft Cosmos DB account discovery rule.'
        - macro: '{$AZURE.COSMOS.MONGO.DB.LOCATION.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Microsoft Cosmos DB account discovery rule.'
        - macro: '{$AZURE.COSMOS.MONGO.DB.NAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in Microsoft Cosmos DB account discovery rule.'
        - macro: '{$AZURE.COSMOS.MONGO.DB.NAME.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Microsoft Cosmos DB account discovery rule.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
        - macro: '{$AZURE.MSSQL.DB.LOCATION.MATCHES}'
          value: '.*'
          description: 'This macro is used in Microsoft SQL databases discovery rule.'
        - macro: '{$AZURE.MSSQL.DB.LOCATION.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Microsoft SQL databases discovery rule.'
        - macro: '{$AZURE.MSSQL.DB.NAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in Microsoft SQL databases discovery rule.'
        - macro: '{$AZURE.MSSQL.DB.NAME.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in Microsoft SQL databases discovery rule.'
        - macro: '{$AZURE.MSSQL.DB.SIZE.NOT.MATCHES}'
          value: ^System$
          description: 'This macro is used in Microsoft SQL databases discovery rule.'
        - macro: '{$AZURE.MYSQL.DB.LOCATION.MATCHES}'
          value: '.*'
          description: 'This macro is used in MySQL servers discovery rule.'
        - macro: '{$AZURE.MYSQL.DB.LOCATION.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in MySQL servers discovery rule.'
        - macro: '{$AZURE.MYSQL.DB.NAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in MySQL servers discovery rule.'
        - macro: '{$AZURE.MYSQL.DB.NAME.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in MySQL servers discovery rule.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PGSQL.DB.LOCATION.MATCHES}'
          value: '.*'
          description: 'This macro is used in PostgreSQL servers discovery rule.'
        - macro: '{$AZURE.PGSQL.DB.LOCATION.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in PostgreSQL servers discovery rule.'
        - macro: '{$AZURE.PGSQL.DB.NAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in PostgreSQL servers discovery rule.'
        - macro: '{$AZURE.PGSQL.DB.NAME.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in PostgreSQL servers discovery rule.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.RESOURCE.GROUP.MATCHES}'
          value: '.*'
          description: 'This macro is used in discovery rules.'
        - macro: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in discovery rules.'
        - macro: '{$AZURE.SCALESET.LOCATION.MATCHES}'
          value: '.*'
          description: 'This macro is used in virtual machine scale sets discovery rule.'
        - macro: '{$AZURE.SCALESET.LOCATION.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in virtual machine scale sets discovery rule.'
        - macro: '{$AZURE.SCALESET.NAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in virtual machine scale sets discovery rule.'
        - macro: '{$AZURE.SCALESET.NAME.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in virtual machine scale sets discovery rule.'
        - macro: '{$AZURE.STORAGE.ACC.AVAILABILITY}'
          value: '70'
          description: 'The warning threshold of the storage account availability.'
        - macro: '{$AZURE.STORAGE.ACC.BLOB.AVAILABILITY}'
          value: '70'
          description: 'The warning threshold of the storage account blob services availability.'
        - macro: '{$AZURE.STORAGE.ACC.LOCATION.MATCHES}'
          value: '.*'
          description: 'This macro is used in storage accounts discovery rule.'
        - macro: '{$AZURE.STORAGE.ACC.LOCATION.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in storage accounts discovery rule.'
        - macro: '{$AZURE.STORAGE.ACC.NAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in storage accounts discovery rule.'
        - macro: '{$AZURE.STORAGE.ACC.NAME.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in storage accounts discovery rule.'
        - macro: '{$AZURE.STORAGE.ACC.TABLE.AVAILABILITY}'
          value: '70'
          description: 'The warning threshold of the storage account table services availability.'
        - macro: '{$AZURE.SUBSCRIPTION.ID}'
          description: 'Microsoft Azure subscription ID.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
        - macro: '{$AZURE.VM.LOCATION.MATCHES}'
          value: '.*'
          description: 'This macro is used in virtual machines discovery rule.'
        - macro: '{$AZURE.VM.LOCATION.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in virtual machines discovery rule.'
        - macro: '{$AZURE.VM.NAME.MATCHES}'
          value: '.*'
          description: 'This macro is used in virtual machines discovery rule.'
        - macro: '{$AZURE.VM.NAME.NOT.MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'This macro is used in virtual machines discovery rule.'
      dashboards:
        - uuid: d30c78be41fe421cb98cedd7683a11f0
          name: 'Overview Azure Storage accounts'
          pages:
            - name: 'Storage transactions'
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '25'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Azure by HTTP'
                        name: 'Azure: Transactions by storage [{#NAME}]'
                    - type: STRING
                      name: reference
                      value: AAAAA
                    - type: INTEGER
                      name: rows
                      value: '6'
            - name: 'Storage engress'
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '25'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Azure by HTTP'
                        name: 'Azure: Storage account [{#NAME}] egress'
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: rows
                      value: '6'
            - name: 'Storage ingress'
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '20'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Azure by HTTP'
                        name: 'Azure: Storage account [{#NAME}] ingress'
                    - type: STRING
                      name: reference
                      value: AAAAC
                    - type: INTEGER
                      name: rows
                      value: '5'
    - uuid: 29325098807848aa928b4192ad5e020f
      template: 'Azure Cosmos DB for MongoDB by HTTP'
      name: 'Azure Cosmos DB for MongoDB by HTTP'
      description: |
        This template is designed to monitor Microsoft Azure Cosmos DB for MongoDB by HTTP.
        It works without any external scripts and uses the script item.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: {$AZURE.APP.ID}, {$AZURE.PASSWORD}, {$AZURE.TENANT.ID}, {$AZURE.SUBSCRIPTION.ID}, and {$AZURE.RESOURCE.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 9e247bdb17f44630b9440b59d5ef251b
          name: 'Autoscale max throughput'
          type: DEPENDENT
          key: azure.cosmosdb.autoscale.max.throughput
          description: 'The autoscale max throughput.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.AutoscaleMaxThroughput.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 35a7d2c96990407f937e07fd160266a9
          name: 'Get errors'
          type: DEPENDENT
          key: azure.cosmosdb.data.errors
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: dfd484aa8a4e4b759e4e34c5318c7176
              expression: 'length(last(/Azure Cosmos DB for MongoDB by HTTP/azure.cosmosdb.data.errors))>0'
              name: '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: 647faea1597c4da6a3cd78694be8e77e
          name: 'Get data'
          type: SCRIPT
          key: azure.cosmosdb.data.get
          history: '0'
          value_type: TEXT
          params: |
            var AzureCosmosDB = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id', 'resource_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		AzureCosmosDB.params = params;
            	},
            
            	login: function () {
            		var response, login = new HttpRequest();
            		if (typeof AzureCosmosDB.params.proxy !== 'undefined' && AzureCosmosDB.params.proxy !== '') {
            			login.setProxy(AzureCosmosDB.params.proxy);
            		}
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(AzureCosmosDB.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureCosmosDB.params.app_id) + '&client_secret=' + encodeURIComponent(AzureCosmosDB.params.password)
            		);
            
            		if (login.getStatus() !== 200) {
            			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.';
            		}
            		AzureCosmosDB.token = response['access_token'];
            	},
            
            	request: function (url) {
            		var response, request = new HttpRequest();
            		if (typeof AzureCosmosDB.params.proxy !== 'undefined' && AzureCosmosDB.params.proxy !== '') {
            			request.setProxy(AzureCosmosDB.params.proxy);
            		}
            		if (!AzureCosmosDB.token) {
            			throw 'Request does not contain access token.';
            		}
            		request.addHeader('Accept: application/json');
            		request.addHeader('Authorization: Bearer ' + AzureCosmosDB.token);
            		Zabbix.log(4, '[ AzureCosmosDB ] request url: ' + url);
            		response = request.get(url);
            
            		if (request.getStatus() !== 200) {
            			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) {
            		var steps = path.split('.');
            		for (var i = 0; i < steps.length; i++) {
            			var step = steps[i];
            			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            				throw 'Required field was not found: ' + path;
            			}
            
            			data = data[step];
            		}
            
            		return data;
            	},
            
            	getMetricsData: function () {
            		var data = {};
            		start_date = new Date((new Date().getTime()) - 600000).toISOString().replace(/\.\d+/, '');
            		end_date = new Date(new Date().getTime()).toISOString().replace(/\.\d+/, '');
            		endpoints = {
            			'availability': '/providers/Microsoft.Insights/metrics?metricnames=ServiceAvailability&api-version=2021-05-01&interval=PT1H&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date),
            			'requests': '/providers/Microsoft.Insights/metrics?metricnames=DataUsage,IndexUsage,DocumentQuota,AvailableStorage,DocumentCount,NormalizedRUConsumption,PhysicalPartitionThroughputInfo,PhysicalPartitionSizeInfo,AutoscaleMaxThroughput,ProvisionedThroughput,TotalRequests,TotalRequestUnits,MetadataRequests,MongoRequests,MongoRequestCharge,ServerSideLatency,ServerSideLatencyGateway,ServerSideLatencyDirect,ReplicationLatency&api-version=2021-05-01&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date),
            		};
            
            		Object.keys(endpoints).forEach(function (field) {
            			data[field] = {};
            			try {
            				metrics = AzureCosmosDB.request('https://management.azure.com' + AzureCosmosDB.params.resource_id + endpoints[field]);
            				if (!metrics.hasOwnProperty('value')) {
            					throw 'Failed getting required field. Check debug log for more information.';
            				}
            
            				for (k in metrics.value) {
            					key = AzureCosmosDB.getField(metrics.value[k], 'name.value')
            					if (metrics.value[k].timeseries.length === 0) {
            						metrics.value[k].timeseries.push({ 'data': ['nodata'] })
            					}
            					data[field][key] = AzureCosmosDB.getField(metrics.value[k], 'timeseries.0.data.0');
            				}
            			}
            			catch (error) {
            				data.error = error.toString();
            			}
            		});
            		return data
            	}
            
            };
            
            try {
            	AzureCosmosDB.setParams(JSON.parse(value));
            	AzureCosmosDB.login();
            	return JSON.stringify(AzureCosmosDB.getMetricsData());
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ AzureCosmosDB ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: resource_id
              value: '{$AZURE.RESOURCE.ID}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: 947a2eb530754a609fa81c59e29fe7b7
          name: 'Data usage'
          type: DEPENDENT
          key: azure.cosmosdb.data.usage
          units: B
          description: 'The total data usage.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.DataUsage.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 0bf3da9168144016b663c9b8e76447fa
          name: 'Document count'
          type: DEPENDENT
          key: azure.cosmosdb.document.count
          description: 'The total document count.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.DocumentCount.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 7fa0f59f8cfa4d9e83086b203e4f71ea
          name: 'Document quota'
          type: DEPENDENT
          key: azure.cosmosdb.document.quota
          units: B
          description: 'The total storage quota.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.DocumentQuota.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b09f9445d960415185457b89b6a73452
          name: 'Index usage'
          type: DEPENDENT
          key: azure.cosmosdb.index.usage
          units: B
          description: 'The total index usage.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.IndexUsage.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: cd35f04b180542cda50dc5d4e979e54e
          name: 'Metadata requests'
          type: DEPENDENT
          key: azure.cosmosdb.metadata.requests
          description: |
            The count of metadata requests.
            Cosmos DB maintains system metadata collection for each account, which allows you to enumerate collections, databases, etc., and their configurations, free of charge.
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.MetadataRequests.count
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: e42cf83e456a490295a84cfe9eb288ef
          name: 'Mongo requests'
          type: DEPENDENT
          key: azure.cosmosdb.mongo.requests
          description: 'The number of Mongo requests made.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.MongoRequests.count
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 8fd4068986af444799ae64c6bc8f16a6
          name: 'Mongo request charge'
          type: DEPENDENT
          key: azure.cosmosdb.mongo.requests.charge
          description: 'The Mongo request units consumed.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.MongoRequestCharge.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: fda6b39ce6ef4b8c8418b2e123ecdd17
          name: 'Normalized RU consumption'
          type: DEPENDENT
          key: azure.cosmosdb.normalized.ru.consumption
          units: '%'
          description: 'The max RU consumption percentage per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.NormalizedRUConsumption.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: be6800214a0443e899c40f8a4b6c3f21
          name: 'Physical partition size'
          type: DEPENDENT
          key: azure.cosmosdb.physical.partition.size
          units: B
          description: 'The physical partition size in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.PhysicalPartitionSizeInfo.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: e30d5eadde15427484e7a0d1cb38e9e3
          name: 'Physical partition throughput'
          type: DEPENDENT
          key: azure.cosmosdb.physical.partition.throughput
          description: 'The physical partition throughput.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.PhysicalPartitionThroughputInfo.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 49311bbfb2584a46b42ed1a7d8fcfd94
          name: 'Provisioned throughput'
          type: DEPENDENT
          key: azure.cosmosdb.provisioned.throughput
          description: 'The provisioned throughput.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.ProvisionedThroughput.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 6d7175e27d10406191c883dc2e5949e4
          name: 'Replication latency, P99'
          type: DEPENDENT
          key: azure.cosmosdb.replication.latency
          value_type: FLOAT
          units: s
          description: 'The P99 replication latency across source and target regions for geo-enabled account.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.ReplicationLatency.average
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: network
        - uuid: d9b5af0c71874114b48464ce20f8cf3d
          name: 'Server side latency'
          type: DEPENDENT
          key: azure.cosmosdb.server.side.latency
          value_type: FLOAT
          units: s
          description: 'The server side latency.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.ServerSideLatency.average
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: network
        - uuid: 7587d3750d1643f085db5931670dc2f3
          name: 'Server side latency, direct'
          type: DEPENDENT
          key: azure.cosmosdb.server.side.latency.direct
          value_type: FLOAT
          units: s
          description: 'The server side latency in direct connection mode.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.ServerSideLatencyDirect.average
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: network
        - uuid: 0aefdc3101fe4bcba4743d6e32671554
          name: 'Server side latency, gateway'
          type: DEPENDENT
          key: azure.cosmosdb.server.side.latency.gateway
          value_type: FLOAT
          units: s
          description: 'The server side latency in gateway connection mode.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.ServerSideLatencyGateway.average
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: network
        - uuid: 42bd03c1753b4f19bc9793b03834cd3d
          name: 'Service availability'
          type: DEPENDENT
          key: azure.cosmosdb.service.availability
          value_type: FLOAT
          units: '%'
          description: 'The account requests availability at one hour granularity.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.availability.ServiceAvailability.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: c7649cd317f04a3d8fec0eebe3df6766
              expression: '(min(/Azure Cosmos DB for MongoDB by HTTP/azure.cosmosdb.service.availability,#3))<{$AZURE.DB.COSMOS.MONGO.AVAILABILITY}'
              name: 'Cosmos DB for MongoDB account: Availability is low'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              tags:
                - tag: scope
                  value: availability
        - uuid: f4d4d2def5e945ab9048ada4813b7f04
          name: 'Total request units'
          type: DEPENDENT
          key: azure.cosmosdb.total.request.units
          value_type: FLOAT
          description: 'The request units consumed per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.TotalRequestUnits.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 3dd2cd4edb7746edb9d917c83b280ca3
          name: 'Total requests'
          type: DEPENDENT
          key: azure.cosmosdb.total.requests
          description: 'Number of requests per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.requests.TotalRequests.count
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.cosmosdb.data.get
          tags:
            - tag: component
              value: storage
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
        - tag: target
          value: cosmosdb
        - tag: target
          value: mongodb
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
        - macro: '{$AZURE.DB.COSMOS.MONGO.AVAILABILITY}'
          value: '70'
          description: 'The warning threshold of the Cosmos DB for MongoDB service availability.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.RESOURCE.ID}'
          description: 'Microsoft Azure Cosmos DB ID.'
        - macro: '{$AZURE.SUBSCRIPTION.ID}'
          description: 'Microsoft Azure subscription ID.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
      dashboards:
        - uuid: 323fb91b388a44bfbd4b7d634f6e6b6c
          name: 'Overview Azure Cosmos DB for MongoDB'
          pages:
            - widgets:
                - type: item
                  name: 'Service Availability'
                  width: '18'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF0000
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        key: azure.cosmosdb.service.availability
                    - type: INTEGER
                      name: show.0
                      value: '2'
                    - type: INTEGER
                      name: show.1
                      value: '4'
                    - type: STRING
                      name: units
                      value: '%'
                    - type: STRING
                      name: units_color
                      value: 66BB6A
                    - type: STRING
                      name: up_color
                      value: 4CAF50
                    - type: STRING
                      name: value_color
                      value: 66BB6A
                - type: graph
                  'y': '4'
                  width: '72'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        name: 'Azure MongoDB: Usage'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  'y': '9'
                  width: '72'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        name: 'Azure MongoDB: Requests'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  'y': '14'
                  width: '72'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        name: 'Azure MongoDB: Latency'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: item
                  name: 'Provisioned Throughput'
                  x: '18'
                  width: '18'
                  height: '4'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        key: azure.cosmosdb.provisioned.throughput
                    - type: INTEGER
                      name: show.0
                      value: '2'
                - type: item
                  name: 'Normalized RU Consumption'
                  x: '36'
                  width: '18'
                  height: '4'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        key: azure.cosmosdb.normalized.ru.consumption
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Document Count'
                  x: '54'
                  width: '18'
                  height: '4'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        key: azure.cosmosdb.document.count
                    - type: INTEGER
                      name: show.0
                      value: '2'
    - uuid: c0263df8d8c14d30b24afcf45a6a354f
      template: 'Azure Cost Management by HTTP'
      name: 'Azure Cost Management by HTTP'
      description: |
        This template is designed to monitor Microsoft Cost Management by HTTP.
        It works without any external scripts and uses the script item.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: {$AZURE.APP.ID}, {$AZURE.PASSWORD}, {$AZURE.TENANT.ID}, {$AZURE.SUBSCRIPTION.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: f50c96da86654a25b937756cc7f7010e
          name: 'Get daily costs'
          type: SCRIPT
          key: azure.get.daily.costs
          delay: 0s;h/5m/30
          history: '0'
          value_type: TEXT
          params: |
            var AzureCost = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            		AzureCost.params = params;
            	},
            
            	login: function () {
            		var response,
            			login = new HttpRequest();
            
            		if (typeof AzureCost.params.proxy !== 'undefined' && AzureCost.params.proxy !== '') {
            			login.setProxy(AzureCost.params.proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(AzureCost.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureCost.params.app_id) + '&client_secret=' + encodeURIComponent(AzureCost.params.password)
            		);
            
            		if (login.getStatus() !== 200) {
            			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.';
            		}
            
            		AzureCost.token = response['access_token'];
            	},
            
            	request: function (url, body) {
            		if (typeof body === 'undefined' || body === null) {
            			body = '';
            		}
            		var response,
            			headers,
            			regex = /-retry-after":"(\d+)"/,
            			ratelimit,
            			request = new HttpRequest();
            
            		if (typeof AzureCost.params.proxy !== 'undefined' && AzureCost.params.proxy !== '') {
            			request.setProxy(AzureCost.params.proxy);
            		}
            		if (!AzureCost.token) {
            			throw 'Request does not contain access token.';
            		}
            		request.addHeader('Accept: application/json');
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + AzureCost.token);
            
            		Zabbix.log(4, '[ AzureCost ] request url: ' + url);
            
            		response = request.post(url, body);
            		headers = JSON.stringify(request.getHeaders());
            
            		if (headers.match(regex) !== null && request.getStatus() === 429) {
            			ratelimit = headers.match(regex)[1];
            			Zabbix.log(4, '[ AzureCost ] Microsoft Cost Management have rate limit requests per 1 minute, retrying after ' + ratelimit + ' seconds');
            			Zabbix.sleep(ratelimit * 1010);
            			response = request.post(url, body);
            		}
            		if (request.getStatus() !== 200) {
            			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) {
            		var steps = path.split('.');
            		for (var i = 0; i < steps.length; i++) {
            			var step = steps[i];
            			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            				throw 'Required field was not found: ' + path;
            			}
            			data = data[step];
            		}
            
            		return data;
            	},
            
            	getCost: function () {
            		var metricData = {},
            			today = new Date(),
            			start_date = new Date(today);
            		start_date.setDate(today.getDate() - 1);
            
            		bodyRawCost = {
            			type: 'Usage',
            			'timeframe': 'Custom',
            			'timePeriod': {
            				'from': start_date,
            				'to': start_date
            			},
            			dataset: {
            				granularity: 'Daily',
            				aggregation: {
            					totalCost: {
            						name: 'PreTaxCost',
            						function: 'Sum'
            					}
            				},
            				grouping: [
            					{
            						type: 'Dimension',
            						name: 'Meter',
            					},
            					{
            						type: 'Dimension',
            						name: 'MeterSubcategory',
            					},
            					{
            						type: 'Dimension',
            						name: 'ResourceGroup',
            					},
            					{
            						type: 'Dimension',
            						name: 'ServiceName',
            					},
            					{
            						type: 'Dimension',
            						name: 'ResourceLocation',
            					}
            				]
            			}
            		};
            		metricData = AzureCost.request('https://management.azure.com/subscriptions/' + AzureCost.params.subscription_id + '/providers/Microsoft.CostManagement/query?api-version=2023-11-01', JSON.stringify(bodyRawCost));
            
            		var columns = AzureCost.getField(metricData, 'properties.columns');
            
            		return transformedData = {
            			data: AzureCost.getField(metricData, 'properties.rows').map(function (row) {
            				rowData = {};
            				columns.forEach(function (column, i) {
            					columnName = columns[i].name;
            					columnType = columns[i].type;
            					cellValue = row[i];
            					rowData[columnName] = column.type === "Number" ? cellValue.toString() : cellValue;
            				});
            				rowData.UsageDate = rowData.UsageDate.replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3");
            
            				return rowData;
            			})
            		};
            	}
            };
            
            try {
            	AzureCost.setParams(JSON.parse(value));
            	AzureCost.login();
            
            	return JSON.stringify(AzureCost.getCost());
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ AzureCost ] ERROR: ' + error);
            
            	return JSON.stringify({ 'error': error });
            }
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: bbf6a0b136464d76a535ca016dcb8ae1
          name: 'Get monthly costs'
          type: SCRIPT
          key: azure.get.monthly.costs
          delay: 0s;h/12
          history: '0'
          value_type: TEXT
          params: |
            var AzureCost = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id', 'month'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            		AzureCost.params = params;
            
            		today = new Date();
            		AzureCost.params.end_date = today.toISOString();
            		month = today.getMonth();
            		today.setMonth(month - params.month);
            		AzureCost.params.start_time = new Date(today.getFullYear(), today.getMonth()).toISOString();
            	},
            
            	login: function () {
            		var response,
            			login = new HttpRequest();
            
            		if (typeof AzureCost.params.proxy !== 'undefined' && AzureCost.params.proxy !== '') {
            			login.setProxy(AzureCost.params.proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(AzureCost.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureCost.params.app_id) + '&client_secret=' + encodeURIComponent(AzureCost.params.password)
            		);
            
            		if (login.getStatus() !== 200) {
            			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.';
            		}
            
            		AzureCost.token = response['access_token'];
            	},
            
            	request: function (url, body) {
            		if (typeof body === 'undefined' || body === null) {
            			body = '';
            		}
            		var response,
            			headers,
            			regex = /-retry-after":"(\d+)"/,
            			ratelimit,
            			request = new HttpRequest();
            
            		if (typeof AzureCost.params.proxy !== 'undefined' && AzureCost.params.proxy !== '') {
            			request.setProxy(AzureCost.params.proxy);
            		}
            		if (!AzureCost.token) {
            			throw 'Request does not contain access token.';
            		}
            		request.addHeader('Accept: application/json');
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + AzureCost.token);
            
            		Zabbix.log(4, '[ AzureCost ] request url: ' + url);
            
            		response = request.post(url, body);
            		headers = JSON.stringify(request.getHeaders());
            
            		if (headers.match(regex) !== null && request.getStatus() === 429) {
            			ratelimit = headers.match(regex)[1];
            			Zabbix.log(4, '[ AzureCost ] Microsoft Cost Management have rate limit requests per 1 minute, retrying after ' + ratelimit + ' seconds');
            			Zabbix.sleep(ratelimit * 1010);
            			response = request.post(url, body);
            		}
            		if (request.getStatus() !== 200) {
            			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) {
            		var steps = path.split('.');
            		for (var i = 0; i < steps.length; i++) {
            			var step = steps[i];
            			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            				throw 'Required field was not found: ' + path;
            			}
            			data = data[step];
            		}
            
            		return data;
            	},
            
            	getCost: function (grouping) {
            		var metricData = {},
            			bodyRawCost = {
            				type: 'Usage',
            				timeframe: 'Custom',
            				timePeriod: {
            					from: AzureCost.params.start_time,
            					to: AzureCost.params.end_date
            				},
            				dataset: {
            					aggregation: {
            						totalCost: {
            							name: 'PreTaxCost',
            							function: 'Sum'
            						}
            					},
            					grouping: [
            						{
            							type: 'Dimension',
            							name: 'BillingMonth'
            						},
            						{
            							type: 'Dimension',
            							name: grouping
            						},
            					]
            				}
            			};
            
            		metricData = AzureCost.request('https://management.azure.com/subscriptions/' + AzureCost.params.subscription_id + '/providers/Microsoft.CostManagement/query?api-version=2023-11-01', JSON.stringify(bodyRawCost));
            
            		var columns = AzureCost.getField(metricData, 'properties.columns');
            
            		return transformedData = {
            			data: AzureCost.getField(metricData, 'properties.rows').map(function (row) {
            				rowData = {};
            				columns.forEach(function (column, i) {
            					columnName = columns[i].name;
            					cellValue = row[i];
            					rowData[columnName] = column.type === "Number" ? cellValue.toString() : cellValue;
            				});
            				rowData.BillingMonth = rowData.BillingMonth.slice(0, 7);
            
            				return rowData;
            			})
            		};
            	}
            };
            
            try {
            	AzureCost.setParams(JSON.parse(value));
            	AzureCost.login();
            
            	serviceCost = AzureCost.getCost('ServiceName');
            	resourceGroupCost = AzureCost.getCost('ResourceGroup');
            	resourceLocationCost = AzureCost.getCost('ResourceLocation');
            	monthCost = AzureCost.getCost('SubscriptionId');
            
            	return JSON.stringify({ resourceGroupCost, resourceLocationCost, serviceCost, monthCost });
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ AzureCost ] ERROR: ' + error);
            
            	return JSON.stringify({ 'error': error });
            }
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: month
              value: '{$AZURE.BILLING.MONTH}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
      discovery_rules:
        - uuid: 1220188c7a1c4df8b75e9021c4515149
          name: 'Azure daily costs by services discovery'
          type: DEPENDENT
          key: azure.daily.services.costs.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#AZURE.RESOURCE.GROUP}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.GROUP.MATCHES}'
              - macro: '{#AZURE.RESOURCE.GROUP}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.GROUP.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#AZURE.RESOURCE.LOCATION}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.LOCATION.MATCHES}'
              - macro: '{#AZURE.RESOURCE.LOCATION}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.LOCATION.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#AZURE.SERVICE.NAME}'
                value: '{$AZURE.LLD.FILTER.SERVICE.MATCHES}'
              - macro: '{#AZURE.SERVICE.NAME}'
                value: '{$AZURE.LLD.FILTER.SERVICE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery of daily costs by services.'
          item_prototypes:
            - uuid: 848ccd4cec2c4902990aa25f90f502a8
              name: 'Service ["{#AZURE.SERVICE.NAME}"]: Meter ["{#AZURE.BILLING.METER}"]: Subcategory ["{#AZURE.BILLING.METER.SUBCATEGORY}"] daily cost'
              type: DEPENDENT
              key: 'azure.daily.cost["{#AZURE.SERVICE.NAME}", "{#AZURE.BILLING.METER}", "{#AZURE.BILLING.METER.SUBCATEGORY}","{#AZURE.RESOURCE.GROUP}"]'
              value_type: FLOAT
              units: '!{#AZURE.BILLING.UNIT}'
              description: 'The daily cost by service {#AZURE.SERVICE.NAME}, meter {#AZURE.BILLING.METER}, subcategory {#AZURE.BILLING.METER.SUBCATEGORY}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.data.[?(@.ServiceName == "{#AZURE.SERVICE.NAME}" && @.Meter == "{#AZURE.BILLING.METER}" && @.MeterSubcategory == "{#AZURE.BILLING.METER.SUBCATEGORY}")].PreTaxCost.first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: azure.get.daily.costs
              tags:
                - tag: component
                  value: cost
                - tag: location
                  value: '{#AZURE.RESOURCE.LOCATION}'
                - tag: meter
                  value: '{#AZURE.BILLING.METER}'
                - tag: resource-group
                  value: '{#AZURE.RESOURCE.GROUP}'
                - tag: service
                  value: '{#AZURE.SERVICE.NAME}'
          graph_prototypes:
            - uuid: 2a1e03e65b1c40cba783493871e245d5
              name: 'Daily Cost: "{#AZURE.SERVICE.NAME}","{#AZURE.BILLING.METER}","{#AZURE.BILLING.METER.SUBCATEGORY}","{#AZURE.RESOURCE.GROUP}"'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 2E7D32
                  item:
                    host: 'Azure Cost Management by HTTP'
                    key: 'azure.daily.cost["{#AZURE.SERVICE.NAME}", "{#AZURE.BILLING.METER}", "{#AZURE.BILLING.METER.SUBCATEGORY}","{#AZURE.RESOURCE.GROUP}"]'
          master_item:
            key: azure.get.daily.costs
          lld_macro_paths:
            - lld_macro: '{#AZURE.BILLING.METER.SUBCATEGORY}'
              path: $.MeterSubcategory
            - lld_macro: '{#AZURE.BILLING.METER}'
              path: $.Meter
            - lld_macro: '{#AZURE.BILLING.UNIT}'
              path: $.Currency
            - lld_macro: '{#AZURE.RESOURCE.GROUP}'
              path: $.ResourceGroup
            - lld_macro: '{#AZURE.RESOURCE.LOCATION}'
              path: $.ResourceLocation
            - lld_macro: '{#AZURE.SERVICE.NAME}'
              path: $.ServiceName
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.data
              error_handler: DISCARD_VALUE
        - uuid: 9c65b60a8e1840dd81367aefe6b0de18
          name: 'Azure monthly costs discovery'
          type: DEPENDENT
          key: azure.monthly.costs.discovery
          description: 'Discovery of monthly costs.'
          item_prototypes:
            - uuid: f91a60d2c1124eb6b297539b0a115c66
              name: 'Month ["{#AZURE.BILLING.MONTH}"] cost'
              type: DEPENDENT
              key: 'azure.monthly.cost["{#AZURE.BILLING.MONTH}"]'
              value_type: FLOAT
              units: '!{#AZURE.BILLING.UNIT}'
              description: 'The monthly cost.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.monthCost.data.[?(@.BillingMonth == "{#AZURE.BILLING.MONTH}")].PreTaxCost.first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: azure.get.monthly.costs
              tags:
                - tag: component
                  value: cost
                - tag: month
                  value: '{#AZURE.BILLING.MONTH}'
          graph_prototypes:
            - uuid: 347342d3d0cc478bab33036872570cdb
              name: 'Azure Cost: Month ["{#AZURE.BILLING.MONTH}"] cost'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 2E7D32
                  item:
                    host: 'Azure Cost Management by HTTP'
                    key: 'azure.monthly.cost["{#AZURE.BILLING.MONTH}"]'
          master_item:
            key: azure.get.monthly.costs
          lld_macro_paths:
            - lld_macro: '{#AZURE.BILLING.MONTH}'
              path: $.BillingMonth
            - lld_macro: '{#AZURE.BILLING.UNIT}'
              path: $.Currency
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.monthCost.data
              error_handler: DISCARD_VALUE
        - uuid: e9a4bf192feb4472aedd40ba2371d286
          name: 'Azure monthly costs by location discovery'
          type: DEPENDENT
          key: azure.monthly.location.costs.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#AZURE.RESOURCE.LOCATION}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.LOCATION.MATCHES}'
              - macro: '{#AZURE.RESOURCE.LOCATION}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.LOCATION.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery of monthly costs by location.'
          item_prototypes:
            - uuid: 7fb097f81a8445acaa6b17bdc4daaaa6
              name: 'Location: ["{#AZURE.RESOURCE.LOCATION}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
              type: DEPENDENT
              key: 'azure.monthly.location.cost["{#AZURE.RESOURCE.LOCATION}", "{#AZURE.BILLING.MONTH}"]'
              value_type: FLOAT
              units: '!{#AZURE.BILLING.UNIT}'
              description: 'The monthly cost by location {#AZURE.RESOURCE.LOCATION}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.resourceLocationCost.data.[?(@.BillingMonth == "{#AZURE.BILLING.MONTH}")]'
                  error_handler: DISCARD_VALUE
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.ResourceLocation == "{#AZURE.RESOURCE.LOCATION}")].PreTaxCost.first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: azure.get.monthly.costs
              tags:
                - tag: component
                  value: cost
                - tag: location
                  value: '{#AZURE.RESOURCE.LOCATION}'
                - tag: month
                  value: '{#AZURE.BILLING.MONTH}'
          graph_prototypes:
            - uuid: e3df27afabb147d3ae07e1a2fa36e89a
              name: 'Azure Cost: ["{#AZURE.RESOURCE.LOCATION}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 2E7D32
                  item:
                    host: 'Azure Cost Management by HTTP'
                    key: 'azure.monthly.location.cost["{#AZURE.RESOURCE.LOCATION}", "{#AZURE.BILLING.MONTH}"]'
          master_item:
            key: azure.get.monthly.costs
          lld_macro_paths:
            - lld_macro: '{#AZURE.BILLING.MONTH}'
              path: $.BillingMonth
            - lld_macro: '{#AZURE.BILLING.UNIT}'
              path: $.Currency
            - lld_macro: '{#AZURE.RESOURCE.LOCATION}'
              path: $.ResourceLocation
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.resourceLocationCost.data
              error_handler: DISCARD_VALUE
        - uuid: 4dfa3b60721e463d97f2f820106f816d
          name: 'Azure monthly costs by resource group discovery'
          type: DEPENDENT
          key: azure.monthly.resource.group.costs.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#AZURE.RESOURCE.GROUP}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.GROUP.MATCHES}'
              - macro: '{#AZURE.RESOURCE.GROUP}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.GROUP.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery of monthly costs by resource group.'
          item_prototypes:
            - uuid: 9a5ed573ac374c08abf81f2b7296f260
              name: 'Resource group: ["{#AZURE.RESOURCE.GROUP}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
              type: DEPENDENT
              key: 'azure.monthly.resource.group.cost["{#AZURE.RESOURCE.GROUP}", "{#AZURE.BILLING.MONTH}"]'
              value_type: FLOAT
              units: '!{#AZURE.BILLING.UNIT}'
              description: 'The monthly cost by resource group {#AZURE.RESOURCE.GROUP}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.resourceGroupCost.data.[?(@.BillingMonth == "{#AZURE.BILLING.MONTH}")]'
                  error_handler: DISCARD_VALUE
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.ResourceGroup == "{#AZURE.RESOURCE.GROUP}")].PreTaxCost.first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: azure.get.monthly.costs
              tags:
                - tag: component
                  value: cost
                - tag: month
                  value: '{#AZURE.BILLING.MONTH}'
                - tag: resource-group
                  value: '{#AZURE.RESOURCE.GROUP}'
          graph_prototypes:
            - uuid: fab17244d2c648e089c57c99615af537
              name: 'Azure Cost: ["{#AZURE.RESOURCE.GROUP}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 2E7D32
                  item:
                    host: 'Azure Cost Management by HTTP'
                    key: 'azure.monthly.resource.group.cost["{#AZURE.RESOURCE.GROUP}", "{#AZURE.BILLING.MONTH}"]'
          master_item:
            key: azure.get.monthly.costs
          lld_macro_paths:
            - lld_macro: '{#AZURE.BILLING.MONTH}'
              path: $.BillingMonth
            - lld_macro: '{#AZURE.BILLING.UNIT}'
              path: $.Currency
            - lld_macro: '{#AZURE.RESOURCE.GROUP}'
              path: $.ResourceGroup
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.resourceGroupCost.data
              error_handler: DISCARD_VALUE
        - uuid: b9b024a7e42540f0b8387af77367b15c
          name: 'Azure monthly costs by services discovery'
          type: DEPENDENT
          key: azure.monthly.services.costs.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#AZURE.SERVICE.NAME}'
                value: '{$AZURE.LLD.FILTER.SERVICE.MATCHES}'
              - macro: '{#AZURE.SERVICE.NAME}'
                value: '{$AZURE.LLD.FILTER.SERVICE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery of monthly costs by services.'
          item_prototypes:
            - uuid: dbad6436c70e41268e3b59c2a7f0e2a2
              name: 'Service ["{#AZURE.SERVICE.NAME}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
              type: DEPENDENT
              key: 'azure.monthly.service.cost["{#AZURE.SERVICE.NAME}", "{#AZURE.BILLING.MONTH}"]'
              value_type: FLOAT
              units: '!{#AZURE.BILLING.UNIT}'
              description: 'The monthly cost by service {#AZURE.SERVICE.NAME}.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$.serviceCost.data.[?(@.BillingMonth == "{#AZURE.BILLING.MONTH}")]'
                  error_handler: DISCARD_VALUE
                - type: JSONPATH
                  parameters:
                    - '$.[?(@.ServiceName == "{#AZURE.SERVICE.NAME}")].PreTaxCost.first()'
                  error_handler: DISCARD_VALUE
              master_item:
                key: azure.get.monthly.costs
              tags:
                - tag: component
                  value: cost
                - tag: month
                  value: '{#AZURE.BILLING.MONTH}'
                - tag: service
                  value: '{#AZURE.SERVICE.NAME}'
          graph_prototypes:
            - uuid: 31f1e30f99ed426d81b48411cc7ffd7f
              name: 'Azure Cost: ["{#AZURE.SERVICE.NAME}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 2E7D32
                  item:
                    host: 'Azure Cost Management by HTTP'
                    key: 'azure.monthly.service.cost["{#AZURE.SERVICE.NAME}", "{#AZURE.BILLING.MONTH}"]'
          master_item:
            key: azure.get.monthly.costs
          lld_macro_paths:
            - lld_macro: '{#AZURE.BILLING.MONTH}'
              path: $.BillingMonth
            - lld_macro: '{#AZURE.BILLING.UNIT}'
              path: $.Currency
            - lld_macro: '{#AZURE.SERVICE.NAME}'
              path: $.ServiceName
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.serviceCost.data
              error_handler: DISCARD_VALUE
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
        - tag: target
          value: cost
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.BILLING.MONTH}'
          value: '11'
          description: 'Months to get historical data from Azure Cost Management API, no more than 11 (plus current month). The time period for pulling the data cannot exceed 1 year.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 60s
          description: 'API response timeout.'
        - macro: '{$AZURE.LLD.FILTER.RESOURCE.GROUP.MATCHES}'
          value: '.*'
          description: 'Filter of discoverable resource groups by name.'
        - macro: '{$AZURE.LLD.FILTER.RESOURCE.GROUP.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discovered resource groups by name.'
        - macro: '{$AZURE.LLD.FILTER.RESOURCE.LOCATION.MATCHES}'
          value: '.*'
          description: 'Filter of discoverable locations by name.'
        - macro: '{$AZURE.LLD.FILTER.RESOURCE.LOCATION.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discovered locations by name.'
        - macro: '{$AZURE.LLD.FILTER.SERVICE.MATCHES}'
          value: '.*'
          description: 'Filter of discoverable services by name.'
        - macro: '{$AZURE.LLD.FILTER.SERVICE.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discovered services by name.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
      dashboards:
        - uuid: a1c2ce224f07483b865ce48090338dc4
          name: 'Overview Azure Costs'
          pages:
            - name: 'Monthly costs'
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '25'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Azure Cost Management by HTTP'
                        name: 'Azure Cost: Month ["{#AZURE.BILLING.MONTH}"] cost'
                    - type: STRING
                      name: reference
                      value: AAAAA
                    - type: INTEGER
                      name: rows
                      value: '6'
            - name: 'Monthly costs by service'
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '25'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Azure Cost Management by HTTP'
                        name: 'Azure Cost: ["{#AZURE.SERVICE.NAME}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: rows
                      value: '6'
            - name: 'Monthly costs by location'
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '25'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Azure Cost Management by HTTP'
                        name: 'Azure Cost: ["{#AZURE.RESOURCE.LOCATION}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
                    - type: STRING
                      name: reference
                      value: AAAAC
                    - type: INTEGER
                      name: rows
                      value: '6'
            - name: 'Monthly costs by resource group'
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '25'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Azure Cost Management by HTTP'
                        name: 'Azure Cost: ["{#AZURE.RESOURCE.GROUP}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
                    - type: STRING
                      name: reference
                      value: AAAAD
                    - type: INTEGER
                      name: rows
                      value: '6'
            - name: 'Daily costs by service'
              widgets:
                - type: graphprototype
                  width: '72'
                  height: '20'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Azure Cost Management by HTTP'
                        name: 'Daily Cost: "{#AZURE.SERVICE.NAME}","{#AZURE.BILLING.METER}","{#AZURE.BILLING.METER.SUBCATEGORY}","{#AZURE.RESOURCE.GROUP}"'
                    - type: STRING
                      name: reference
                      value: AAAAE
                    - type: INTEGER
                      name: rows
                      value: '5'
    - uuid: 2d8b9329b5d04cdf85bf17d2d0db2b29
      template: 'Azure Microsoft SQL Database by HTTP'
      name: 'Azure Microsoft SQL Database by HTTP'
      description: |
        This template is designed to monitor Microsoft SQL databases by HTTP.
        It works without any external scripts and uses the script item.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: {$AZURE.APP.ID}, {$AZURE.PASSWORD}, {$AZURE.TENANT.ID}, {$AZURE.SUBSCRIPTION.ID}, and {$AZURE.RESOURCE.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 2ff1f479e0b447f2b85e75e99bc011fe
          name: 'Availability status detailed'
          type: DEPENDENT
          key: azure.db.mssql.availability.details
          value_type: CHAR
          description: 'The summary description of the availability status.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.summary
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: health
        - uuid: f15e8075ac9a4f1ca6e95106940b246e
          name: 'Availability state'
          type: DEPENDENT
          key: azure.db.mssql.availability.state
          description: 'The availability status of the resource.'
          valuemap:
            name: 'Azure resource health state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.availabilityState
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: STR_REPLACE
              parameters:
                - Available
                - '0'
            - type: STR_REPLACE
              parameters:
                - Degraded
                - '1'
            - type: STR_REPLACE
              parameters:
                - Unavailable
                - '2'
            - type: STR_REPLACE
              parameters:
                - Unknown
                - '3'
            - type: IN_RANGE
              parameters:
                - '0'
                - '3'
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: 5156f35b82084fd3b1d1a11c35757993
              expression: 'last(/Azure Microsoft SQL Database by HTTP/azure.db.mssql.availability.state)=1'
              name: 'Microsoft SQL database is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in a degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 0cf3cce995c241838e13df12d5908b61
              expression: 'last(/Azure Microsoft SQL Database by HTTP/azure.db.mssql.availability.state)=3'
              name: 'Microsoft SQL database is in unknown state'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The resource state is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 2130dc83dee94fdfad87894127c6a578
              expression: 'last(/Azure Microsoft SQL Database by HTTP/azure.db.mssql.availability.state)=2'
              name: 'Microsoft SQL database is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: ce744d69ed12435db781fbc6100d97ab
          name: 'Connections failed: System errors'
          type: DEPENDENT
          key: azure.db.mssql.connections.failed.system
          value_type: FLOAT
          description: 'The count of failed connections with system errors.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.connection_failed.total
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 8ec27240f59947858c41762a266cab25
          name: 'Connections successful'
          type: DEPENDENT
          key: azure.db.mssql.connections.successful
          value_type: FLOAT
          description: 'The count of successful connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.connection_successful.total
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 04737f2746444d2fb348a9444964dc7a
          name: 'CPU limit'
          type: DEPENDENT
          key: azure.db.mssql.cpu.limit
          value_type: FLOAT
          description: 'The CPU limit. Applies to the vCore-based databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_limit.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: e55a199cc0bd4749a69478da8268785d
          name: 'Percentage CPU'
          type: DEPENDENT
          key: azure.db.mssql.cpu.percentage
          value_type: FLOAT
          units: '%'
          description: 'The CPU percent of a host.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 506c034e707442519792a4366bc0879d
              expression: 'min(/Azure Microsoft SQL Database by HTTP/azure.db.mssql.cpu.percentage,5m)>{$AZURE.DB.CPU.UTIL.CRIT}'
              name: 'High CPU utilization'
              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: 9a4a948f41e4434e9a94b3d9546df896
          name: 'CPU used'
          type: DEPENDENT
          key: azure.db.mssql.cpu.used
          value_type: FLOAT
          description: 'The CPU used. Applies to the vCore-based databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_used.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: e8aa1b70a7384ffead05cd2e95a6f10a
          name: 'Get errors'
          type: DEPENDENT
          key: azure.db.mssql.data.errors
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.errors
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: 62d08fe430bd45e890c81547860d5c3d
              expression: 'length(last(/Azure Microsoft SQL Database by HTTP/azure.db.mssql.data.errors))>0'
              name: '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: 741cc1ec6a824e429f06b3d12a8a7082
          name: 'Get data'
          type: SCRIPT
          key: azure.db.mssql.data.get
          history: '0'
          value_type: TEXT
          params: |
            var AzureDB = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id', 'resource_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		AzureDB.params = params;
            	},
            
            
            	request: function (url, data) {
            		if (typeof data === 'undefined' || data === null) {
            			data = '';
            		}
            
            		var response, request = new HttpRequest();
            		if (typeof AzureDB.params.proxy !== 'undefined' && AzureDB.params.proxy !== '') {
            			request.setProxy(AzureDB.params.proxy);
            		}
            		if (AzureDB.token) {
            			request.addHeader('Accept: application/json');
            			request.addHeader('Authorization: Bearer ' + AzureDB.token);
            		}
            
            		Zabbix.log(4, '[ Azure ] Sending request: ' + url);
            
            		if (data !== '') {
            			request.addHeader('Content-Type: application/x-www-form-urlencoded');
            			response = request.post(url, data);
            		}
            		else {
            			response = request.get(url);
            		}
            
            		Zabbix.log(4, '[ Azure ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200 || response === null) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	}
            
            };
            
            var metrics = [
            	'cpu_percent',
            	'physical_data_read_percent',
            	'log_write_percent',
            	'storage',
            	'connection_successful',
            	'connection_failed',
            	'blocked_by_firewall',
            	'deadlock',
            	'storage_percent',
            	'xtp_storage_percent',
            	'workers_percent',
            	'sessions_percent',
            	'sessions_count',
            	'cpu_limit',
            	'cpu_used',
            	'sqlserver_process_core_percent',
            	'sqlserver_process_memory_percent',
            	'tempdb_data_size',
            	'tempdb_log_size',
            	'tempdb_log_used_percent',
            	'allocated_data_storage'
            ],
            	day_metrics = 'full_backup_size_bytes,diff_backup_size_bytes,log_backup_size_bytes',
            	prepared_metrics = [],
            	data = {};
            	data['errors'] = {};
            	data['metrics'] = {};
            
            try {
            	AzureDB.setParams(JSON.parse(value));
            
            	try {
            		result = AzureDB.request(
            			'https://login.microsoftonline.com/' + encodeURIComponent(AzureDB.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureDB.params.app_id) + '&client_secret=' + encodeURIComponent(AzureDB.params.password)
            		);
            
            		if ('access_token' in result) {
            			AzureDB.token = result['access_token'];
            		} else {
            			throw 'Auth response does not contain access token.';
            		}
            	}
            	catch (error) {
            		data.errors.auth = error.toString();
            	}
            
            	if (!('auth' in data.errors)) {
            		try {
            			health = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2020-05-01');
            			if ('value' in health && Array.isArray(health.value) && health.value.length > 0 && 'properties' in health.value[0] && typeof health.value[0].properties === 'object') {
            				data.health = health.value[0].properties;
            			}
            		}
            		catch (error) {
            			data.errors.health = error.toString();
            		}
            
            		for (var i = 0; i < metrics.length; i += 20) {
            			var chunk = metrics.slice(i, i + 20);
            
            			prepared_metrics.push(
            				chunk.map(function (element) {
            					return encodeURIComponent(element);
            				}).join(',')
            			);
            		}
            
            		start_date = new Date((new Date().getTime()) - 300000).toISOString().replace(/\.\d+/, '');
            		end_date = new Date().toISOString().replace(/\.\d+/, '');
            
            		for (var j in prepared_metrics) {
            			try {
            				metrics_data = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.Insights/metrics?metricnames=' + prepared_metrics[j] + '&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date) + '&api-version=2021-05-01');
            				if ('value' in metrics_data && Array.isArray(metrics_data.value) && metrics_data.value.length > 0) {
            					for (k in metrics_data.value) {
            						if ('name' in metrics_data.value[k] && typeof metrics_data.value[k].name === 'object' && 'value' in metrics_data.value[k].name && typeof metrics_data.value[k].name.value === 'string' && 'timeseries' in metrics_data.value[k] && Array.isArray(metrics_data.value[k].timeseries) && metrics_data.value[k].timeseries.length > 0 && 'data' in metrics_data.value[k].timeseries[0] && Array.isArray(metrics_data.value[k].timeseries[0].data) && metrics_data.value[k].timeseries[0].data.length > 0) {
            							data.metrics[metrics_data.value[k].name.value.replace(/(\s|\/)+/g, '')] = metrics_data.value[k].timeseries[0].data[metrics_data.value[k].timeseries[0].data.length - 1];
            						}
            					}
            				}
            			}
            			catch (error) {
            				data.errors[prepared_metrics[j]] = error.toString();
            			}
            		}
            		start_date = new Date((new Date().getTime()) - 86400000).toISOString().replace(/\.\d+/, '');
            		end_date = new Date().toISOString().replace(/\.\d+/, '');
            		try {
            			metrics_data = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.Insights/metrics?metricnames=' + day_metrics + '&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date) + '&api-version=2021-05-01');
            			if ('value' in metrics_data && Array.isArray(metrics_data.value) && metrics_data.value.length > 0) {
            				for (l in metrics_data.value) {
            					if ('name' in metrics_data.value[l] && typeof metrics_data.value[l].name === 'object' && 'value' in metrics_data.value[l].name && typeof metrics_data.value[l].name.value === 'string' && 'timeseries' in metrics_data.value[l] && Array.isArray(metrics_data.value[l].timeseries) && metrics_data.value[l].timeseries.length > 0 && 'data' in metrics_data.value[l].timeseries[0] && Array.isArray(metrics_data.value[l].timeseries[0].data) && metrics_data.value[l].timeseries[0].data.length > 0) {
            						data.metrics[metrics_data.value[l].name.value.replace(/(\s|\/)+/g, '')] = metrics_data.value[l].timeseries[0].data[metrics_data.value[l].timeseries[0].data.length - 1];
            					}
            				}
            			}
            		}
            		catch (error) {
            			data.errors[day_metrics] = error.toString();
            		}
            	}
            }
            catch (error) {
            	data.errors.params = error.toString();
            }
            
            if (Object.keys(data.errors).length !== 0) {
            	errors = 'Failed to receive data:';
            	for (var error in data.errors) {
            		errors += '\n' + error + ' : ' + data.errors[error];
            	}
            	data.errors = errors;
            }
            else {
            	data.errors = '';
            }
            
            return JSON.stringify(data);
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: resource_id
              value: '{$AZURE.RESOURCE.ID}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: 75d9288a8240425782cce8701c1bdfa8
          name: 'Data IO percentage'
          type: DEPENDENT
          key: azure.db.mssql.data.read.percentage
          value_type: FLOAT
          units: '%'
          description: 'The percentage of physical data read.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.physical_data_read_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: operations
        - uuid: 81f87d35131c426299b233279f8f6c4b
          name: Deadlocks
          type: DEPENDENT
          key: azure.db.mssql.deadlocks
          value_type: FLOAT
          description: 'The count of deadlocks. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.deadlock.total
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 4d78e4691b6f4ab095849e6af2713638
          name: 'Connections blocked by firewall'
          type: DEPENDENT
          key: azure.db.mssql.firewall.blocked
          value_type: FLOAT
          description: 'The count of connections blocked by firewall.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.blocked_by_firewall.total
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 324c16e5da5b40c78d687f1f41a9d180
          name: 'Log IO percentage'
          type: DEPENDENT
          key: azure.db.mssql.log.write.percentage
          value_type: FLOAT
          units: '%'
          description: 'The percentage of I/O log. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.log_write_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: operations
        - uuid: f417464b2de14e3292d68442570b931d
          name: 'SQL Server process core percent'
          type: DEPENDENT
          key: azure.db.mssql.server.cpu.percent
          value_type: FLOAT
          units: '%'
          description: 'The CPU usage as a percentage of the SQL DB process. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.sqlserver_process_core_percent.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: cpu
            - tag: component
              value: server
        - uuid: b39aa0798a824dafb3f3871b6406106a
          name: 'SQL Server process memory percent'
          type: DEPENDENT
          key: azure.db.mssql.server.memory.percent
          value_type: FLOAT
          units: '%'
          description: 'Memory usage as a percentage of the SQL DB process. Not applicable to data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.sqlserver_process_memory_percent.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: memory
            - tag: component
              value: server
        - uuid: 754b453cdf464f73b09eced3dd3e5859
          name: 'Sessions count'
          type: DEPENDENT
          key: azure.db.mssql.sessions.count
          value_type: FLOAT
          description: 'The number of active sessions. Not applicable to Synapse DW Analytics.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.sessions_count.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: sessions
        - uuid: b6696ac3d83841e2a001cdad1aeaea89
          name: 'Sessions percentage'
          type: DEPENDENT
          key: azure.db.mssql.sessions.percent
          value_type: FLOAT
          units: '%'
          description: 'The percentage of sessions. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.sessions_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: sessions
        - uuid: fddff3dcbcf44c408314946f01f26a79
          name: 'Data space allocated'
          type: DEPENDENT
          key: azure.db.mssql.storage.allocated
          value_type: FLOAT
          units: B
          description: 'The allocated data storage. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.allocated_data_storage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 3d492b552468462ba17524a9c6951dd7
          name: 'Differential backup storage size'
          type: DEPENDENT
          key: azure.db.mssql.storage.backup.diff.size
          value_type: FLOAT
          units: B
          description: 'Cumulative differential backup storage size. Applies to the vCore-based databases. Not applicable to the Hyperscale databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.diff_backup_size_bytes.maximum
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: e8cd0339a82248e3ad777374f219552e
          name: 'Log backup storage size'
          type: DEPENDENT
          key: azure.db.mssql.storage.backup.log.size
          value_type: FLOAT
          units: B
          description: 'Cumulative log backup storage size. Applies to the vCore-based and Hyperscale databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.log_backup_size_bytes.maximum
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: c92867a096ad4d89b31a2dba7e560df1
          name: 'Full backup storage size'
          type: DEPENDENT
          key: azure.db.mssql.storage.backup.size
          value_type: FLOAT
          units: B
          description: 'Cumulative full backup storage size. Applies to the vCore-based databases. Not applicable to the Hyperscale databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.full_backup_size_bytes.maximum
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 6eb5dc0a0b864c0bb35634612472ed38
          name: 'Data space used percent'
          type: DEPENDENT
          key: azure.db.mssql.storage.percent
          value_type: FLOAT
          units: '%'
          description: 'Data space used percent. Not applicable to the data warehouses or Hyperscale databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_percent.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: a2d6cf9ac67d4d0eb312e9536299b345
              expression: 'last(/Azure Microsoft SQL Database by HTTP/azure.db.mssql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.CRIT}'
              name: 'Storage space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Critical utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 6dbf1d3aeb8b44b8bd96a9ca75f5249e
              expression: 'last(/Azure Microsoft SQL Database by HTTP/azure.db.mssql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.WARN}'
              name: 'Storage space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: a0335bde6f3546cdad5bbd2db8fa50b1
          name: 'Data space used'
          type: DEPENDENT
          key: azure.db.mssql.storage.used
          value_type: FLOAT
          units: B
          description: 'Data space used. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 6ff07a9a680749bfa3deabbec508b7c3
          name: 'In-Memory OLTP storage percent'
          type: DEPENDENT
          key: azure.db.mssql.storage.xtp.percent
          value_type: FLOAT
          units: '%'
          description: 'In-Memory OLTP storage percent. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.xtp_storage_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 76da2f210c084546a19ce156e0aee1d6
          name: 'Tempdb data file size'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.data.size
          value_type: FLOAT
          units: B
          description: 'The space used in `tempdb` data files, expressed in bytes. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.tempdb_data_size.maximum
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: dd2986cc6ce441fe9b3ab9b44b5fc103
          name: 'Tempdb log used percent'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.log.percent
          value_type: FLOAT
          units: '%'
          description: 'The percentage of space used in `tempdb` transaction log file. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.tempdb_log_used_percent.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 51212e2af3854079950064bd9d16da83
          name: 'Tempdb log file size'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.log.size
          value_type: FLOAT
          units: B
          description: 'The space used in `tempdb` transaction log file, expressed in bytes. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.tempdb_log_size.maximum
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b5d63b2cbcb1470d8559a90cb3df0002
          name: 'Workers percentage'
          type: DEPENDENT
          key: azure.db.mssql.workers.percent
          value_type: FLOAT
          units: '%'
          description: 'The percentage of workers. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.workers_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: workers
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
        - tag: target
          value: mssql
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
        - macro: '{$AZURE.DB.CPU.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of CPU utilization, expressed in %.'
        - macro: '{$AZURE.DB.MEMORY.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of memory utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.CRIT}'
          value: '90'
          description: 'The critical threshold of storage utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.WARN}'
          value: '80'
          description: 'The warning threshold of storage utilization, expressed in %.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.RESOURCE.ID}'
          description: 'Microsoft Azure Microsoft SQL database ID.'
        - macro: '{$AZURE.SUBSCRIPTION.ID}'
          description: 'Microsoft Azure subscription ID.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
      dashboards:
        - uuid: 72b6f0916b9245adadb3445327aed633
          name: 'Overview Azure Microsoft SQL Database'
          pages:
            - widgets:
                - type: item
                  name: Deadlocks
                  width: '12'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.deadlocks
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'SQL Server process memory percent'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.server.memory.percent
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'CPU limit'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.cpu.limit
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Data space allocated'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.storage.allocated
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections successful'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.connections.successful
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Availability state'
                  x: '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.availability.state
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: up_color
                      value: FF0000
                - type: item
                  name: 'SQL Server process core percent'
                  x: '12'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.server.cpu.percent
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'CPU used'
                  x: '12'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.cpu.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Data space used'
                  x: '12'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.storage.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections failed: System errors'
                  x: '12'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.connections.failed.system
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: itemhistory
                  name: 'Availability status detailed'
                  x: '24'
                  width: '48'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: columns.0.display
                      value: '4'
                    - type: ITEM
                      name: columns.0.itemid
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.availability.details
                    - type: INTEGER
                      name: columns.0.monospace_font
                      value: '1'
                    - type: STRING
                      name: columns.0.name
                      value: 'Azure Microsoft SQL: Availability status detailed'
                    - type: STRING
                      name: reference
                      value: BAAAG
                    - type: INTEGER
                      name: show_timestamp
                      value: '1'
                - type: item
                  name: 'Sessions count'
                  x: '24'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.sessions.count
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: graph
                  name: 'Percentage CPU'
                  x: '24'
                  'y': '6'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        name: 'Azure Microsoft SQL: CPU usage'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'Storage utilization'
                  x: '24'
                  'y': '9'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        name: 'Azure Microsoft SQL: Storage utilization'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: Connections
                  x: '24'
                  'y': '12'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        name: 'Azure Microsoft SQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: item
                  name: 'Workers percentage'
                  x: '36'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.workers.percent
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'Full backup storage size'
                  x: '48'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.storage.backup.size
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Data IO percentage'
                  x: '60'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Database by HTTP'
                        key: azure.db.mssql.data.read.percentage
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
      valuemaps:
        - uuid: 6f9c01899d9e45c9a1316ee081718e9e
          name: 'Azure resource health state'
          mappings:
            - value: '0'
              newvalue: Available
            - value: '1'
              newvalue: Degraded
            - value: '2'
              newvalue: Unavailable
            - value: '3'
              newvalue: Unknown
    - uuid: 5175afdf713744d9a81ce53864ccfc1d
      template: 'Azure Microsoft SQL Serverless Database by HTTP'
      name: 'Azure Microsoft SQL Serverless Database by HTTP'
      description: |
        This template is designed to monitor Microsoft SQL serverless databases by HTTP.
        It works without any external scripts and uses the script item.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: {$AZURE.APP.ID}, {$AZURE.PASSWORD}, {$AZURE.TENANT.ID}, {$AZURE.SUBSCRIPTION.ID}, and {$AZURE.RESOURCE.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 7c11fcc4f4b349f8b98fac93ae5e32be
          name: 'App CPU billed'
          type: DEPENDENT
          key: azure.db.mssql.app.cpu.billed
          value_type: FLOAT
          description: 'App CPU billed. Applies to serverless databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.app_cpu_billed.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: 6e67a868b2d84838803d3cb464ae9648
          name: 'App CPU percentage'
          type: DEPENDENT
          key: azure.db.mssql.app.cpu.percent
          value_type: FLOAT
          units: '%'
          description: 'App CPU percentage. Applies to serverless databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.app_cpu_percent.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: a38a887341914e75a01c7527c40b678f
          name: 'App memory percentage'
          type: DEPENDENT
          key: azure.db.mssql.app.memory.percent
          value_type: FLOAT
          units: '%'
          description: 'App memory percentage. Applies to serverless databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.app_memory_percent.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: memory
        - uuid: c2d3bc4ff95b4e05898dccee3d73a349
          name: 'Availability status detailed'
          type: DEPENDENT
          key: azure.db.mssql.availability.details
          value_type: CHAR
          description: 'The summary description of the availability status.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.summary
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: health
        - uuid: 9a3f2e99a768492c859c8f368c6a5cd3
          name: 'Availability state'
          type: DEPENDENT
          key: azure.db.mssql.availability.state
          description: 'The availability status of the resource.'
          valuemap:
            name: 'Azure resource health state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.availabilityState
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: STR_REPLACE
              parameters:
                - Available
                - '0'
            - type: STR_REPLACE
              parameters:
                - Degraded
                - '1'
            - type: STR_REPLACE
              parameters:
                - Unavailable
                - '2'
            - type: STR_REPLACE
              parameters:
                - Unknown
                - '3'
            - type: IN_RANGE
              parameters:
                - '0'
                - '3'
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: 37c52a28908a45378266f68acdf5c308
              expression: 'last(/Azure Microsoft SQL Serverless Database by HTTP/azure.db.mssql.availability.state)=1'
              name: 'Microsoft SQL database is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in a degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 20bd79f05f3241a9950a83dcd9e325ba
              expression: 'last(/Azure Microsoft SQL Serverless Database by HTTP/azure.db.mssql.availability.state)=3'
              name: 'Microsoft SQL database is in unknown state'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The resource state is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 124813388e9844e8aae5ce474a66a774
              expression: 'last(/Azure Microsoft SQL Serverless Database by HTTP/azure.db.mssql.availability.state)=2'
              name: 'Microsoft SQL database is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 2457708a49d141faa16bd7b4ceb2c0a4
          name: 'Connections failed: System errors'
          type: DEPENDENT
          key: azure.db.mssql.connections.failed.system
          value_type: FLOAT
          description: 'The count of failed connections with system errors.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.connection_failed.total
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 59e028a7323d4222a4efd727314327c1
          name: 'Connections successful'
          type: DEPENDENT
          key: azure.db.mssql.connections.successful
          value_type: FLOAT
          description: 'The count of successful connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.connection_successful.total
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 0dc1cf6302574c1fbb51583e03409713
          name: 'CPU limit'
          type: DEPENDENT
          key: azure.db.mssql.cpu.limit
          value_type: FLOAT
          description: 'The CPU limit. Applies to the vCore-based databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_limit.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: 53be31ecfd48472c8edfe223107c0b07
          name: 'Percentage CPU'
          type: DEPENDENT
          key: azure.db.mssql.cpu.percentage
          value_type: FLOAT
          units: '%'
          description: 'The CPU percent of a host.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 933a04a1455b4a89b1527f9ce7848259
              expression: 'min(/Azure Microsoft SQL Serverless Database by HTTP/azure.db.mssql.cpu.percentage,5m)>{$AZURE.DB.CPU.UTIL.CRIT}'
              name: 'High CPU utilization'
              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: ec0fc85904e149939836c2818a6ca66a
          name: 'CPU used'
          type: DEPENDENT
          key: azure.db.mssql.cpu.used
          value_type: FLOAT
          description: 'The CPU used. Applies to the vCore-based databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_used.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: d933dbacb2b94e40a757e15f13d51d2d
          name: 'Get errors'
          type: DEPENDENT
          key: azure.db.mssql.data.errors
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.errors
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: f56b125a8eff49d2aa002609c7df8b34
              expression: 'length(last(/Azure Microsoft SQL Serverless Database by HTTP/azure.db.mssql.data.errors))>0'
              name: '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: e1c668773b974deeaf64c0d51d1cb02d
          name: 'Get data'
          type: SCRIPT
          key: azure.db.mssql.data.get
          history: '0'
          value_type: TEXT
          params: |
            var AzureDB = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id', 'resource_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		AzureDB.params = params;
            	},
            
            
            	request: function (url, data) {
            		if (typeof data === 'undefined' || data === null) {
            			data = '';
            		}
            		var response, request = new HttpRequest();
            		if (typeof AzureDB.params.proxy !== 'undefined' && AzureDB.params.proxy !== '') {
            			request.setProxy(AzureDB.params.proxy);
            		}
            		if (AzureDB.token) {
            			request.addHeader('Accept: application/json');
            			request.addHeader('Authorization: Bearer ' + AzureDB.token);
            		}
            
            		Zabbix.log(4, '[ Azure ] Sending request: ' + url);
            
            		if (data !== '') {
            			request.addHeader('Content-Type: application/x-www-form-urlencoded');
            			response = request.post(url, data);
            		}
            		else {
            			response = request.get(url);
            		}
            
            		Zabbix.log(4, '[ Azure ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200 || response === null) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	}
            
            };
            
            var metrics = [
            	'cpu_percent',
            	'physical_data_read_percent',
            	'log_write_percent',
            	'storage',
            	'connection_successful',
            	'connection_failed',
            	'blocked_by_firewall',
            	'deadlock',
            	'storage_percent',
            	'xtp_storage_percent',
            	'workers_percent',
            	'sessions_percent',
            	'cpu_limit',
            	'cpu_used',
            	'sqlserver_process_core_percent',
            	'sqlserver_process_memory_percent',
            	'tempdb_data_size',
            	'tempdb_log_size',
            	'tempdb_log_used_percent',
            	'app_cpu_billed',
            	'app_cpu_percent',
            	'app_memory_percent',
            	'allocated_data_storage'
            ],
            	prepared_metrics = [],
            	data = {};
            	data['errors'] = {};
            	data['metrics'] = {};
            
            try {
            	AzureDB.setParams(JSON.parse(value));
            
            	try {
            		result = AzureDB.request(
            			'https://login.microsoftonline.com/' + encodeURIComponent(AzureDB.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureDB.params.app_id) + '&client_secret=' + encodeURIComponent(AzureDB.params.password)
            		);
            
            		if ('access_token' in result) {
            			AzureDB.token = result['access_token'];
            		} else {
            			throw 'Auth response does not contain access token.';
            		}
            	}
            	catch (error) {
            		data.errors.auth = error.toString();
            	}
            
            	if (!('auth' in data.errors)) {
            		try {
            			health = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2020-05-01');
            			if ('value' in health && Array.isArray(health.value) && health.value.length > 0 && 'properties' in health.value[0] && typeof health.value[0].properties === 'object') {
            				data.health = health.value[0].properties;
            			}
            		}
            		catch (error) {
            			data.errors.health = error.toString();
            		}
            
            		for (var i = 0; i < metrics.length; i += 20) {
            			var chunk = metrics.slice(i, i + 20);
            
            			prepared_metrics.push(
            				chunk.map(function (element) {
            					return encodeURIComponent(element);
            				}).join(',')
            			);
            		}
            
            		start_date = new Date((new Date().getTime()) - 300000).toISOString().replace(/\.\d+/, '');
            		end_date = new Date().toISOString().replace(/\.\d+/, '');
            
            		for (var j in prepared_metrics) {
            			try {
            				metrics_data = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.Insights/metrics?metricnames=' + prepared_metrics[j] + '&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date) + '&api-version=2021-05-01');
            				if ('value' in metrics_data && Array.isArray(metrics_data.value) && metrics_data.value.length > 0) {
            					for (k in metrics_data.value) {
            						if ('name' in metrics_data.value[k] && typeof metrics_data.value[k].name === 'object' && 'value' in metrics_data.value[k].name && typeof metrics_data.value[k].name.value === 'string' && 'timeseries' in metrics_data.value[k] && Array.isArray(metrics_data.value[k].timeseries) && metrics_data.value[k].timeseries.length > 0 && 'data' in metrics_data.value[k].timeseries[0] && Array.isArray(metrics_data.value[k].timeseries[0].data) && metrics_data.value[k].timeseries[0].data.length > 0) {
            							data.metrics[metrics_data.value[k].name.value.replace(/(\s|\/)+/g, '')] = metrics_data.value[k].timeseries[0].data[metrics_data.value[k].timeseries[0].data.length - 1];
            						}
            					}
            				}
            			}
            			catch (error) {
            				data.errors[prepared_metrics[j]] = error.toString();
            			}
            		}
            	}
            }
            catch (error) {
            	data.errors.params = error.toString();
            }
            
            if (Object.keys(data.errors).length !== 0) {
            	errors = 'Failed to receive data:';
            	for (var error in data.errors) {
            		errors += '\n' + error + ' : ' + data.errors[error];
            	}
            	data.errors = errors;
            }
            else {
            	data.errors = '';
            }
            
            return JSON.stringify(data);
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: resource_id
              value: '{$AZURE.RESOURCE.ID}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: 40b15dd3d7a943d99f1bbe7fb34a9f48
          name: 'Data IO percentage'
          type: DEPENDENT
          key: azure.db.mssql.data.read.percentage
          value_type: FLOAT
          units: '%'
          description: 'The physical data read percentage.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.physical_data_read_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: operations
        - uuid: 25b97b67d87945b48ae5c44b1db20187
          name: Deadlocks
          type: DEPENDENT
          key: azure.db.mssql.deadlocks
          value_type: FLOAT
          description: 'The count of deadlocks. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.deadlock.total
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: network
        - uuid: de91693b0a3345b4ad2c9aafd2af5325
          name: 'Connections blocked by firewall'
          type: DEPENDENT
          key: azure.db.mssql.firewall.blocked
          value_type: FLOAT
          description: 'The count of connections blocked by firewall.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.blocked_by_firewall.total
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: network
        - uuid: b41292705c284a77847856c2818d7145
          name: 'Log IO percentage'
          type: DEPENDENT
          key: azure.db.mssql.log.write.percentage
          value_type: FLOAT
          units: '%'
          description: 'The percentage of I/O log. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.log_write_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: operations
        - uuid: 7b772170199f41d4ab614dee66176630
          name: 'SQL Server process core percent'
          type: DEPENDENT
          key: azure.db.mssql.server.cpu.percent
          value_type: FLOAT
          units: '%'
          description: 'The CPU usage as a percentage of the SQL DB process. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.sqlserver_process_core_percent.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: cpu
            - tag: component
              value: server
        - uuid: 5c0a5b745c094475b1e7a0d4f17a5627
          name: 'SQL Server process memory percent'
          type: DEPENDENT
          key: azure.db.mssql.server.memory.percent
          value_type: FLOAT
          units: '%'
          description: 'Memory usage as a percentage of the SQL DB process. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.sqlserver_process_memory_percent.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: memory
            - tag: component
              value: server
        - uuid: 924d96d212764c3ab18e5c14daa58840
          name: 'Sessions percentage'
          type: DEPENDENT
          key: azure.db.mssql.sessions.percent
          value_type: FLOAT
          units: '%'
          description: 'The percentage of sessions. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.sessions_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: sessions
        - uuid: a87fd8ac96944e57ac58b39a18f6ad41
          name: 'Data space allocated'
          type: DEPENDENT
          key: azure.db.mssql.storage.allocated
          value_type: FLOAT
          units: B
          description: 'The allocated data storage. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.allocated_data_storage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 2f95fd2dd48c4664afc5cd62d02b0b0a
          name: 'Data space used percent'
          type: DEPENDENT
          key: azure.db.mssql.storage.percent
          value_type: FLOAT
          units: '%'
          description: 'The percentage of used data space. Not applicable to the data warehouses or Hyperscale databases.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_percent.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 4638130e599243fba3206abc85a7447f
              expression: 'last(/Azure Microsoft SQL Serverless Database by HTTP/azure.db.mssql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.CRIT}'
              name: 'Storage space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Critical utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 4732eab4aabf439fa0b2d80b63e821e5
              expression: 'last(/Azure Microsoft SQL Serverless Database by HTTP/azure.db.mssql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.WARN}'
              name: 'Storage space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 3b1fb8f993e74795b38abd56eceace0a
          name: 'Data space used'
          type: DEPENDENT
          key: azure.db.mssql.storage.used
          value_type: FLOAT
          units: B
          description: 'Data space used. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: fbd572ca3d3f42eea794ce78a5a27ec1
          name: 'In-Memory OLTP storage percent'
          type: DEPENDENT
          key: azure.db.mssql.storage.xtp.percent
          value_type: FLOAT
          units: '%'
          description: 'In-Memory OLTP storage percent. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.xtp_storage_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: cea8a8ea0eaa4d26a28721882c19d9cd
          name: 'Tempdb data file size'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.data.size
          value_type: FLOAT
          units: B
          description: 'Space used in `tempdb` data files, expressed in bytes. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.tempdb_data_size.maximum
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 6c8196751a504b82920b7ffa5314a2fc
          name: 'Tempdb log used percent'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.log.percent
          value_type: FLOAT
          units: '%'
          description: 'The percentage of space used in `tempdb` transaction log files. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.tempdb_log_used_percent.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b83992d1001c41b6ad3d13dbb227a733
          name: 'Tempdb log file size'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.log.size
          value_type: FLOAT
          units: B
          description: 'Space used in `tempdb` transaction log files, expressed in bytes. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.tempdb_log_size.maximum
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: a4f597ab784a4e31aedc82bfb34feeb7
          name: 'Workers percentage'
          type: DEPENDENT
          key: azure.db.mssql.workers.percent
          value_type: FLOAT
          units: '%'
          description: 'The percentage of workers. Not applicable to the data warehouses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.workers_percent.average
          master_item:
            key: azure.db.mssql.data.get
          tags:
            - tag: component
              value: workers
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
        - tag: target
          value: mssql
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
        - macro: '{$AZURE.DB.CPU.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of CPU utilization, expressed in %.'
        - macro: '{$AZURE.DB.MEMORY.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of memory utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.CRIT}'
          value: '90'
          description: 'The critical threshold of storage utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.WARN}'
          value: '80'
          description: 'The warning threshold of storage utilization, expressed in %.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.RESOURCE.ID}'
          description: 'Microsoft Azure Microsoft SQL database ID.'
        - macro: '{$AZURE.SUBSCRIPTION.ID}'
          description: 'Microsoft Azure subscription ID.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
      dashboards:
        - uuid: 7a1b55d933ba4a529f2fccef44e5cff7
          name: 'Overview Azure Microsoft SQL Serverless Database'
          pages:
            - widgets:
                - type: item
                  name: Deadlocks
                  width: '12'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.deadlocks
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'SQL Server process memory percent'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.server.memory.percent
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'CPU limit'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.cpu.limit
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Data space allocated'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.storage.allocated
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections successful'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.connections.successful
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Availability state'
                  x: '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.availability.state
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: up_color
                      value: FF0000
                - type: item
                  name: 'SQL Server process core percent'
                  x: '12'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.server.cpu.percent
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'CPU used'
                  x: '12'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.cpu.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Data space used'
                  x: '12'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.storage.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections failed: System errors'
                  x: '12'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.connections.failed.system
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: itemhistory
                  name: 'Availability status detailed'
                  x: '24'
                  width: '48'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: columns.0.display
                      value: '4'
                    - type: ITEM
                      name: columns.0.itemid
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.availability.details
                    - type: INTEGER
                      name: columns.0.monospace_font
                      value: '1'
                    - type: STRING
                      name: columns.0.name
                      value: 'Azure Microsoft SQL: Availability status detailed'
                    - type: STRING
                      name: reference
                      value: BAAAF
                    - type: INTEGER
                      name: show_timestamp
                      value: '1'
                - type: item
                  name: 'Sessions percentage'
                  x: '24'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.sessions.percent
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: graph
                  name: 'Percentage CPU'
                  x: '24'
                  'y': '6'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        name: 'Azure Microsoft SQL: CPU usage'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'Storage utilization'
                  x: '24'
                  'y': '9'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        name: 'Azure Microsoft SQL: Storage utilization'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: Connections
                  x: '24'
                  'y': '12'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        name: 'Azure Microsoft SQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: item
                  name: 'Workers percentage'
                  x: '36'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.workers.percent
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'App memory percentage'
                  x: '48'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.app.memory.percent
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'Data IO percentage'
                  x: '60'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Microsoft SQL Serverless Database by HTTP'
                        key: azure.db.mssql.data.read.percentage
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
      valuemaps:
        - uuid: c87b2eaeb88c4932ad63c73fcafa5331
          name: 'Azure resource health state'
          mappings:
            - value: '0'
              newvalue: Available
            - value: '1'
              newvalue: Degraded
            - value: '2'
              newvalue: Unavailable
            - value: '3'
              newvalue: Unknown
    - uuid: ec92c7b0b1d14946b6ac61de89357199
      template: 'Azure MySQL Flexible Server by HTTP'
      name: 'Azure MySQL Flexible Server by HTTP'
      description: |
        This template is designed to monitor Microsoft Azure MySQL flexible servers by HTTP.
        It works without any external scripts and uses the script item.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: {$AZURE.APP.ID}, {$AZURE.PASSWORD}, {$AZURE.TENANT.ID}, {$AZURE.SUBSCRIPTION.ID}, and {$AZURE.RESOURCE.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 9c87cde45e984ce282d8ba9fbe184f9b
          name: 'Availability status detailed'
          type: DEPENDENT
          key: azure.db.mysql.availability.details
          value_type: CHAR
          description: 'The summary description of the availability status.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.summary
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: health
        - uuid: 7f2d8e8d94ae4c87ba0480a2d9518f65
          name: 'Availability state'
          type: DEPENDENT
          key: azure.db.mysql.availability.state
          description: 'The availability status of the resource.'
          valuemap:
            name: 'Azure resource health state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.availabilityState
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: STR_REPLACE
              parameters:
                - Available
                - '0'
            - type: STR_REPLACE
              parameters:
                - Degraded
                - '1'
            - type: STR_REPLACE
              parameters:
                - Unavailable
                - '2'
            - type: STR_REPLACE
              parameters:
                - Unknown
                - '3'
            - type: IN_RANGE
              parameters:
                - '0'
                - '3'
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: e822fd2214fb41db9b57cdb8eec0444a
              expression: 'last(/Azure MySQL Flexible Server by HTTP/azure.db.mysql.availability.state)=1'
              name: 'MySQL server is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in a degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: ebb35037a5b646a0bd2c6be44bb1f3c6
              expression: 'last(/Azure MySQL Flexible Server by HTTP/azure.db.mysql.availability.state)=3'
              name: 'MySQL server is in unknown state'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The resource state is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 240b861c09a94e209036782b6c7496fa
              expression: 'last(/Azure MySQL Flexible Server by HTTP/azure.db.mysql.availability.state)=2'
              name: 'MySQL server is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: cab6ac822f2c4e118b030e49cc15eaa2
          name: 'Connections aborted'
          type: DEPENDENT
          key: azure.db.mysql.connections.aborted
          value_type: FLOAT
          description: 'The count of aborted connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.aborted_connections.total
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: network
          triggers:
            - uuid: 3346ea2331c14fa18658eb33e461ec7c
              expression: 'min(/Azure MySQL Flexible Server by HTTP/azure.db.mysql.connections.aborted,5m)>{$AZURE.DB.ABORTED.CONN.MAX.WARN}'
              name: 'Server has aborted connections'
              opdata: 'Current value: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The number of failed attempts to connect to the MySQL server is more than `{$AZURE.DB.ABORTED.CONN.MAX.WARN}`.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 71b33f0a5d37498dbb57d185ac0f2741
          name: 'Connections active'
          type: DEPENDENT
          key: azure.db.mysql.connections.active
          value_type: FLOAT
          description: 'The count of active connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.active_connections.maximum
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 1993ae276fe44db6a89451291749f703
          name: 'Connections total'
          type: DEPENDENT
          key: azure.db.mysql.connections.total
          value_type: FLOAT
          description: 'The count of total connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.total_connections.total
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: network
        - uuid: b235666b98954555ae5e75e757bba707
          name: 'CPU credits consumed'
          type: DEPENDENT
          key: azure.db.mysql.cpu.credits.consumed
          value_type: FLOAT
          description: 'The consumed CPU credits.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_credits_consumed.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: 4f591346d3d34d49b37cfff2a169f57e
          name: 'CPU credits remaining'
          type: DEPENDENT
          key: azure.db.mysql.cpu.credits.remaining
          value_type: FLOAT
          description: 'The remaining CPU credits.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_credits_remaining.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: afe4d11c2f474428acc00d153ad2a6e5
          name: 'Percentage CPU'
          type: DEPENDENT
          key: azure.db.mysql.cpu.percentage
          value_type: FLOAT
          units: '%'
          description: 'The CPU percent of a host.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_percent.maximum
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 5af82cc95239479c86c7ab3dabcfb592
              expression: 'min(/Azure MySQL Flexible Server by HTTP/azure.db.mysql.cpu.percentage,5m)>{$AZURE.DB.CPU.UTIL.CRIT}'
              name: 'High CPU utilization'
              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: f960e7667571497c96454b5c4b7b69ff
          name: 'Get errors'
          type: DEPENDENT
          key: azure.db.mysql.data.errors
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.errors
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: 98c1b86b79e9469cac2870fb2ba42949
              expression: 'length(last(/Azure MySQL Flexible Server by HTTP/azure.db.mysql.data.errors))>0'
              name: '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: de712334db1440309fa68f9252d4f9bc
          name: 'Get data'
          type: SCRIPT
          key: azure.db.mysql.data.get
          history: '0'
          value_type: TEXT
          params: |
            var AzureDB = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id', 'resource_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		AzureDB.params = params;
            	},
            
            
            	request: function (url, data) {
            		if (typeof data === 'undefined' || data === null) {
            			data = '';
            		}
            
            		var response, request = new HttpRequest();
            		if (typeof AzureDB.params.proxy !== 'undefined' && AzureDB.params.proxy !== '') {
            			request.setProxy(AzureDB.params.proxy);
            		}
            		if (AzureDB.token) {
            			request.addHeader('Accept: application/json');
            			request.addHeader('Authorization: Bearer ' + AzureDB.token);
            		}
            
            		Zabbix.log(4, '[ Azure ] Sending request: ' + url);
            
            		if (data !== '') {
            			request.addHeader('Content-Type: application/x-www-form-urlencoded');
            			response = request.post(url, data);
            		}
            		else {
            			response = request.get(url);
            		}
            
            		Zabbix.log(4, '[ Azure ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200 || response === null) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	}
            
            };
            
            var metrics = [
            	'cpu_percent',
            	'memory_percent',
            	'network_bytes_egress',
            	'network_bytes_ingress',
            	'active_connections',
            	'total_connections',
            	'aborted_connections',
            	'Queries',
            	'io_consumption_percent',
            	'storage_percent',
            	'storage_used',
            	'storage_limit',
            	'backup_storage_used',
            	'replication_lag',
            	'cpu_credits_remaining',
            	'cpu_credits_consumed'
            ],
            	prepared_metrics = [],
            	data = {};
            	data['errors'] = {};
            	data['metrics'] = {};
            
            try {
            	AzureDB.setParams(JSON.parse(value));
            
            	try {
            		result = AzureDB.request(
            			'https://login.microsoftonline.com/' + encodeURIComponent(AzureDB.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureDB.params.app_id) + '&client_secret=' + encodeURIComponent(AzureDB.params.password)
            		);
            
            		if ('access_token' in result) {
            			AzureDB.token = result['access_token'];
            		} else {
            			throw 'Auth response does not contain access token.';
            		}
            	}
            	catch (error) {
            		data.errors.auth = error.toString();
            	}
            
            	if (!('auth' in data.errors)) {
            		try {
            			health = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2020-05-01');
            			if ('value' in health && Array.isArray(health.value) && health.value.length > 0 && 'properties' in health.value[0] && typeof health.value[0].properties === 'object') {
            				data.health = health.value[0].properties;
            			}
            		}
            		catch (error) {
            			data.errors.health = error.toString();
            		}
            
            		for (var i = 0; i < metrics.length; i += 20) {
            			var chunk = metrics.slice(i, i + 20);
            
            			prepared_metrics.push(
            				chunk.map(function (element) {
            					return encodeURIComponent(element);
            				}).join(',')
            			);
            		}
            
            		start_date = new Date((new Date().getTime()) - 300000).toISOString().replace(/\.\d+/, '');
            		end_date = new Date().toISOString().replace(/\.\d+/, '');
            
            		for (var j in prepared_metrics) {
            			try {
            				metrics_data = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.Insights/metrics?metricnames=' + prepared_metrics[j] + '&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date) + '&api-version=2021-05-01');
            				if ('value' in metrics_data && Array.isArray(metrics_data.value) && metrics_data.value.length > 0) {
            					for (k in metrics_data.value) {
            						if ('name' in metrics_data.value[k] && typeof metrics_data.value[k].name === 'object' && 'value' in metrics_data.value[k].name && typeof metrics_data.value[k].name.value === 'string' && 'timeseries' in metrics_data.value[k] && Array.isArray(metrics_data.value[k].timeseries) && metrics_data.value[k].timeseries.length > 0 && 'data' in metrics_data.value[k].timeseries[0] && Array.isArray(metrics_data.value[k].timeseries[0].data) && metrics_data.value[k].timeseries[0].data.length > 0) {
            							data.metrics[metrics_data.value[k].name.value.replace(/(\s|\/)+/g, '')] = metrics_data.value[k].timeseries[0].data[metrics_data.value[k].timeseries[0].data.length - 1];
            						}
            					}
            				}
            			}
            			catch (error) {
            				data.errors[prepared_metrics[j]] = error.toString();
            			}
            		}
            	}
            }
            catch (error) {
            	data.errors.params = error.toString();
            }
            
            if (Object.keys(data.errors).length !== 0) {
            	errors = 'Failed to receive data:';
            	for (var error in data.errors) {
            		errors += '\n' + error + ' : ' + data.errors[error];
            	}
            	data.errors = errors;
            }
            else {
            	data.errors = '';
            }
            
            return JSON.stringify(data);
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: resource_id
              value: '{$AZURE.RESOURCE.ID}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: b4a6363aac734b6c8d043718ca667c09
          name: 'IO consumption percent'
          type: DEPENDENT
          key: azure.db.mysql.io.consumption.percent
          value_type: FLOAT
          units: '%'
          description: 'The consumption percent of I/O.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.io_consumption_percent.maximum
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: operations
        - uuid: f0f56a67942a40509d6835f3da9eb7e2
          name: 'Memory utilization'
          type: DEPENDENT
          key: azure.db.mysql.memory.percentage
          value_type: FLOAT
          units: '%'
          description: 'The memory percent of a host.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.memory_percent.maximum
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: memory
        - uuid: 84f3d2b152784993944a2d4c3fad1a59
          name: 'Network out'
          type: DEPENDENT
          key: azure.db.mysql.network.egress
          value_type: FLOAT
          units: bps
          description: 'Network egress of a host, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.network_bytes_egress.total
            - type: MULTIPLIER
              parameters:
                - '0.0088'
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 5f38b6b4e3a849d09022bd34c4347088
          name: 'Network in'
          type: DEPENDENT
          key: azure.db.mysql.network.ingress
          value_type: FLOAT
          units: bps
          description: 'Network ingress of a host, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.network_bytes_ingress.total
            - type: MULTIPLIER
              parameters:
                - '0.0088'
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 05329dcdb2e14080a43d1bf7553037f6
          name: Queries
          type: DEPENDENT
          key: azure.db.mysql.queries
          value_type: FLOAT
          description: 'The count of queries.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.Queries.total
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: queries
        - uuid: 80a05247fec04e39a99ccafaefbd0441
          name: 'Replication lag'
          type: DEPENDENT
          key: azure.db.mysql.replication.lag
          value_type: FLOAT
          units: s
          description: 'The replication lag, expressed in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.replication_lag.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: replication
        - uuid: 8d5cd0d3cd0744a5a260a8a0485f6735
          name: 'Backup storage used'
          type: DEPENDENT
          key: azure.db.mysql.storage.backup.used
          value_type: FLOAT
          units: B
          description: 'Used backup storage, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.backup_storage_used.maximum
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 78f3e03b5caf4f85a3c61513cf242f76
          name: 'Storage limit'
          type: DEPENDENT
          key: azure.db.mysql.storage.limit
          value_type: FLOAT
          units: B
          description: 'The storage limit, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_limit.maximum
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: ced51184b59643adaa51bef90710166b
          name: 'Storage percent'
          type: DEPENDENT
          key: azure.db.mysql.storage.percent
          value_type: FLOAT
          units: '%'
          description: 'The storage utilization, expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_percent.maximum
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 1703edc1553644e5aa25d35928c5eafd
              expression: 'last(/Azure MySQL Flexible Server by HTTP/azure.db.mysql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.CRIT}'
              name: 'Storage space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Critical utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: a2ec23a5e77c40aa9e45d214f4e06ca1
              expression: 'last(/Azure MySQL Flexible Server by HTTP/azure.db.mysql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.WARN}'
              name: 'Storage space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 9f96e947eee646f890742676e9f9a22a
          name: 'Storage used'
          type: DEPENDENT
          key: azure.db.mysql.storage.used
          value_type: FLOAT
          units: B
          description: 'Used storage space, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_used.maximum
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
        - tag: target
          value: mysql
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
        - macro: '{$AZURE.DB.ABORTED.CONN.MAX.WARN}'
          value: '25'
          description: 'The number of failed attempts to connect to the MySQL server for a trigger expression.'
        - macro: '{$AZURE.DB.CPU.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of CPU utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.CRIT}'
          value: '90'
          description: 'The critical threshold of the storage utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.WARN}'
          value: '80'
          description: 'The warning threshold of the storage utilization, expressed in %.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.RESOURCE.ID}'
          description: 'Microsoft Azure MySQL server ID.'
        - macro: '{$AZURE.SUBSCRIPTION.ID}'
          description: 'Microsoft Azure subscription ID.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
      dashboards:
        - uuid: 12974ad6fc5a42ba9683af06f9166cef
          name: 'Overview Azure MySQL Flexible Server'
          pages:
            - widgets:
                - type: item
                  name: 'Memory utilization'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.memory.percentage
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'CPU credits consumed'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.cpu.credits.consumed
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Storage used'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.storage.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Network in'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.network.ingress
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections active'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.connections.active
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Percentage CPU'
                  x: '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.cpu.percentage
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'CPU credits remaining'
                  x: '12'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.cpu.credits.remaining
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Storage limit'
                  x: '12'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.storage.limit
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Network out'
                  x: '12'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.network.egress
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections total'
                  x: '12'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.connections.total
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Availability state'
                  x: '24'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.availability.state
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: up_color
                      value: FF0000
                - type: item
                  name: 'Backup storage used'
                  x: '24'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.storage.backup.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: graph
                  name: 'Storage utilization'
                  x: '24'
                  'y': '6'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        name: 'Azure MySQL: Storage utilization'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'Network traffic'
                  x: '24'
                  'y': '9'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        name: 'Azure MySQL: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: Connections
                  x: '24'
                  'y': '12'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        name: 'Azure MySQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: itemhistory
                  name: 'Availability status detailed'
                  x: '36'
                  width: '36'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: columns.0.display
                      value: '4'
                    - type: ITEM
                      name: columns.0.itemid
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.availability.details
                    - type: INTEGER
                      name: columns.0.monospace_font
                      value: '1'
                    - type: STRING
                      name: columns.0.name
                      value: 'Azure MySQL: Availability status detailed'
                    - type: STRING
                      name: reference
                      value: BAAAB
                    - type: INTEGER
                      name: show_timestamp
                      value: '1'
                - type: item
                  name: Queries
                  x: '36'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.queries
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'IO consumption percent'
                  x: '48'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.io.consumption.percent
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'Replication lag'
                  x: '60'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Flexible Server by HTTP'
                        key: azure.db.mysql.replication.lag
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
      valuemaps:
        - uuid: 4eec167b4d69441398b96b8e375d6825
          name: 'Azure resource health state'
          mappings:
            - value: '0'
              newvalue: Available
            - value: '1'
              newvalue: Degraded
            - value: '2'
              newvalue: Unavailable
            - value: '3'
              newvalue: Unknown
    - uuid: c1396bf1e8cf46f6a407e88ddceef0b8
      template: 'Azure MySQL Single Server by HTTP'
      name: 'Azure MySQL Single Server by HTTP'
      description: |
        This template is designed to monitor Microsoft Azure MySQL single servers by HTTP.
        It works without any external scripts and uses the script item.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: {$AZURE.APP.ID}, {$AZURE.PASSWORD}, {$AZURE.TENANT.ID}, {$AZURE.SUBSCRIPTION.ID}, and {$AZURE.RESOURCE.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: c7771aa67d3c424490d8de2d6c2d609a
          name: 'Availability status detailed'
          type: DEPENDENT
          key: azure.db.mysql.availability.details
          value_type: CHAR
          description: 'The summary description of the availability status.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.summary
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: health
        - uuid: c325b977b26e4e00acc3ea8703895f05
          name: 'Availability state'
          type: DEPENDENT
          key: azure.db.mysql.availability.state
          description: 'The availability status of the resource.'
          valuemap:
            name: 'Azure resource health state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.availabilityState
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: STR_REPLACE
              parameters:
                - Available
                - '0'
            - type: STR_REPLACE
              parameters:
                - Degraded
                - '1'
            - type: STR_REPLACE
              parameters:
                - Unavailable
                - '2'
            - type: STR_REPLACE
              parameters:
                - Unknown
                - '3'
            - type: IN_RANGE
              parameters:
                - '0'
                - '3'
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: 91a32645266547d78df3a70b44c7782b
              expression: 'last(/Azure MySQL Single Server by HTTP/azure.db.mysql.availability.state)=1'
              name: 'MySQL server is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in a degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 852aba88476a40aeb2170b933726b7d8
              expression: 'last(/Azure MySQL Single Server by HTTP/azure.db.mysql.availability.state)=3'
              name: 'MySQL server is in unknown state'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The resource state is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 5f2d2254dfc24f5481207585bed0d933
              expression: 'last(/Azure MySQL Single Server by HTTP/azure.db.mysql.availability.state)=2'
              name: 'MySQL server is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 69aba8caa6874c9d9423926a2ee78e99
          name: 'Connections active'
          type: DEPENDENT
          key: azure.db.mysql.connections.active
          value_type: FLOAT
          description: 'The count of active connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.active_connections.average
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: network
        - uuid: e185b56984914507bc40c07c55153967
          name: 'Connections failed'
          type: DEPENDENT
          key: azure.db.mysql.connections.failed
          value_type: FLOAT
          description: 'The count of failed connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.connections_failed.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: network
          triggers:
            - uuid: 5b3a09ca04704e6a9972ee4865d358cd
              expression: 'min(/Azure MySQL Single Server by HTTP/azure.db.mysql.connections.failed,5m)>{$AZURE.DB.FAILED.CONN.MAX.WARN}'
              name: 'Server has failed connections'
              opdata: 'Current value: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The number of failed attempts to connect to the MySQL server is more than `{$AZURE.DB.FAILED.CONN.MAX.WARN}`.'
              tags:
                - tag: scope
                  value: availability
        - uuid: d0b5864a56094166b76fbc58a5e05c7c
          name: 'Percentage CPU'
          type: DEPENDENT
          key: azure.db.mysql.cpu.percentage
          value_type: FLOAT
          units: '%'
          description: 'The CPU percent of a host.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_percent.average
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 7115fb320e2b4cc1ad1739c8a6cee155
              expression: 'min(/Azure MySQL Single Server by HTTP/azure.db.mysql.cpu.percentage,5m)>{$AZURE.DB.CPU.UTIL.CRIT}'
              name: 'High CPU utilization'
              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: 2fc253a20100478d91cac13590a64bfc
          name: 'Get errors'
          type: DEPENDENT
          key: azure.db.mysql.data.errors
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.errors
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: df5fa33f8c13413bb9d61ea4470b9b2d
              expression: 'length(last(/Azure MySQL Single Server by HTTP/azure.db.mysql.data.errors))>0'
              name: '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: cd62d92ef0384ea9acf0cae71c88ebc6
          name: 'Get data'
          type: SCRIPT
          key: azure.db.mysql.data.get
          history: '0'
          value_type: TEXT
          params: |
            var AzureDB = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id', 'resource_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		AzureDB.params = params;
            	},
            
            
            	request: function (url, data) {
            		if (typeof data === 'undefined' || data === null) {
            			data = '';
            		}
            
            		var response, request = new HttpRequest();
            		if (typeof AzureDB.params.proxy !== 'undefined' && AzureDB.params.proxy !== '') {
            			request.setProxy(AzureDB.params.proxy);
            		}
            		if (AzureDB.token) {
            			request.addHeader('Accept: application/json');
            			request.addHeader('Authorization: Bearer ' + AzureDB.token);
            		}
            
            		Zabbix.log(4, '[ Azure ] Sending request: ' + url);
            
            		if (data !== '') {
            			request.addHeader('Content-Type: application/x-www-form-urlencoded');
            			response = request.post(url, data);
            		}
            		else {
            			response = request.get(url);
            		}
            
            		Zabbix.log(4, '[ Azure ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200 || response === null) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	}
            
            };
            
            var metrics = [
            	'cpu_percent',
            	'memory_percent',
            	'io_consumption_percent',
            	'storage_percent',
            	'storage_used',
            	'storage_limit',
            	'serverlog_storage_percent',
            	'serverlog_storage_usage',
            	'serverlog_storage_limit',
            	'active_connections',
            	'connections_failed',
            	'seconds_behind_master',
            	'backup_storage_used',
            	'network_bytes_egress',
            	'network_bytes_ingress'
            ],
            	prepared_metrics = [],
            	data = {};
            data['errors'] = {};
            data['metrics'] = {};
            
            try {
            	AzureDB.setParams(JSON.parse(value));
            
            	try {
            		result = AzureDB.request(
            			'https://login.microsoftonline.com/' + encodeURIComponent(AzureDB.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureDB.params.app_id) + '&client_secret=' + encodeURIComponent(AzureDB.params.password)
            		);
            
            		if ('access_token' in result) {
            			AzureDB.token = result['access_token'];
            		} else {
            			throw 'Auth response does not contain access token.';
            		}
            	}
            	catch (error) {
            		data.errors.auth = error.toString();
            	}
            
            	if (!('auth' in data.errors)) {
            		try {
            			health = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2020-05-01');
            			if ('value' in health && Array.isArray(health.value) && health.value.length > 0 && 'properties' in health.value[0] && typeof health.value[0].properties === 'object') {
            				data.health = health.value[0].properties;
            			}
            		}
            		catch (error) {
            			data.errors.health = error.toString();
            		}
            
            		for (var i = 0; i < metrics.length; i += 20) {
            			var chunk = metrics.slice(i, i + 20);
            
            			prepared_metrics.push(
            				chunk.map(function (element) {
            					return encodeURIComponent(element);
            				}).join(',')
            			);
            		}
            
            		start_date = new Date((new Date().getTime()) - 300000).toISOString().replace(/\.\d+/, '');
            		end_date = new Date().toISOString().replace(/\.\d+/, '');
            
            		for (var j in prepared_metrics) {
            			try {
            				metrics_data = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.Insights/metrics?metricnames=' + prepared_metrics[j] + '&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date) + '&api-version=2021-05-01');
            				if ('value' in metrics_data && Array.isArray(metrics_data.value) && metrics_data.value.length > 0) {
            					for (k in metrics_data.value) {
            						if ('name' in metrics_data.value[k] && typeof metrics_data.value[k].name === 'object' && 'value' in metrics_data.value[k].name && typeof metrics_data.value[k].name.value === 'string' && 'timeseries' in metrics_data.value[k] && Array.isArray(metrics_data.value[k].timeseries) && metrics_data.value[k].timeseries.length > 0 && 'data' in metrics_data.value[k].timeseries[0] && Array.isArray(metrics_data.value[k].timeseries[0].data) && metrics_data.value[k].timeseries[0].data.length > 0) {
            							data.metrics[metrics_data.value[k].name.value.replace(/(\s|\/)+/g, '')] = metrics_data.value[k].timeseries[0].data[metrics_data.value[k].timeseries[0].data.length - 1];
            						}
            					}
            				}
            			}
            			catch (error) {
            				data.errors[prepared_metrics[j]] = error.toString();
            			}
            		}
            	}
            }
            catch (error) {
            	data.errors.params = error.toString();
            }
            
            if (Object.keys(data.errors).length !== 0) {
            	errors = 'Failed to receive data:';
            	for (var error in data.errors) {
            		errors += '\n' + error + ' : ' + data.errors[error];
            	}
            	data.errors = errors;
            }
            else {
            	data.errors = '';
            }
            
            return JSON.stringify(data);
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: resource_id
              value: '{$AZURE.RESOURCE.ID}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: a17c365253eb4821841ec82ac8f61106
          name: 'IO consumption percent'
          type: DEPENDENT
          key: azure.db.mysql.io.consumption.percent
          value_type: FLOAT
          units: '%'
          description: 'The consumption percent of I/O.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.io_consumption_percent.average
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: operations
        - uuid: 5c19c08912634993b1f96fb11e5d1ae2
          name: 'Memory utilization'
          type: DEPENDENT
          key: azure.db.mysql.memory.percentage
          value_type: FLOAT
          units: '%'
          description: 'The memory percent of a host.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.memory_percent.average
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: a67b35f1ac674d6692b0b2bcd6f89bd8
              expression: 'min(/Azure MySQL Single Server by HTTP/azure.db.mysql.memory.percentage,5m)>{$AZURE.DB.MEMORY.UTIL.CRIT}'
              name: 'High memory utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The system is running out of free memory.'
              tags:
                - tag: scope
                  value: performance
        - uuid: fe1b9846a634412aaa6a76fc05dbe46a
          name: 'Network out'
          type: DEPENDENT
          key: azure.db.mysql.network.egress
          value_type: FLOAT
          units: bps
          description: 'The network outbound traffic across the active connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.network_bytes_egress.total
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.0088'
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 1cc97817bda5470887e3d5d9f2d78650
          name: 'Network in'
          type: DEPENDENT
          key: azure.db.mysql.network.ingress
          value_type: FLOAT
          units: bps
          description: 'The network inbound traffic across the active connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.network_bytes_ingress.total
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.0088'
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 8e60794282ea42c7bad1573811b2e498
          name: 'Replication lag'
          type: DEPENDENT
          key: azure.db.mysql.replication.lag
          value_type: FLOAT
          units: s
          description: 'The replication lag, expressed in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.seconds_behind_master.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: replication
        - uuid: 1303a659d17a4e4fa9fa03cef35fef5a
          name: 'Backup storage used'
          type: DEPENDENT
          key: azure.db.mysql.storage.backup.used
          value_type: FLOAT
          units: B
          description: 'Used backup storage, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.backup_storage_used.average
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 4aed6d0c01d1458fbd1f7c7ea5386303
          name: 'Storage limit'
          type: DEPENDENT
          key: azure.db.mysql.storage.limit
          value_type: FLOAT
          units: B
          description: 'The storage limit, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_limit.maximum
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 5b1b350be6f0409fb7ab842571c3f086
          name: 'Storage percent'
          type: DEPENDENT
          key: azure.db.mysql.storage.percent
          value_type: FLOAT
          units: '%'
          description: 'The storage utilization, expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_percent.average
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 3afcb840e8004822a2dada2a89971f69
              expression: 'last(/Azure MySQL Single Server by HTTP/azure.db.mysql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.CRIT}'
              name: 'Storage space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Critical utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 2e605f906b284f769e7c880d4e642b43
              expression: 'last(/Azure MySQL Single Server by HTTP/azure.db.mysql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.WARN}'
              name: 'Storage space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 7f553d8a0898477b87a2828e51efcfcc
          name: 'Server log storage limit'
          type: DEPENDENT
          key: azure.db.mysql.storage.server.log.limit
          value_type: FLOAT
          units: B
          description: 'The storage limit of server log, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.serverlog_storage_limit.maximum
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: cf5a77306c554a24b3741ef065b6d27a
          name: 'Server log storage percent'
          type: DEPENDENT
          key: azure.db.mysql.storage.server.log.percent
          value_type: FLOAT
          units: '%'
          description: 'The storage utilization by server log, expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.serverlog_storage_percent.average
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 8ed99a951e264185b1e0f343d7ea0aec
          name: 'Server log storage used'
          type: DEPENDENT
          key: azure.db.mysql.storage.server.log.used
          value_type: FLOAT
          units: B
          description: 'The storage space used by server log, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.serverlog_storage_usage.average
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 0c9a5496d9884c8e9a434fb232b3208f
          name: 'Storage used'
          type: DEPENDENT
          key: azure.db.mysql.storage.used
          value_type: FLOAT
          units: B
          description: 'Used storage space, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_used.average
          master_item:
            key: azure.db.mysql.data.get
          tags:
            - tag: component
              value: storage
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
        - tag: target
          value: mysql
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
        - macro: '{$AZURE.DB.CPU.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of CPU utilization, expressed in %.'
        - macro: '{$AZURE.DB.FAILED.CONN.MAX.WARN}'
          value: '25'
          description: 'The number of failed attempts to connect to the MySQL server for trigger expression.'
        - macro: '{$AZURE.DB.MEMORY.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of memory utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.CRIT}'
          value: '90'
          description: 'The critical threshold of storage utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.WARN}'
          value: '80'
          description: 'The warning threshold of storage utilization, expressed in %.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.RESOURCE.ID}'
          description: 'Microsoft Azure MySQL server ID.'
        - macro: '{$AZURE.SUBSCRIPTION.ID}'
          description: 'Microsoft Azure subscription ID.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
      dashboards:
        - uuid: 8760f5409fbd488d8b8e8ba24d9077ae
          name: 'Overview Azure MySQL Single Server'
          pages:
            - widgets:
                - type: item
                  name: 'Memory utilization'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.memory.percentage
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'Network in'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.network.ingress
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Server log storage limit'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.storage.server.log.limit
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Storage limit'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.storage.limit
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections active'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.connections.active
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Percentage CPU'
                  x: '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.cpu.percentage
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'Network out'
                  x: '12'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.network.egress
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Server log storage used'
                  x: '12'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.storage.server.log.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Storage used'
                  x: '12'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.storage.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections failed'
                  x: '12'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.connections.failed
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Availability state'
                  x: '24'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.availability.state
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: up_color
                      value: FF0000
                - type: graph
                  name: 'Network traffic'
                  x: '24'
                  'y': '3'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        name: 'Azure MySQL: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'Server log storage utilization'
                  x: '24'
                  'y': '6'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        name: 'Azure MySQL: Server log storage utilization'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: 'Storage utilization'
                  x: '24'
                  'y': '9'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        name: 'Azure MySQL: Storage utilization'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  name: Connections
                  x: '24'
                  'y': '12'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        name: 'Azure MySQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: itemhistory
                  name: 'Availability status detailed'
                  x: '36'
                  width: '36'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: columns.0.display
                      value: '4'
                    - type: ITEM
                      name: columns.0.itemid
                      value:
                        host: 'Azure MySQL Single Server by HTTP'
                        key: azure.db.mysql.availability.details
                    - type: INTEGER
                      name: columns.0.monospace_font
                      value: '1'
                    - type: STRING
                      name: columns.0.name
                      value: 'Azure MySQL: Availability status detailed'
                    - type: STRING
                      name: reference
                      value: BAAAC
                    - type: INTEGER
                      name: show_timestamp
                      value: '1'
      valuemaps:
        - uuid: 323a5259fb854724891515767f341540
          name: 'Azure resource health state'
          mappings:
            - value: '0'
              newvalue: Available
            - value: '1'
              newvalue: Degraded
            - value: '2'
              newvalue: Unavailable
            - value: '3'
              newvalue: Unknown
    - uuid: 35ef29f24158444097272d2ea7fa6044
      template: 'Azure PostgreSQL Flexible Server by HTTP'
      name: 'Azure PostgreSQL Flexible Server by HTTP'
      description: |
        This template is designed to monitor Microsoft Azure PostgreSQL flexible servers by HTTP.
        It works without any external scripts and uses the script item.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: {$AZURE.APP.ID}, {$AZURE.PASSWORD}, {$AZURE.TENANT.ID}, {$AZURE.SUBSCRIPTION.ID}, and {$AZURE.RESOURCE.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 7f7deae517e54cf582ae758a6988037b
          name: 'Availability status detailed'
          type: DEPENDENT
          key: azure.db.pgsql.availability.details
          value_type: CHAR
          description: 'The summary description of the availability status.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.summary
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: health
        - uuid: cd9072a3895c42dab794707f3bcaf743
          name: 'Availability state'
          type: DEPENDENT
          key: azure.db.pgsql.availability.state
          description: 'The availability status of the resource.'
          valuemap:
            name: 'Azure resource health state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.availabilityState
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: STR_REPLACE
              parameters:
                - Available
                - '0'
            - type: STR_REPLACE
              parameters:
                - Degraded
                - '1'
            - type: STR_REPLACE
              parameters:
                - Unavailable
                - '2'
            - type: STR_REPLACE
              parameters:
                - Unknown
                - '3'
            - type: IN_RANGE
              parameters:
                - '0'
                - '3'
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: 65b5c39b48e248c4866c511bbba91e1b
              expression: 'last(/Azure PostgreSQL Flexible Server by HTTP/azure.db.pgsql.availability.state)=1'
              name: 'PostgreSQL server is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in a degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: d8ce86c853064cba80c9883052ed1403
              expression: 'last(/Azure PostgreSQL Flexible Server by HTTP/azure.db.pgsql.availability.state)=3'
              name: 'PostgreSQL server is in unknown state'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The resource state is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 9572c9e56a6b44368bcf2d8a17a220d8
              expression: 'last(/Azure PostgreSQL Flexible Server by HTTP/azure.db.pgsql.availability.state)=2'
              name: 'PostgreSQL server is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 05ada75c666e45269c3c36159f9902cc
          name: 'Connections active'
          type: DEPENDENT
          key: azure.db.pgsql.connections.active
          value_type: FLOAT
          description: 'The count of active connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.active_connections.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 00d1116141874dbfb204ebfe96c203f1
          name: 'Connections failed'
          type: DEPENDENT
          key: azure.db.pgsql.connections.failed
          value_type: FLOAT
          description: 'The count of failed connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.connections_failed.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: network
        - uuid: f422f01bf1c9484e880581f31f70e120
          name: 'Connections succeeded'
          type: DEPENDENT
          key: azure.db.pgsql.connections.succeeded
          value_type: FLOAT
          description: 'The count of succeeded connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.connections_succeeded.total
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 1f1270c6981b4d08864572410fdeccde
          name: 'CPU credits consumed'
          type: DEPENDENT
          key: azure.db.pgsql.cpu.credits.consumed
          value_type: FLOAT
          description: 'The total number of credits consumed by the database server.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_credits_consumed.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: e55082c4a278435286335cebd2ae1cac
          name: 'CPU credits remaining'
          type: DEPENDENT
          key: azure.db.pgsql.cpu.credits.remaining
          value_type: FLOAT
          description: 'The total number of credits available to burst.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_credits_remaining.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: 8d85c5c73c894cdda6324832a703fea2
          name: 'Percentage CPU'
          type: DEPENDENT
          key: azure.db.pgsql.cpu.percentage
          value_type: FLOAT
          units: '%'
          description: 'The CPU percent of a host.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_percent.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: f8672e4488b740a9a17395689c3d853c
              expression: 'min(/Azure PostgreSQL Flexible Server by HTTP/azure.db.pgsql.cpu.percentage,5m)>{$AZURE.DB.CPU.UTIL.CRIT}'
              name: 'High CPU utilization'
              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: 06c4226667ec4c4489e6d3ad31c3135f
          name: 'Get errors'
          type: DEPENDENT
          key: azure.db.pgsql.data.errors
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.errors
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: 55962f0d8a4c44c9a6b09da705e94c59
              expression: 'length(last(/Azure PostgreSQL Flexible Server by HTTP/azure.db.pgsql.data.errors))>0'
              name: '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: 1792c0566e8a438dad5e299d8f5b9094
          name: 'Get data'
          type: SCRIPT
          key: azure.db.pgsql.data.get
          history: '0'
          value_type: TEXT
          params: |
            var AzureDB = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id', 'resource_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		AzureDB.params = params;
            	},
            
            
            	request: function (url, data) {
            		if (typeof data === 'undefined' || data === null) {
            			data = '';
            		}
            
            		var response, request = new HttpRequest();
            		if (typeof AzureDB.params.proxy !== 'undefined' && AzureDB.params.proxy !== '') {
            			request.setProxy(AzureDB.params.proxy);
            		}
            		if (AzureDB.token) {
            			request.addHeader('Accept: application/json');
            			request.addHeader('Authorization: Bearer ' + AzureDB.token);
            		}
            
            		Zabbix.log(4, '[ Azure ] Sending request: ' + url);
            
            		if (data !== '') {
            			request.addHeader('Content-Type: application/x-www-form-urlencoded');
            			response = request.post(url, data);
            		}
            		else {
            			response = request.get(url);
            		}
            
            		Zabbix.log(4, '[ Azure ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200 || response === null) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	}
            
            };
            
            var metrics = [
            	'cpu_percent',
            	'memory_percent',
            	'iops',
            	'disk_queue_depth',
            	'read_throughput',
            	'write_throughput',
            	'read_iops',
            	'write_iops',
            	'network_bytes_egress',
            	'network_bytes_ingress',
            	'active_connections',
            	'connections_failed',
            	'connections_succeeded',
            	'storage_percent',
            	'storage_used',
            	'storage_free',
            	'txlogs_storage_used',
            	'backup_storage_used',
            	'maximum_used_transactionIDs',
            	'cpu_credits_remaining',
            	'cpu_credits_consumed'
            ],
            	prepared_metrics = [],
            	data = {};
            	data['errors'] = {};
            	data['metrics'] = {};
            
            try {
            	AzureDB.setParams(JSON.parse(value));
            
            	try {
            		result = AzureDB.request(
            			'https://login.microsoftonline.com/' + encodeURIComponent(AzureDB.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureDB.params.app_id) + '&client_secret=' + encodeURIComponent(AzureDB.params.password)
            		);
            
            		if ('access_token' in result) {
            			AzureDB.token = result['access_token'];
            		} else {
            			throw 'Auth response does not contain access token.';
            		}
            	}
            	catch (error) {
            		data.errors.auth = error.toString();
            	}
            
            	if (!('auth' in data.errors)) {
            		try {
            			health = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2020-05-01');
            			if ('value' in health && Array.isArray(health.value) && health.value.length > 0 && 'properties' in health.value[0] && typeof health.value[0].properties === 'object') {
            				data.health = health.value[0].properties;
            			}
            		}
            		catch (error) {
            			data.errors.health = error.toString();
            		}
            
            		for (var i = 0; i < metrics.length; i += 20) {
            			var chunk = metrics.slice(i, i + 20);
            
            			prepared_metrics.push(
            				chunk.map(function (element) {
            					return encodeURIComponent(element);
            				}).join(',')
            			);
            		}
            
            		start_date = new Date((new Date().getTime()) - 600000).toISOString().replace(/\.\d+/, '');
            		end_date = new Date().toISOString().replace(/\.\d+/, '');
            
            		for (var j in prepared_metrics) {
            			try {
            				metrics_data = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.Insights/metrics?metricnames=' + prepared_metrics[j] + '&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date) + '&api-version=2021-05-01');
            				if ('value' in metrics_data && Array.isArray(metrics_data.value) && metrics_data.value.length > 0) {
            					for (k in metrics_data.value) {
            						if ('name' in metrics_data.value[k] && typeof metrics_data.value[k].name === 'object' && 'value' in metrics_data.value[k].name && typeof metrics_data.value[k].name.value === 'string' && 'timeseries' in metrics_data.value[k] && Array.isArray(metrics_data.value[k].timeseries) && metrics_data.value[k].timeseries.length > 0 && 'data' in metrics_data.value[k].timeseries[0] && Array.isArray(metrics_data.value[k].timeseries[0].data) && metrics_data.value[k].timeseries[0].data.length > 0) {
            							if (metrics_data.value[k].name.value === 'disk_queue_depth' ||
            								metrics_data.value[k].name.value === 'read_throughput' ||
            								metrics_data.value[k].name.value === 'write_throughput' ||
            								metrics_data.value[k].name.value === 'read_iops' ||
            								metrics_data.value[k].name.value === 'write_iops') {
            									data.metrics[metrics_data.value[k].name.value.replace(/(\s|\/)+/g, '')] = metrics_data.value[k].timeseries[0].data[metrics_data.value[k].timeseries[0].data.length - 6];
            							} else {
            								data.metrics[metrics_data.value[k].name.value.replace(/(\s|\/)+/g, '')] = metrics_data.value[k].timeseries[0].data[metrics_data.value[k].timeseries[0].data.length - 1];
            							}
            						}
            					}
            				}
            			}
            			catch (error) {
            				data.errors[prepared_metrics[j]] = error.toString();
            			}
            		}
            	}
            }
            catch (error) {
            	data.errors.params = error.toString();
            }
            
            if (Object.keys(data.errors).length !== 0) {
            	errors = 'Failed to receive data:';
            	for (var error in data.errors) {
            		errors += '\n' + error + ' : ' + data.errors[error];
            	}
            	data.errors = errors;
            }
            else {
            	data.errors = '';
            }
            
            return JSON.stringify(data);
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: resource_id
              value: '{$AZURE.RESOURCE.ID}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: 9fc7a458995d4ac8a4c1d8550177471d
          name: 'Data disk read Bps'
          type: DEPENDENT
          key: azure.db.pgsql.disk.bps.read
          value_type: FLOAT
          units: Bps
          description: 'Bytes read per second from the data disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.read_throughput.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 46c500b44164430c952be3a1b2008fb8
          name: 'Data disk write Bps'
          type: DEPENDENT
          key: azure.db.pgsql.disk.bps.write
          value_type: FLOAT
          units: Bps
          description: 'Bytes written per second to the data disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.write_throughput.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b8812461d49a4ff5a2177c2990969c38
          name: 'Data disk queue depth'
          type: DEPENDENT
          key: azure.db.pgsql.disk.queue.depth
          value_type: FLOAT
          description: 'The number of outstanding I/O operations to the data disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.disk_queue_depth.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 10dd8ed658d8442ca39ac1decf9bc2f8
          name: 'Data disk IOPS'
          type: DEPENDENT
          key: azure.db.pgsql.iops
          value_type: FLOAT
          units: '!ops'
          description: 'I/O operations per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.iops.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: dee65b110a4842ccba8e74eefc097304
          name: 'Data disk read IOPS'
          type: DEPENDENT
          key: azure.db.pgsql.iops.read
          value_type: FLOAT
          units: '!ops'
          description: 'The number of the data disk I/O read operations per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.read_iops.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 805dfa040c0a4700acac4b5b1f8a4d11
          name: 'Data disk write IOPS'
          type: DEPENDENT
          key: azure.db.pgsql.iops.write
          value_type: FLOAT
          units: '!ops'
          description: 'The number of the data disk I/O write operations per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.write_iops.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: d1d909c2dd0d42649094ec8339e08881
          name: 'Memory utilization'
          type: DEPENDENT
          key: azure.db.pgsql.memory.percentage
          value_type: FLOAT
          units: '%'
          description: 'The memory percent of a host.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.memory_percent.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: aac52a89709044ed987a365a1d5af17b
              expression: 'min(/Azure PostgreSQL Flexible Server by HTTP/azure.db.pgsql.memory.percentage,5m)>{$AZURE.DB.MEMORY.UTIL.CRIT}'
              name: 'High memory utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The system is running out of free memory.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 040898e15a26455a9992c603ca2d45df
          name: 'Network out'
          type: DEPENDENT
          key: azure.db.pgsql.network.egress
          value_type: FLOAT
          units: bps
          description: 'The network outbound traffic across the active connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.network_bytes_egress.total
            - type: MULTIPLIER
              parameters:
                - '0.1333'
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 8e398d8b33444a148760ec33622755a6
          name: 'Network in'
          type: DEPENDENT
          key: azure.db.pgsql.network.ingress
          value_type: FLOAT
          units: bps
          description: 'The network inbound traffic across the active connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.network_bytes_ingress.total
            - type: MULTIPLIER
              parameters:
                - '0.1333'
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: network
        - uuid: ebebf8b3a2884576abb250fdc2385c6f
          name: 'Backup storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.backup.used
          value_type: FLOAT
          units: B
          description: 'Used backup storage, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.backup_storage_used.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 9bbfba89a1834798b71260536fedab55
          name: 'Storage free'
          type: DEPENDENT
          key: azure.db.pgsql.storage.free
          value_type: FLOAT
          units: B
          description: 'Free storage space, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_free.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: d9d97e728d1741568fce925c0fca33a8
          name: 'Storage percent'
          type: DEPENDENT
          key: azure.db.pgsql.storage.percent
          value_type: FLOAT
          units: '%'
          description: 'The storage utilization, expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_percent.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: de3142bed28340d9abe518cd3967b024
              expression: 'last(/Azure PostgreSQL Flexible Server by HTTP/azure.db.pgsql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.CRIT}'
              name: 'Storage space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Critical utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: e948600affaa4ff4a0ab4e50f4858c0a
              expression: 'last(/Azure PostgreSQL Flexible Server by HTTP/azure.db.pgsql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.WARN}'
              name: 'Storage space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 4dae6c2c1dbf4492a73fd1834cae6aad
          name: 'Transaction log storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.txlogs.used
          value_type: FLOAT
          units: B
          description: 'The storage space used by transaction log, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.txlogs_storage_used.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 7a85b5223ec44ff8bc996c9df1673611
          name: 'Storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.used
          value_type: FLOAT
          units: B
          description: 'Used storage space, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_used.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 6df77ed1d4614ca793df56dbc70d821c
          name: 'Maximum used transaction IDs'
          type: DEPENDENT
          key: azure.db.pgsql.txid.used.max
          value_type: FLOAT
          description: 'The maximum number of used transaction IDs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.maximum_used_transactionIDs.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
        - tag: target
          value: postgresql
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
        - macro: '{$AZURE.DB.CPU.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of CPU utilization, expressed in %.'
        - macro: '{$AZURE.DB.MEMORY.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of memory utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.CRIT}'
          value: '90'
          description: 'The critical threshold of storage utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.WARN}'
          value: '80'
          description: 'The warning threshold of storage utilization, expressed in %.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.RESOURCE.ID}'
          description: 'Microsoft Azure PostgreSQL server ID.'
        - macro: '{$AZURE.SUBSCRIPTION.ID}'
          description: 'Microsoft Azure subscription ID.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
      dashboards:
        - uuid: 89588d831e7348b6b41b47a2cca79190
          name: 'Overview Azure PostgreSQL Flexible Server'
          pages:
            - widgets:
                - type: item
                  name: 'Memory utilization'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.memory.percentage
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'Data disk queue depth'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.disk.queue.depth
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Storage free'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.storage.free
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Network in'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.network.ingress
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections active'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.connections.active
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Percentage CPU'
                  x: '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.cpu.percentage
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'Data disk IOPS'
                  x: '12'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.iops
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Storage used'
                  x: '12'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.storage.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Network out'
                  x: '12'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.network.egress
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections failed'
                  x: '12'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.connections.failed
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Availability state'
                  x: '24'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.availability.state
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: up_color
                      value: FF0000
                - type: item
                  name: 'Data disk read IOPS'
                  x: '24'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.iops.read
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: graph
                  name: 'Storage utilization'
                  x: '24'
                  'y': '6'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        name: 'Azure PostgreSQL: Storage utilization'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'Network traffic'
                  x: '24'
                  'y': '9'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        name: 'Azure PostgreSQL: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: Connections
                  x: '24'
                  'y': '12'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        name: 'Azure PostgreSQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: itemhistory
                  name: 'Availability status detailed'
                  x: '36'
                  width: '36'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: columns.0.display
                      value: '4'
                    - type: ITEM
                      name: columns.0.itemid
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.availability.details
                    - type: INTEGER
                      name: columns.0.monospace_font
                      value: '1'
                    - type: STRING
                      name: columns.0.name
                      value: 'Azure PostgreSQL: Availability status detailed'
                    - type: STRING
                      name: reference
                      value: BAAAD
                    - type: INTEGER
                      name: show_timestamp
                      value: '1'
                - type: item
                  name: 'Data disk write IOPS'
                  x: '36'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.iops.write
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Data disk read Bps'
                  x: '48'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.disk.bps.read
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Data disk write Bps'
                  x: '60'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Flexible Server by HTTP'
                        key: azure.db.pgsql.disk.bps.write
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
      valuemaps:
        - uuid: f208cf6141c44659a2c6904ec4cd7ac3
          name: 'Azure resource health state'
          mappings:
            - value: '0'
              newvalue: Available
            - value: '1'
              newvalue: Degraded
            - value: '2'
              newvalue: Unavailable
            - value: '3'
              newvalue: Unknown
    - uuid: d023e2cd326c486f908e3e361d1fe157
      template: 'Azure PostgreSQL Single Server by HTTP'
      name: 'Azure PostgreSQL Single Server by HTTP'
      description: |
        This template is designed to monitor Microsoft Azure PostgreSQL servers by HTTP.
        It works without any external scripts and uses the script item.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: {$AZURE.APP.ID}, {$AZURE.PASSWORD}, {$AZURE.TENANT.ID}, {$AZURE.SUBSCRIPTION.ID}, and {$AZURE.RESOURCE.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 9eb43a5ffb0d4e07be8d1fccfdecd2aa
          name: 'Availability status detailed'
          type: DEPENDENT
          key: azure.db.pgsql.availability.details
          value_type: CHAR
          description: 'The summary description of the availability status.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.summary
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: health
        - uuid: df4c66646f864f79b5f5e9f71dbefe82
          name: 'Availability state'
          type: DEPENDENT
          key: azure.db.pgsql.availability.state
          description: 'The availability status of the resource.'
          valuemap:
            name: 'Azure resource health state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.availabilityState
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: STR_REPLACE
              parameters:
                - Available
                - '0'
            - type: STR_REPLACE
              parameters:
                - Degraded
                - '1'
            - type: STR_REPLACE
              parameters:
                - Unavailable
                - '2'
            - type: STR_REPLACE
              parameters:
                - Unknown
                - '3'
            - type: IN_RANGE
              parameters:
                - '0'
                - '3'
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: 699ca12c916746b1bf1e121261771cc3
              expression: 'last(/Azure PostgreSQL Single Server by HTTP/azure.db.pgsql.availability.state)=1'
              name: 'PostgreSQL server is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in a degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 14e45ba0bc26409a89d92edfda152947
              expression: 'last(/Azure PostgreSQL Single Server by HTTP/azure.db.pgsql.availability.state)=3'
              name: 'PostgreSQL server is in unknown state'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The resource state is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 4dc9113f8a914ac098d8736dba5aed4a
              expression: 'last(/Azure PostgreSQL Single Server by HTTP/azure.db.pgsql.availability.state)=2'
              name: 'PostgreSQL server is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 3d0d3e1fe77740e4bd7b720368707214
          name: 'Connections active'
          type: DEPENDENT
          key: azure.db.pgsql.connections.active
          value_type: FLOAT
          description: 'The count of active connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.active_connections.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 353a6ba543a84b32b16a5809ae63b4e1
          name: 'Connections failed'
          type: DEPENDENT
          key: azure.db.pgsql.connections.failed
          value_type: FLOAT
          description: 'The count of failed connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.connections_failed.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 537330b2372b434ebcea8a77a809c2f3
          name: 'Percentage CPU'
          type: DEPENDENT
          key: azure.db.pgsql.cpu.percentage
          value_type: FLOAT
          units: '%'
          description: 'The CPU percent of a host.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.cpu_percent.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 33bd2ef88ad3468b9f0b2b1358cc7448
              expression: 'min(/Azure PostgreSQL Single Server by HTTP/azure.db.pgsql.cpu.percentage,5m)>{$AZURE.DB.CPU.UTIL.CRIT}'
              name: 'High CPU utilization'
              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: 5b132ff050c94daa92b252529a52c535
          name: 'Get errors'
          type: DEPENDENT
          key: azure.db.pgsql.data.errors
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.errors
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: dd3d0be997204f8b9968ef5839fb7a9b
              expression: 'length(last(/Azure PostgreSQL Single Server by HTTP/azure.db.pgsql.data.errors))>0'
              name: '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: e47d863822e64e6292bfa3e684bc2839
          name: 'Get data'
          type: SCRIPT
          key: azure.db.pgsql.data.get
          history: '0'
          value_type: TEXT
          params: |
            var AzureDB = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id', 'resource_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		AzureDB.params = params;
            	},
            
            
            	request: function (url, data) {
            		if (typeof data === 'undefined' || data === null) {
            			data = '';
            		}
            
            		var response, request = new HttpRequest();
            		if (typeof AzureDB.params.proxy !== 'undefined' && AzureDB.params.proxy !== '') {
            			request.setProxy(AzureDB.params.proxy);
            		}
            		if (AzureDB.token) {
            			request.addHeader('Accept: application/json');
            			request.addHeader('Authorization: Bearer ' + AzureDB.token);
            		}
            
            		Zabbix.log(4, '[ Azure ] Sending request: ' + url);
            
            		if (data !== '') {
            			request.addHeader('Content-Type: application/x-www-form-urlencoded');
            			response = request.post(url, data);
            		}
            		else {
            			response = request.get(url);
            		}
            
            		Zabbix.log(4, '[ Azure ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() !== 200 || response === null) {
            			throw 'Request failed with status code ' + request.getStatus() + ': ' + response;
            		}
            
            		try {
            			return JSON.parse(response);
            		}
            		catch (error) {
            			throw 'Failed to parse response received from API.';
            		}
            	}
            
            };
            
            var metrics = [
            	'cpu_percent',
            	'memory_percent',
            	'io_consumption_percent',
            	'storage_percent',
            	'storage_used',
            	'storage_limit',
            	'serverlog_storage_percent',
            	'serverlog_storage_usage',
            	'serverlog_storage_limit',
            	'active_connections',
            	'connections_failed',
            	'backup_storage_used',
            	'network_bytes_egress',
            	'network_bytes_ingress',
            	'pg_replica_log_delay_in_seconds',
            	'pg_replica_log_delay_in_bytes'
            ],
            	prepared_metrics = [],
            	data = {};
            	data['errors'] = {};
            	data['metrics'] = {};
            
            try {
            	AzureDB.setParams(JSON.parse(value));
            
            	try {
            		result = AzureDB.request(
            			'https://login.microsoftonline.com/' + encodeURIComponent(AzureDB.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureDB.params.app_id) + '&client_secret=' + encodeURIComponent(AzureDB.params.password)
            		);
            
            		if ('access_token' in result) {
            			AzureDB.token = result['access_token'];
            		} else {
            			throw 'Auth response does not contain access token.';
            		}
            	}
            	catch (error) {
            		data.errors.auth = error.toString();
            	}
            
            	if (!('auth' in data.errors)) {
            		try {
            			health = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2020-05-01');
            			if ('value' in health && Array.isArray(health.value) && health.value.length > 0 && 'properties' in health.value[0] && typeof health.value[0].properties === 'object') {
            				data.health = health.value[0].properties;
            			}
            		}
            		catch (error) {
            			data.errors.health = error.toString();
            		}
            
            		for (var i = 0; i < metrics.length; i += 20) {
            			var chunk = metrics.slice(i, i + 20);
            
            			prepared_metrics.push(
            				chunk.map(function (element) {
            					return encodeURIComponent(element);
            				}).join(',')
            			);
            		}
            
            		start_date = new Date((new Date().getTime()) - 300000).toISOString().replace(/\.\d+/, '');
            		end_date = new Date().toISOString().replace(/\.\d+/, '');
            
            		for (var j in prepared_metrics) {
            			try {
            				metrics_data = AzureDB.request('https://management.azure.com' + AzureDB.params.resource_id + '/providers/Microsoft.Insights/metrics?metricnames=' + prepared_metrics[j] + '&timespan=' + encodeURIComponent(start_date) + '/' + encodeURIComponent(end_date) + '&api-version=2021-05-01');
            				if ('value' in metrics_data && Array.isArray(metrics_data.value) && metrics_data.value.length > 0) {
            					for (k in metrics_data.value) {
            						if ('name' in metrics_data.value[k] && typeof metrics_data.value[k].name === 'object' && 'value' in metrics_data.value[k].name && typeof metrics_data.value[k].name.value === 'string' && 'timeseries' in metrics_data.value[k] && Array.isArray(metrics_data.value[k].timeseries) && metrics_data.value[k].timeseries.length > 0 && 'data' in metrics_data.value[k].timeseries[0] && Array.isArray(metrics_data.value[k].timeseries[0].data) && metrics_data.value[k].timeseries[0].data.length > 0) {
            							data.metrics[metrics_data.value[k].name.value.replace(/(\s|\/)+/g, '')] = metrics_data.value[k].timeseries[0].data[metrics_data.value[k].timeseries[0].data.length - 1];
            						}
            					}
            				}
            			}
            			catch (error) {
            				data.errors[prepared_metrics[j]] = error.toString();
            			}
            		}
            	}
            }
            catch (error) {
            	data.errors.params = error.toString();
            }
            
            if (Object.keys(data.errors).length !== 0) {
            	errors = 'Failed to receive data:';
            	for (var error in data.errors) {
            		errors += '\n' + error + ' : ' + data.errors[error];
            	}
            	data.errors = errors;
            }
            else {
            	data.errors = '';
            }
            
            return JSON.stringify(data);
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: resource_id
              value: '{$AZURE.RESOURCE.ID}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: 9eade85c49bc462aab33b03e37581d87
          name: 'IO consumption percent'
          type: DEPENDENT
          key: azure.db.pgsql.io.consumption.percent
          value_type: FLOAT
          units: '%'
          description: 'The consumption percent of I/O.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.io_consumption_percent.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: operations
        - uuid: e2ee4882b08f45788e6abb698265810e
          name: 'Memory utilization'
          type: DEPENDENT
          key: azure.db.pgsql.memory.percentage
          value_type: FLOAT
          units: '%'
          description: 'The memory percent of a host.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.memory_percent.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: memory
          triggers:
            - uuid: 3119f21167a546369c05d31cda2e0147
              expression: 'min(/Azure PostgreSQL Single Server by HTTP/azure.db.pgsql.memory.percentage,5m)>{$AZURE.DB.MEMORY.UTIL.CRIT}'
              name: 'High memory utilization'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The system is running out of free memory.'
              tags:
                - tag: scope
                  value: performance
        - uuid: f81eeb98d5e942f296c360ff71e8bf8d
          name: 'Network out'
          type: DEPENDENT
          key: azure.db.pgsql.network.egress
          value_type: FLOAT
          units: bps
          description: 'The network outbound traffic across the active connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.network_bytes_egress.total
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.1333'
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 51f7e35042d04ddb88c7703d1b015d3b
          name: 'Network in'
          type: DEPENDENT
          key: azure.db.pgsql.network.ingress
          value_type: FLOAT
          units: bps
          description: 'The network inbound traffic across the active connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.network_bytes_ingress.total
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.1333'
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: network
        - uuid: 1db9e470b527476fae1d26d4b67f855b
          name: 'Replication lag'
          type: DEPENDENT
          key: azure.db.pgsql.replica.log.delay
          value_type: FLOAT
          units: s
          description: 'The replication lag, expressed in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.pg_replica_log_delay_in_seconds.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: replication
        - uuid: 6cdfda8f9e6640f8a8536f88729d75d6
          name: 'Max lag across replicas in bytes'
          type: DEPENDENT
          key: azure.db.pgsql.replica.log.delay.bytes
          value_type: FLOAT
          units: B
          description: 'Lag for the most lagging replica, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.pg_replica_log_delay_in_bytes.maximum
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: replication
        - uuid: 6b06fb0e008640839dc3cda5bcc3f91a
          name: 'Backup storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.backup.used
          value_type: FLOAT
          units: B
          description: 'Used backup storage, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.backup_storage_used.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b8d5ac0b049a4d73b2f35f59c7e7609c
          name: 'Storage limit'
          type: DEPENDENT
          key: azure.db.pgsql.storage.limit
          value_type: FLOAT
          units: B
          description: 'The storage limit, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_limit.maximum
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 750b4d3438614cc992694136d309c3cb
          name: 'Storage percent'
          type: DEPENDENT
          key: azure.db.pgsql.storage.percent
          value_type: FLOAT
          units: '%'
          description: 'The storage utilization, expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_percent.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
          triggers:
            - uuid: 6538d2c8ed774feb951204308f1458ce
              expression: 'last(/Azure PostgreSQL Single Server by HTTP/azure.db.pgsql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.CRIT}'
              name: 'Storage space is critically low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'Critical utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
            - uuid: 7f7a004cfc2a492092dd74c475888e8b
              expression: 'last(/Azure PostgreSQL Single Server by HTTP/azure.db.pgsql.storage.percent)>{$AZURE.DB.STORAGE.PUSED.WARN}'
              name: 'Storage space is low'
              opdata: 'Current utilization: {ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'High utilization of the storage space.'
              tags:
                - tag: scope
                  value: capacity
        - uuid: 399ef67426494a5cb7a820d056dfd4d5
          name: 'Server log storage limit'
          type: DEPENDENT
          key: azure.db.pgsql.storage.server.log.limit
          value_type: FLOAT
          units: B
          description: 'The storage limit of server log, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.serverlog_storage_limit.maximum
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: ef6890330ebe4fe09f46b0d2f6d3f827
          name: 'Server log storage percent'
          type: DEPENDENT
          key: azure.db.pgsql.storage.server.log.percent
          value_type: FLOAT
          units: '%'
          description: 'The storage utilization by server log, expressed in %.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.serverlog_storage_percent.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 36bd10a959964083ae47349dd83ec695
          name: 'Server log storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.server.log.used
          value_type: FLOAT
          units: B
          description: 'The storage space used by server log, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.serverlog_storage_usage.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
        - uuid: dcbb87d442a04938b23e68f739f1e36f
          name: 'Storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.used
          value_type: FLOAT
          units: B
          description: 'Used storage space, expressed in bytes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.storage_used.average
          master_item:
            key: azure.db.pgsql.data.get
          tags:
            - tag: component
              value: storage
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
        - tag: target
          value: postgresql
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
        - macro: '{$AZURE.DB.CPU.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of CPU utilization, expressed in %.'
        - macro: '{$AZURE.DB.MEMORY.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of memory utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.CRIT}'
          value: '90'
          description: 'The critical threshold of storage utilization, expressed in %.'
        - macro: '{$AZURE.DB.STORAGE.PUSED.WARN}'
          value: '80'
          description: 'The warning threshold of storage utilization, expressed in %.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.RESOURCE.ID}'
          description: 'Microsoft Azure PostgreSQL server ID.'
        - macro: '{$AZURE.SUBSCRIPTION.ID}'
          description: 'Microsoft Azure subscription ID.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
      dashboards:
        - uuid: 9ef73571560743379fa0b4929370e1b4
          name: 'Overview Azure PostgreSQL Single Server'
          pages:
            - widgets:
                - type: item
                  name: 'Memory utilization'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.memory.percentage
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'Network in'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.network.ingress
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Server log storage limit'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.storage.server.log.limit
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Storage limit'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.storage.limit
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections active'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.connections.active
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Percentage CPU'
                  x: '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.cpu.percentage
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: units
                      value: '%'
                - type: item
                  name: 'Network out'
                  x: '12'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.network.egress
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Server log storage used'
                  x: '12'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.storage.server.log.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Storage used'
                  x: '12'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.storage.used
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Connections failed'
                  x: '12'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.connections.failed
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Availability state'
                  x: '24'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.availability.state
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: up_color
                      value: FF0000
                - type: graph
                  name: 'Network traffic'
                  x: '24'
                  'y': '3'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        name: 'Azure PostgreSQL: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'Server log storage utilization'
                  x: '24'
                  'y': '6'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        name: 'Azure PostgreSQL: Server log storage utilization'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: 'Storage utilization'
                  x: '24'
                  'y': '9'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        name: 'Azure PostgreSQL: Storage utilization'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  name: Connections
                  x: '24'
                  'y': '12'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        name: 'Azure PostgreSQL: Connections'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: itemhistory
                  name: 'Availability status detailed'
                  x: '36'
                  width: '36'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: columns.0.display
                      value: '4'
                    - type: ITEM
                      name: columns.0.itemid
                      value:
                        host: 'Azure PostgreSQL Single Server by HTTP'
                        key: azure.db.pgsql.availability.details
                    - type: INTEGER
                      name: columns.0.monospace_font
                      value: '1'
                    - type: STRING
                      name: columns.0.name
                      value: 'Azure PostgreSQL: Availability status detailed'
                    - type: STRING
                      name: reference
                      value: BAAAE
                    - type: INTEGER
                      name: show_timestamp
                      value: '1'
      valuemaps:
        - uuid: 61fc206aaae04abda4012e031f0e27ac
          name: 'Azure resource health state'
          mappings:
            - value: '0'
              newvalue: Available
            - value: '1'
              newvalue: Degraded
            - value: '2'
              newvalue: Unavailable
            - value: '3'
              newvalue: Unknown
    - uuid: 820fa4a1565c43e4aac07a691a5bface
      template: 'Azure Virtual Machine by HTTP'
      name: 'Azure Virtual Machine by HTTP'
      description: |
        This template is designed to monitor Microsoft Azure virtual machines (VMs) by HTTP.
        It works without any external scripts and uses the script item.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: {$AZURE.APP.ID}, {$AZURE.PASSWORD}, {$AZURE.TENANT.ID}, {$AZURE.SUBSCRIPTION.ID}, and {$AZURE.RESOURCE.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 86f996df859a445994ed671feab6012f
          name: 'VM availability metric'
          type: DEPENDENT
          key: azure.vm.availability
          value_type: FLOAT
          description: 'Measure of availability of virtual machine over time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VmAvailabilityMetric.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: health
        - uuid: c299999d69904340acd44fead6c7672c
          name: 'Availability status detailed'
          type: DEPENDENT
          key: azure.vm.availability.details
          value_type: CHAR
          description: 'The summary description of availability status.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.summary
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: health
        - uuid: 25e2af44bfbf4e9083ce493d85232088
          name: 'Availability state'
          type: DEPENDENT
          key: azure.vm.availability.state
          description: |
            The availability status of the resource.
            0 - Available - no events detected that affect the health of the resource.
            1 - Degraded  - your resource detected a loss in performance, although it's still available for use.
            2 - Unavailable - the service detected an ongoing platform or non-platform event that affects the health of the resource.
            3 - Unknown - Resource Health hasn't received information about the resource for more than 10 minutes.
          valuemap:
            name: 'Azure resource health state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.availabilityState
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: STR_REPLACE
              parameters:
                - Available
                - '0'
            - type: STR_REPLACE
              parameters:
                - Degraded
                - '1'
            - type: STR_REPLACE
              parameters:
                - Unavailable
                - '2'
            - type: STR_REPLACE
              parameters:
                - Unknown
                - '3'
            - type: IN_RANGE
              parameters:
                - '0'
                - '3'
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: c0170d8a09ae460da923fe773b2b0bd0
              expression: 'last(/Azure Virtual Machine by HTTP/azure.vm.availability.state)=1'
              name: 'Virtual machine is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in a degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: e1b85765b83445ebbf15f02d782b9858
              expression: 'last(/Azure Virtual Machine by HTTP/azure.vm.availability.state)=3'
              name: 'Virtual machine is in unknown state'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The resource state is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: b3d764ff735e44f8806cc4d29090719e
              expression: 'last(/Azure Virtual Machine by HTTP/azure.vm.availability.state)=2'
              name: 'Virtual machine is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: a93308573303437487d151de340fcaed
          name: 'VM cached bandwidth consumed'
          type: DEPENDENT
          key: azure.vm.cached.bandwidth.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the cached disk bandwidth consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMCachedBandwidthConsumedPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 989dec26d97d44b6bd4a84fdbd37dec5
          name: 'VM cached IOPS consumed'
          type: DEPENDENT
          key: azure.vm.cached.iops.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the cached disk IOPS consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMCachedIOPSConsumedPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: fb0641ca8f104cf1bebdced63cd6af16
          name: 'CPU credits consumed'
          type: DEPENDENT
          key: azure.vm.cpu.credits.consumed
          value_type: FLOAT
          description: 'Total number of credits consumed by the virtual machine. Only available on B-series burstable VMs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.CPUCreditsConsumed.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: 963752cbaba046cab1f05b0cbcff3137
          name: 'CPU credits remaining'
          type: DEPENDENT
          key: azure.vm.cpu.credits.remaining
          value_type: FLOAT
          description: 'Total number of credits available to burst. Available only on B-series burstable VMs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.CPUCreditsRemaining.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: 492edacf92544a95a5aa7b034efa7931
          name: 'CPU utilization'
          type: DEPENDENT
          key: azure.vm.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: 'Percentage of allocated compute units that are currently in use by virtual machine.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PercentageCPU.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: 9e6d9394570641418b4291befb1e38e5
              expression: 'min(/Azure Virtual Machine by HTTP/azure.vm.cpu.utilization,5m)>{$AZURE.VM.CPU.UTIL.CRIT}'
              name: 'High CPU utilization'
              event_name: 'CPU utilization is high (over {$AZURE.VM.CPU.UTIL.CRIT}% for last 5m)'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 68c730e4904f402cb12fb71b45fede02
          name: 'Data disk used burst BPS credits'
          type: DEPENDENT
          key: azure.vm.data.disk.bandwidth.burst.used
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the data disk burst bandwidth credits used so far.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskUsedBurstBPSCreditsPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 47cda13c203e4f1e9918eb73fd8afa20
          name: 'Data disk bandwidth consumed'
          type: DEPENDENT
          key: azure.vm.data.disk.bandwidth.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the data disk bandwidth consumed per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskBandwidthConsumedPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: d0fb23206d564e1da746bff3369056c1
          name: 'Data disk max burst bandwidth'
          type: DEPENDENT
          key: azure.vm.data.disk.bandwidth.max
          value_type: FLOAT
          units: Bps
          description: 'Maximum byte-per-second throughput that the data disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskMaxBurstBandwidth.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: c61ad4af97c243cca75bbece40eea795
          name: 'Data disk target bandwidth'
          type: DEPENDENT
          key: azure.vm.data.disk.bandwidth.target
          value_type: FLOAT
          units: Bps
          description: 'Baseline byte-per-second throughput that the data disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskTargetBandwidth.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 731a82833bdd42c59c453adf8625e3b4
          name: 'Data disk used burst IO credits'
          type: DEPENDENT
          key: azure.vm.data.disk.iops.burst.used
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the data disk burst I/O credits used so far.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskUsedBurstIOCreditsPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 3121980d3319431691ed9e98d176430b
          name: 'Data disk IOPS consumed'
          type: DEPENDENT
          key: azure.vm.data.disk.iops.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the data disk input/output (I/O) consumed per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskIOPSConsumedPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 6afcbb02c53243faa341670f155678e4
          name: 'Data disk max burst IOPS'
          type: DEPENDENT
          key: azure.vm.data.disk.iops.max
          value_type: FLOAT
          units: '!iops'
          description: 'Maximum IOPS that the data disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskMaxBurstIOPS.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 9370988456e74b889700ea5798d17092
          name: 'Data disk target IOPS'
          type: DEPENDENT
          key: azure.vm.data.disk.iops.target
          value_type: FLOAT
          units: '!iops'
          description: 'Baseline IOPS that the data disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskTargetIOPS.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b81f304bbc2a42df9b0550ecdc1ec6b7
          name: 'Data disk queue depth'
          type: DEPENDENT
          key: azure.vm.data.disk.queue.depth
          value_type: FLOAT
          description: 'The number of outstanding IO requests that are waiting to be performed on a disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskQueueDepth.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 021d92f3075544319191d6f85a701222
          name: 'Data disk read rate'
          type: DEPENDENT
          key: azure.vm.data.disk.read.bps
          value_type: FLOAT
          units: Bps
          description: 'Bytes per second read from a single disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskReadBytessec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: cc31283ab96548b7bdcc88e89dfae53c
          name: 'Data disk IOPS read'
          type: DEPENDENT
          key: azure.vm.data.disk.read.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Read IOPS from a single disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskReadOperationsSec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b8712f8fd60a43f6b099d9eafed19945
          name: 'Data disk write rate'
          type: DEPENDENT
          key: azure.vm.data.disk.write.bps
          value_type: FLOAT
          units: Bps
          description: 'Bytes per second written to a single disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskWriteBytessec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 87794f5a502b4e2db91f820483e38fb3
          name: 'Data disk IOPS write'
          type: DEPENDENT
          key: azure.vm.data.disk.write.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Write IOPS from a single disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskWriteOperationsSec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: e253c2a908944be1a033fc3df550d979
          name: 'Get errors'
          type: DEPENDENT
          key: azure.vm.data.errors
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.errors
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: 87236c99652643ba800601a461d66d94
              expression: 'length(last(/Azure Virtual Machine by HTTP/azure.vm.data.errors))>0'
              name: '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: cff54514d795495da8bc1152e02631aa
          name: 'Get data'
          type: SCRIPT
          key: azure.vm.data.get
          history: '0'
          value_type: TEXT
          params: |
            var Azure = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id', 'resource_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		Azure.params = params;
            	},
            
            	login: function () {
            		var response, login = new HttpRequest();
            
            		if (typeof Azure.params.proxy !== 'undefined' && Azure.params.proxy !== '') {
            			login.setProxy(Azure.params.proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(Azure.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(Azure.params.app_id) + '&client_secret=' + encodeURIComponent(Azure.params.password)
            		);
            
            		if (login.getStatus() !== 200) {
            			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.';
            		}
            
            		Azure.token = response['access_token'];
            	},
            
            	request: function (url) {
            		var response, request = new HttpRequest();
            
            		if (typeof Azure.params.proxy !== 'undefined' && Azure.params.proxy !== '') {
            			request.setProxy(Azure.params.proxy);
            		}
            
            		if (!Azure.token) {
            			throw 'Request does not contain access token.';
            		}
            
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + Azure.token);
            		Zabbix.log(4, '[ AzureVM ] request url: ' + url);
            
            		response = request.get(url);
            
            		if (request.getStatus() !== 200) {
            			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) {
            		var steps = path.split('.');
            
            		for (var i = 0; i < steps.length; i++) {
            			var step = steps[i];
            			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            				throw 'Required field was not found: ' + path;
            			}
            			data = data[step];
            		}
            
            		return data;
            	},
            
            	getMetricsData: function () {
            		var data = {},
            			metric_endpoints = {
            				'main_and_premium_metrics': '/providers/Microsoft.Insights/metrics?metricnames=' + encodeURIComponent('Percentage CPU,CPU Credits Remaining,CPU Credits Consumed,VmAvailabilityMetric,Available Memory Bytes,Network In Total,Network Out Total,Inbound Flows,Outbound Flows,Inbound Flows Maximum Creation Rate,Outbound Flows Maximum Creation Rate,Premium Data Disk Cache Read Hit,Premium Data Disk Cache Read Miss,Premium OS Disk Cache Read Hit,Premium OS Disk Cache Read Miss,VM Cached Bandwidth Consumed Percentage,VM Cached IOPS Consumed Percentage,VM Uncached Bandwidth Consumed Percentage,VM Uncached IOPS Consumed Percentage') + '&api-version=2024-02-01&timespan=PT1M',
            				'disks_metrics': '/providers/Microsoft.Insights/metrics?metricnames=' + encodeURIComponent('Disk Read Bytes,Disk Write Bytes,Disk Read Operations/Sec,Disk Write Operations/Sec,Data Disk Latency,Data Disk Read Bytes/sec,Data Disk Write Bytes/sec,Data Disk Read Operations/Sec,Data Disk Write Operations/Sec,Data Disk Queue Depth,Data Disk Bandwidth Consumed Percentage,Data Disk IOPS Consumed Percentage,Data Disk Target Bandwidth,Data Disk Target IOPS,Data Disk Max Burst Bandwidth,Data Disk Max Burst IOPS,Data Disk Used Burst BPS Credits Percentage,Data Disk Used Burst IO Credits Percentage') + '&api-version=2024-02-01&timespan=PT1M',
            				'os_disk_metrics': '/providers/Microsoft.Insights/metrics?metricnames=' + encodeURIComponent('OS Disk Latency,OS Disk Read Bytes/sec,OS Disk Write Bytes/sec,OS Disk Read Operations/Sec,OS Disk Write Operations/Sec,OS Disk Queue Depth,OS Disk Bandwidth Consumed Percentage,OS Disk IOPS Consumed Percentage,OS Disk Target Bandwidth,OS Disk Target IOPS,OS Disk Max Burst Bandwidth,OS Disk Max Burst IOPS,OS Disk Used Burst BPS Credits Percentage,OS Disk Used Burst IO Credits Percentage,Temp Disk Latency,Temp Disk Read Bytes/sec,Temp Disk Write Bytes/sec,Temp Disk Read Operations/Sec,Temp Disk Write Operations/Sec,Temp Disk Queue Depth') + '&api-version=2024-02-01&timespan=PT1M'
            			};
            		data.metrics = {};
            
            		Object.keys(metric_endpoints).forEach(function (field) {
            			metrics = Azure.getField(Azure.request('https://management.azure.com' + Azure.params.resource_id + metric_endpoints[field]), 'value');
            			for (k in metrics) {
            				key = Azure.getField(metrics[k], 'name.value').replace(/(\s|\/)+/g, '');
            				if (metrics[k].timeseries.length === 0) {
            					metrics[k].timeseries.push({ 'data': ['nodata'] })
            				}
            				data.metrics[key] = Azure.getField(metrics[k], 'timeseries.0.data.0');
            			}
            		});
            
            		data.health = Azure.getField(Azure.request('https://management.azure.com' + Azure.params.resource_id + '/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2020-05-01'), 'value.0.properties');
            
            		return data
            	}
            };
            
            try {
            	Azure.setParams(JSON.parse(value));
            	Azure.login();
            	return JSON.stringify(Azure.getMetricsData());
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ AzureVM ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
          description: 'The result of API requests is expressed in the JSON.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: resource_id
              value: '{$AZURE.RESOURCE.ID}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: 903b8b2724924d5e8627253d851f09e5
          name: 'Data disk latency'
          type: DEPENDENT
          key: azure.vm.disk.latency
          value_type: FLOAT
          units: s
          description: 'Average time to complete each IO during the monitoring period for Data Disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskLatency.average
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 1dc9f8d45b6f48a38f701f089cbcb279
          name: 'Disk read'
          type: DEPENDENT
          key: azure.vm.disk.read.bytes
          value_type: FLOAT
          units: B
          description: 'Bytes read from the disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskReadBytes.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: cd3240d31a4f42a89b5c9817ea288b5a
          name: 'Disk IOPS read'
          type: DEPENDENT
          key: azure.vm.disk.read.ops
          value_type: FLOAT
          units: '!iops'
          description: 'The count of read operations from the disk per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskReadOperationsSec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b5e2070bde1444ea809ba4e0a29b05d9
          name: 'Disk write'
          type: DEPENDENT
          key: azure.vm.disk.write.bytes
          value_type: FLOAT
          units: B
          description: 'Bytes written to the disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskWriteBytes.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 0d93d1b510614c1f83418bd481f1e7cb
          name: 'Disk IOPS write'
          type: DEPENDENT
          key: azure.vm.disk.write.ops
          value_type: FLOAT
          units: '!iops'
          description: 'The count of write operations to the disk per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskWriteOperationsSec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 3a30a59aabd54c8b8feb1f4a8ba06db5
          name: 'Inbound flows'
          type: DEPENDENT
          key: azure.vm.flows.inbound
          value_type: FLOAT
          description: 'The number of current flows in the inbound direction (the traffic going into the VM).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.InboundFlows.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: network
        - uuid: 3964ffbb7ea949f69863edcf91f5c555
          name: 'Inbound flows max creation rate'
          type: DEPENDENT
          key: azure.vm.flows.inbound.max
          value_type: FLOAT
          description: 'Maximum creation rate of the inbound flows (the traffic going into the VM).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.InboundFlowsMaximumCreationRate.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: network
        - uuid: 2084cb1d010a4ab494c0826c458d922a
          name: 'Outbound flows'
          type: DEPENDENT
          key: azure.vm.flows.outbound
          value_type: FLOAT
          description: 'The number of current flows in the outbound direction (the traffic going out of the VM).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OutboundFlows.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: network
        - uuid: eac3e6b53d394e3289fc03bf5772799c
          name: 'Outbound flows max creation rate'
          type: DEPENDENT
          key: azure.vm.flows.outbound.max
          value_type: FLOAT
          description: 'Maximum creation rate of the outbound flows (the traffic going out of the VM).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OutboundFlowsMaximumCreationRate.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: network
        - uuid: 0a354c9b104b468d9749adfd28d1373e
          name: 'Available memory'
          type: DEPENDENT
          key: azure.vm.memory.available
          value_type: FLOAT
          units: B
          description: 'Amount of physical memory, in bytes, immediately available for the allocation to a process or for a system use in the virtual machine.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.AvailableMemoryBytes.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: memory
        - uuid: 411c5f6fcb374c4c90e2951a546c0c08
          name: 'Network in total'
          type: DEPENDENT
          key: azure.vm.network.in.total
          value_type: FLOAT
          units: B
          description: 'The number of bytes received by the VM via all network interfaces (incoming traffic).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.NetworkInTotal.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: network
        - uuid: ee2ef1d1e2844ae8be2a5f04c86631ba
          name: 'Network out total'
          type: DEPENDENT
          key: azure.vm.network.out.total
          value_type: FLOAT
          units: B
          description: 'The number of bytes sent by the VM via all network interfaces (outgoing traffic).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.NetworkOutTotal.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: network
        - uuid: 9d42609950864c899a0d63b94f1d2235
          name: 'OS disk used burst BPS credits'
          type: DEPENDENT
          key: azure.vm.os.disk.bandwidth.burst.used
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the OS disk burst bandwidth credits used so far.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskUsedBurstBPSCreditsPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 24c58e473c5c4b8388a0e78ae38378fc
          name: 'OS disk bandwidth consumed'
          type: DEPENDENT
          key: azure.vm.os.disk.bandwidth.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the operating system disk bandwidth consumed per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskBandwidthConsumedPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 7d0ca132bc264ac08e3c55809bdc40d1
          name: 'OS disk max burst bandwidth'
          type: DEPENDENT
          key: azure.vm.os.disk.bandwidth.max
          value_type: FLOAT
          units: Bps
          description: 'Maximum byte-per-second throughput that the OS disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskMaxBurstBandwidth.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 5cc422b7da3145fa885a88bb6165e3b9
          name: 'OS disk target bandwidth'
          type: DEPENDENT
          key: azure.vm.os.disk.bandwidth.target
          value_type: FLOAT
          units: Bps
          description: 'Baseline byte-per-second throughput that the OS disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskTargetBandwidth.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: c08f45df2e594e1fab01ba63df7da05b
          name: 'OS disk used burst IO credits'
          type: DEPENDENT
          key: azure.vm.os.disk.iops.burst.used
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the OS disk burst I/O credits used so far.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskUsedBurstIOCreditsPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 33a7fff9758046e3be07dad6c0a710ca
          name: 'OS disk IOPS consumed'
          type: DEPENDENT
          key: azure.vm.os.disk.iops.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the operating system disk I/Os consumed per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskIOPSConsumedPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 8374282688dc4fabb770c07eb335c666
          name: 'OS disk max burst IOPS'
          type: DEPENDENT
          key: azure.vm.os.disk.iops.max
          value_type: FLOAT
          units: '!iops'
          description: 'Maximum IOPS that the OS disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskMaxBurstIOPS.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 556941b1df5d470f8de628230b085623
          name: 'OS disk target IOPS'
          type: DEPENDENT
          key: azure.vm.os.disk.iops.target
          value_type: FLOAT
          units: '!iops'
          description: 'Baseline IOPS that the OS disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskTargetIOPS.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 3932b607cff14ee0a891c96587438807
          name: 'OS disk latency'
          type: DEPENDENT
          key: azure.vm.os.disk.latency
          value_type: FLOAT
          units: s
          description: 'Average time to complete each IO during the monitoring period for OS Disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskLatency.average
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: ca8fe9d0ea58482c9bb8b83a716362a2
          name: 'OS disk queue depth'
          type: DEPENDENT
          key: azure.vm.os.disk.queue.depth
          value_type: FLOAT
          description: 'The OS disk queue depth (or queue length).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskQueueDepth.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 30265aac759d45769769eae081f570ac
          name: 'OS disk read rate'
          type: DEPENDENT
          key: azure.vm.os.disk.read.bps
          value_type: FLOAT
          units: Bps
          description: 'Bytes/sec read from a single disk during the monitoring period - for an OS disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskReadBytessec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: f11fcbbd63234993a9c301dc8bac3e80
          name: 'OS disk IOPS read'
          type: DEPENDENT
          key: azure.vm.os.disk.read.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Read IOPS from a single disk during the monitoring period - for an OS disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskReadOperationsSec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 7645519a786b42908f1ec693128899c2
          name: 'OS disk write rate'
          type: DEPENDENT
          key: azure.vm.os.disk.write.bps
          value_type: FLOAT
          units: Bps
          description: 'Bytes/sec written to a single disk during the monitoring period - for an OS disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskWriteBytessec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 1e9392bc0c934e7d93f743c86e36e23e
          name: 'OS disk IOPS write'
          type: DEPENDENT
          key: azure.vm.os.disk.write.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Write IOPS from a single disk during the monitoring period - for an OS disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskWriteOperationsSec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: d6fcff826cfa486d945f33708be2f630
          name: 'Premium data disk cache read hit in %'
          type: DEPENDENT
          key: azure.vm.premium.data.disk.cache.read.hit
          value_type: FLOAT
          units: '%'
          description: 'Percentage of premium data disk cache read hit.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PremiumDataDiskCacheReadHit.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 288853ee5d08442fa43f8df1dfcc7823
          name: 'Premium data disk cache read miss in %'
          type: DEPENDENT
          key: azure.vm.premium.data.disk.cache.read.miss
          value_type: FLOAT
          units: '%'
          description: 'Percentage of premium data disk cache read miss.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PremiumDataDiskCacheReadMiss.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 66b629ae3d7e4abeaf0282414c91876f
          name: 'Premium OS disk cache read hit in %'
          type: DEPENDENT
          key: azure.vm.premium.os.disk.cache.read.hit
          value_type: FLOAT
          units: '%'
          description: 'Percentage of premium OS disk cache read hit.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PremiumOSDiskCacheReadHit.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 3927f34d5d0649d7ac29703f64054dbf
          name: 'Premium OS disk cache read miss in %'
          type: DEPENDENT
          key: azure.vm.premium.os.disk.cache.read.miss
          value_type: FLOAT
          units: '%'
          description: 'Percentage of premium OS disk cache read miss.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PremiumOSDiskCacheReadMiss.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 7d2ca29fce9a4c9ba60279f07de73089
          name: 'Temp disk latency'
          type: DEPENDENT
          key: azure.vm.temp.disk.latency
          value_type: FLOAT
          units: s
          description: 'Average time to complete each IO during the monitoring period for temp disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.TempDiskLatency.average
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.001'
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 67638ce2228e4f5d9f4aae44d9c4a47f
          name: 'Temp disk queue depth'
          type: DEPENDENT
          key: azure.vm.temp.disk.queue.depth
          value_type: FLOAT
          description: 'Temp Disk queue depth (or queue length).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.TempDiskQueueDepth.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: f07200debf2d49dba3c0a63102258c6c
          name: 'Temp disk read rate'
          type: DEPENDENT
          key: azure.vm.temp.disk.read.bps
          value_type: FLOAT
          units: Bps
          description: 'Bytes/Sec read from a single disk during the monitoring period for temp disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.TempDiskReadBytessec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 4b7b661391ac46179913a0e1bf012e76
          name: 'Temp disk IOPS read'
          type: DEPENDENT
          key: azure.vm.temp.disk.read.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Read IOPS from a single disk during the monitoring period for temp disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.TempDiskReadOperationsSec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: dc3601128000423b8b46ef1046562105
          name: 'Temp disk write rate'
          type: DEPENDENT
          key: azure.vm.temp.disk.write.bps
          value_type: FLOAT
          units: Bps
          description: 'Bytes/Sec written to a single disk during the monitoring period for temp disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.TempDiskWriteBytessec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: d03cdea05ae549ffb63c6db4a7e40c13
          name: 'Temp disk IOPS write'
          type: DEPENDENT
          key: azure.vm.temp.disk.write.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Bytes/Sec written to a single disk during the monitoring period for temp disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.TempDiskWriteOperationsSec.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: d6e85395e34b4288988a5287d287f182
          name: 'VM uncached bandwidth consumed'
          type: DEPENDENT
          key: azure.vm.uncached.bandwidth.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the uncached disk bandwidth consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMUncachedBandwidthConsumedPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 124203560922429bb32b76c45f24b2b9
          name: 'VM uncached IOPS consumed'
          type: DEPENDENT
          key: azure.vm.uncached.iops.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of the uncached disk IOPS consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMUncachedIOPSConsumedPercentage.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.RESOURCE.ID}'
          description: 'Microsoft Azure virtual machine ID.'
        - macro: '{$AZURE.SUBSCRIPTION.ID}'
          description: 'Microsoft Azure subscription ID.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
        - macro: '{$AZURE.VM.CPU.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of CPU utilization, expressed in %.'
      dashboards:
        - uuid: 527e3c432d3842d0968480d8f91a712e
          name: 'Overview Azure Virtual Machine'
          pages:
            - widgets:
                - type: clock
                  name: 'Local time'
                  width: '12'
                  height: '3'
                - type: item
                  name: 'CPU credits consumed'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.cpu.credits.consumed
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Network in'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.network.in.total
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Disk read rate'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.disk.read.bytes
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'OS disk read operations/sec'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.os.disk.read.ops
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Inbound flows'
                  'y': '15'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.flows.inbound
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Available memory'
                  x: '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.memory.available
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'CPU credits remaining'
                  x: '12'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.cpu.credits.remaining
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Network out'
                  x: '12'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.network.out.total
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Disk write rate'
                  x: '12'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.disk.write.bytes
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'OS disk write operations/sec'
                  x: '12'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.os.disk.write.ops
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Outbound flows'
                  x: '12'
                  'y': '15'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.flows.outbound
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Availability state'
                  x: '24'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.availability.state
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: up_color
                      value: FF0000
                - type: graph
                  name: 'Percentage CPU'
                  x: '24'
                  'y': '3'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        name: 'Azure: Percentage CPU'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'Network traffic'
                  x: '24'
                  'y': '6'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        name: 'Azure: Network traffic'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: 'Disk read/write bytes'
                  x: '24'
                  'y': '9'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        name: 'Azure: Disk read/write bytes'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  name: 'OS disk read/write rates'
                  x: '24'
                  'y': '12'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        name: 'Azure: OS disk read/write IOPS'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  name: Flows
                  x: '24'
                  'y': '15'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        name: 'Azure: Flows'
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: itemhistory
                  name: 'Availability status detailed'
                  x: '36'
                  width: '36'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: columns.0.display
                      value: '4'
                    - type: ITEM
                      name: columns.0.itemid
                      value:
                        host: 'Azure Virtual Machine by HTTP'
                        key: azure.vm.availability.details
                    - type: INTEGER
                      name: columns.0.monospace_font
                      value: '1'
                    - type: STRING
                      name: columns.0.name
                      value: 'Azure: Availability status detailed'
                    - type: STRING
                      name: reference
                      value: BAAAA
                    - type: INTEGER
                      name: show_timestamp
                      value: '1'
      valuemaps:
        - uuid: 38c8ce1516704ec2a6f1ea9686db56b9
          name: 'Azure resource health state'
          mappings:
            - value: '0'
              newvalue: Available
            - value: '1'
              newvalue: Degraded
            - value: '2'
              newvalue: Unavailable
            - value: '3'
              newvalue: Unknown
    - uuid: d0fd5d346b1740dda9d3a976371789dd
      template: 'Azure VM Scale Set by HTTP'
      name: 'Azure VM Scale Set by HTTP'
      description: |
        This template is designed to monitor Microsoft Azure virtual machine scale sets by HTTP.
        It works without any external scripts and uses the script item.
        
        Setup:
          1. Create an Azure service principal via the Azure command-line interface (Azure CLI) for your subscription.
            `az ad sp create-for-rbac --name zabbix --role reader --scope /subscriptions/<subscription_id>`
            See https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli for more details.
          2. Link the template to a host.
          3. Configure the macros: {$AZURE.APP.ID}, {$AZURE.PASSWORD}, {$AZURE.TENANT.ID}, {$AZURE.SUBSCRIPTION.ID}, and {$AZURE.RESOURCE.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"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Cloud
      items:
        - uuid: eea82baaa0684ba688a69da62bf1eec5
          name: 'VM availability metric'
          type: DEPENDENT
          key: azure.scaleset.availability
          value_type: FLOAT
          description: 'Measure of availability of the virtual machines over time.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VmAvailabilityMetric.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: health
        - uuid: 21740af2abca461f88a81f07ba297929
          name: 'Availability status detailed'
          type: DEPENDENT
          key: azure.scaleset.availability.details
          value_type: CHAR
          description: 'The summary description of availability status.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.summary
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: health
        - uuid: 65e1ca0b38e04adca069388a4c5e3869
          name: 'Availability state'
          type: DEPENDENT
          key: azure.scaleset.availability.state
          description: |
            The availability status of the resource.
            0 - Available - no events detected that affect the health of the resource.
            1 - Degraded  - your resource detected a loss in performance, although it's still available for use.
            2 - Unavailable - the service detected an ongoing platform or non-platform event that affects the health of the resource.
            3 - Unknown - Resource Health hasn't received information about the resource for more than 10 minutes.
          valuemap:
            name: 'Azure resource health state'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.availabilityState
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: STR_REPLACE
              parameters:
                - Available
                - '0'
            - type: STR_REPLACE
              parameters:
                - Degraded
                - '1'
            - type: STR_REPLACE
              parameters:
                - Unavailable
                - '2'
            - type: STR_REPLACE
              parameters:
                - Unknown
                - '3'
            - type: IN_RANGE
              parameters:
                - '0'
                - '3'
              error_handler: CUSTOM_VALUE
              error_handler_params: '3'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: a1aadc807a6d40bd8dd2049c0ead6e38
              expression: 'last(/Azure VM Scale Set by HTTP/azure.scaleset.availability.state)=1'
              name: 'Virtual machine scale set is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in a degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: c09bb8da8bb54c45b6d424a63ec892ae
              expression: 'last(/Azure VM Scale Set by HTTP/azure.scaleset.availability.state)=3'
              name: 'Virtual machine scale set is in unknown state'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              description: 'The resource state is unknown.'
              tags:
                - tag: scope
                  value: availability
            - uuid: eff890c95f574ad09af82ad79803e733
              expression: 'last(/Azure VM Scale Set by HTTP/azure.scaleset.availability.state)=2'
              name: 'Virtual machine scale set is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: dd6bac4dda51446e9a16450c61b8e23e
          name: 'CPU credits consumed'
          type: DEPENDENT
          key: azure.scaleset.cpu.credits.consumed
          value_type: FLOAT
          description: 'Total number of credits consumed by the virtual machine. Only available on B-series burstable VMs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.CPUCreditsConsumed.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: e05426408c9f448a9f8df40a52b6502a
          name: 'CPU credits remaining'
          type: DEPENDENT
          key: azure.scaleset.cpu.credits.remaining
          value_type: FLOAT
          description: 'Total number of credits available to burst. Only available on B-series burstable VMs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.CPUCreditsRemaining.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: cpu
        - uuid: 0883913383d54b81b5c67b65dc595ae3
          name: 'CPU utilization'
          type: DEPENDENT
          key: azure.scaleset.cpu.utilization
          value_type: FLOAT
          units: '%'
          description: 'The percentage of allocated compute units that are currently in use by the virtual machine(s).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PercentageCPU.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: cpu
          triggers:
            - uuid: a3706a6c3349429b89b6915a6b0fb5c1
              expression: 'min(/Azure VM Scale Set by HTTP/azure.scaleset.cpu.utilization,5m)>{$AZURE.SCALESET.CPU.UTIL.CRIT}'
              name: 'High CPU utilization'
              event_name: 'CPU utilization is high (over {$AZURE.SCALESET.CPU.UTIL.CRIT}% for last 5m)'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The CPU utilization is too high. The system might be slow to respond.'
              tags:
                - tag: scope
                  value: performance
        - uuid: bc342d5b3c42487887df3a82cd65e265
          name: 'Data disk max burst bandwidth'
          type: DEPENDENT
          key: azure.scaleset.data.disk.bandwidth.burst.max
          value_type: FLOAT
          units: Bps
          description: 'Maximum byte-per-second throughput the data disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskMaxBurstBandwidth.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 1d19657c420b4a0a9e601a4effefa58f
          name: 'Data disk used burst BPS credits'
          type: DEPENDENT
          key: azure.scaleset.data.disk.bandwidth.burst.used
          value_type: FLOAT
          units: '%'
          description: 'Percentage of data disk burst bandwidth credits used so far.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskUsedBurstBPSCreditsPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 76a0d87846b74a128d63f62da04050ab
          name: 'Data disk bandwidth consumed'
          type: DEPENDENT
          key: azure.scaleset.data.disk.bandwidth.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of data disk bandwidth consumed per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskBandwidthConsumedPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: dd3994c9e83f48d395e61c91aae2f17d
          name: 'Data disk target bandwidth'
          type: DEPENDENT
          key: azure.scaleset.data.disk.bandwidth.target
          value_type: FLOAT
          units: Bps
          description: 'Baseline byte-per-second throughput the data disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskTargetBandwidth.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 53ab6e4d0dcd46d48c6ede579ca00366
          name: 'Data disk max burst IOPS'
          type: DEPENDENT
          key: azure.scaleset.data.disk.iops.burst.max
          value_type: FLOAT
          units: '!iops'
          description: 'Maximum IOPS the data disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskMaxBurstIOPS.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: e4bfd5f8c13d44e69facf507a10db553
          name: 'Data disk used burst IO credits'
          type: DEPENDENT
          key: azure.scaleset.data.disk.iops.burst.used
          value_type: FLOAT
          units: '%'
          description: 'Percentage of data disk burst I/O credits used so far.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskUsedBurstIOCreditsPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: d7633aaf087741ec8558198dc382df1a
          name: 'Data disk IOPS consumed'
          type: DEPENDENT
          key: azure.scaleset.data.disk.iops.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of data disk I/Os consumed per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskIOPSConsumedPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 86123a1bff83403a8190fc5f61c4edd7
          name: 'Data disk target IOPS'
          type: DEPENDENT
          key: azure.scaleset.data.disk.iops.target
          value_type: FLOAT
          units: '!iops'
          description: 'Baseline IOPS the data disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskTargetIOPS.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 72cadbd3a3ae409b8f192217c2ff6cb1
          name: 'Data disk queue depth'
          type: DEPENDENT
          key: azure.scaleset.data.disk.queue.depth
          description: 'Data disk queue depth (or queue length).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskQueueDepth.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: d42c402ec613423287335538136bcd05
          name: 'Data disk read rate'
          type: DEPENDENT
          key: azure.scaleset.data.disk.read.bps
          value_type: FLOAT
          units: Bps
          description: 'Bytes/sec read from a single disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskReadBytessec.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 2e265f80dccd4542a0f4b0adf462fec0
          name: 'Data disk IOPS read'
          type: DEPENDENT
          key: azure.scaleset.data.disk.read.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Read IOPS from a single disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskReadOperationsSec.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 99b8c634131d49b7828e88a44342e2b6
          name: 'Data disk write rate'
          type: DEPENDENT
          key: azure.scaleset.data.disk.write.bps
          value_type: FLOAT
          units: Bps
          description: 'Bytes/sec written to a single disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskWriteBytessec.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 0c46306040db41af895ab9a82d55ad31
          name: 'Data disk IOPS write'
          type: DEPENDENT
          key: azure.scaleset.data.disk.write.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Write IOPS from a single disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskWriteOperationsSec.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 14a25a861b9f491194ea055c189cc2f9
          name: 'Get errors'
          type: DEPENDENT
          key: azure.scaleset.data.errors
          value_type: TEXT
          description: 'A list of errors from API requests.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.error
              error_handler: CUSTOM_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: error
          triggers:
            - uuid: 1d114800a6534498b52a2dd25e93d719
              expression: 'length(last(/Azure VM Scale Set by HTTP/azure.scaleset.data.errors))>0'
              name: '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: f783d047862144f2baed76bb281cec5b
          name: 'Get data'
          type: SCRIPT
          key: azure.scaleset.data.get
          history: '0'
          value_type: TEXT
          params: |
            var Azure = {
            	params: {},
            	token: null,
            
            	setParams: function (params) {
            		['app_id', 'password', 'tenant_id', 'subscription_id', 'resource_id'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined' || params[field] === '') {
            				throw 'Required param is not set: ' + field + '.';
            			}
            		});
            
            		Azure.params = params;
            	},
            
            	login: function () {
            		var response, login = new HttpRequest();
            
            		if (typeof Azure.params.proxy !== 'undefined' && Azure.params.proxy !== '') {
            			login.setProxy(Azure.params.proxy);
            		}
            
            		login.addHeader('Content-Type: application/x-www-form-urlencoded');
            		response = login.post(
            			'https://login.microsoftonline.com/' + encodeURIComponent(Azure.params.tenant_id) + '/oauth2/token',
            			'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(Azure.params.app_id) + '&client_secret=' + encodeURIComponent(Azure.params.password)
            		);
            
            		if (login.getStatus() !== 200) {
            			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.';
            		}
            
            		Azure.token = response['access_token'];
            	},
            
            	request: function (url) {
            		var response, request = new HttpRequest();
            
            		if (typeof Azure.params.proxy !== 'undefined' && Azure.params.proxy !== '') {
            			request.setProxy(Azure.params.proxy);
            		}
            
            		if (!Azure.token) {
            			throw 'Request does not contain access token.';
            		}
            
            		request.addHeader('Content-Type: application/json');
            		request.addHeader('Authorization: Bearer ' + Azure.token);
            		Zabbix.log(4, '[ AzureVMSS ] request url: ' + url);
            
            		response = request.get(url);
            
            		if (request.getStatus() !== 200) {
            			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) {
            		var steps = path.split('.');
            
            		for (var i = 0; i < steps.length; i++) {
            			var step = steps[i];
            			if (typeof data !== 'object' || typeof data[step] === 'undefined') {
            				throw 'Required field was not found: ' + path;
            			}
            			data = data[step];
            		}
            
            		return data;
            	},
            
            	getMetricsData: function () {
            		var data = {},
            			metric_endpoints = {
            				'main_metrics': '/providers/Microsoft.Insights/metrics?metricnames=' + encodeURIComponent('Available Memory Bytes,CPU Credits Consumed,CPU Credits Remaining,Percentage CPU,Inbound Flows,Inbound Flows Maximum Creation Rate,Network In,Network In Total,Network Out,Network Out Total,Outbound Flows,Outbound Flows Maximum Creation Rate,VmAvailabilityMetric') + '&api-version=2021-05-01&timespan=PT1M',
            				'disks_metrics': '/providers/Microsoft.Insights/metrics?metricnames=' + encodeURIComponent('Data Disk Bandwidth Consumed Percentage,Data Disk IOPS Consumed Percentage,Data Disk Max Burst Bandwidth,Data Disk Max Burst IOPS,Data Disk Queue Depth,Data Disk Read Bytes/sec,Data Disk Read Operations/Sec,Data Disk Target Bandwidth,Data Disk Target IOPS,Data Disk Used Burst BPS Credits Percentage,Data Disk Used Burst IO Credits Percentage,Data Disk Write Bytes/sec,Data Disk Write Operations/Sec,Disk Read Bytes,Disk Read Operations/Sec,Disk Write Bytes,Disk Write Operations/Sec') + '&api-version=2021-05-01&timespan=PT1M',
            				'os_disk_metrics': '/providers/Microsoft.Insights/metrics?metricnames=' + encodeURIComponent('OS Disk Bandwidth Consumed Percentage,OS Disk IOPS Consumed Percentage,OS Disk Max Burst Bandwidth,OS Disk Max Burst IOPS,OS Disk Queue Depth,OS Disk Read Bytes/sec,OS Disk Read Operations/Sec,OS Disk Target Bandwidth,OS Disk Target IOPS,OS Disk Used Burst BPS Credits Percentage,OS Disk Used Burst IO Credits Percentage,OS Disk Write Bytes/sec,OS Disk Write Operations/Sec') + '&api-version=2021-05-01&timespan=PT1M',
            				'premium_and_vm_metrics': '/providers/Microsoft.Insights/metrics?metricnames=' + encodeURIComponent('Premium Data Disk Cache Read Hit,Premium Data Disk Cache Read Miss,Premium OS Disk Cache Read Hit,Premium OS Disk Cache Read Miss,VM Cached Bandwidth Consumed Percentage,VM Cached IOPS Consumed Percentage,VM Local Used Burst BPS Credits Percentage,VM Local Used Burst IO Credits Percentage,VM Remote Used Burst BPS Credits Percentage,VM Remote Used Burst IO Credits Percentage,VM Uncached Bandwidth Consumed Percentage,VM Uncached IOPS Consumed Percentage') + '&api-version=2021-05-01&timespan=PT1M'
            			};
            
            		data.metrics = {};
            
            		Object.keys(metric_endpoints).forEach(function (field) {
            			metrics = Azure.getField(Azure.request('https://management.azure.com' + Azure.params.resource_id + metric_endpoints[field]), 'value');
            			for (k in metrics) {
            				key = Azure.getField(metrics[k], 'name.value').replace(/(\s|\/)+/g, '');
            				if (metrics[k].timeseries.length === 0) {
            					metrics[k].timeseries.push({ 'data': ['nodata'] })
            				}
            				data.metrics[key] = Azure.getField(metrics[k], 'timeseries.0.data.0');
            			}
            		});
            
            		data.capacity = Azure.getField(Azure.request('https://management.azure.com' + Azure.params.resource_id + '?api-version=2024-03-01'), 'sku.capacity');
            		data.health = Azure.getField(Azure.request('https://management.azure.com' + Azure.params.resource_id + '/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2020-05-01'), 'value.0.properties');
            
            		return data
            	}
            };
            
            try {
            	Azure.setParams(JSON.parse(value));
            	Azure.login();
            	return JSON.stringify(Azure.getMetricsData());
            }
            catch (error) {
            	error += (String(error).endsWith('.')) ? '' : '.';
            	Zabbix.log(3, '[ AzureVMSS ] ERROR: ' + error);
            	return JSON.stringify({ 'error': error });
            }
            
          description: 'Gathers data of the virtual machine scale set.'
          timeout: '{$AZURE.DATA.TIMEOUT}'
          parameters:
            - name: app_id
              value: '{$AZURE.APP.ID}'
            - name: password
              value: '{$AZURE.PASSWORD}'
            - name: proxy
              value: '{$AZURE.PROXY}'
            - name: resource_id
              value: '{$AZURE.RESOURCE.ID}'
            - name: subscription_id
              value: '{$AZURE.SUBSCRIPTION.ID}'
            - name: tenant_id
              value: '{$AZURE.TENANT.ID}'
          tags:
            - tag: component
              value: raw
        - uuid: aa8675f8f0fa454db27d46308ab92c79
          name: 'Disk read'
          type: DEPENDENT
          key: azure.scaleset.disk.read
          value_type: FLOAT
          units: B
          description: 'Bytes read from the disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskReadBytes.total
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 39f1d8154bc540b78f3d1c04ea68144f
          name: 'Disk IOPS read'
          type: DEPENDENT
          key: azure.scaleset.disk.read.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Disk read IOPS.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskReadOperationsSec.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: a419f2280662418abe7692d22a5344fb
          name: 'Disk write'
          type: DEPENDENT
          key: azure.scaleset.disk.write
          value_type: FLOAT
          units: B
          description: 'Bytes written to the disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskWriteBytes.total
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 96ac2287bae3415cae1b0a8590954d02
          name: 'Disk IOPS write'
          type: DEPENDENT
          key: azure.scaleset.disk.write.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Write IOPS from a single disk during the monitoring period.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskWriteOperationsSec.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 7f0cb52d4db84c2b8d8ef8f82cc6d77b
          name: 'Inbound flows'
          type: DEPENDENT
          key: azure.scaleset.flows.inbound
          value_type: FLOAT
          description: 'Inbound Flows are the number of current flows in the inbound direction (traffic going into the VMs).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.InboundFlows.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: network
        - uuid: dacfd47b3c3142ce9ca043ebda4e7614
          name: 'Inbound flow maximum creation rate'
          type: DEPENDENT
          key: azure.scaleset.flows.inbound.max
          value_type: FLOAT
          description: 'The maximum creation rate of inbound flows (traffic going into the VM).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.InboundFlowsMaximumCreationRate.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: network
        - uuid: 8ef6bb3bc1884426ab3fe9998acf4e25
          name: 'Outbound flows'
          type: DEPENDENT
          key: azure.scaleset.flows.outbound
          value_type: FLOAT
          description: 'Outbound Flows are the number of current flows in the outbound direction (traffic going out of the VMs).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OutboundFlows.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: network
        - uuid: 15b8f8fde6e4458e8904428537a8b32a
          name: 'Outbound flow maximum creation rate'
          type: DEPENDENT
          key: azure.scaleset.flows.outbound.max
          value_type: FLOAT
          description: 'The maximum creation rate of outbound flows (traffic going out of the VM).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OutboundFlowsMaximumCreationRate.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: network
        - uuid: 4025ada5ba4940b88b48b7b71efbe07b
          name: 'Network in total'
          type: DEPENDENT
          key: azure.scaleset.network.in.total
          value_type: FLOAT
          units: B
          description: 'The number of bytes received on all network interfaces by the virtual machine(s) (incoming traffic).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.NetworkInTotal.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: network
        - uuid: 6bca5eeb39194c5f83f83863f1e6b4c6
          name: 'Network out total'
          type: DEPENDENT
          key: azure.scaleset.network.out.total
          value_type: FLOAT
          units: B
          description: 'The number of bytes out on all network interfaces by the virtual machine(s) (outgoing traffic).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.NetworkOutTotal.total
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: network
        - uuid: d81be2d243124ebd8efd5fa4fd79d3f6
          name: 'OS disk used burst BPS credits'
          type: DEPENDENT
          key: azure.scaleset.os.disk.bandwidth.burst.used
          value_type: FLOAT
          units: '%'
          description: 'Percentage of OS Disk burst bandwidth credits used so far.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskUsedBurstBPSCreditsPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b66ff8f85e614b9c9db479e8452a3acb
          name: 'OS disk bandwidth consumed'
          type: DEPENDENT
          key: azure.scaleset.os.disk.bandwidth.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of operating system disk bandwidth consumed per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskBandwidthConsumedPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b5f5c9d4040c4b889287658532aec890
          name: 'OS disk max burst bandwidth'
          type: DEPENDENT
          key: azure.scaleset.os.disk.bandwidth.max
          value_type: FLOAT
          units: Bps
          description: 'Maximum byte-per-second throughput the OS Disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskMaxBurstBandwidth.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 4f28508261554a11a858f905160a5db2
          name: 'OS disk target bandwidth'
          type: DEPENDENT
          key: azure.scaleset.os.disk.bandwidth.target
          value_type: FLOAT
          units: Bps
          description: 'Baseline byte-per-second throughput the OS Disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskTargetBandwidth.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 97005b2f1be1455f8002b3f777898163
          name: 'OS disk used burst IO credits'
          type: DEPENDENT
          key: azure.scaleset.os.disk.iops.burst.used
          value_type: FLOAT
          units: '%'
          description: 'Percentage of OS Disk burst I/O credits used so far.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskUsedBurstIOCreditsPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 87e51f85e00646d4bfe12840f444e47a
          name: 'OS disk IOPS consumed'
          type: DEPENDENT
          key: azure.scaleset.os.disk.iops.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of operating system disk I/Os consumed per minute.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskIOPSConsumedPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 1ff472b5cca24332abea886bff44435f
          name: 'OS disk max burst IOPS'
          type: DEPENDENT
          key: azure.scaleset.os.disk.iops.max
          value_type: FLOAT
          units: '!iops'
          description: 'Maximum IOPS the OS Disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskMaxBurstIOPS.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 72b19174782d4905be402e2825098f17
          name: 'OS disk target IOPS'
          type: DEPENDENT
          key: azure.scaleset.os.disk.iops.target
          value_type: FLOAT
          units: '!iops'
          description: 'Baseline IOPS the OS disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskTargetIOPS.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 3bbb425e37894415b002e026e34259a2
          name: 'OS disk queue depth'
          type: DEPENDENT
          key: azure.scaleset.os.disk.queue.depth
          value_type: FLOAT
          description: 'OS Disk queue depth (or queue length).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskQueueDepth.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 7879801b929249d0b266ae905307beee
          name: 'OS disk read rate'
          type: DEPENDENT
          key: azure.scaleset.os.disk.read.bps
          value_type: FLOAT
          units: Bps
          description: 'Bytes/sec read from a single disk during the monitoring period - for an OS disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskReadBytessec.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 542881bbbb694b1a84befbb772ded703
          name: 'OS disk IOPS read'
          type: DEPENDENT
          key: azure.scaleset.os.disk.read.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Read IOPS from a single disk during the monitoring period - for an OS disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskReadOperationsSec.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: c86371d6f8224b418f003a7fdefe9884
          name: 'OS disk write rate'
          type: DEPENDENT
          key: azure.scaleset.os.disk.write.bps
          value_type: FLOAT
          units: Bps
          description: 'Bytes/sec written to a single disk during the monitoring period - for an OS disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskWriteBytessec.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 77d95de6fdbd49ba9bae68e75f792560
          name: 'OS disk IOPS write'
          type: DEPENDENT
          key: azure.scaleset.os.disk.write.ops
          value_type: FLOAT
          units: '!iops'
          description: 'Write IOPS from a single disk during the monitoring period - for an OS disk.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskWriteOperationsSec.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 25915ce6d37740bf83f656c5cc7b9960
          name: 'Premium data disk cache read hit in %'
          type: DEPENDENT
          key: azure.scaleset.premium.data.disk.cache.read.hit
          value_type: FLOAT
          units: '%'
          description: 'Percentage of premium data disk cache read hit.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PremiumDataDiskCacheReadHit.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: f04f8f7e59ec4786b5ea8765cbf69b82
          name: 'Premium data disk cache read miss in %'
          type: DEPENDENT
          key: azure.scaleset.premium.data.disk.cache.read.miss
          value_type: FLOAT
          units: '%'
          description: 'Percentage of premium data disk cache read miss.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PremiumDataDiskCacheReadMiss.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 65442659fe944842811638ac04dc998a
          name: 'Premium OS disk cache read hit in %'
          type: DEPENDENT
          key: azure.scaleset.premium.os.disk.cache.read.hit
          value_type: FLOAT
          units: '%'
          description: 'Percentage of premium OS disk cache read hit.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PremiumOSDiskCacheReadHit.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 981c83a8623c481ca040c66f5d5738ec
          name: 'Premium OS disk cache read miss in %'
          type: DEPENDENT
          key: azure.scaleset.premium.os.disk.cache.read.miss
          value_type: FLOAT
          units: '%'
          description: 'Percentage of premium OS disk cache read miss.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PremiumOSDiskCacheReadMiss.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 8bfbc99e09314aeea7c0d0563d148c11
          name: 'VM cached bandwidth consumed'
          type: DEPENDENT
          key: azure.scaleset.vm.cached.bandwidth.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of cached disk bandwidth consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMCachedBandwidthConsumedPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: ae97e2890b5844749913f3a1d650091d
          name: 'VM cached IOPS consumed'
          type: DEPENDENT
          key: azure.scaleset.vm.cached.iops.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of cached disk IOPS consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMCachedIOPSConsumedPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 7124d8d7d2b246feaa8959fd6d5aba0f
          name: 'Virtual machine count'
          type: DEPENDENT
          key: azure.scaleset.vm.count
          description: 'Current amount of virtual machines in the scale set.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.capacity
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: cd77906ed04a42f28bb702bc513504a0
              expression: 'min(/Azure VM Scale Set by HTTP/azure.scaleset.vm.count,5m)>{$AZURE.SCALESET.VM.COUNT.CRIT}'
              name: 'High amount of VMs in the scale set'
              event_name: 'Number of VMs is high (over {$AZURE.SCALESET.VM.COUNT.CRIT} for last 5m)'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'High amount of VMs in the scale set.'
              tags:
                - tag: scope
                  value: performance
        - uuid: 31f742e4476f4ab09d3a2bd46f820098
          name: 'Available memory'
          type: DEPENDENT
          key: azure.scaleset.vm.memory
          value_type: FLOAT
          units: B
          description: 'Amount of physical memory, in bytes, immediately available for allocation to a process or for system use in the virtual machine.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.AvailableMemoryBytes.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: memory
        - uuid: 8271a3a47a744e23bd239919760fb9b4
          name: 'VM uncached bandwidth consumed'
          type: DEPENDENT
          key: azure.scaleset.vm.uncached.bandwidth.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of uncached disk bandwidth consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMUncachedBandwidthConsumedPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
        - uuid: dd8f8111b6914ba38f6fe2f707dbb9f1
          name: 'VM uncached IOPS consumed'
          type: DEPENDENT
          key: azure.scaleset.vm.uncached.iops.consumed
          value_type: FLOAT
          units: '%'
          description: 'Percentage of uncached disk IOPS consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMUncachedIOPSConsumedPercentage.average
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.scaleset.data.get
          tags:
            - tag: component
              value: storage
      tags:
        - tag: class
          value: software
        - tag: target
          value: azure
      macros:
        - macro: '{$AZURE.APP.ID}'
          description: 'The App ID of Microsoft Azure.'
        - macro: '{$AZURE.DATA.TIMEOUT}'
          value: 15s
          description: 'API response timeout.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets the HTTP proxy value. If this macro is empty, then no proxy is used.'
        - macro: '{$AZURE.RESOURCE.ID}'
          description: 'Microsoft Azure virtual machine ID.'
        - macro: '{$AZURE.SCALESET.CPU.UTIL.CRIT}'
          value: '90'
          description: 'The critical threshold of CPU utilization, expressed in %.'
        - macro: '{$AZURE.SCALESET.VM.COUNT.CRIT}'
          value: '100'
          description: 'The critical amount of virtual machines in the scale set.'
        - macro: '{$AZURE.SUBSCRIPTION.ID}'
          description: 'Microsoft Azure subscription ID.'
        - macro: '{$AZURE.TENANT.ID}'
          description: 'Microsoft Azure tenant ID.'
      dashboards:
        - uuid: 1a38b3783a6b41cca3e5cfadd64d4534
          name: 'Overview Azure VM Scale Set'
          pages:
            - widgets:
                - type: item
                  name: 'Virtual machine count'
                  width: '12'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.vm.count
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'CPU credits consumed'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.cpu.credits.consumed
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Network in'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.network.in.total
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Disk read'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.disk.read
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'OS disk read operations/sec'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.disk.read.ops
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Inbound flows'
                  'y': '15'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.flows.inbound
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Available memory'
                  x: '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.vm.memory
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'CPU credits remaining'
                  x: '12'
                  'y': '3'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.cpu.credits.remaining
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Network out'
                  x: '12'
                  'y': '6'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.network.out.total
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Disk write'
                  x: '12'
                  'y': '9'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.disk.write
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'OS disk write operations/sec'
                  x: '12'
                  'y': '12'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.disk.write.ops
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Outbound flows'
                  x: '12'
                  'y': '15'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.flows.outbound
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                - type: item
                  name: 'Availability state'
                  x: '24'
                  width: '12'
                  height: '3'
                  fields:
                    - type: ITEM
                      name: itemid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.availability.state
                    - type: INTEGER
                      name: show.0
                      value: '4'
                    - type: INTEGER
                      name: show.1
                      value: '2'
                    - type: STRING
                      name: up_color
                      value: FF0000
                - type: graph
                  name: 'CPU Utilization'
                  x: '24'
                  'y': '3'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        name: 'CPU Utilization'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  name: 'Network traffic'
                  x: '24'
                  'y': '6'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        name: 'Network traffic, bytes'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graph
                  name: 'Disk read/write bytes'
                  x: '24'
                  'y': '9'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        name: 'Disk read/write bytes'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graph
                  name: 'OS disk read/write rates'
                  x: '24'
                  'y': '12'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        name: 'OS disk IOPS read/write'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  name: Flows
                  x: '24'
                  'y': '15'
                  width: '48'
                  height: '3'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        name: Flows
                    - type: STRING
                      name: reference
                      value: AAAAE
                - type: itemhistory
                  name: 'Availability status detailed'
                  x: '36'
                  width: '36'
                  height: '3'
                  fields:
                    - type: INTEGER
                      name: columns.0.display
                      value: '4'
                    - type: ITEM
                      name: columns.0.itemid
                      value:
                        host: 'Azure VM Scale Set by HTTP'
                        key: azure.scaleset.availability.details
                    - type: INTEGER
                      name: columns.0.monospace_font
                      value: '1'
                    - type: STRING
                      name: columns.0.name
                      value: '|'
                    - type: STRING
                      name: reference
                      value: BAAAA
                    - type: INTEGER
                      name: show_column_header
                      value: '0'
                    - type: INTEGER
                      name: show_timestamp
                      value: '1'
      valuemaps:
        - uuid: fc7ca60876144ac8b240db81537920a6
          name: 'Azure resource health state'
          mappings:
            - value: '0'
              newvalue: Available
            - value: '1'
              newvalue: Degraded
            - value: '2'
              newvalue: Unavailable
            - value: '3'
              newvalue: Unknown
  graphs:
    - uuid: 781dd83ed494465bbf2c16efbc753a51
      name: 'Azure: Data disk read/write Bps'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.data.disk.read.bps
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.data.disk.write.bps
    - uuid: 7d198b2f6186498ab39ece80f3f7b30e
      name: 'Azure: Data disk read/write IOPS'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.data.disk.read.ops
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.data.disk.write.ops
    - uuid: a2d0eb282276486896067f8a30f8ea51
      name: 'Azure: Disk read/write bytes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.disk.read.bytes
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.disk.write.bytes
    - uuid: 58a8c6942314408ab0e88b15d53f67e5
      name: 'Azure: Disk read/write IOPS'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.disk.read.ops
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.disk.write.ops
    - uuid: b427ad3dbb8d4f8caf1edfb0cab04733
      name: 'Azure: Flows'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.flows.inbound
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.flows.outbound
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.flows.inbound.max
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.flows.outbound.max
    - uuid: f0f37dc8840a45ba8e8cb62f5fea6804
      name: 'Azure: Network traffic'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.network.in.total
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.network.out.total
    - uuid: 41bd1642704c4d3fbe4fb34c8c389320
      name: 'Azure: OS disk read/write Bps'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.os.disk.read.bps
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.os.disk.write.bps
    - uuid: df77fe1de4ae46f98744ff73ed427b3b
      name: 'Azure: OS disk read/write IOPS'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.os.disk.read.ops
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.os.disk.write.ops
    - uuid: 39ca70fc12cf4c6d9fdc23e8562b2f13
      name: 'Azure: Percentage CPU'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.cpu.utilization
    - uuid: 3051d683b44b48ee94030465254abc7f
      name: 'Azure: Premium data disk cache read'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.premium.data.disk.cache.read.hit
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.premium.data.disk.cache.read.miss
    - uuid: d727dc11deaa46b282892552c9b03752
      name: 'Azure: Premium OS disk cache read'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.premium.os.disk.cache.read.hit
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Virtual Machine by HTTP'
            key: azure.vm.premium.os.disk.cache.read.miss
    - uuid: 3b278de1b81a4be7acc865568962c323
      name: 'Azure Microsoft SQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Microsoft SQL Database by HTTP'
            key: azure.db.mssql.connections.successful
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Microsoft SQL Database by HTTP'
            key: azure.db.mssql.connections.failed.system
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Azure Microsoft SQL Database by HTTP'
            key: azure.db.mssql.firewall.blocked
    - uuid: 62a9a5e1fb044a52a0b534bd4eeea914
      name: 'Azure Microsoft SQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Microsoft SQL Serverless Database by HTTP'
            key: azure.db.mssql.connections.successful
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Microsoft SQL Serverless Database by HTTP'
            key: azure.db.mssql.connections.failed.system
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Azure Microsoft SQL Serverless Database by HTTP'
            key: azure.db.mssql.firewall.blocked
    - uuid: fe250a5f509d45babea9fcd12accbcac
      name: 'Azure Microsoft SQL: CPU usage'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Microsoft SQL Database by HTTP'
            key: azure.db.mssql.cpu.limit
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Microsoft SQL Database by HTTP'
            key: azure.db.mssql.cpu.used
    - uuid: 083d307db8954fc59e8e5cfccefc16c1
      name: 'Azure Microsoft SQL: CPU usage'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Microsoft SQL Serverless Database by HTTP'
            key: azure.db.mssql.cpu.limit
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Microsoft SQL Serverless Database by HTTP'
            key: azure.db.mssql.cpu.used
    - uuid: ec5714017c744484be8c264d24a0e694
      name: 'Azure Microsoft SQL: Storage utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Microsoft SQL Database by HTTP'
            key: azure.db.mssql.storage.used
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Microsoft SQL Database by HTTP'
            key: azure.db.mssql.storage.allocated
    - uuid: f541b6591683433aba4b3e58a8ad1e5c
      name: 'Azure Microsoft SQL: Storage utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Microsoft SQL Serverless Database by HTTP'
            key: azure.db.mssql.storage.used
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Microsoft SQL Serverless Database by HTTP'
            key: azure.db.mssql.storage.allocated
    - uuid: 89256a1eba8c49d2b7469a68ff050ac5
      name: 'Azure MongoDB: Latency'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.server.side.latency.gateway
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.server.side.latency
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.server.side.latency.direct
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.replication.latency
    - uuid: a1225fc27d334c5bbb5043e3d468bf02
      name: 'Azure MongoDB: Requests'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.total.requests
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.total.request.units
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.metadata.requests
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.mongo.requests
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.mongo.requests.charge
    - uuid: 07168aaf3abb42f6b61746cc6e2d2910
      name: 'Azure MongoDB: Usage'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.data.usage
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.index.usage
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Azure Cosmos DB for MongoDB by HTTP'
            key: azure.cosmosdb.document.quota
    - uuid: 750ae48e6ef749c19a06f4bbe716f92f
      name: 'Azure MySQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure MySQL Flexible Server by HTTP'
            key: azure.db.mysql.connections.active
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure MySQL Flexible Server by HTTP'
            key: azure.db.mysql.connections.total
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Azure MySQL Flexible Server by HTTP'
            key: azure.db.mysql.connections.aborted
    - uuid: 360a24b56be74cf48df3135008437824
      name: 'Azure MySQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure MySQL Single Server by HTTP'
            key: azure.db.mysql.connections.active
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure MySQL Single Server by HTTP'
            key: azure.db.mysql.connections.failed
    - uuid: f929f47602734f82a79f22a5f4446f61
      name: 'Azure MySQL: Network traffic'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure MySQL Flexible Server by HTTP'
            key: azure.db.mysql.network.egress
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure MySQL Flexible Server by HTTP'
            key: azure.db.mysql.network.ingress
    - uuid: dc6840162405481ebc1c3c98fdfcaef1
      name: 'Azure MySQL: Network traffic'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure MySQL Single Server by HTTP'
            key: azure.db.mysql.network.egress
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure MySQL Single Server by HTTP'
            key: azure.db.mysql.network.ingress
    - uuid: 3fcf43fd338e4902874d940fc0bec8b9
      name: 'Azure MySQL: Server log storage utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure MySQL Single Server by HTTP'
            key: azure.db.mysql.storage.server.log.used
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure MySQL Single Server by HTTP'
            key: azure.db.mysql.storage.server.log.limit
    - uuid: 4210e6b4ed8744589dce88217e961a56
      name: 'Azure MySQL: Storage utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure MySQL Flexible Server by HTTP'
            key: azure.db.mysql.storage.used
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure MySQL Flexible Server by HTTP'
            key: azure.db.mysql.storage.limit
    - uuid: bdc178e6faaa4850badc0c60c7c80d40
      name: 'Azure MySQL: Storage utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure MySQL Single Server by HTTP'
            key: azure.db.mysql.storage.used
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure MySQL Single Server by HTTP'
            key: azure.db.mysql.storage.limit
    - uuid: 2b60e8b1fd7c43f4ac61812e43c0e1ca
      name: 'Azure PostgreSQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure PostgreSQL Flexible Server by HTTP'
            key: azure.db.pgsql.connections.active
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure PostgreSQL Flexible Server by HTTP'
            key: azure.db.pgsql.connections.succeeded
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Azure PostgreSQL Flexible Server by HTTP'
            key: azure.db.pgsql.connections.failed
    - uuid: c76cf8ec6a584af6be815ec4a9257a8c
      name: 'Azure PostgreSQL: Connections'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure PostgreSQL Single Server by HTTP'
            key: azure.db.pgsql.connections.active
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure PostgreSQL Single Server by HTTP'
            key: azure.db.pgsql.connections.failed
    - uuid: a4679d243b574bea84397c980723c68b
      name: 'Azure PostgreSQL: Network traffic'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure PostgreSQL Flexible Server by HTTP'
            key: azure.db.pgsql.network.egress
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure PostgreSQL Flexible Server by HTTP'
            key: azure.db.pgsql.network.ingress
    - uuid: 8bc17d843775414ea971e640e1fe5ec0
      name: 'Azure PostgreSQL: Network traffic'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure PostgreSQL Single Server by HTTP'
            key: azure.db.pgsql.network.egress
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure PostgreSQL Single Server by HTTP'
            key: azure.db.pgsql.network.ingress
    - uuid: 9e750a5a462b4429ac5a36a72bd60c66
      name: 'Azure PostgreSQL: Server log storage utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure PostgreSQL Single Server by HTTP'
            key: azure.db.pgsql.storage.server.log.used
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure PostgreSQL Single Server by HTTP'
            key: azure.db.pgsql.storage.server.log.limit
    - uuid: 5fa13cfbdd784475818fae06ff94f879
      name: 'Azure PostgreSQL: Storage utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure PostgreSQL Flexible Server by HTTP'
            key: azure.db.pgsql.storage.used
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure PostgreSQL Flexible Server by HTTP'
            key: azure.db.pgsql.storage.free
    - uuid: 9ecd071a77364c4486fa5f63125cd985
      name: 'Azure PostgreSQL: Storage utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure PostgreSQL Single Server by HTTP'
            key: azure.db.pgsql.storage.used
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure PostgreSQL Single Server by HTTP'
            key: azure.db.pgsql.storage.limit
    - uuid: 36ff6447ea4f403eb0f13dc6322c99ea
      name: 'CPU Utilization'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.cpu.utilization
    - uuid: 66b7d2f063064a1b8912e2b2e57d2d40
      name: 'Data disk IOPS read/write'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.data.disk.read.ops
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.data.disk.write.ops
    - uuid: 9bbdd448793e41b6b8aef38c7cad41c6
      name: 'Data disk read/write Bps'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.data.disk.read.bps
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.data.disk.write.bps
    - uuid: 2d0a30934cf7444f89fe031178599abc
      name: 'Disk IOPS read/write'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.disk.read.ops
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.disk.write.ops
    - uuid: 7b724a3805d84dbb99fcbf5c2fd633b4
      name: 'Disk read/write bytes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.disk.read
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.disk.write
    - uuid: e4d6ccffbf274347a3fdade920467ae2
      name: Flows
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.flows.inbound
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.flows.outbound
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.flows.inbound.max
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.flows.outbound.max
    - uuid: 9109c16ec3b540118aff0e458fb00580
      name: 'Network traffic, bytes'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.network.in.total
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.network.out.total
    - uuid: 079e812dd9af48cda80993ad9b3a59d0
      name: 'OS disk IOPS read/write'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.os.disk.read.ops
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.os.disk.write.ops
    - uuid: de643aefc3b340e3a4cd81216a78709d
      name: 'OS disk read/write Bps'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.os.disk.read.bps
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.os.disk.write.bps
    - uuid: dd3b9363272949d8a1fef02f6c14229d
      name: 'Premium data disk cache read'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.premium.data.disk.cache.read.hit
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.premium.data.disk.cache.read.miss
    - uuid: 8a432a338a9540b4888f9f019164acdb
      name: 'Premium OS disk cache read'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.premium.os.disk.cache.read.hit
        - sortorder: '1'
          color: F63100
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.premium.os.disk.cache.read.miss
    - uuid: 8d04afa2c9d2459e926a9c20af37e4f8
      name: 'Virtual machine count'
      graph_items:
        - color: 199C0D
          item:
            host: 'Azure VM Scale Set by HTTP'
            key: azure.scaleset.vm.count
