zabbix_export:
  version: '6.0'
  date: '2023-11-14T06:33:34Z'
  groups:
    - uuid: c2c162144c2d4c5491c8801193af4945
      name: Templates/Cloud
    - uuid: 748ad4d098d447d492bb935c907f652f
      name: Templates/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"
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 7b2fe9a7ee164718933eb456b0068fea
          name: 'Azure: Get errors'
          type: DEPENDENT
          key: azure.get.errors
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure: 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: 'Azure: Get resources'
          type: SCRIPT
          key: azure.get.resources
          delay: 10m
          history: '0'
          trends: '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"}
                ];
                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: 'Azure: Get storage accounts'
          type: SCRIPT
          key: azure.get.storage.acc
          delay: 10m
          history: '0'
          trends: '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: 'Azure: Get storage accounts errors'
          type: DEPENDENT
          key: azure.get.storage.acc.errors
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure: 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: 'Azure: 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
          delay: '0'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
                formulaid: A
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
              - macro: '{#LOCATION}'
                value: '{$AZURE.COSMOS.MONGO.DB.LOCATION.MATCHES}'
                formulaid: C
              - macro: '{#LOCATION}'
                value: '{$AZURE.COSMOS.MONGO.DB.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: D
              - macro: '{#NAME}'
                value: '{$AZURE.COSMOS.MONGO.DB.NAME.MATCHES}'
                formulaid: E
              - macro: '{#NAME}'
                value: '{$AZURE.COSMOS.MONGO.DB.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: F
              - macro: '{#TYPE}'
                value: ^Microsoft.DocumentDB/databaseAccounts
                formulaid: G
          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: Templates/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$
                    formulaid: A
              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
          delay: '0'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
                formulaid: A
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
              - macro: '{#LOCATION}'
                value: '{$AZURE.MSSQL.DB.LOCATION.MATCHES}'
                formulaid: C
              - macro: '{#LOCATION}'
                value: '{$AZURE.MSSQL.DB.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: D
              - macro: '{#NAME}'
                value: '{$AZURE.MSSQL.DB.NAME.MATCHES}'
                formulaid: E
              - macro: '{#NAME}'
                value: '{$AZURE.MSSQL.DB.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: F
              - macro: '{#SIZE}'
                value: '{$AZURE.MSSQL.DB.SIZE.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: G
              - macro: '{#TYPE}'
                value: ^Microsoft.Sql/servers/databases
                formulaid: H
          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: Templates/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$'
                    formulaid: A
              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).)*$'
                    formulaid: A
              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
          delay: '0'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
                formulaid: A
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
              - macro: '{#LOCATION}'
                value: '{$AZURE.MYSQL.DB.LOCATION.MATCHES}'
                formulaid: C
              - macro: '{#LOCATION}'
                value: '{$AZURE.MYSQL.DB.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: D
              - macro: '{#NAME}'
                value: '{$AZURE.MYSQL.DB.NAME.MATCHES}'
                formulaid: E
              - macro: '{#NAME}'
                value: '{$AZURE.MYSQL.DB.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: F
              - macro: '{#TYPE}'
                value: ^Microsoft.DBforMySQL
                formulaid: G
          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: Templates/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
                    formulaid: A
              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
                    formulaid: A
              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
          delay: '0'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
                formulaid: A
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
              - macro: '{#LOCATION}'
                value: '{$AZURE.PGSQL.DB.LOCATION.MATCHES}'
                formulaid: C
              - macro: '{#LOCATION}'
                value: '{$AZURE.PGSQL.DB.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: D
              - macro: '{#NAME}'
                value: '{$AZURE.PGSQL.DB.NAME.MATCHES}'
                formulaid: E
              - macro: '{#NAME}'
                value: '{$AZURE.PGSQL.DB.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: F
              - macro: '{#TYPE}'
                value: ^Microsoft.DBforPostgreSQL
                formulaid: G
          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: Templates/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
                    formulaid: A
              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
                    formulaid: A
              operations:
                - operationobject: HOST_PROTOTYPE
                  operator: REGEXP
                  templates:
                    - name: 'Azure PostgreSQL Single Server by HTTP'
        - uuid: 3b9bde32dd6b4e3aa2dd8d7949f655e9
          name: 'Storage accounts discovery'
          type: DEPENDENT
          key: azure.starage.acc.discovery
          delay: '0'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
                formulaid: A
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
              - macro: '{#LOCATION}'
                value: '{$AZURE.STORAGE.ACC.LOCATION.MATCHES}'
                formulaid: C
              - macro: '{#LOCATION}'
                value: '{$AZURE.STORAGE.ACC.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: D
              - macro: '{#NAME}'
                value: '{$AZURE.STORAGE.ACC.NAME.MATCHES}'
                formulaid: E
              - macro: '{#NAME}'
                value: '{$AZURE.STORAGE.ACC.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: F
          description: 'The list of all storage accounts available under the subscription.'
          item_prototypes:
            - uuid: 3361508a601748f5aca339f952430889
              name: 'Azure: Storage account [{#NAME}]: Get data'
              type: SCRIPT
              key: 'azure.get.storage.acc[{#NAME}]'
              history: '0'
              trends: '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: 'Azure: Storage account [{#NAME}]: Availability'
              type: DEPENDENT
              key: 'azure.storage.availability[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Availability is low'
                  event_name: 'Azure: 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: 'Azure: Storage account [{#NAME}]: Blob Availability'
              type: DEPENDENT
              key: 'azure.storage.blob.availability[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Blob Availability is low'
                  event_name: 'Azure: Storage account [{#NAME} blob availability is too low (less than {$AZURE.STORAGE.ACC.BLOB.AVAILABILITY:"{#NAME}"}%)'
                  opdata: '{ITEM.LASTVALUE1}'
                  priority: WARNING
                  tags:
                    - tag: scope
                      value: availability
            - uuid: c6437ade4fee44f783ab379fb179508d
              name: 'Azure: Storage account [{#NAME}]: Blob Capacity'
              type: DEPENDENT
              key: 'azure.storage.blob.capacity[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Blob Container Count'
              type: DEPENDENT
              key: 'azure.storage.blob.container.count[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Blob Count'
              type: DEPENDENT
              key: 'azure.storage.blob.count[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Blob Egress'
              type: DEPENDENT
              key: 'azure.storage.blob.engress[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Blob Index Capacity'
              type: DEPENDENT
              key: 'azure.storage.blob.index.capacity[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Blob Ingress'
              type: DEPENDENT
              key: 'azure.storage.blob.ingress[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Blob Success E2E Latency'
              type: DEPENDENT
              key: 'azure.storage.blob.success.e2e.latency[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Blob Success Server Latency'
              type: DEPENDENT
              key: 'azure.storage.blob.success.server.latency[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Blob Transactions'
              type: DEPENDENT
              key: 'azure.storage.blob.transactions[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Egress'
              type: DEPENDENT
              key: 'azure.storage.engress[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Capacity'
              type: DEPENDENT
              key: 'azure.storage.file.capacity[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Count'
              type: DEPENDENT
              key: 'azure.storage.file.count[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Egress'
              type: DEPENDENT
              key: 'azure.storage.file.engress[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Ingress'
              type: DEPENDENT
              key: 'azure.storage.file.ingress[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Share Capacity Quota'
              type: DEPENDENT
              key: 'azure.storage.file.share.capacity.quota[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Share Count'
              type: DEPENDENT
              key: 'azure.storage.file.share.count[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Share Snapshot Size'
              type: DEPENDENT
              key: 'azure.storage.file.share.snapshot.size[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Share Snapshot Count'
              type: DEPENDENT
              key: 'azure.storage.file.shares.snapshot.count[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Success E2E Latency'
              type: DEPENDENT
              key: 'azure.storage.file.success.e2e.latency[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Success Server Latency'
              type: DEPENDENT
              key: 'azure.storage.file.success.server.latency[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: File Transactions'
              type: DEPENDENT
              key: 'azure.storage.file.transactions[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Ingress'
              type: DEPENDENT
              key: 'azure.storage.ingress[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Queue Capacity'
              type: DEPENDENT
              key: 'azure.storage.queue.capacity[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Queue Count'
              type: DEPENDENT
              key: 'azure.storage.queue.count[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Queue Egress'
              type: DEPENDENT
              key: 'azure.storage.queue.engress[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Queue Ingress'
              type: DEPENDENT
              key: 'azure.storage.queue.ingress[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Queue Message Count'
              type: DEPENDENT
              key: 'azure.storage.queue.message.count[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Queue Success E2E Latency'
              type: DEPENDENT
              key: 'azure.storage.queue.success.e2e.latency[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Queue Success Server Latency'
              type: DEPENDENT
              key: 'azure.storage.queue.success.server.latency[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Queue Transactions'
              type: DEPENDENT
              key: 'azure.storage.queue.transactions[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Success E2E Latency'
              type: DEPENDENT
              key: 'azure.storage.success.e2e.latency[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Success Server Latency'
              type: DEPENDENT
              key: 'azure.storage.success.server.latency[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Table Availability'
              type: DEPENDENT
              key: 'azure.storage.table.availability[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Table Availability is low'
                  event_name: 'Azure: 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: 'Azure: Storage account [{#NAME}]: Table Capacity'
              type: DEPENDENT
              key: 'azure.storage.table.capacity[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Table Count'
              type: DEPENDENT
              key: 'azure.storage.table.count[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Table Egress'
              type: DEPENDENT
              key: 'azure.storage.table.engress[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Table Entity Count'
              type: DEPENDENT
              key: 'azure.storage.table.entity.count[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Table Ingress'
              type: DEPENDENT
              key: 'azure.storage.table.ingress[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Table Success E2E Latency'
              type: DEPENDENT
              key: 'azure.storage.table.success.e2e.latency[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Table Success Server Latency'
              type: DEPENDENT
              key: 'azure.storage.table.success.server.latency[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Table Transactions'
              type: DEPENDENT
              key: 'azure.storage.table.transactions[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Transactions'
              type: DEPENDENT
              key: 'azure.storage.transactions[{#NAME}]'
              delay: '0'
              history: 7d
              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: 'Azure: Storage account [{#NAME}]: Used Capacity'
              type: DEPENDENT
              key: 'azure.storage.used.capacity[{#NAME}]'
              delay: '0'
              history: 7d
              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: 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
          delay: '0'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.MATCHES}'
                formulaid: A
              - macro: '{#GROUP}'
                value: '{$AZURE.RESOURCE.GROUP.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
              - macro: '{#LOCATION}'
                value: '{$AZURE.VM.LOCATION.MATCHES}'
                formulaid: C
              - macro: '{#LOCATION}'
                value: '{$AZURE.VM.LOCATION.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: D
              - macro: '{#NAME}'
                value: '{$AZURE.VM.NAME.MATCHES}'
                formulaid: E
              - macro: '{#NAME}'
                value: '{$AZURE.VM.NAME.NOT.MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: F
              - macro: '{#TYPE}'
                value: ^Microsoft.Compute/virtualMachines$
                formulaid: G
          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: '{#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: 'A response timeout for API.'
        - 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 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.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.'
    - 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"
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 9e247bdb17f44630b9440b59d5ef251b
          name: 'Azure MongoDB: Autoscale max throughput'
          type: DEPENDENT
          key: azure.cosmosdb.autoscale.max.throughput
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Get errors'
          type: DEPENDENT
          key: azure.cosmosdb.data.errors
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure MongoDB: 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: 'Azure MongoDB: Get data'
          type: SCRIPT
          key: azure.cosmosdb.data.get
          history: '0'
          trends: '0'
          value_type: TEXT
          params: |
            var AzureCosmoDB = {
                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 + '.';
                        }
                    });
            
                    AzureCosmoDB.params = params;
                },
            
                login: function () {
                    var response, login = new HttpRequest();
                    if (typeof AzureCosmoDB.params.proxy !== 'undefined' && AzureCosmoDB.params.proxy !== '') {
                        login.setProxy(AzureCosmoDB.params.proxy);
                    }
                    login.addHeader('Content-Type: application/x-www-form-urlencoded');
                    response = login.post(
                        'https://login.microsoftonline.com/' + encodeURIComponent(AzureCosmoDB.params.tenant_id) + '/oauth2/token',
                        'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureCosmoDB.params.app_id) + '&client_secret=' + encodeURIComponent(AzureCosmoDB.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.';
                    }
                    AzureCosmoDB.token = response['access_token'];
                },
            
                request: function (url) {
                    var response, request = new HttpRequest();
                    if (typeof AzureCosmoDB.params.proxy !== 'undefined' && AzureCosmoDB.params.proxy !== '') {
                        request.setProxy(AzureCosmoDB.params.proxy);
                    }
                    if (!AzureCosmoDB.token) {
                        throw 'Request does not contain access token.';
                    }
                    request.addHeader('Accept: application/json');
                    request.addHeader('Authorization: Bearer ' + AzureCosmoDB.token);
                    Zabbix.log(4, '[ AzureCosmoDB ] 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 = AzureCosmoDB.request('https://management.azure.com' + AzureCosmoDB.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 = AzureCosmoDB.getField(metrics.value[k], 'name.value')
                                if (metrics.value[k].timeseries.length === 0) {
                                    metrics.value[k].timeseries.push({ 'data': ['nodata'] })
                                }
                                data[field][key] = AzureCosmoDB.getField(metrics.value[k], 'timeseries.0.data.0');
                            }
                        }
                        catch (error) {
                            data.error = error.toString();
                        }
                    });
                    return data
                }
            
            };
            
            try {
                AzureCosmoDB.setParams(JSON.parse(value));
                AzureCosmoDB.login();
                return JSON.stringify(AzureCosmoDB.getMetricsData());
            }
            catch (error) {
                error += (String(error).endsWith('.')) ? '' : '.';
                Zabbix.log(3, '[ AzureCosmoDB ] 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: 'Azure MongoDB: Data usage'
          type: DEPENDENT
          key: azure.cosmosdb.data.usage
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Document count'
          type: DEPENDENT
          key: azure.cosmosdb.document.count
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Document quota'
          type: DEPENDENT
          key: azure.cosmosdb.document.quota
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Index usage'
          type: DEPENDENT
          key: azure.cosmosdb.index.usage
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Metadata requests'
          type: DEPENDENT
          key: azure.cosmosdb.metadata.requests
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Mongo requests'
          type: DEPENDENT
          key: azure.cosmosdb.mongo.requests
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Mongo request charge'
          type: DEPENDENT
          key: azure.cosmosdb.mongo.requests.charge
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Normalized RU consumption'
          type: DEPENDENT
          key: azure.cosmosdb.normalized.ru.consumption
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Physical partition size'
          type: DEPENDENT
          key: azure.cosmosdb.physical.partition.size
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Physical partition throughput'
          type: DEPENDENT
          key: azure.cosmosdb.physical.partition.throughput
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Provisioned throughput'
          type: DEPENDENT
          key: azure.cosmosdb.provisioned.throughput
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Replication latency, P99'
          type: DEPENDENT
          key: azure.cosmosdb.replication.latency
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Server side latency'
          type: DEPENDENT
          key: azure.cosmosdb.server.side.latency
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Server side latency, direct'
          type: DEPENDENT
          key: azure.cosmosdb.server.side.latency.direct
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Server side latency, gateway'
          type: DEPENDENT
          key: azure.cosmosdb.server.side.latency.gateway
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Service availability'
          type: DEPENDENT
          key: azure.cosmosdb.service.availability
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Cosmos DB for MongoDB account: Availability is low'
              opdata: '{ITEM.LASTVALUE1}'
              priority: WARNING
              tags:
                - tag: scope
                  value: availability
        - uuid: f4d4d2def5e945ab9048ada4813b7f04
          name: 'Azure MongoDB: Total request units'
          type: DEPENDENT
          key: azure.cosmosdb.total.request.units
          delay: '0'
          history: 7d
          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: 'Azure MongoDB: Total requests'
          type: DEPENDENT
          key: azure.cosmosdb.total.requests
          delay: '0'
          history: 7d
          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: 'A response timeout for API.'
        - 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 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 Cosmos DB for MongoDB'
          pages:
            - widgets:
                - type: ITEM
                  name: 'Service Availability'
                  width: '6'
                  height: '4'
                  fields:
                    - type: INTEGER
                      name: adv_conf
                      value: '1'
                    - type: INTEGER
                      name: decimal_places
                      value: '0'
                    - type: STRING
                      name: down_color
                      value: FF0000
                    - type: ITEM
                      name: itemid
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        key: azure.cosmosdb.service.availability
                    - type: INTEGER
                      name: show
                      value: '2'
                    - type: INTEGER
                      name: show
                      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_CLASSIC
                  'y': '4'
                  width: '24'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        name: 'Azure MongoDB: Usage'
                - type: GRAPH_CLASSIC
                  'y': '9'
                  width: '24'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        name: 'Azure MongoDB: Requests'
                - type: GRAPH_CLASSIC
                  'y': '14'
                  width: '24'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        name: 'Azure MongoDB: Latency'
                - type: ITEM
                  name: 'Provisioned Throughput'
                  x: '6'
                  width: '6'
                  height: '4'
                  fields:
                    - type: ITEM
                      name: itemid
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        key: azure.cosmosdb.provisioned.throughput
                    - type: INTEGER
                      name: show
                      value: '2'
                - type: ITEM
                  name: 'Normalized RU Consumption'
                  x: '12'
                  width: '6'
                  height: '4'
                  fields:
                    - type: ITEM
                      name: itemid
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        key: azure.cosmosdb.normalized.ru.consumption
                    - type: INTEGER
                      name: show
                      value: '2'
                    - type: INTEGER
                      name: show
                      value: '4'
                - type: ITEM
                  name: 'Document Count'
                  x: '18'
                  width: '6'
                  height: '4'
                  fields:
                    - type: ITEM
                      name: itemid
                      value:
                        host: 'Azure Cosmos DB for MongoDB by HTTP'
                        key: azure.cosmosdb.document.count
                    - type: INTEGER
                      name: show
                      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"
      groups:
        - name: Templates/Cloud
      items:
        - uuid: f50c96da86654a25b937756cc7f7010e
          name: 'Azure Cost: Get daily costs'
          type: SCRIPT
          key: azure.get.daily.costs
          delay: 0s;h/5m/30
          history: '0'
          trends: '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,
                        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);
            
                    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 originalData = {},
                        today = new Date(),
                        start_date = new Date(today);
                    start_date.setDate(today.getDate() - 1);
            
                    body_raw_cost = {
                        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',
                                }
                            ]
                        }
                    };
                    originalData = AzureCost.request('https://management.azure.com/subscriptions/' + AzureCost.params.subscription_id + '/providers/Microsoft.CostManagement/query?api-version=2023-03-01', JSON.stringify(body_raw_cost));
            
                    var columns = AzureCost.getField(originalData, 'properties.columns');
            
                    transformedData = {
                        data: AzureCost.getField(originalData, 'properties.rows').map(function (row) {
                            rowData = {};
            
                            for (i = 0; i < columns.length; i++) {
                                columnName = columns[i].name;
                                columnType = columns[i].type;
                                cellValue = row[i];
            
                                rowData[columnName] = columnType === "Number" ? cellValue.toString() : cellValue;
                            }
                            rowData.UsageDate = rowData.UsageDate.replace(/(\d{4})(\d{2})(\d{2})/, "$1-$2-$3");
                            return rowData;
                        })
                    };
            
                    return transformedData;
            
                }
            };
            
            try {
                AzureCost.setParams(JSON.parse(value));
                AzureCost.login();
                return JSON.stringify(AzureCost.getCost(), null, 4);
            
            }
            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: 'Azure Cost: Get monthly costs'
          type: SCRIPT
          key: azure.get.monthly.costs
          delay: 0s;h/12
          history: '0'
          trends: '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,
                        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);
            
                    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 = {},
                        body_raw_cost = {
                            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-03-01', JSON.stringify(body_raw_cost));
            
                    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 }, null, 4);
            
            }
            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
          delay: '0'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#AZURE.RESOURCE.GROUP}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.GROUP.MATCHES}'
                formulaid: A
              - macro: '{#AZURE.RESOURCE.GROUP}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.GROUP.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
              - macro: '{#AZURE.RESOURCE.LOCATION}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.LOCATION.MATCHES}'
                formulaid: C
              - macro: '{#AZURE.RESOURCE.LOCATION}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.LOCATION.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: D
              - macro: '{#AZURE.SERVICE.NAME}'
                value: '{$AZURE.LLD.FILTER.SERVICE.MATCHES}'
                formulaid: E
              - macro: '{#AZURE.SERVICE.NAME}'
                value: '{$AZURE.LLD.FILTER.SERVICE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: F
          description: 'Discovery of daily costs by services.'
          item_prototypes:
            - uuid: 848ccd4cec2c4902990aa25f90f502a8
              name: 'Azure Cost: 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}"]'
              delay: '0'
              history: 7d
              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
          delay: '0'
          description: 'Discovery of monthly costs.'
          item_prototypes:
            - uuid: f91a60d2c1124eb6b297539b0a115c66
              name: 'Azure Cost: Month ["{#AZURE.BILLING.MONTH}"] cost'
              type: DEPENDENT
              key: 'azure.monthly.cost["{#AZURE.BILLING.MONTH}"]'
              delay: '0'
              history: 7d
              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
          delay: '0'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#AZURE.RESOURCE.LOCATION}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.LOCATION.MATCHES}'
                formulaid: A
              - macro: '{#AZURE.RESOURCE.LOCATION}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.LOCATION.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
          description: 'Discovery of monthly costs by location.'
          item_prototypes:
            - uuid: 7fb097f81a8445acaa6b17bdc4daaaa6
              name: 'Azure Cost: Location: ["{#AZURE.RESOURCE.LOCATION}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
              type: DEPENDENT
              key: 'azure.monthly.location.cost["{#AZURE.RESOURCE.LOCATION}", "{#AZURE.BILLING.MONTH}"]'
              delay: '0'
              history: 7d
              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
          delay: '0'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#AZURE.RESOURCE.GROUP}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.GROUP.MATCHES}'
                formulaid: A
              - macro: '{#AZURE.RESOURCE.GROUP}'
                value: '{$AZURE.LLD.FILTER.RESOURCE.GROUP.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
          description: 'Discovery of monthly costs by resource group.'
          item_prototypes:
            - uuid: 9a5ed573ac374c08abf81f2b7296f260
              name: 'Azure Cost: Resource group: ["{#AZURE.RESOURCE.GROUP}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
              type: DEPENDENT
              key: 'azure.monthly.resource.group.cost["{#AZURE.RESOURCE.GROUP}", "{#AZURE.BILLING.MONTH}"]'
              delay: '0'
              history: 7d
              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
          delay: '0'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#AZURE.SERVICE.NAME}'
                value: '{$AZURE.LLD.FILTER.SERVICE.MATCHES}'
                formulaid: A
              - macro: '{#AZURE.SERVICE.NAME}'
                value: '{$AZURE.LLD.FILTER.SERVICE.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
                formulaid: B
          description: 'Discovery of monthly costs by services.'
          item_prototypes:
            - uuid: dbad6436c70e41268e3b59c2a7f0e2a2
              name: 'Azure Cost: Service ["{#AZURE.SERVICE.NAME}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
              type: DEPENDENT
              key: 'azure.monthly.service.cost["{#AZURE.SERVICE.NAME}", "{#AZURE.BILLING.MONTH}"]'
              delay: '0'
              history: 7d
              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: 15s
          description: 'A response timeout for API.'
        - 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 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: GRAPH_PROTOTYPE
                  width: '24'
                  height: '25'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid
                      value:
                        host: 'Azure Cost Management by HTTP'
                        name: 'Azure Cost: Month ["{#AZURE.BILLING.MONTH}"] cost'
                    - type: INTEGER
                      name: rows
                      value: '6'
            - name: 'Monthly costs by service'
              widgets:
                - type: GRAPH_PROTOTYPE
                  width: '24'
                  height: '25'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid
                      value:
                        host: 'Azure Cost Management by HTTP'
                        name: 'Azure Cost: ["{#AZURE.SERVICE.NAME}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
                    - type: INTEGER
                      name: rows
                      value: '6'
            - name: 'Monthly costs by location'
              widgets:
                - type: GRAPH_PROTOTYPE
                  width: '24'
                  height: '25'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid
                      value:
                        host: 'Azure Cost Management by HTTP'
                        name: 'Azure Cost: ["{#AZURE.RESOURCE.LOCATION}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
                    - type: INTEGER
                      name: rows
                      value: '6'
            - name: 'Monthly costs by service'
              widgets:
                - type: GRAPH_PROTOTYPE
                  width: '24'
                  height: '25'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid
                      value:
                        host: 'Azure Cost Management by HTTP'
                        name: 'Azure Cost: ["{#AZURE.RESOURCE.GROUP}"]: Month ["{#AZURE.BILLING.MONTH}"] cost'
                    - type: INTEGER
                      name: rows
                      value: '6'
            - name: 'Daily costs by service'
              widgets:
                - type: GRAPH_PROTOTYPE
                  width: '24'
                  height: '20'
                  fields:
                    - type: GRAPH_PROTOTYPE
                      name: graphid
                      value:
                        host: 'Azure Cost Management by HTTP'
                        name: 'Daily Cost: "{#AZURE.SERVICE.NAME}","{#AZURE.BILLING.METER}","{#AZURE.BILLING.METER.SUBCATEGORY}","{#AZURE.RESOURCE.GROUP}"'
                    - 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"
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 2ff1f479e0b447f2b85e75e99bc011fe
          name: 'Azure Microsoft SQL: Availability status detailed'
          type: DEPENDENT
          key: azure.db.mssql.availability.details
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure Microsoft SQL: Availability state'
          type: DEPENDENT
          key: azure.db.mssql.availability.state
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Microsoft SQL database is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 0cf3cce995c241838e13df12d5908b61
              expression: 'last(/Azure Microsoft SQL Database by HTTP/azure.db.mssql.availability.state)=3'
              name: 'Azure Microsoft SQL: 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: 'Azure Microsoft SQL: Microsoft SQL database is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: ce744d69ed12435db781fbc6100d97ab
          name: 'Azure Microsoft SQL: Connections failed: System errors'
          type: DEPENDENT
          key: azure.db.mssql.connections.failed.system
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Connections successful'
          type: DEPENDENT
          key: azure.db.mssql.connections.successful
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: CPU limit'
          type: DEPENDENT
          key: azure.db.mssql.cpu.limit
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Percentage CPU'
          type: DEPENDENT
          key: azure.db.mssql.cpu.percentage
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: 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: 'Azure Microsoft SQL: CPU used'
          type: DEPENDENT
          key: azure.db.mssql.cpu.used
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Get errors'
          type: DEPENDENT
          key: azure.db.mssql.data.errors
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure Microsoft SQL: 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: 'Azure Microsoft SQL: Get data'
          type: SCRIPT
          key: azure.db.mssql.data.get
          history: '0'
          trends: '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: 'Azure Microsoft SQL: Data IO percentage'
          type: DEPENDENT
          key: azure.db.mssql.data.read.percentage
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Deadlocks'
          type: DEPENDENT
          key: azure.db.mssql.deadlocks
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Connections blocked by firewall'
          type: DEPENDENT
          key: azure.db.mssql.firewall.blocked
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Log IO percentage'
          type: DEPENDENT
          key: azure.db.mssql.log.write.percentage
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: SQL Server process core percent'
          type: DEPENDENT
          key: azure.db.mssql.server.cpu.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: SQL Server process memory percent'
          type: DEPENDENT
          key: azure.db.mssql.server.memory.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Sessions count'
          type: DEPENDENT
          key: azure.db.mssql.sessions.count
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Sessions percentage'
          type: DEPENDENT
          key: azure.db.mssql.sessions.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Data space allocated'
          type: DEPENDENT
          key: azure.db.mssql.storage.allocated
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Differential backup storage size'
          type: DEPENDENT
          key: azure.db.mssql.storage.backup.diff.size
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Log backup storage size'
          type: DEPENDENT
          key: azure.db.mssql.storage.backup.log.size
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Full backup storage size'
          type: DEPENDENT
          key: azure.db.mssql.storage.backup.size
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Data space used percent'
          type: DEPENDENT
          key: azure.db.mssql.storage.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: 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: 'Azure Microsoft SQL: 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: 'Azure Microsoft SQL: Data space used'
          type: DEPENDENT
          key: azure.db.mssql.storage.used
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: In-Memory OLTP storage percent'
          type: DEPENDENT
          key: azure.db.mssql.storage.xtp.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Tempdb data file size'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.data.size
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Tempdb log used percent'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.log.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Tempdb log file size'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.log.size
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Workers percentage'
          type: DEPENDENT
          key: azure.db.mssql.workers.percent
          delay: '0'
          history: 7d
          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: 'A response timeout for API.'
        - 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 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.'
      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"
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 7c11fcc4f4b349f8b98fac93ae5e32be
          name: 'Azure Microsoft SQL: App CPU billed'
          type: DEPENDENT
          key: azure.db.mssql.app.cpu.billed
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: App CPU percentage'
          type: DEPENDENT
          key: azure.db.mssql.app.cpu.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: App memory percentage'
          type: DEPENDENT
          key: azure.db.mssql.app.memory.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Availability status detailed'
          type: DEPENDENT
          key: azure.db.mssql.availability.details
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure Microsoft SQL: Availability state'
          type: DEPENDENT
          key: azure.db.mssql.availability.state
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Microsoft SQL database is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in 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: 'Azure Microsoft SQL: 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: 'Azure Microsoft SQL: Microsoft SQL database is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 2457708a49d141faa16bd7b4ceb2c0a4
          name: 'Azure Microsoft SQL: Connections failed: System errors'
          type: DEPENDENT
          key: azure.db.mssql.connections.failed.system
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Connections successful'
          type: DEPENDENT
          key: azure.db.mssql.connections.successful
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: CPU limit'
          type: DEPENDENT
          key: azure.db.mssql.cpu.limit
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Percentage CPU'
          type: DEPENDENT
          key: azure.db.mssql.cpu.percentage
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: 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: 'Azure Microsoft SQL: CPU used'
          type: DEPENDENT
          key: azure.db.mssql.cpu.used
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Get errors'
          type: DEPENDENT
          key: azure.db.mssql.data.errors
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure Microsoft SQL: 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: 'Azure Microsoft SQL: Get data'
          type: SCRIPT
          key: azure.db.mssql.data.get
          history: '0'
          trends: '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: 'Azure Microsoft SQL: Data IO percentage'
          type: DEPENDENT
          key: azure.db.mssql.data.read.percentage
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Deadlocks'
          type: DEPENDENT
          key: azure.db.mssql.deadlocks
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Connections blocked by firewall'
          type: DEPENDENT
          key: azure.db.mssql.firewall.blocked
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Log IO percentage'
          type: DEPENDENT
          key: azure.db.mssql.log.write.percentage
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: SQL Server process core percent'
          type: DEPENDENT
          key: azure.db.mssql.server.cpu.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: SQL Server process memory percent'
          type: DEPENDENT
          key: azure.db.mssql.server.memory.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Sessions percentage'
          type: DEPENDENT
          key: azure.db.mssql.sessions.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Data space allocated'
          type: DEPENDENT
          key: azure.db.mssql.storage.allocated
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Data space used percent'
          type: DEPENDENT
          key: azure.db.mssql.storage.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: 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: 'Azure Microsoft SQL: 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: 'Azure Microsoft SQL: Data space used'
          type: DEPENDENT
          key: azure.db.mssql.storage.used
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: In-Memory OLTP storage percent'
          type: DEPENDENT
          key: azure.db.mssql.storage.xtp.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Tempdb data file size'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.data.size
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Tempdb log used percent'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.log.percent
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Tempdb log file size'
          type: DEPENDENT
          key: azure.db.mssql.tempdb.log.size
          delay: '0'
          history: 7d
          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: 'Azure Microsoft SQL: Workers percentage'
          type: DEPENDENT
          key: azure.db.mssql.workers.percent
          delay: '0'
          history: 7d
          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: 'A response timeout for API.'
        - 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 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.'
      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"
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 9c87cde45e984ce282d8ba9fbe184f9b
          name: 'Azure MySQL: Availability status detailed'
          type: DEPENDENT
          key: azure.db.mysql.availability.details
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure MySQL: Availability state'
          type: DEPENDENT
          key: azure.db.mysql.availability.state
          delay: '0'
          history: 7d
          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: 'Azure MySQL: MySQL server is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: ebb35037a5b646a0bd2c6be44bb1f3c6
              expression: 'last(/Azure MySQL Flexible Server by HTTP/azure.db.mysql.availability.state)=3'
              name: 'Azure MySQL: 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: 'Azure MySQL: MySQL server is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: cab6ac822f2c4e118b030e49cc15eaa2
          name: 'Azure MySQL: Connections aborted'
          type: DEPENDENT
          key: azure.db.mysql.connections.aborted
          delay: '0'
          history: 7d
          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: 'Azure MySQL: 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: 'Azure MySQL: Connections active'
          type: DEPENDENT
          key: azure.db.mysql.connections.active
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Connections total'
          type: DEPENDENT
          key: azure.db.mysql.connections.total
          delay: '0'
          history: 7d
          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: 'Azure MySQL: CPU credits consumed'
          type: DEPENDENT
          key: azure.db.mysql.cpu.credits.consumed
          delay: '0'
          history: 7d
          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: 'Azure MySQL: CPU credits remaining'
          type: DEPENDENT
          key: azure.db.mysql.cpu.credits.remaining
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Percentage CPU'
          type: DEPENDENT
          key: azure.db.mysql.cpu.percentage
          delay: '0'
          history: 7d
          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: 'Azure MySQL: 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: 'Azure MySQL: Get errors'
          type: DEPENDENT
          key: azure.db.mysql.data.errors
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure MySQL: 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: 'Azure MySQL: Get data'
          type: SCRIPT
          key: azure.db.mysql.data.get
          history: '0'
          trends: '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: 'Azure MySQL: IO consumption percent'
          type: DEPENDENT
          key: azure.db.mysql.io.consumption.percent
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Memory utilization'
          type: DEPENDENT
          key: azure.db.mysql.memory.percentage
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Network out'
          type: DEPENDENT
          key: azure.db.mysql.network.egress
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Network in'
          type: DEPENDENT
          key: azure.db.mysql.network.ingress
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Queries'
          type: DEPENDENT
          key: azure.db.mysql.queries
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Replication lag'
          type: DEPENDENT
          key: azure.db.mysql.replication.lag
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Backup storage used'
          type: DEPENDENT
          key: azure.db.mysql.storage.backup.used
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Storage limit'
          type: DEPENDENT
          key: azure.db.mysql.storage.limit
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Storage percent'
          type: DEPENDENT
          key: azure.db.mysql.storage.percent
          delay: '0'
          history: 7d
          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: 'Azure MySQL: 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: 'Azure MySQL: 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: 'Azure MySQL: Storage used'
          type: DEPENDENT
          key: azure.db.mysql.storage.used
          delay: '0'
          history: 7d
          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: 'A response timeout for API.'
        - 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 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.'
      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"
      groups:
        - name: Templates/Cloud
      items:
        - uuid: c7771aa67d3c424490d8de2d6c2d609a
          name: 'Azure MySQL: Availability status detailed'
          type: DEPENDENT
          key: azure.db.mysql.availability.details
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure MySQL: Availability state'
          type: DEPENDENT
          key: azure.db.mysql.availability.state
          delay: '0'
          history: 7d
          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: 'Azure MySQL: MySQL server is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 852aba88476a40aeb2170b933726b7d8
              expression: 'last(/Azure MySQL Single Server by HTTP/azure.db.mysql.availability.state)=3'
              name: 'Azure MySQL: 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: 'Azure MySQL: MySQL server is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 69aba8caa6874c9d9423926a2ee78e99
          name: 'Azure MySQL: Connections active'
          type: DEPENDENT
          key: azure.db.mysql.connections.active
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Connections failed'
          type: DEPENDENT
          key: azure.db.mysql.connections.failed
          delay: '0'
          history: 7d
          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: 'Azure MySQL: 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: 'Azure MySQL: Percentage CPU'
          type: DEPENDENT
          key: azure.db.mysql.cpu.percentage
          delay: '0'
          history: 7d
          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: 'Azure MySQL: 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: 'Azure MySQL: Get errors'
          type: DEPENDENT
          key: azure.db.mysql.data.errors
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure MySQL: 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: 'Azure MySQL: Get data'
          type: SCRIPT
          key: azure.db.mysql.data.get
          history: '0'
          trends: '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: 'Azure MySQL: IO consumption percent'
          type: DEPENDENT
          key: azure.db.mysql.io.consumption.percent
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Memory utilization'
          type: DEPENDENT
          key: azure.db.mysql.memory.percentage
          delay: '0'
          history: 7d
          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: 'Azure MySQL: 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: 'Azure MySQL: Network out'
          type: DEPENDENT
          key: azure.db.mysql.network.egress
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Network in'
          type: DEPENDENT
          key: azure.db.mysql.network.ingress
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Replication lag'
          type: DEPENDENT
          key: azure.db.mysql.replication.lag
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Backup storage used'
          type: DEPENDENT
          key: azure.db.mysql.storage.backup.used
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Storage limit'
          type: DEPENDENT
          key: azure.db.mysql.storage.limit
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Storage percent'
          type: DEPENDENT
          key: azure.db.mysql.storage.percent
          delay: '0'
          history: 7d
          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: 'Azure MySQL: 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: 'Azure MySQL: 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: 'Azure MySQL: Server log storage limit'
          type: DEPENDENT
          key: azure.db.mysql.storage.server.log.limit
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Server log storage percent'
          type: DEPENDENT
          key: azure.db.mysql.storage.server.log.percent
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Server log storage used'
          type: DEPENDENT
          key: azure.db.mysql.storage.server.log.used
          delay: '0'
          history: 7d
          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: 'Azure MySQL: Storage used'
          type: DEPENDENT
          key: azure.db.mysql.storage.used
          delay: '0'
          history: 7d
          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: 'A response timeout for API.'
        - 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 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.'
      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"
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 7f7deae517e54cf582ae758a6988037b
          name: 'Azure PostgreSQL: Availability status detailed'
          type: DEPENDENT
          key: azure.db.pgsql.availability.details
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure PostgreSQL: Availability state'
          type: DEPENDENT
          key: azure.db.pgsql.availability.state
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: PostgreSQL server is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: d8ce86c853064cba80c9883052ed1403
              expression: 'last(/Azure PostgreSQL Flexible Server by HTTP/azure.db.pgsql.availability.state)=3'
              name: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: PostgreSQL server is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 05ada75c666e45269c3c36159f9902cc
          name: 'Azure PostgreSQL: Connections active'
          type: DEPENDENT
          key: azure.db.pgsql.connections.active
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Connections failed'
          type: DEPENDENT
          key: azure.db.pgsql.connections.failed
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Connections succeeded'
          type: DEPENDENT
          key: azure.db.pgsql.connections.succeeded
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: CPU credits consumed'
          type: DEPENDENT
          key: azure.db.pgsql.cpu.credits.consumed
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: CPU credits remaining'
          type: DEPENDENT
          key: azure.db.pgsql.cpu.credits.remaining
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Percentage CPU'
          type: DEPENDENT
          key: azure.db.pgsql.cpu.percentage
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: Get errors'
          type: DEPENDENT
          key: azure.db.pgsql.data.errors
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: Get data'
          type: SCRIPT
          key: azure.db.pgsql.data.get
          history: '0'
          trends: '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: 'Azure PostgreSQL: Data disk read Bps'
          type: DEPENDENT
          key: azure.db.pgsql.disk.bps.read
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Data disk write Bps'
          type: DEPENDENT
          key: azure.db.pgsql.disk.bps.write
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Data disk queue depth'
          type: DEPENDENT
          key: azure.db.pgsql.disk.queue.depth
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Data disk IOPS'
          type: DEPENDENT
          key: azure.db.pgsql.iops
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Data disk read IOPS'
          type: DEPENDENT
          key: azure.db.pgsql.iops.read
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Data disk write IOPS'
          type: DEPENDENT
          key: azure.db.pgsql.iops.write
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Memory utilization'
          type: DEPENDENT
          key: azure.db.pgsql.memory.percentage
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: Network out'
          type: DEPENDENT
          key: azure.db.pgsql.network.egress
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Network in'
          type: DEPENDENT
          key: azure.db.pgsql.network.ingress
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Backup storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.backup.used
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Storage free'
          type: DEPENDENT
          key: azure.db.pgsql.storage.free
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Storage percent'
          type: DEPENDENT
          key: azure.db.pgsql.storage.percent
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: Transaction log storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.txlogs.used
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.used
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Maximum used transaction IDs'
          type: DEPENDENT
          key: azure.db.pgsql.txid.used.max
          delay: '0'
          history: 7d
          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: 'A response timeout for API.'
        - 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 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.'
      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"
      groups:
        - name: Templates/Cloud
      items:
        - uuid: 9eb43a5ffb0d4e07be8d1fccfdecd2aa
          name: 'Azure PostgreSQL: Availability status detailed'
          type: DEPENDENT
          key: azure.db.pgsql.availability.details
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure PostgreSQL: Availability state'
          type: DEPENDENT
          key: azure.db.pgsql.availability.state
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: PostgreSQL server is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: 14e45ba0bc26409a89d92edfda152947
              expression: 'last(/Azure PostgreSQL Single Server by HTTP/azure.db.pgsql.availability.state)=3'
              name: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: PostgreSQL server is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: 3d0d3e1fe77740e4bd7b720368707214
          name: 'Azure PostgreSQL: Connections active'
          type: DEPENDENT
          key: azure.db.pgsql.connections.active
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Connections failed'
          type: DEPENDENT
          key: azure.db.pgsql.connections.failed
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Percentage CPU'
          type: DEPENDENT
          key: azure.db.pgsql.cpu.percentage
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: Get errors'
          type: DEPENDENT
          key: azure.db.pgsql.data.errors
          delay: '0'
          history: 7d
          trends: '0'
          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: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: Get data'
          type: SCRIPT
          key: azure.db.pgsql.data.get
          history: '0'
          trends: '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: 'Azure PostgreSQL: IO consumption percent'
          type: DEPENDENT
          key: azure.db.pgsql.io.consumption.percent
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Memory utilization'
          type: DEPENDENT
          key: azure.db.pgsql.memory.percentage
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: Network out'
          type: DEPENDENT
          key: azure.db.pgsql.network.egress
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Network in'
          type: DEPENDENT
          key: azure.db.pgsql.network.ingress
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Replication lag'
          type: DEPENDENT
          key: azure.db.pgsql.replica.log.delay
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Max lag across replicas in bytes'
          type: DEPENDENT
          key: azure.db.pgsql.replica.log.delay.bytes
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Backup storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.backup.used
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Storage limit'
          type: DEPENDENT
          key: azure.db.pgsql.storage.limit
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Storage percent'
          type: DEPENDENT
          key: azure.db.pgsql.storage.percent
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: 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: 'Azure PostgreSQL: Server log storage limit'
          type: DEPENDENT
          key: azure.db.pgsql.storage.server.log.limit
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Server log storage percent'
          type: DEPENDENT
          key: azure.db.pgsql.storage.server.log.percent
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Server log storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.server.log.used
          delay: '0'
          history: 7d
          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: 'Azure PostgreSQL: Storage used'
          type: DEPENDENT
          key: azure.db.pgsql.storage.used
          delay: '0'
          history: 7d
          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: 'A response timeout for API.'
        - 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 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.'
      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"
      groups:
        - name: Templates/Cloud
      items:
        - uuid: c299999d69904340acd44fead6c7672c
          name: 'Azure: Availability status detailed'
          type: DEPENDENT
          key: azure.vm.availability.details
          delay: '0'
          history: 7d
          trends: '0'
          value_type: CHAR
          description: 'The summary description of availability status.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.health.summary
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1h
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: health
        - uuid: 25e2af44bfbf4e9083ce493d85232088
          name: 'Azure: Availability state'
          type: DEPENDENT
          key: azure.vm.availability.state
          delay: '0'
          history: 7d
          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.vm.data.get
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: c0170d8a09ae460da923fe773b2b0bd0
              expression: 'last(/Azure Virtual Machine by HTTP/azure.vm.availability.state)=1'
              name: 'Azure: Virtual machine is degraded'
              opdata: '{ITEM.LASTVALUE1}'
              priority: AVERAGE
              description: 'The resource is in degraded state.'
              tags:
                - tag: scope
                  value: availability
            - uuid: e1b85765b83445ebbf15f02d782b9858
              expression: 'last(/Azure Virtual Machine by HTTP/azure.vm.availability.state)=3'
              name: 'Azure: 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: 'Azure: Virtual machine is unavailable'
              opdata: '{ITEM.LASTVALUE1}'
              priority: HIGH
              description: 'The resource state is unavailable.'
              tags:
                - tag: scope
                  value: availability
        - uuid: a93308573303437487d151de340fcaed
          name: 'Azure: VM cached bandwidth consumed percentage'
          type: DEPENDENT
          key: azure.vm.cached.bandwidth.consumed.percentage
          delay: '0'
          history: 7d
          units: '%'
          description: 'The percentage of the cached disk bandwidth consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMCachedBandwidthConsumedPercentage.average
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 989dec26d97d44b6bd4a84fdbd37dec5
          name: 'Azure: VM cached IOPS consumed percentage'
          type: DEPENDENT
          key: azure.vm.cached.iops.consumed.percentage
          delay: '0'
          history: 7d
          units: '%'
          description: 'The percentage of the cached disk IOPS consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMCachedIOPSConsumedPercentage.average
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: fb0641ca8f104cf1bebdced63cd6af16
          name: 'Azure: CPU credits consumed'
          type: DEPENDENT
          key: azure.vm.cpu.credits.consumed
          delay: '0'
          history: 7d
          value_type: FLOAT
          description: 'The 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: 'Azure: CPU credits remaining'
          type: DEPENDENT
          key: azure.vm.cpu.credits.remaining
          delay: '0'
          history: 7d
          value_type: FLOAT
          description: 'The 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: 'Azure: Percentage CPU'
          type: DEPENDENT
          key: azure.vm.cpu.percentage
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of allocated computing units that are currently in use by VMs.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.PercentageCPU.average
          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.percentage,5m)>{$AZURE.VM.CPU.UTIL.CRIT}'
              name: 'Azure: High CPU utilization'
              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: 47cda13c203e4f1e9918eb73fd8afa20
          name: 'Azure: Data disk bandwidth consumed percentage'
          type: DEPENDENT
          key: azure.vm.data.disk.bandwidth.consumed.percentage
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '%'
          description: 'The 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: 3121980d3319431691ed9e98d176430b
          name: 'Azure: Data disk IOPS consumed percentage'
          type: DEPENDENT
          key: azure.vm.data.disk.iops.consumed.percentage
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '%'
          description: 'The 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: d0fb23206d564e1da746bff3369056c1
          name: 'Azure: Data disk max burst bandwidth'
          type: DEPENDENT
          key: azure.vm.data.disk.max.bandwidth
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: Bps
          description: 'The maximum bytes per second throughput that the data disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskMaxBurstBandwidth.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 6afcbb02c53243faa341670f155678e4
          name: 'Azure: Data disk max burst IOPS'
          type: DEPENDENT
          key: azure.vm.data.disk.max.iops
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '!iops'
          description: 'The maximum IOPS that the data disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskMaxBurstIOPS.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b81f304bbc2a42df9b0550ecdc1ec6b7
          name: 'Azure: Data disk queue depth'
          type: DEPENDENT
          key: azure.vm.data.disk.queue.depth
          delay: '0'
          history: 7d
          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: 'Azure: Data disk read rate'
          type: DEPENDENT
          key: azure.vm.data.disk.read.bps
          delay: '0'
          history: 7d
          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: 'Azure: Data disk read operations/sec'
          type: DEPENDENT
          key: azure.vm.data.disk.read.ops
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '!iops'
          description: 'The 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: c61ad4af97c243cca75bbece40eea795
          name: 'Azure: Data disk target bandwidth'
          type: DEPENDENT
          key: azure.vm.data.disk.target.bandwidth
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: Bps
          description: 'Baseline bytes per second throughput that the data disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskTargetBandwidth.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 9370988456e74b889700ea5798d17092
          name: 'Azure: Data disk target IOPS'
          type: DEPENDENT
          key: azure.vm.data.disk.target.iops
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '!iops'
          description: 'The baseline IOPS that the data disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DataDiskTargetIOPS.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 68c730e4904f402cb12fb71b45fede02
          name: 'Azure: Data disk used burst BPS credits percentage'
          type: DEPENDENT
          key: azure.vm.data.disk.used.burst.bandwidth
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '%'
          description: 'The 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: 731a82833bdd42c59c453adf8625e3b4
          name: 'Azure: Data disk used burst IO credits percentage'
          type: DEPENDENT
          key: azure.vm.data.disk.used.burst.iops
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '%'
          description: 'The 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: b8712f8fd60a43f6b099d9eafed19945
          name: 'Azure: Data disk write rate'
          type: DEPENDENT
          key: azure.vm.data.disk.write.bps
          delay: '0'
          history: 7d
          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: 'Azure: Data disk write operations/sec'
          type: DEPENDENT
          key: azure.vm.data.disk.write.ops
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '!iops'
          description: 'The 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: 'Azure: Get errors'
          type: DEPENDENT
          key: azure.vm.data.errors
          delay: '0'
          history: 7d
          trends: '0'
          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.vm.data.get
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: 87236c99652643ba800601a461d66d94
              expression: 'length(last(/Azure Virtual Machine by HTTP/azure.vm.data.errors))>0'
              name: 'Azure: 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: 'Azure: Get data'
          type: SCRIPT
          key: azure.vm.data.get
          history: '0'
          trends: '0'
          value_type: TEXT
          params: |
            var AzureVM = {
                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 + '.';
                        }
                    });
            
                    AzureVM.params = params;
                },
            
            
                request: function (url, data) {
                    if (typeof data === 'undefined' || data === null) {
                        data = '';
                    }
            
                    var response, request = new HttpRequest();
                    if (typeof AzureVM.params.proxy !== 'undefined' && AzureVM.params.proxy !== '') {
                        request.setProxy(AzureVM.params.proxy);
                    }
                    if (AzureVM.token) {
                        request.addHeader('Accept: application/json');
                        request.addHeader('Authorization: Bearer ' + AzureVM.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 = [
                'Percentage CPU',
                'Network In',
                'Network Out',
                'Disk Read Bytes',
                'Disk Write Bytes',
                'Disk Read Operations/sec',
                'Disk Write Operations/sec',
                'CPU Credits Remaining',
                'CPU Credits Consumed',
                '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',
                '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',
                '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',
                'Network In Total',
                'Network Out Total',
                'Available Memory Bytes'
            ],
                prepared_metrics = [],
                data = {};
                data['errors'] = {};
                data['metrics'] = {};
            
            try {
                AzureVM.setParams(JSON.parse(value));
            
                try {
                    result = AzureVM.request(
                        'https://login.microsoftonline.com/' + encodeURIComponent(AzureVM.params.tenant_id) + '/oauth2/token',
                        'grant_type=client_credentials&resource=' + encodeURIComponent('https://management.azure.com/') + '&client_id=' + encodeURIComponent(AzureVM.params.app_id) + '&client_secret=' + encodeURIComponent(AzureVM.params.password)
                    );
            
                    if ('access_token' in result) {
                        AzureVM.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 = AzureVM.request('https://management.azure.com' + AzureVM.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 = AzureVM.request('https://management.azure.com' + AzureVM.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 > 2) {
                                        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 - 3];
                                    }
                                }
                            }
                        }
                        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: 1dc9f8d45b6f48a38f701f089cbcb279
          name: 'Azure: Disk read rate'
          type: DEPENDENT
          key: azure.vm.disk.read.bytes
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: Bps
          description: 'Bytes read from the disk during the monitoring period (1 minute).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskReadBytes.total
            - type: MULTIPLIER
              parameters:
                - '0.0167'
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: cd3240d31a4f42a89b5c9817ea288b5a
          name: 'Azure: Disk read operations/sec'
          type: DEPENDENT
          key: azure.vm.disk.read.ops
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '!iops'
          description: 'The count of read operations from the disk per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskReadOperationsSec.average
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: b5e2070bde1444ea809ba4e0a29b05d9
          name: 'Azure: Disk write rate'
          type: DEPENDENT
          key: azure.vm.disk.write.bytes
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: Bps
          description: 'Bytes written to the disk during the monitoring period (1 minute).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskWriteBytes.total
            - type: MULTIPLIER
              parameters:
                - '0.0167'
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 0d93d1b510614c1f83418bd481f1e7cb
          name: 'Azure: Disk write operations/sec'
          type: DEPENDENT
          key: azure.vm.disk.write.ops
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '!iops'
          description: 'The count of write operations to the disk per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.DiskWriteOperationsSec.average
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 3a30a59aabd54c8b8feb1f4a8ba06db5
          name: 'Azure: Inbound flows'
          type: DEPENDENT
          key: azure.vm.flows.inbound
          delay: '0'
          history: 7d
          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: 'Azure: Inbound flows max creation rate'
          type: DEPENDENT
          key: azure.vm.flows.inbound.max
          delay: '0'
          history: 7d
          value_type: FLOAT
          description: 'The 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: 'Azure: Outbound flows'
          type: DEPENDENT
          key: azure.vm.flows.outbound
          delay: '0'
          history: 7d
          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: 'Azure: Outbound flows max creation rate'
          type: DEPENDENT
          key: azure.vm.flows.outbound.max
          delay: '0'
          history: 7d
          value_type: FLOAT
          description: 'The 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: 'Azure: Available memory'
          type: DEPENDENT
          key: azure.vm.memory.available
          delay: '0'
          history: 7d
          units: B
          description: 'The amount of physical memory (in bytes) immediately available for the allocation to a process or for a system use in the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.AvailableMemoryBytes.average
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: memory
        - uuid: 411c5f6fcb374c4c90e2951a546c0c08
          name: 'Azure: Network in total'
          type: DEPENDENT
          key: azure.vm.network.in.total
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: bps
          description: 'The number of bytes received by the VMs via all network interfaces (incoming traffic).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.NetworkInTotal.total
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.1333'
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: network
        - uuid: ee2ef1d1e2844ae8be2a5f04c86631ba
          name: 'Azure: Network out total'
          type: DEPENDENT
          key: azure.vm.network.out.total
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: bps
          description: 'The number of bytes sent by the VMs via all network interfaces (outgoing traffic).'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.NetworkOutTotal.total
              error_handler: DISCARD_VALUE
            - type: MULTIPLIER
              parameters:
                - '0.1333'
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: network
        - uuid: 24c58e473c5c4b8388a0e78ae38378fc
          name: 'Azure: OS disk bandwidth consumed percentage'
          type: DEPENDENT
          key: azure.vm.os.disk.bandwidth.consumed.percentage
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of the operating system''s 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: 33a7fff9758046e3be07dad6c0a710ca
          name: 'Azure: OS disk IOPS consumed percentage'
          type: DEPENDENT
          key: azure.vm.os.disk.iops.consumed.percentage
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '%'
          description: 'The percentage of the operating system''s 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: 7d0ca132bc264ac08e3c55809bdc40d1
          name: 'Azure: OS disk max burst bandwidth'
          type: DEPENDENT
          key: azure.vm.os.disk.max.bandwidth
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: Bps
          description: 'Maximum bytes per second throughput that the OS disk can achieve with bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskMaxBurstBandwidth.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 8374282688dc4fabb770c07eb335c666
          name: 'Azure: OS disk max burst IOPS'
          type: DEPENDENT
          key: azure.vm.os.disk.max.iops
          delay: '0'
          history: 7d
          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
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: ca8fe9d0ea58482c9bb8b83a716362a2
          name: 'Azure: OS disk queue depth'
          type: DEPENDENT
          key: azure.vm.os.disk.queue.depth
          delay: '0'
          history: 7d
          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: 'Azure: OS disk read rate'
          type: DEPENDENT
          key: azure.vm.os.disk.read.bps
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: Bps
          description: 'Bytes per second read from a single disk during the monitoring period for 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: 'Azure: OS disk read operations/sec'
          type: DEPENDENT
          key: azure.vm.os.disk.read.ops
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '!iops'
          description: 'The read IOPS from a single disk during the monitoring period for 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: 5cc422b7da3145fa885a88bb6165e3b9
          name: 'Azure: OS disk target bandwidth'
          type: DEPENDENT
          key: azure.vm.os.disk.target.bandwidth
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: Bps
          description: 'Baseline bytes per second throughput that the OS disk can achieve without bursting.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.OSDiskTargetBandwidth.average
              error_handler: DISCARD_VALUE
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 556941b1df5d470f8de628230b085623
          name: 'Azure: OS disk target IOPS'
          type: DEPENDENT
          key: azure.vm.os.disk.target.iops
          delay: '0'
          history: 7d
          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
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 9d42609950864c899a0d63b94f1d2235
          name: 'Azure: OS disk used burst BPS credits percentage'
          type: DEPENDENT
          key: azure.vm.os.disk.used.burst.bandwidth
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '%'
          description: 'The 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: c08f45df2e594e1fab01ba63df7da05b
          name: 'Azure: OS disk used burst IO credits percentage'
          type: DEPENDENT
          key: azure.vm.os.disk.used.burst.iops
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '%'
          description: 'The 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: 7645519a786b42908f1ec693128899c2
          name: 'Azure: OS disk write rate'
          type: DEPENDENT
          key: azure.vm.os.disk.write.bps
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: Bps
          description: 'Bytes per second written to a single disk during the monitoring period for 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: 'Azure: OS disk write operations/sec'
          type: DEPENDENT
          key: azure.vm.os.disk.write.ops
          delay: '0'
          history: 7d
          value_type: FLOAT
          units: '!iops'
          description: 'The write IOPS from a single disk during the monitoring period for 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: 'Azure: Premium data disk cache read hit'
          type: DEPENDENT
          key: azure.vm.premium.data.disk.cache.read.hit
          delay: '0'
          history: 7d
          units: '%'
          description: '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: 'Azure: Premium data disk cache read miss'
          type: DEPENDENT
          key: azure.vm.premium.data.disk.cache.read.miss
          delay: '0'
          history: 7d
          units: '%'
          description: '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: 'Azure: Premium OS disk cache read hit'
          type: DEPENDENT
          key: azure.vm.premium.os.disk.cache.read.hit
          delay: '0'
          history: 7d
          units: '%'
          description: '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: 'Azure: Premium OS disk cache read miss'
          type: DEPENDENT
          key: azure.vm.premium.os.disk.cache.read.miss
          delay: '0'
          history: 7d
          units: '%'
          description: '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: d6e85395e34b4288988a5287d287f182
          name: 'Azure: VM uncached bandwidth consumed percentage'
          type: DEPENDENT
          key: azure.vm.uncached.bandwidth.consumed.percentage
          delay: '0'
          history: 7d
          units: '%'
          description: 'The percentage of the uncached disk bandwidth consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMUncachedBandwidthConsumedPercentage.average
          master_item:
            key: azure.vm.data.get
          tags:
            - tag: component
              value: storage
        - uuid: 124203560922429bb32b76c45f24b2b9
          name: 'Azure: VM uncached IOPS consumed percentage'
          type: DEPENDENT
          key: azure.vm.uncached.iops.consumed.percentage
          delay: '0'
          history: 7d
          units: '%'
          description: 'The percentage of the uncached disk IOPS consumed by the VM.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.metrics.VMUncachedIOPSConsumedPercentage.average
          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: 'A response timeout for API.'
        - macro: '{$AZURE.PASSWORD}'
          type: SECRET_TEXT
          description: 'Microsoft Azure password.'
        - macro: '{$AZURE.PROXY}'
          description: 'Sets 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 %.'
      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
  graphs:
    - uuid: 781dd83ed494465bbf2c16efbc753a51
      name: 'Azure: Data disk read/write bytes'
      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 rates'
      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 rates'
      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 bytes'
      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 rates'
      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: 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
